Bug 104088 - [V8] Replace v8::Undefined() with v8Undefined() where possible (part 1)
Summary: [V8] Replace v8::Undefined() with v8Undefined() where possible (part 1)
Status: RESOLVED WONTFIX
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-12-04 22:09 PST by Kentaro Hara
Modified: 2012-12-04 22:50 PST (History)
3 users (show)

See Also:


Attachments
Patch (7.58 KB, patch)
2012-12-04 22:10 PST, Kentaro Hara
haraken: review-
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-12-04 22:09:50 PST
v8Undefined() is faster than v8::Undefined(). See https://bugs.webkit.org/show_bug.cgi?id=93218#c17
Comment 1 Kentaro Hara 2012-12-04 22:10:48 PST
Created attachment 177669 [details]
Patch
Comment 2 Kentaro Hara 2012-12-04 22:11:19 PST
Comment on attachment 177669 [details]
Patch

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

> Source/WebCore/bindings/v8/V8Binding.h:141
>      inline v8::Handle<v8::Value> v8Undefined()

Maybe should we rename this method to clarify the above situation?
Comment 3 Adam Barth 2012-12-04 22:17:55 PST
Comment on attachment 177669 [details]
Patch

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

How did you verify that the difference was not important in these cases?

>> Source/WebCore/bindings/v8/V8Binding.h:141
>>      inline v8::Handle<v8::Value> v8Undefined()
> 
> Maybe should we rename this method to clarify the above situation?

v8EmptyHandle() ?
Comment 4 Kentaro Hara 2012-12-04 22:27:08 PST
> How did you verify that the difference was not important in these cases?

If the value is returned to V8 without being used, then the value can be safely replaced with Handle<Value>(). V8 converts Handle<Value>() to v8::Undefined(). (V8 bindings are already mixing Handle<Value>() and v8::Undefined() for an undefined value that is returned to V8.)

> >> Source/WebCore/bindings/v8/V8Binding.h:141
> >>      inline v8::Handle<v8::Value> v8Undefined()
> > 
> > Maybe should we rename this method to clarify the above situation?
> 
> v8EmptyHandle() ?

Approach 1: We name it v8EmptyHandle(). We use v8EmptyHandle() for an undefined value that is returned to V8. The disadvantage of this approach is that people won't understand why it is OK to return v8EmptyHandle() even though the spec requires to return an undefined value.

Approach 2: Given that Handle<Value>() and v8::Undefined(isolate) have the same speed, we can use v8::Undefined(isolate) for an undefined value that is returned to V8. This approach might be less confusing.
Comment 5 Adam Barth 2012-12-04 22:48:39 PST
Yeah, approach 2 sounds better.  Then we don't have to worry about the difference between undefined and empty handles.

I'd like to get to the point where we're passing around a non-0 isolate everywhere.  Approach 2 seems more consistent with that future.
Comment 6 Kentaro Hara 2012-12-04 22:49:39 PST
(In reply to comment #5)
> Yeah, approach 2 sounds better.  Then we don't have to worry about the difference between undefined and empty handles.

Sounds reasonable, I'll take the approach 2.