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

Commit 64e558d

Browse files
author
Raphael Kubo da Costa
committed
Merge pull request #339 from hujiajie/fix-webcl-profiling-info
[WebCL] Let WebCLEvent.prototype.getProfilingInfo() return 64-bit pro…
2 parents 54e413c + bceae30 commit 64e558d

File tree

3 files changed

+13
-11
lines changed

3 files changed

+13
-11
lines changed

third_party/WebKit/Source/modules/webcl/WebCLEvent.cpp

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -84,18 +84,20 @@ int WebCLEvent::getStatus()
8484
return CL_INVALID_VALUE;
8585
}
8686

87-
unsigned WebCLEvent::getProfilingInfo(int paramName, ExceptionState& es)
87+
ScriptValue WebCLEvent::getProfilingInfo(ScriptState* scriptState, unsigned paramName, ExceptionState& es)
8888
{
89+
v8::Isolate* isolate = scriptState->isolate();
90+
8991
if (isReleased()) {
9092
es.throwWebCLException(WebCLException::INVALID_EVENT, WebCLException::invalidEventMessage);
91-
return 0;
93+
return ScriptValue(scriptState, v8::Null(isolate));
9294
}
9395

9496
int status = getStatus();
9597
unsigned properties = m_commandQueue ? m_commandQueue->getProperties() : 0;
9698
if (isUserEvent() || status != CL_COMPLETE || !(properties & CL_QUEUE_PROFILING_ENABLE)) {
9799
es.throwWebCLException(WebCLException::PROFILING_INFO_NOT_AVAILABLE, WebCLException::profilingInfoNotAvailableMessage);
98-
return 0;
100+
return ScriptValue(scriptState, v8::Null(isolate));
99101
}
100102

101103
cl_int err = CL_SUCCESS;
@@ -104,30 +106,30 @@ unsigned WebCLEvent::getProfilingInfo(int paramName, ExceptionState& es)
104106
case CL_PROFILING_COMMAND_QUEUED:
105107
err = clGetEventProfilingInfo(m_clEvent, CL_PROFILING_COMMAND_QUEUED, sizeof(cl_ulong), &ulongUnits, nullptr);
106108
if (err == CL_SUCCESS)
107-
return static_cast<unsigned long long>(ulongUnits);
109+
return ScriptValue(scriptState, v8::Number::New(isolate, static_cast<double>(ulongUnits)));
108110
break;
109111
case CL_PROFILING_COMMAND_SUBMIT:
110112
err = clGetEventProfilingInfo(m_clEvent, CL_PROFILING_COMMAND_SUBMIT, sizeof(cl_ulong), &ulongUnits, nullptr);
111113
if (err == CL_SUCCESS)
112-
return static_cast<unsigned long long>(ulongUnits);
114+
return ScriptValue(scriptState, v8::Number::New(isolate, static_cast<double>(ulongUnits)));
113115
break;
114116
case CL_PROFILING_COMMAND_START:
115117
err = clGetEventProfilingInfo(m_clEvent, CL_PROFILING_COMMAND_START, sizeof(cl_ulong), &ulongUnits, nullptr);
116118
if (err == CL_SUCCESS)
117-
return static_cast<unsigned long long>(ulongUnits);
119+
return ScriptValue(scriptState, v8::Number::New(isolate, static_cast<double>(ulongUnits)));
118120
break;
119121
case CL_PROFILING_COMMAND_END:
120122
err = clGetEventProfilingInfo(m_clEvent, CL_PROFILING_COMMAND_END, sizeof(cl_ulong), &ulongUnits, nullptr);
121123
if (err == CL_SUCCESS)
122-
return static_cast<unsigned long long>(ulongUnits);
124+
return ScriptValue(scriptState, v8::Number::New(isolate, static_cast<double>(ulongUnits)));
123125
break;
124126
default:
125127
es.throwWebCLException(WebCLException::INVALID_VALUE, WebCLException::invalidValueMessage);
126-
return 0;
128+
return ScriptValue(scriptState, v8::Null(isolate));
127129
}
128130

129131
WebCLException::throwException(err, es);
130-
return 0;
132+
return ScriptValue(scriptState, v8::Null(isolate));
131133
}
132134

133135
void WebCLEvent::setCallback(unsigned commandExecCallbackType, WebCLCallback* callback, ExceptionState& es)

third_party/WebKit/Source/modules/webcl/WebCLEvent.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class WebCLEvent : public WebCLObject, public ScriptWrappable {
2727
static PassRefPtr<WebCLEvent> create();
2828

2929
virtual ScriptValue getInfo(ScriptState*, unsigned, ExceptionState&);
30-
unsigned getProfilingInfo(int, ExceptionState&);
30+
virtual ScriptValue getProfilingInfo(ScriptState*, unsigned, ExceptionState&);
3131
void setCallback(unsigned, WebCLCallback*, ExceptionState&);
3232
void release() override;
3333

third_party/WebKit/Source/modules/webcl/WebCLEvent.idl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ typedef unsigned long long CLulong;
88
Constructor,
99
] interface WebCLEvent {
1010
[CallWith=ScriptState, RaisesException] any getInfo(CLenum name);
11-
[RaisesException] CLulong getProfilingInfo(CLenum name);
11+
[CallWith=ScriptState, RaisesException] any getProfilingInfo(CLenum name);
1212
[RaisesException] void setCallback(CLenum commandExecCallbackType,
1313
WebCLCallback notify);
1414
void release();

0 commit comments

Comments
 (0)