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 2998 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3009 | 3009 |
3010 | 3010 |
3011 #ifdef DEBUG | 3011 #ifdef DEBUG |
3012 #define ISOLATE_FIELD_OFFSET(type, name, ignored) \ | 3012 #define ISOLATE_FIELD_OFFSET(type, name, ignored) \ |
3013 const intptr_t Isolate::name##_debug_offset_ = OFFSET_OF(Isolate, name##_); | 3013 const intptr_t Isolate::name##_debug_offset_ = OFFSET_OF(Isolate, name##_); |
3014 ISOLATE_INIT_LIST(ISOLATE_FIELD_OFFSET) | 3014 ISOLATE_INIT_LIST(ISOLATE_FIELD_OFFSET) |
3015 ISOLATE_INIT_ARRAY_LIST(ISOLATE_FIELD_OFFSET) | 3015 ISOLATE_INIT_ARRAY_LIST(ISOLATE_FIELD_OFFSET) |
3016 #undef ISOLATE_FIELD_OFFSET | 3016 #undef ISOLATE_FIELD_OFFSET |
3017 #endif | 3017 #endif |
3018 | 3018 |
3019 | 3019 Handle<Symbol> Isolate::SymbolFor(Heap::RootListIndex dictionary_index, |
3020 Handle<JSObject> Isolate::SetUpSubregistry(Handle<JSObject> registry, | 3020 Handle<String> name, bool private_symbol) { |
3021 Handle<Map> map, const char* cname) { | 3021 Handle<String> key = factory()->InternalizeString(name); |
3022 Handle<String> name = factory()->InternalizeUtf8String(cname); | 3022 Handle<NameDictionary> dictionary = |
3023 Handle<JSObject> obj = factory()->NewJSObjectFromMap(map); | 3023 Handle<NameDictionary>::cast(heap()->root_handle(dictionary_index)); |
3024 JSObject::NormalizeProperties(obj, CLEAR_INOBJECT_PROPERTIES, 0, | 3024 int entry = dictionary->FindEntry(key); |
3025 "SetupSymbolRegistry"); | 3025 Handle<Symbol> symbol; |
3026 JSObject::AddProperty(registry, name, obj, NONE); | 3026 if (entry == NameDictionary::kNotFound) { |
3027 return obj; | 3027 PropertyDetails details = PropertyDetails::Empty(); |
| 3028 symbol = |
| 3029 private_symbol ? factory()->NewPrivateSymbol() : factory()->NewSymbol(); |
| 3030 symbol->set_name(*key); |
| 3031 dictionary = NameDictionary::Add(dictionary, key, symbol, |
| 3032 PropertyDetails::Empty(), &entry); |
| 3033 switch (dictionary_index) { |
| 3034 case Heap::kPublicSymbolTableRootIndex: |
| 3035 symbol->set_is_public(true); |
| 3036 heap()->set_public_symbol_table(*dictionary); |
| 3037 break; |
| 3038 case Heap::kApiSymbolTableRootIndex: |
| 3039 heap()->set_api_symbol_table(*dictionary); |
| 3040 break; |
| 3041 case Heap::kApiPrivateSymbolTableRootIndex: |
| 3042 heap()->set_api_private_symbol_table(*dictionary); |
| 3043 break; |
| 3044 default: |
| 3045 UNREACHABLE(); |
| 3046 } |
| 3047 } else { |
| 3048 symbol = Handle<Symbol>(Symbol::cast(dictionary->ValueAt(entry))); |
| 3049 } |
| 3050 return symbol; |
3028 } | 3051 } |
3029 | 3052 |
3030 | |
3031 Handle<JSObject> Isolate::GetSymbolRegistry() { | |
3032 if (heap()->symbol_registry()->IsSmi()) { | |
3033 Handle<Map> map = factory()->NewMap(JS_OBJECT_TYPE, JSObject::kHeaderSize); | |
3034 Handle<JSObject> registry = factory()->NewJSObjectFromMap(map); | |
3035 heap()->set_symbol_registry(*registry); | |
3036 | |
3037 SetUpSubregistry(registry, map, "for"); | |
3038 SetUpSubregistry(registry, map, "for_api"); | |
3039 SetUpSubregistry(registry, map, "keyFor"); | |
3040 SetUpSubregistry(registry, map, "private_api"); | |
3041 } | |
3042 return Handle<JSObject>::cast(factory()->symbol_registry()); | |
3043 } | |
3044 | |
3045 | |
3046 void Isolate::AddBeforeCallEnteredCallback(BeforeCallEnteredCallback callback) { | 3053 void Isolate::AddBeforeCallEnteredCallback(BeforeCallEnteredCallback callback) { |
3047 for (int i = 0; i < before_call_entered_callbacks_.length(); i++) { | 3054 for (int i = 0; i < before_call_entered_callbacks_.length(); i++) { |
3048 if (callback == before_call_entered_callbacks_.at(i)) return; | 3055 if (callback == before_call_entered_callbacks_.at(i)) return; |
3049 } | 3056 } |
3050 before_call_entered_callbacks_.Add(callback); | 3057 before_call_entered_callbacks_.Add(callback); |
3051 } | 3058 } |
3052 | 3059 |
3053 | 3060 |
3054 void Isolate::RemoveBeforeCallEnteredCallback( | 3061 void Isolate::RemoveBeforeCallEnteredCallback( |
3055 BeforeCallEnteredCallback callback) { | 3062 BeforeCallEnteredCallback callback) { |
(...skipping 448 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3504 // Then check whether this scope intercepts. | 3511 // Then check whether this scope intercepts. |
3505 if ((flag & intercept_mask_)) { | 3512 if ((flag & intercept_mask_)) { |
3506 intercepted_flags_ |= flag; | 3513 intercepted_flags_ |= flag; |
3507 return true; | 3514 return true; |
3508 } | 3515 } |
3509 return false; | 3516 return false; |
3510 } | 3517 } |
3511 | 3518 |
3512 } // namespace internal | 3519 } // namespace internal |
3513 } // namespace v8 | 3520 } // namespace v8 |
OLD | NEW |