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/isolate.h" | 5 #include "src/isolate.h" |
6 | 6 |
7 #include <stdlib.h> | 7 #include <stdlib.h> |
8 | 8 |
9 #include <fstream> // NOLINT(readability/streams) | 9 #include <fstream> // NOLINT(readability/streams) |
10 #include <sstream> | 10 #include <sstream> |
(...skipping 3014 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3025 | 3025 |
3026 | 3026 |
3027 #ifdef DEBUG | 3027 #ifdef DEBUG |
3028 #define ISOLATE_FIELD_OFFSET(type, name, ignored) \ | 3028 #define ISOLATE_FIELD_OFFSET(type, name, ignored) \ |
3029 const intptr_t Isolate::name##_debug_offset_ = OFFSET_OF(Isolate, name##_); | 3029 const intptr_t Isolate::name##_debug_offset_ = OFFSET_OF(Isolate, name##_); |
3030 ISOLATE_INIT_LIST(ISOLATE_FIELD_OFFSET) | 3030 ISOLATE_INIT_LIST(ISOLATE_FIELD_OFFSET) |
3031 ISOLATE_INIT_ARRAY_LIST(ISOLATE_FIELD_OFFSET) | 3031 ISOLATE_INIT_ARRAY_LIST(ISOLATE_FIELD_OFFSET) |
3032 #undef ISOLATE_FIELD_OFFSET | 3032 #undef ISOLATE_FIELD_OFFSET |
3033 #endif | 3033 #endif |
3034 | 3034 |
3035 | 3035 Handle<Symbol> Isolate::SymbolFor(Heap::RootListIndex dictionary_index, |
3036 Handle<JSObject> Isolate::SetUpSubregistry(Handle<JSObject> registry, | 3036 Handle<String> name, bool private_symbol) { |
3037 Handle<Map> map, const char* cname) { | 3037 Handle<String> key = factory()->InternalizeString(name); |
3038 Handle<String> name = factory()->InternalizeUtf8String(cname); | 3038 Handle<NameDictionary> dictionary = |
3039 Handle<JSObject> obj = factory()->NewJSObjectFromMap(map); | 3039 Handle<NameDictionary>::cast(heap()->root_handle(dictionary_index)); |
3040 JSObject::NormalizeProperties(obj, CLEAR_INOBJECT_PROPERTIES, 0, | 3040 int entry = dictionary->FindEntry(key); |
3041 "SetupSymbolRegistry"); | 3041 Handle<Symbol> symbol; |
3042 JSObject::AddProperty(registry, name, obj, NONE); | 3042 if (entry == NameDictionary::kNotFound) { |
3043 return obj; | 3043 symbol = |
| 3044 private_symbol ? factory()->NewPrivateSymbol() : factory()->NewSymbol(); |
| 3045 symbol->set_name(*key); |
| 3046 dictionary = NameDictionary::Add(dictionary, key, symbol, |
| 3047 PropertyDetails::Empty(), &entry); |
| 3048 switch (dictionary_index) { |
| 3049 case Heap::kPublicSymbolTableRootIndex: |
| 3050 symbol->set_is_public(true); |
| 3051 heap()->set_public_symbol_table(*dictionary); |
| 3052 break; |
| 3053 case Heap::kApiSymbolTableRootIndex: |
| 3054 heap()->set_api_symbol_table(*dictionary); |
| 3055 break; |
| 3056 case Heap::kApiPrivateSymbolTableRootIndex: |
| 3057 heap()->set_api_private_symbol_table(*dictionary); |
| 3058 break; |
| 3059 default: |
| 3060 UNREACHABLE(); |
| 3061 } |
| 3062 } else { |
| 3063 symbol = Handle<Symbol>(Symbol::cast(dictionary->ValueAt(entry))); |
| 3064 } |
| 3065 return symbol; |
3044 } | 3066 } |
3045 | 3067 |
3046 | |
3047 Handle<JSObject> Isolate::GetSymbolRegistry() { | |
3048 if (heap()->symbol_registry()->IsSmi()) { | |
3049 Handle<Map> map = factory()->NewMap(JS_OBJECT_TYPE, JSObject::kHeaderSize); | |
3050 Handle<JSObject> registry = factory()->NewJSObjectFromMap(map); | |
3051 heap()->set_symbol_registry(*registry); | |
3052 | |
3053 SetUpSubregistry(registry, map, "for"); | |
3054 SetUpSubregistry(registry, map, "for_api"); | |
3055 SetUpSubregistry(registry, map, "keyFor"); | |
3056 SetUpSubregistry(registry, map, "private_api"); | |
3057 } | |
3058 return Handle<JSObject>::cast(factory()->symbol_registry()); | |
3059 } | |
3060 | |
3061 | |
3062 void Isolate::AddBeforeCallEnteredCallback(BeforeCallEnteredCallback callback) { | 3068 void Isolate::AddBeforeCallEnteredCallback(BeforeCallEnteredCallback callback) { |
3063 for (int i = 0; i < before_call_entered_callbacks_.length(); i++) { | 3069 for (int i = 0; i < before_call_entered_callbacks_.length(); i++) { |
3064 if (callback == before_call_entered_callbacks_.at(i)) return; | 3070 if (callback == before_call_entered_callbacks_.at(i)) return; |
3065 } | 3071 } |
3066 before_call_entered_callbacks_.Add(callback); | 3072 before_call_entered_callbacks_.Add(callback); |
3067 } | 3073 } |
3068 | 3074 |
3069 | 3075 |
3070 void Isolate::RemoveBeforeCallEnteredCallback( | 3076 void Isolate::RemoveBeforeCallEnteredCallback( |
3071 BeforeCallEnteredCallback callback) { | 3077 BeforeCallEnteredCallback callback) { |
(...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3511 // Then check whether this scope intercepts. | 3517 // Then check whether this scope intercepts. |
3512 if ((flag & intercept_mask_)) { | 3518 if ((flag & intercept_mask_)) { |
3513 intercepted_flags_ |= flag; | 3519 intercepted_flags_ |= flag; |
3514 return true; | 3520 return true; |
3515 } | 3521 } |
3516 return false; | 3522 return false; |
3517 } | 3523 } |
3518 | 3524 |
3519 } // namespace internal | 3525 } // namespace internal |
3520 } // namespace v8 | 3526 } // namespace v8 |
OLD | NEW |