Skip to content
This repository was archived by the owner on Apr 3, 2020. It is now read-only.

Commit 46b7436

Browse files
hujiajieRaphael Kubo da Costa
authored and
Raphael Kubo da Costa
committed
[Blink] WebCL support for Crosswalk.
WebCL 1.0 defines a JavaScript binding to the Khronos OpenCL standard for heterogeneous parallel computing. Its spec is available at: http://www.khronos.org/registry/webcl/specs/latest/1.0/ This patch includes WebCL basic APIs support, dynamic loading mechanism etc. WebCL support is controlled by "ENABLE_WEBCL" flag, and it's enabled by default on Android. If you want to disable with WebCL, please add "-Denable_webcl=0" when running the "xwalk/gyp_xwalk" before building. Currently, Intel CPU/GPU, Qualcomm CPU/GPU and Power VR GPU are supported. But OpenCL library isn't always shipped with device by default, even it supports OpenCL. For example: Google Nexus series. It requires to install OpenCL library manually. TEST=WebCL conformances test on Asus MemoPad and Xiaomi3. Known issue: 1. miss oilpan support. 2. miss cl_khr_gl_sharing extension support. 3. load library in render process. [email protected], [email protected], [email protected] BUG=XWALK-4254
1 parent 22d7a73 commit 46b7436

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

74 files changed

+10784
-0
lines changed

third_party/WebKit/Source/bindings/core/v8/ExceptionState.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,18 @@ void ExceptionState::throwDOMException(const ExceptionCode& ec, const String& me
7272
setException(V8ThrowException::createDOMException(m_isolate, ec, processedMessage, m_creationContext));
7373
}
7474

75+
void ExceptionState::throwWebCLException(const ExceptionCode& ec, const String& message)
76+
{
77+
ASSERT(ec);
78+
ASSERT(m_isolate);
79+
ASSERT(!m_creationContext.IsEmpty());
80+
81+
m_code = ec;
82+
String processedMessage = addExceptionContext(message);
83+
m_message = processedMessage;
84+
setException(V8ThrowException::createWebCLException(m_isolate, ec, message, processedMessage, m_creationContext));
85+
}
86+
7587
void ExceptionState::throwSecurityError(const String& sanitizedMessage, const String& unsanitizedMessage)
7688
{
7789
ASSERT(m_isolate);

third_party/WebKit/Source/bindings/core/v8/ExceptionState.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ class CORE_EXPORT ExceptionState {
8080
, m_isolate(isolate) { ASSERT(m_context == ConstructionContext || m_context == EnumerationContext || m_context == IndexedSetterContext || m_context == IndexedGetterContext || m_context == IndexedDeletionContext); }
8181

8282
virtual void throwDOMException(const ExceptionCode&, const String& message);
83+
virtual void throwWebCLException(const ExceptionCode&, const String& message);
8384
virtual void throwTypeError(const String& message);
8485
virtual void throwSecurityError(const String& sanitizedMessage, const String& unsanitizedMessage = String());
8586
virtual void throwRangeError(const String& message);

third_party/WebKit/Source/bindings/core/v8/V8ThrowException.cpp

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,11 @@
2828
#include "bindings/core/v8/BindingSecurity.h"
2929
#include "bindings/core/v8/V8Binding.h"
3030
#include "bindings/core/v8/V8DOMException.h"
31+
#include "bindings/core/v8/V8WebCLException.h"
3132
#include "core/dom/DOMException.h"
3233
#include "core/dom/ExceptionCode.h"
34+
#include "core/webcl/WebCLException.h"
35+
#include "wtf/RefPtr.h"
3336

3437
namespace blink {
3538

@@ -47,6 +50,19 @@ static void domExceptionStackSetter(v8::Local<v8::Name> name, v8::Local<v8::Valu
4750
ALLOW_UNUSED_LOCAL(unused);
4851
}
4952

53+
static void webclExceptionStackGetter(v8::Local<v8::Name> name, const v8::PropertyCallbackInfo<v8::Value>& info)
54+
{
55+
v8::Isolate* isolate = info.GetIsolate();
56+
v8::Local<v8::Value> value;
57+
if (info.Data().As<v8::Object>()->Get(isolate->GetCurrentContext(), v8AtomicString(isolate, "stack")).ToLocal(&value))
58+
v8SetReturnValue(info, value);
59+
}
60+
61+
static void webclExceptionStackSetter(v8::Local<v8::Name> name, v8::Local<v8::Value> value, const v8::PropertyCallbackInfo<void>& info)
62+
{
63+
info.Data().As<v8::Object>()->Set(v8AtomicString(info.GetIsolate(), "stack"), value);
64+
}
65+
5066
v8::Local<v8::Value> V8ThrowException::createDOMException(v8::Isolate* isolate, int ec, const String& sanitizedMessage, const String& unsanitizedMessage, const v8::Local<v8::Object>& creationContext)
5167
{
5268
if (ec <= 0 || v8::V8::IsExecutionTerminating())
@@ -104,6 +120,33 @@ v8::Local<v8::Value> V8ThrowException::throwDOMException(int ec, const String& s
104120
return V8ThrowException::throwException(exception, isolate);
105121
}
106122

123+
v8::Local<v8::Value> V8ThrowException::createWebCLException(v8::Isolate* isolate, int ec, const String& name, const String& message, const v8::Local<v8::Object>& creationContext)
124+
{
125+
if (ec <= 0 || v8::V8::IsExecutionTerminating())
126+
return v8Undefined();
127+
128+
v8::TryCatch tryCatch;
129+
130+
RefPtr<WebCLException> webclException = WebCLException::create(ec, name, message);
131+
v8::Local<v8::Value> exception = toV8(webclException, creationContext, isolate);
132+
133+
if (tryCatch.HasCaught()) {
134+
ASSERT(exception.IsEmpty());
135+
return tryCatch.Exception();
136+
}
137+
ASSERT(!exception.IsEmpty());
138+
139+
// Attach an Error object to the WebCLException. This is then lazily used to get the stack value.
140+
v8::Local<v8::Value> error = v8::Exception::Error(v8String(isolate, webclException->message()));
141+
ASSERT(!error.IsEmpty());
142+
v8::Local<v8::Object> exceptionObject = exception.As<v8::Object>();
143+
v8::Maybe<bool> result = exceptionObject->SetAccessor(isolate->GetCurrentContext(), v8AtomicString(isolate, "stack"), webclExceptionStackGetter, webclExceptionStackSetter, v8::MaybeLocal<v8::Value>(error));
144+
ASSERT_UNUSED(result, result.FromJust());
145+
V8HiddenValue::setHiddenValue(isolate, exceptionObject, V8HiddenValue::error(isolate), error);
146+
147+
return exception;
148+
}
149+
107150
v8::Local<v8::Value> V8ThrowException::createGeneralError(v8::Isolate* isolate, const String& message)
108151
{
109152
return v8::Exception::Error(v8String(isolate, message.isNull() ? "Error" : message));

third_party/WebKit/Source/bindings/core/v8/V8ThrowException.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ class CORE_EXPORT V8ThrowException {
4646
}
4747
static v8::Local<v8::Value> throwDOMException(int, const String& sanitizedMessage, const String& unsanitizedMessage, const v8::Local<v8::Object>& creationContext, v8::Isolate*);
4848

49+
static v8::Local<v8::Value> createWebCLException(v8::Isolate*, int, const String& name, const String& message, const v8::Local<v8::Object>& creationContext);
50+
4951
static v8::Local<v8::Value> throwException(v8::Local<v8::Value>, v8::Isolate*);
5052

5153
static v8::Local<v8::Value> createGeneralError(v8::Isolate*, const String&);

0 commit comments

Comments
 (0)