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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « no previous file | src/builtins/arm/builtins-arm.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/api.h" 5 #include "src/api.h"
6 6
7 #include <string.h> // For memcpy, strlen. 7 #include <string.h> // For memcpy, strlen.
8 #ifdef V8_USE_ADDRESS_SANITIZER 8 #ifdef V8_USE_ADDRESS_SANITIZER
9 #include <sanitizer/asan_interface.h> 9 #include <sanitizer/asan_interface.h>
10 #endif // V8_USE_ADDRESS_SANITIZER 10 #endif // V8_USE_ADDRESS_SANITIZER
(...skipping 8033 matching lines...) Expand 10 before | Expand all | Expand 10 after
8044 mode == ArrayBufferCreationMode::kExternalized, data, 8044 mode == ArrayBufferCreationMode::kExternalized, data,
8045 byte_length, i::SharedFlag::kShared); 8045 byte_length, i::SharedFlag::kShared);
8046 return Utils::ToLocalShared(obj); 8046 return Utils::ToLocalShared(obj);
8047 } 8047 }
8048 8048
8049 8049
8050 Local<Symbol> v8::Symbol::New(Isolate* isolate, Local<String> name) { 8050 Local<Symbol> v8::Symbol::New(Isolate* isolate, Local<String> name) {
8051 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); 8051 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
8052 LOG_API(i_isolate, Symbol, New); 8052 LOG_API(i_isolate, Symbol, New);
8053 ENTER_V8_NO_SCRIPT_NO_EXCEPTION(i_isolate); 8053 ENTER_V8_NO_SCRIPT_NO_EXCEPTION(i_isolate);
8054 i::Handle<i::Symbol> result = i_isolate->factory()->NewSymbol(); 8054 i::Handle<i::Symbol> result;
8055 if (!name.IsEmpty()) result->set_name(*Utils::OpenHandle(*name)); 8055 i::Handle<i::Object> i_name =
8056 name.IsEmpty()
8057 ? i::Handle<i::Object>::cast(i_isolate->factory()->undefined_value())
8058 : i::Handle<i::Object>::cast(Utils::OpenHandle(*name));
8059 if (!i_isolate->factory()->NewSymbol(i_name).ToHandle(&result)) {
8060 i::FatalProcessOutOfMemory("v8::Symbol::New");
8061 }
8056 return Utils::ToLocal(result); 8062 return Utils::ToLocal(result);
8057 } 8063 }
8058 8064
8059 8065
8060 Local<Symbol> v8::Symbol::For(Isolate* isolate, Local<String> name) { 8066 Local<Symbol> v8::Symbol::For(Isolate* isolate, Local<String> name) {
8061 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); 8067 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
8062 i::Handle<i::String> i_name = Utils::OpenHandle(*name); 8068 i::Handle<i::String> i_name = Utils::OpenHandle(*name);
8063 return Utils::ToLocal(i_isolate->SymbolFor( 8069 return Utils::ToLocal(i_isolate->SymbolFor(
8064 i::Heap::kPublicSymbolTableRootIndex, i_name, false)); 8070 i::Heap::kPublicSymbolTableRootIndex, i_name, false));
8065 } 8071 }
(...skipping 26 matching lines...) Expand all
8092 8098
8093 WELL_KNOWN_SYMBOLS(SYMBOL_GETTER) 8099 WELL_KNOWN_SYMBOLS(SYMBOL_GETTER)
8094 8100
8095 #undef SYMBOL_GETTER 8101 #undef SYMBOL_GETTER
8096 #undef WELL_KNOWN_SYMBOLS 8102 #undef WELL_KNOWN_SYMBOLS
8097 8103
8098 Local<Private> v8::Private::New(Isolate* isolate, Local<String> name) { 8104 Local<Private> v8::Private::New(Isolate* isolate, Local<String> name) {
8099 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); 8105 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
8100 LOG_API(i_isolate, Private, New); 8106 LOG_API(i_isolate, Private, New);
8101 ENTER_V8_NO_SCRIPT_NO_EXCEPTION(i_isolate); 8107 ENTER_V8_NO_SCRIPT_NO_EXCEPTION(i_isolate);
8102 i::Handle<i::Symbol> symbol = i_isolate->factory()->NewPrivateSymbol(); 8108 i::Handle<i::Symbol> result;
8103 if (!name.IsEmpty()) symbol->set_name(*Utils::OpenHandle(*name)); 8109 i::Handle<i::Object> i_name =
8104 Local<Symbol> result = Utils::ToLocal(symbol); 8110 name.IsEmpty()
8105 return v8::Local<Private>(reinterpret_cast<Private*>(*result)); 8111 ? i::Handle<i::Object>::cast(i_isolate->factory()->undefined_value())
8112 : i::Handle<i::Object>::cast(Utils::OpenHandle(*name));
8113 if (!i_isolate->factory()->NewPrivateSymbol(i_name).ToHandle(&result)) {
8114 i::FatalProcessOutOfMemory("v8::Private::New");
8115 }
8116 return v8::Local<Private>(
8117 reinterpret_cast<Private*>(*Utils::ToLocal(result)));
8106 } 8118 }
8107 8119
8108 8120
8109 Local<Private> v8::Private::ForApi(Isolate* isolate, Local<String> name) { 8121 Local<Private> v8::Private::ForApi(Isolate* isolate, Local<String> name) {
8110 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); 8122 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
8111 i::Handle<i::String> i_name = Utils::OpenHandle(*name); 8123 i::Handle<i::String> i_name = Utils::OpenHandle(*name);
8112 Local<Symbol> result = Utils::ToLocal(i_isolate->SymbolFor( 8124 Local<Symbol> result = Utils::ToLocal(i_isolate->SymbolFor(
8113 i::Heap::kApiPrivateSymbolTableRootIndex, i_name, true)); 8125 i::Heap::kApiPrivateSymbolTableRootIndex, i_name, true));
8114 return v8::Local<Private>(reinterpret_cast<Private*>(*result)); 8126 return v8::Local<Private>(reinterpret_cast<Private*>(*result));
8115 } 8127 }
(...skipping 2396 matching lines...) Expand 10 before | Expand all | Expand 10 after
10512 Address callback_address = 10524 Address callback_address =
10513 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); 10525 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback));
10514 VMState<EXTERNAL> state(isolate); 10526 VMState<EXTERNAL> state(isolate);
10515 ExternalCallbackScope call_scope(isolate, callback_address); 10527 ExternalCallbackScope call_scope(isolate, callback_address);
10516 callback(info); 10528 callback(info);
10517 } 10529 }
10518 10530
10519 10531
10520 } // namespace internal 10532 } // namespace internal
10521 } // namespace v8 10533 } // namespace v8
OLDNEW
« 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