Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(141)

Unified Diff: src/api.cc

Issue 2900703002: [es2015] Precompute the descriptive string for symbols. (Closed)
Patch Set: Address feedback. Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/builtins/arm/builtins-arm.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/api.cc
diff --git a/src/api.cc b/src/api.cc
index 330174e79a2f6c4fd73aa1d22e6b2194b244bd2e..80caf0a426c22fe8b6df3c25e5b417af4594e168 100644
--- a/src/api.cc
+++ b/src/api.cc
@@ -8051,8 +8051,14 @@ Local<Symbol> v8::Symbol::New(Isolate* isolate, Local<String> name) {
i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
LOG_API(i_isolate, Symbol, New);
ENTER_V8_NO_SCRIPT_NO_EXCEPTION(i_isolate);
- i::Handle<i::Symbol> result = i_isolate->factory()->NewSymbol();
- if (!name.IsEmpty()) result->set_name(*Utils::OpenHandle(*name));
+ i::Handle<i::Symbol> result;
+ i::Handle<i::Object> i_name =
+ name.IsEmpty()
+ ? i::Handle<i::Object>::cast(i_isolate->factory()->undefined_value())
+ : i::Handle<i::Object>::cast(Utils::OpenHandle(*name));
+ if (!i_isolate->factory()->NewSymbol(i_name).ToHandle(&result)) {
+ i::FatalProcessOutOfMemory("v8::Symbol::New");
+ }
return Utils::ToLocal(result);
}
@@ -8099,10 +8105,16 @@ Local<Private> v8::Private::New(Isolate* isolate, Local<String> name) {
i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
LOG_API(i_isolate, Private, New);
ENTER_V8_NO_SCRIPT_NO_EXCEPTION(i_isolate);
- i::Handle<i::Symbol> symbol = i_isolate->factory()->NewPrivateSymbol();
- if (!name.IsEmpty()) symbol->set_name(*Utils::OpenHandle(*name));
- Local<Symbol> result = Utils::ToLocal(symbol);
- return v8::Local<Private>(reinterpret_cast<Private*>(*result));
+ i::Handle<i::Symbol> result;
+ i::Handle<i::Object> i_name =
+ name.IsEmpty()
+ ? i::Handle<i::Object>::cast(i_isolate->factory()->undefined_value())
+ : i::Handle<i::Object>::cast(Utils::OpenHandle(*name));
+ if (!i_isolate->factory()->NewPrivateSymbol(i_name).ToHandle(&result)) {
+ i::FatalProcessOutOfMemory("v8::Private::New");
+ }
+ return v8::Local<Private>(
+ reinterpret_cast<Private*>(*Utils::ToLocal(result)));
}
« no previous file with comments | « no previous file | src/builtins/arm/builtins-arm.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698