From bceae306fbfa132fcc75d1c0d1c1aca122c91c21 Mon Sep 17 00:00:00 2001 From: hujiajie Date: Wed, 6 Apr 2016 09:33:24 +0800 Subject: [PATCH] [WebCL] Let WebCLEvent.prototype.getProfilingInfo() return 64-bit profiling info. The profiling info of an event is a 64-bit value that describes the current device time counter in nanoseconds (https://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clGetEventProfilingInfo.html), but in previous implementation it was implicitly casted as a 32-bit integer so that the return value can fit the binding code generated from the IDL interface, and thus made the return value almost useless. I believe it is a typo in the WebCL specification that caused the original defective IDL interface, and this commit fixes the problem. BUG=XWALK-6705 --- .../Source/modules/webcl/WebCLEvent.cpp | 20 ++++++++++--------- .../WebKit/Source/modules/webcl/WebCLEvent.h | 2 +- .../Source/modules/webcl/WebCLEvent.idl | 2 +- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/third_party/WebKit/Source/modules/webcl/WebCLEvent.cpp b/third_party/WebKit/Source/modules/webcl/WebCLEvent.cpp index c4ac399d9c3f2..f2d4a699fe5c4 100644 --- a/third_party/WebKit/Source/modules/webcl/WebCLEvent.cpp +++ b/third_party/WebKit/Source/modules/webcl/WebCLEvent.cpp @@ -84,18 +84,20 @@ int WebCLEvent::getStatus() return CL_INVALID_VALUE; } -unsigned WebCLEvent::getProfilingInfo(int paramName, ExceptionState& es) +ScriptValue WebCLEvent::getProfilingInfo(ScriptState* scriptState, unsigned paramName, ExceptionState& es) { + v8::Isolate* isolate = scriptState->isolate(); + if (isReleased()) { es.throwWebCLException(WebCLException::INVALID_EVENT, WebCLException::invalidEventMessage); - return 0; + return ScriptValue(scriptState, v8::Null(isolate)); } int status = getStatus(); unsigned properties = m_commandQueue ? m_commandQueue->getProperties() : 0; if (isUserEvent() || status != CL_COMPLETE || !(properties & CL_QUEUE_PROFILING_ENABLE)) { es.throwWebCLException(WebCLException::PROFILING_INFO_NOT_AVAILABLE, WebCLException::profilingInfoNotAvailableMessage); - return 0; + return ScriptValue(scriptState, v8::Null(isolate)); } cl_int err = CL_SUCCESS; @@ -104,30 +106,30 @@ unsigned WebCLEvent::getProfilingInfo(int paramName, ExceptionState& es) case CL_PROFILING_COMMAND_QUEUED: err = clGetEventProfilingInfo(m_clEvent, CL_PROFILING_COMMAND_QUEUED, sizeof(cl_ulong), &ulongUnits, nullptr); if (err == CL_SUCCESS) - return static_cast(ulongUnits); + return ScriptValue(scriptState, v8::Number::New(isolate, static_cast(ulongUnits))); break; case CL_PROFILING_COMMAND_SUBMIT: err = clGetEventProfilingInfo(m_clEvent, CL_PROFILING_COMMAND_SUBMIT, sizeof(cl_ulong), &ulongUnits, nullptr); if (err == CL_SUCCESS) - return static_cast(ulongUnits); + return ScriptValue(scriptState, v8::Number::New(isolate, static_cast(ulongUnits))); break; case CL_PROFILING_COMMAND_START: err = clGetEventProfilingInfo(m_clEvent, CL_PROFILING_COMMAND_START, sizeof(cl_ulong), &ulongUnits, nullptr); if (err == CL_SUCCESS) - return static_cast(ulongUnits); + return ScriptValue(scriptState, v8::Number::New(isolate, static_cast(ulongUnits))); break; case CL_PROFILING_COMMAND_END: err = clGetEventProfilingInfo(m_clEvent, CL_PROFILING_COMMAND_END, sizeof(cl_ulong), &ulongUnits, nullptr); if (err == CL_SUCCESS) - return static_cast(ulongUnits); + return ScriptValue(scriptState, v8::Number::New(isolate, static_cast(ulongUnits))); break; default: es.throwWebCLException(WebCLException::INVALID_VALUE, WebCLException::invalidValueMessage); - return 0; + return ScriptValue(scriptState, v8::Null(isolate)); } WebCLException::throwException(err, es); - return 0; + return ScriptValue(scriptState, v8::Null(isolate)); } void WebCLEvent::setCallback(unsigned commandExecCallbackType, WebCLCallback* callback, ExceptionState& es) diff --git a/third_party/WebKit/Source/modules/webcl/WebCLEvent.h b/third_party/WebKit/Source/modules/webcl/WebCLEvent.h index 2b8415788150f..1b5e49cf21ba1 100644 --- a/third_party/WebKit/Source/modules/webcl/WebCLEvent.h +++ b/third_party/WebKit/Source/modules/webcl/WebCLEvent.h @@ -27,7 +27,7 @@ class WebCLEvent : public WebCLObject, public ScriptWrappable { static PassRefPtr create(); virtual ScriptValue getInfo(ScriptState*, unsigned, ExceptionState&); - unsigned getProfilingInfo(int, ExceptionState&); + virtual ScriptValue getProfilingInfo(ScriptState*, unsigned, ExceptionState&); void setCallback(unsigned, WebCLCallback*, ExceptionState&); void release() override; diff --git a/third_party/WebKit/Source/modules/webcl/WebCLEvent.idl b/third_party/WebKit/Source/modules/webcl/WebCLEvent.idl index acdcf2195f880..94d0142f6bc38 100644 --- a/third_party/WebKit/Source/modules/webcl/WebCLEvent.idl +++ b/third_party/WebKit/Source/modules/webcl/WebCLEvent.idl @@ -8,7 +8,7 @@ typedef unsigned long long CLulong; Constructor, ] interface WebCLEvent { [CallWith=ScriptState, RaisesException] any getInfo(CLenum name); - [RaisesException] CLulong getProfilingInfo(CLenum name); + [CallWith=ScriptState, RaisesException] any getProfilingInfo(CLenum name); [RaisesException] void setCallback(CLenum commandExecCallbackType, WebCLCallback notify); void release();