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

Unified Diff: src/runtime.cc

Issue 196103004: Add support for per-isolate private symbols (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Comments & more Created 6 years, 9 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 side-by-side diff with in-line comments
Download patch
Index: src/runtime.cc
diff --git a/src/runtime.cc b/src/runtime.cc
index b4c34ef76922cf8b997b6ecd72f34c88d85e3587..2eae22d321d03df7d0d2b65d4e57de32784332fa 100644
--- a/src/runtime.cc
+++ b/src/runtime.cc
@@ -621,6 +621,25 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_CreatePrivateSymbol) {
}
+RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateGlobalPrivateSymbol) {
+ HandleScope scope(isolate);
+ ASSERT(args.length() == 1);
+ CONVERT_ARG_HANDLE_CHECKED(String, name, 0);
+ Handle<JSObject> registry = isolate->GetSymbolRegistry();
+ Handle<String> part = handle(isolate->heap()->private_intern_string());
Michael Starzinger 2014/03/24 15:17:19 nit: You can just use isolate->factory()->private_
rossberg 2014/03/24 15:54:46 Done.
+ Handle<JSObject> privates =
+ Handle<JSObject>::cast(JSObject::GetProperty(registry, part));
+ Handle<Object> symbol = JSObject::GetProperty(privates, name);
+ if (!symbol->IsSymbol()) {
+ ASSERT(symbol->IsUndefined());
+ symbol = isolate->factory()->NewPrivateSymbol();
+ Handle<Symbol>::cast(symbol)->set_name(*name);
+ JSObject::SetProperty(privates, name, symbol, NONE, STRICT);
+ }
+ return *symbol;
+}
+
+
RUNTIME_FUNCTION(MaybeObject*, Runtime_NewSymbolWrapper) {
ASSERT(args.length() == 1);
CONVERT_ARG_CHECKED(Symbol, symbol, 0);
@@ -637,9 +656,9 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_SymbolDescription) {
RUNTIME_FUNCTION(MaybeObject*, Runtime_SymbolRegistry) {
- SealHandleScope shs(isolate);
+ HandleScope hs(isolate);
Michael Starzinger 2014/03/24 15:17:19 nit: s/hs/scope/ for consistency and grep-ability.
rossberg 2014/03/24 15:54:46 Done.
ASSERT(args.length() == 0);
- return isolate->heap()->symbol_registry();
+ return *isolate->GetSymbolRegistry();
}

Powered by Google App Engine
This is Rietveld 408576698