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

Unified Diff: src/isolate.cc

Issue 2551763003: v8::Private::ForApi should be context-independent. (Closed)
Patch Set: fix Created 4 years 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/isolate.h ('k') | src/js/symbol.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/isolate.cc
diff --git a/src/isolate.cc b/src/isolate.cc
index 7a3570f6a0d0828d20660c2a3ec149372d4a2250..14b9df7b10832feabe95bb2cc10a3dfcd470ef91 100644
--- a/src/isolate.cc
+++ b/src/isolate.cc
@@ -3032,33 +3032,39 @@ ISOLATE_INIT_ARRAY_LIST(ISOLATE_FIELD_OFFSET)
#undef ISOLATE_FIELD_OFFSET
#endif
-
-Handle<JSObject> Isolate::SetUpSubregistry(Handle<JSObject> registry,
- Handle<Map> map, const char* cname) {
- Handle<String> name = factory()->InternalizeUtf8String(cname);
- Handle<JSObject> obj = factory()->NewJSObjectFromMap(map);
- JSObject::NormalizeProperties(obj, CLEAR_INOBJECT_PROPERTIES, 0,
- "SetupSymbolRegistry");
- JSObject::AddProperty(registry, name, obj, NONE);
- return obj;
-}
-
-
-Handle<JSObject> Isolate::GetSymbolRegistry() {
- if (heap()->symbol_registry()->IsSmi()) {
- Handle<Map> map = factory()->NewMap(JS_OBJECT_TYPE, JSObject::kHeaderSize);
- Handle<JSObject> registry = factory()->NewJSObjectFromMap(map);
- heap()->set_symbol_registry(*registry);
-
- SetUpSubregistry(registry, map, "for");
- SetUpSubregistry(registry, map, "for_api");
- SetUpSubregistry(registry, map, "keyFor");
- SetUpSubregistry(registry, map, "private_api");
+Handle<Symbol> Isolate::SymbolFor(Heap::RootListIndex dictionary_index,
+ Handle<String> name, bool private_symbol) {
+ Handle<String> key = factory()->InternalizeString(name);
+ Handle<NameDictionary> dictionary =
+ Handle<NameDictionary>::cast(heap()->root_handle(dictionary_index));
+ int entry = dictionary->FindEntry(key);
+ Handle<Symbol> symbol;
+ if (entry == NameDictionary::kNotFound) {
+ symbol =
+ private_symbol ? factory()->NewPrivateSymbol() : factory()->NewSymbol();
+ symbol->set_name(*key);
+ dictionary = NameDictionary::Add(dictionary, key, symbol,
+ PropertyDetails::Empty(), &entry);
+ switch (dictionary_index) {
+ case Heap::kPublicSymbolTableRootIndex:
+ symbol->set_is_public(true);
+ heap()->set_public_symbol_table(*dictionary);
+ break;
+ case Heap::kApiSymbolTableRootIndex:
+ heap()->set_api_symbol_table(*dictionary);
+ break;
+ case Heap::kApiPrivateSymbolTableRootIndex:
+ heap()->set_api_private_symbol_table(*dictionary);
+ break;
+ default:
+ UNREACHABLE();
+ }
+ } else {
+ symbol = Handle<Symbol>(Symbol::cast(dictionary->ValueAt(entry)));
}
- return Handle<JSObject>::cast(factory()->symbol_registry());
+ return symbol;
}
-
void Isolate::AddBeforeCallEnteredCallback(BeforeCallEnteredCallback callback) {
for (int i = 0; i < before_call_entered_callbacks_.length(); i++) {
if (callback == before_call_entered_callbacks_.at(i)) return;
« no previous file with comments | « src/isolate.h ('k') | src/js/symbol.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698