OLD | NEW |
---|---|
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 6174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6185 if (!symbol->IsSymbol()) { | 6185 if (!symbol->IsSymbol()) { |
6186 DCHECK(symbol->IsUndefined()); | 6186 DCHECK(symbol->IsUndefined()); |
6187 symbol = i_isolate->factory()->NewSymbol(); | 6187 symbol = i_isolate->factory()->NewSymbol(); |
6188 i::Handle<i::Symbol>::cast(symbol)->set_name(*i_name); | 6188 i::Handle<i::Symbol>::cast(symbol)->set_name(*i_name); |
6189 i::JSObject::SetProperty(symbols, i_name, symbol, i::STRICT).Assert(); | 6189 i::JSObject::SetProperty(symbols, i_name, symbol, i::STRICT).Assert(); |
6190 } | 6190 } |
6191 return Utils::ToLocal(i::Handle<i::Symbol>::cast(symbol)); | 6191 return Utils::ToLocal(i::Handle<i::Symbol>::cast(symbol)); |
6192 } | 6192 } |
6193 | 6193 |
6194 | 6194 |
6195 Local<Symbol> v8::Symbol::ForInternal(Isolate* isolate, Local<String> name) { | |
6196 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); | |
6197 i::Handle<i::String> i_name = Utils::OpenHandle(*name); | |
6198 i::Handle<i::JSObject> registry = i_isolate->GetSymbolRegistry(); | |
6199 i::Handle<i::String> part = i_isolate->factory()->for_intern_string(); | |
arv (Not doing code reviews)
2014/08/19 02:02:25
Maybe it is time to refactor this into a function
yhirano
2014/08/19 02:17:55
Done.
| |
6200 i::Handle<i::JSObject> symbols = i::Handle<i::JSObject>::cast( | |
6201 i::Object::GetPropertyOrElement(registry, part).ToHandleChecked()); | |
6202 i::Handle<i::Object> symbol = | |
6203 i::Object::GetPropertyOrElement(symbols, i_name).ToHandleChecked(); | |
6204 if (!symbol->IsSymbol()) { | |
6205 DCHECK(symbol->IsUndefined()); | |
6206 symbol = i_isolate->factory()->NewSymbol(); | |
6207 i::Handle<i::Symbol>::cast(symbol)->set_name(*i_name); | |
6208 i::JSObject::SetProperty(symbols, i_name, symbol, i::STRICT).Assert(); | |
6209 } | |
6210 return Utils::ToLocal(i::Handle<i::Symbol>::cast(symbol)); | |
6211 } | |
6212 | |
6213 | |
6195 Local<Private> v8::Private::New(Isolate* isolate, Local<String> name) { | 6214 Local<Private> v8::Private::New(Isolate* isolate, Local<String> name) { |
6196 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); | 6215 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); |
6197 EnsureInitializedForIsolate(i_isolate, "v8::Private::New()"); | 6216 EnsureInitializedForIsolate(i_isolate, "v8::Private::New()"); |
6198 LOG_API(i_isolate, "Private::New()"); | 6217 LOG_API(i_isolate, "Private::New()"); |
6199 ENTER_V8(i_isolate); | 6218 ENTER_V8(i_isolate); |
6200 i::Handle<i::Symbol> symbol = i_isolate->factory()->NewPrivateSymbol(); | 6219 i::Handle<i::Symbol> symbol = i_isolate->factory()->NewPrivateSymbol(); |
6201 if (!name.IsEmpty()) symbol->set_name(*Utils::OpenHandle(*name)); | 6220 if (!name.IsEmpty()) symbol->set_name(*Utils::OpenHandle(*name)); |
6202 Local<Symbol> result = Utils::ToLocal(symbol); | 6221 Local<Symbol> result = Utils::ToLocal(symbol); |
6203 return v8::Handle<Private>(reinterpret_cast<Private*>(*result)); | 6222 return v8::Handle<Private>(reinterpret_cast<Private*>(*result)); |
6204 } | 6223 } |
(...skipping 1440 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
7645 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); | 7664 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); |
7646 Address callback_address = | 7665 Address callback_address = |
7647 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 7666 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); |
7648 VMState<EXTERNAL> state(isolate); | 7667 VMState<EXTERNAL> state(isolate); |
7649 ExternalCallbackScope call_scope(isolate, callback_address); | 7668 ExternalCallbackScope call_scope(isolate, callback_address); |
7650 callback(info); | 7669 callback(info); |
7651 } | 7670 } |
7652 | 7671 |
7653 | 7672 |
7654 } } // namespace v8::internal | 7673 } } // namespace v8::internal |
OLD | NEW |