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

Side by Side Diff: src/api.cc

Issue 2903533002: Revert of [es2015] Precompute the descriptive string for symbols. (Closed)
Patch Set: 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; 8054 i::Handle<i::Symbol> result = i_isolate->factory()->NewSymbol();
8055 i::Handle<i::Object> i_name = 8055 if (!name.IsEmpty()) result->set_name(*Utils::OpenHandle(*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 }
8062 return Utils::ToLocal(result); 8056 return Utils::ToLocal(result);
8063 } 8057 }
8064 8058
8065 8059
8066 Local<Symbol> v8::Symbol::For(Isolate* isolate, Local<String> name) { 8060 Local<Symbol> v8::Symbol::For(Isolate* isolate, Local<String> name) {
8067 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); 8061 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
8068 i::Handle<i::String> i_name = Utils::OpenHandle(*name); 8062 i::Handle<i::String> i_name = Utils::OpenHandle(*name);
8069 return Utils::ToLocal(i_isolate->SymbolFor( 8063 return Utils::ToLocal(i_isolate->SymbolFor(
8070 i::Heap::kPublicSymbolTableRootIndex, i_name, false)); 8064 i::Heap::kPublicSymbolTableRootIndex, i_name, false));
8071 } 8065 }
(...skipping 26 matching lines...) Expand all
8098 8092
8099 WELL_KNOWN_SYMBOLS(SYMBOL_GETTER) 8093 WELL_KNOWN_SYMBOLS(SYMBOL_GETTER)
8100 8094
8101 #undef SYMBOL_GETTER 8095 #undef SYMBOL_GETTER
8102 #undef WELL_KNOWN_SYMBOLS 8096 #undef WELL_KNOWN_SYMBOLS
8103 8097
8104 Local<Private> v8::Private::New(Isolate* isolate, Local<String> name) { 8098 Local<Private> v8::Private::New(Isolate* isolate, Local<String> name) {
8105 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); 8099 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
8106 LOG_API(i_isolate, Private, New); 8100 LOG_API(i_isolate, Private, New);
8107 ENTER_V8_NO_SCRIPT_NO_EXCEPTION(i_isolate); 8101 ENTER_V8_NO_SCRIPT_NO_EXCEPTION(i_isolate);
8108 i::Handle<i::Symbol> result; 8102 i::Handle<i::Symbol> symbol = i_isolate->factory()->NewPrivateSymbol();
8109 i::Handle<i::Object> i_name = 8103 if (!name.IsEmpty()) symbol->set_name(*Utils::OpenHandle(*name));
8110 name.IsEmpty() 8104 Local<Symbol> result = Utils::ToLocal(symbol);
8111 ? i::Handle<i::Object>::cast(i_isolate->factory()->undefined_value()) 8105 return v8::Local<Private>(reinterpret_cast<Private*>(*result));
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)));
8118 } 8106 }
8119 8107
8120 8108
8121 Local<Private> v8::Private::ForApi(Isolate* isolate, Local<String> name) { 8109 Local<Private> v8::Private::ForApi(Isolate* isolate, Local<String> name) {
8122 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); 8110 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
8123 i::Handle<i::String> i_name = Utils::OpenHandle(*name); 8111 i::Handle<i::String> i_name = Utils::OpenHandle(*name);
8124 Local<Symbol> result = Utils::ToLocal(i_isolate->SymbolFor( 8112 Local<Symbol> result = Utils::ToLocal(i_isolate->SymbolFor(
8125 i::Heap::kApiPrivateSymbolTableRootIndex, i_name, true)); 8113 i::Heap::kApiPrivateSymbolTableRootIndex, i_name, true));
8126 return v8::Local<Private>(reinterpret_cast<Private*>(*result)); 8114 return v8::Local<Private>(reinterpret_cast<Private*>(*result));
8127 } 8115 }
(...skipping 2396 matching lines...) Expand 10 before | Expand all | Expand 10 after
10524 Address callback_address = 10512 Address callback_address =
10525 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); 10513 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback));
10526 VMState<EXTERNAL> state(isolate); 10514 VMState<EXTERNAL> state(isolate);
10527 ExternalCallbackScope call_scope(isolate, callback_address); 10515 ExternalCallbackScope call_scope(isolate, callback_address);
10528 callback(info); 10516 callback(info);
10529 } 10517 }
10530 10518
10531 10519
10532 } // namespace internal 10520 } // namespace internal
10533 } // namespace v8 10521 } // 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