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

Commit

Permalink
[WebCL] Let WebCLEvent.prototype.getProfilingInfo() return 64-bit pro…
Browse files Browse the repository at this point in the history
…filing 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
  • Loading branch information
hujiajie authored and Raphael Kubo da Costa committed Apr 8, 2016
1 parent b4e2eae commit 58a9a9f
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 11 deletions.
20 changes: 11 additions & 9 deletions third_party/WebKit/Source/modules/webcl/WebCLEvent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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<unsigned long long>(ulongUnits);
return ScriptValue(scriptState, v8::Number::New(isolate, static_cast<double>(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<unsigned long long>(ulongUnits);
return ScriptValue(scriptState, v8::Number::New(isolate, static_cast<double>(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<unsigned long long>(ulongUnits);
return ScriptValue(scriptState, v8::Number::New(isolate, static_cast<double>(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<unsigned long long>(ulongUnits);
return ScriptValue(scriptState, v8::Number::New(isolate, static_cast<double>(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)
Expand Down
2 changes: 1 addition & 1 deletion third_party/WebKit/Source/modules/webcl/WebCLEvent.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class WebCLEvent : public WebCLObject, public ScriptWrappable {
static PassRefPtr<WebCLEvent> 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;

Expand Down
2 changes: 1 addition & 1 deletion third_party/WebKit/Source/modules/webcl/WebCLEvent.idl
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 58a9a9f

Please sign in to comment.