April 5, 2013, 3:51 p.m.
(2013-04-05 15:51:24 UTC)
#1
Wladimir Palant
http://codereview.adblockplus.org/10085006/diff/1/src/GlobalJsObject.cpp File src/GlobalJsObject.cpp (right): http://codereview.adblockplus.org/10085006/diff/1/src/GlobalJsObject.cpp#newcode17 src/GlobalJsObject.cpp:17: isolate, v8::Local<v8::Function>::Cast(arguments[0])); What will this produce if the first ...
April 8, 2013, 8:36 a.m.
(2013-04-08 08:36:00 UTC)
#2
Uploaded a new patch set addressing all issues. http://codereview.adblockplus.org/10085006/diff/1/src/GlobalJsObject.cpp File src/GlobalJsObject.cpp (right): http://codereview.adblockplus.org/10085006/diff/1/src/GlobalJsObject.cpp#newcode17 src/GlobalJsObject.cpp:17: isolate, ...
April 8, 2013, 1:07 p.m.
(2013-04-08 13:07:48 UTC)
#3
Uploaded a new patch set addressing all issues.
http://codereview.adblockplus.org/10085006/diff/1/src/GlobalJsObject.cpp
File src/GlobalJsObject.cpp (right):
http://codereview.adblockplus.org/10085006/diff/1/src/GlobalJsObject.cpp#newc...
src/GlobalJsObject.cpp:17: isolate,
v8::Local<v8::Function>::Cast(arguments[0]));
On 2013/04/08 08:36:00, Wladimir Palant wrote:
> What will this produce if the first argument isn't a function? And what if
there
> isn't a sufficient number of arguments?
Phew, good find. V8 isn't exactly documented but I assumed they'd throw an
exception and that's it... Instead it's actually causing a fatal error and
crashes the whole runtime.
I made sure to check argument number and types properly and added some tests.
http://codereview.adblockplus.org/10085006/diff/1/src/GlobalJsObject.cpp#newc...
src/GlobalJsObject.cpp:37: const v8::Locker locker(isolate);
On 2013/04/08 08:36:00, Wladimir Palant wrote:
> Does this really lock when this line is reached or already when the scope is
> entered? I would add an additional scope after the Sleep() call.
Yes it will, the constructor is being called after the sleep, and I'd be very
surprised if any compiler changed the order here.
http://codereview.adblockplus.org/10085006/diff/1/src/GlobalJsObject.cpp#newc...
src/GlobalJsObject.cpp:40: delete this;
On 2013/04/08 08:36:00, Wladimir Palant wrote:
> Self-deleting object?
>
> 1) Is that a good practice?
> 2) Is it thread-safe? Won't it corrupt the memory allocation table if
delete/new
> operations run simultaneously on different threads?
1) Depends. It's not generally considered a bad practice, but I can't think of
many situations where it makes sense. I can't think of another way that doesn't
involve some additional house keeping thread, which I'd rather avoid.
2) It's not thread safe, but we can ensure thread safety by making sure that we
don't delete the object from the outside. And since we don't even store a
reference to it, that's safe right now.
http://codereview.adblockplus.org/10085006/diff/1/src/GlobalJsObject.cpp#newc...
src/GlobalJsObject.cpp:61: // clearTimeout(), we can safe that for later.
On 2013/04/08 08:36:00, Wladimir Palant wrote:
> safe => save?
Yes, of course.
http://codereview.adblockplus.org/10085006/diff/1/src/JsEngine.cpp
File src/JsEngine.cpp (right):
http://codereview.adblockplus.org/10085006/diff/1/src/JsEngine.cpp#newcode112
src/JsEngine.cpp:112: std::string AdblockPlus::JsEngine::GetGlobal(const
std::string& name)
On 2013/04/08 08:36:00, Wladimir Palant wrote:
> This name got me thoroughly confused. Please rename into "GetGlobalVariable" -
> the global *object* is definitely not what you are looking for here.
Sure. Called it "GetVariable" since I think that "Global" is kinda obvious
there.
http://codereview.adblockplus.org/10085006/diff/1/test/GlobalJsObject.cpp
File test/GlobalJsObject.cpp (right):
http://codereview.adblockplus.org/10085006/diff/1/test/GlobalJsObject.cpp#new...
test/GlobalJsObject.cpp:22: }
On 2013/04/08 08:36:00, Wladimir Palant wrote:
> How about testing whether two timeouts execute in the right order? That would
> also address my locking question from before.
Sure, added a test.
Wladimir Palant
LGTM, feel free to address the nits however. http://codereview.adblockplus.org/10085006/diff/1/src/GlobalJsObject.cpp File src/GlobalJsObject.cpp (right): http://codereview.adblockplus.org/10085006/diff/1/src/GlobalJsObject.cpp#newcode40 src/GlobalJsObject.cpp:40: delete ...
April 8, 2013, 2:03 p.m.
(2013-04-08 14:03:47 UTC)
#4
Issue 10085006: Implement setTimeout
(Closed)
Created April 5, 2013, 3:49 p.m. by Felix Dahlke
Modified April 8, 2013, 3:10 p.m.
Reviewers: Wladimir Palant
Base URL:
Comments: 15