Bug 102870 - [V8] Replace V8Parameter::prepare() with V8Parameter::operator=()
Summary: [V8] Replace V8Parameter::prepare() with V8Parameter::operator=()
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebCore JavaScript (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Kentaro Hara
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-11-20 21:37 PST by Kentaro Hara
Modified: 2012-11-21 01:08 PST (History)
3 users (show)

See Also:


Attachments
Patch (5.48 KB, patch)
2012-11-20 21:39 PST, Kentaro Hara
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Kentaro Hara 2012-11-20 21:37:43 PST
This is an incremental step for V8Parameter refactoring.

By replacing V8Parameter::prepare() with V8Parameter::operator=(), we can make EXCEPTION_BLOCK() and STRING_TO_V8PARAMETER_EXCEPTION_BLOCK() equivalent (except for a return value).

In the next patch, I will remove STRING_TO_V8PARAMETER_EXCEPTION_BLOCK().
Comment 1 Kentaro Hara 2012-11-20 21:39:14 PST
Created attachment 175334 [details]
Patch
Comment 2 Adam Barth 2012-11-21 00:17:44 PST
Comment on attachment 175334 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=175334&action=review

> Source/WebCore/bindings/v8/V8BindingMacros.h:71
> -    type var(value);                                                 \
> +    type var;                                                        \
>      {                                                                \
>          v8::TryCatch block;                                          \
> -        var.prepare();                                               \
> +        var = (value);                                               \

Does it matter that you're moving the evaluation of (value) inside the TryCatch block?  Perhaps it matters if evaluating (value) throws an exception?
Comment 3 Kentaro Hara 2012-11-21 00:28:06 PST
(In reply to comment #2)
> > -    type var(value);                                                 \
> > +    type var;                                                        \
> >      {                                                                \
> >          v8::TryCatch block;                                          \
> > -        var.prepare();                                               \
> > +        var = (value);                                               \
> 
> Does it matter that you're moving the evaluation of (value) inside the TryCatch block?  Perhaps it matters if evaluating (value) throws an exception?

'=' throws an exception.
Comment 4 Adam Barth 2012-11-21 00:31:01 PST
> '=' throws an exception.

I understand that.  The issue is that evaluating (value) itself might throw and exception.  Because this is a macro and not an inline function, you've changed the time at which the expression (value) is evaluated.  Now it is evaluated in the context of the try block.
Comment 5 Kentaro Hara 2012-11-21 00:37:03 PST
(In reply to comment #4)
> > '=' throws an exception.
> 
> I understand that.  The issue is that evaluating (value) itself might throw and exception.  Because this is a macro and not an inline function, you've changed the time at which the expression (value) is evaluated.  Now it is evaluated in the context of the try block.

Ah, got it... So, to guarantee that this patch won't change any behavior, I should check that there is no STRING_TO_V8PARAMETER_EXCEPTION_BLOCK() that is inside any TryCatch block, right?

c.f. EXCEPTION_BLOCK() evaluates (value) inside the try block.
Comment 6 Adam Barth 2012-11-21 00:38:31 PST
> Ah, got it... So, to guarantee that this patch won't change any behavior, I should check that there is no STRING_TO_V8PARAMETER_EXCEPTION_BLOCK() that is inside any TryCatch block, right?
> 
> c.f. EXCEPTION_BLOCK() evaluates (value) inside the try block.

I doubt it's a problem, I just wanted to make sure you were aware of the (small) change you were making to the behavior.
Comment 7 Kentaro Hara 2012-11-21 00:42:47 PST
(In reply to comment #6)
> > Ah, got it... So, to guarantee that this patch won't change any behavior, I should check that there is no STRING_TO_V8PARAMETER_EXCEPTION_BLOCK() that is inside any TryCatch block, right?
> > 
> > c.f. EXCEPTION_BLOCK() evaluates (value) inside the try block.
> 
> I doubt it's a problem, I just wanted to make sure you were aware of the (small) change you were making to the behavior.

Thanks. Currently there is no (STRING_TO_V8PARAMETER_)EXCEPTION_BLOCK() that is inside a TryCatch block (Note: Due to a V8 bug (http://code.google.com/p/v8/issues/detail?id=2166), currently we cannot nest TryCatch blocks), so this change would be safe.
Comment 8 WebKit Review Bot 2012-11-21 01:08:43 PST
Comment on attachment 175334 [details]
Patch

Clearing flags on attachment: 175334

Committed r135359: <http://trac.webkit.org/changeset/135359>
Comment 9 WebKit Review Bot 2012-11-21 01:08:46 PST
All reviewed patches have been landed.  Closing bug.