Bug 94588

Summary: [V8] Replace v8::String::NewSymbol() in CodeGeneratorV8.pm with v8String()
Product: WebKit Reporter: Kentaro Hara <haraken>
Component: WebCore JavaScriptAssignee: Kentaro Hara <haraken>
Status: RESOLVED INVALID    
Severity: Normal CC: abarth, dcarney, japhet, webkit.review.bot
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Bug Depends on:    
Bug Blocks: 93095    
Attachments:
Description Flags
Patch none

Kentaro Hara
Reported 2012-08-21 05:02:33 PDT
v8String() is much faster than v8::String::NewSymbol(). // 83 nano sec static v8::Handle<v8::Value> attr1AttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info) { static String str1 = String("foo"); static String str2 = String("foo"); v8::Handle<v8::Value> v1 = v8String(str1); v8::Handle<v8::Value> v2 = v8String(str2); if (!v1.IsEmpty() && !v2.IsEmpty()) return v8Undefined(); return v8::Null(); // Never reach. } // 86 nano sec static v8::Handle<v8::Value> attr2AttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info) { static String str1 = String("foo"); static String str2 = String("bar"); v8::Handle<v8::Value> v1 = v8String(str1); v8::Handle<v8::Value> v2 = v8String(str2); if (!v1.IsEmpty() && !v2.IsEmpty()) return v8Undefined(); return v8::Null(); // Never reach. } // 376 nano sec static v8::Handle<v8::Value> attr3AttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info) { v8::Handle<v8::Value> v1 = v8::String::NewSymbol("foo", 3); v8::Handle<v8::Value> v2 = v8::String::NewSymbol("foo", 3); if (!v1.IsEmpty() && !v2.IsEmpty()) return v8Undefined(); return v8::Null(); // Never reach. } // 377 nano sec static v8::Handle<v8::Value> attr4AttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info) { v8::Handle<v8::Value> v1 = v8::String::NewSymbol("foo", 3); v8::Handle<v8::Value> v2 = v8::String::NewSymbol("bar", 3); if (!v1.IsEmpty() && !v2.IsEmpty()) return v8Undefined(); return v8::Null(); // Never reach. }
Attachments
Patch (27.83 KB, patch)
2012-08-21 05:51 PDT, Kentaro Hara
no flags
Kentaro Hara
Comment 1 2012-08-21 05:40:37 PDT
Sorry, the above performance measurement was not fair. We need to compare the time for converting char* to v8::String. Updated result: // 272 nano sec static v8::Handle<v8::Value> attr3AttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info) { v8::Handle<v8::Value> v1 = v8String(String("foo")); v8::Handle<v8::Value> v2 = v8String(String("bar")); if (!v1.IsEmpty() && !v2.IsEmpty()) return v8Undefined(); return v8::Null(); // Never reach. } // 377 nano sec static v8::Handle<v8::Value> attr4AttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info) { v8::Handle<v8::Value> v1 = v8::String::NewSymbol("foo"); v8::Handle<v8::Value> v2 = v8::String::NewSymbol("bar"); if (!v1.IsEmpty() && !v2.IsEmpty()) return v8Undefined(); return v8::Null(); // Never reach. } Anyway, v8String() is faster than String::NewSymbol().
Kentaro Hara
Comment 2 2012-08-21 05:51:54 PDT
Adam Barth
Comment 3 2012-08-21 08:16:00 PDT
Do you have any thoughts on https://bugs.webkit.org/show_bug.cgi?id=94574#c5 ? I wonder if there's a place for NewSymbol in some cases.
Eric Seidel (no email)
Comment 4 2012-08-22 13:31:15 PDT
Comment on attachment 159669 [details] Patch OK.
WebKit Review Bot
Comment 5 2012-08-22 14:13:49 PDT
Comment on attachment 159669 [details] Patch Clearing flags on attachment: 159669 Committed r126348: <http://trac.webkit.org/changeset/126348>
WebKit Review Bot
Comment 6 2012-08-22 14:13:52 PDT
All reviewed patches have been landed. Closing bug.
Kentaro Hara
Comment 7 2012-08-22 23:54:18 PDT
Reverted r126348 for reason: We should use v8::String::NewSymbol() for symbols. See https://bugs.webkit.org/show_bug.cgi?id=94574#c10 for more details Committed r126397: <http://trac.webkit.org/changeset/126397>
Kentaro Hara
Comment 8 2012-08-22 23:55:36 PDT
(In reply to comment #6) > All reviewed patches have been landed. Closing bug. This patch is not quite right. As abarth pointed out, we should use String::NewSymbol() for symbols and use String::New() for other strings. See https://bugs.webkit.org/show_bug.cgi?id=94574#c10 for more details.
Note You need to log in before you can comment on or make changes to this bug.