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

Side by Side Diff: src/symbol.js

Issue 196103004: Add support for per-isolate private symbols (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Rebased 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 if (!(IS_SYMBOL(this) || IS_SYMBOL_WRAPPER(this))) { 58 if (!(IS_SYMBOL(this) || IS_SYMBOL_WRAPPER(this))) {
59 throw MakeTypeError( 59 throw MakeTypeError(
60 'incompatible_method_receiver', ["Symbol.prototype.valueOf", this]); 60 'incompatible_method_receiver', ["Symbol.prototype.valueOf", this]);
61 } 61 }
62 return %_ValueOf(this); 62 return %_ValueOf(this);
63 } 63 }
64 64
65 65
66 function GetSymbolRegistry() { 66 function GetSymbolRegistry() {
67 var registry = %SymbolRegistry(); 67 var registry = %SymbolRegistry();
68 if (!('internal' in registry)) { 68 if (!('for' in registry)) {
69 registry.internal = {__proto__: null};
70 registry.for = {__proto__: null}; 69 registry.for = {__proto__: null};
70 registry.for_intern = {__proto__: null};
71 registry.keyFor = {__proto__: null}; 71 registry.keyFor = {__proto__: null};
72 // Other members are added and used in runtime and API functions:
73 // registry.private_intern
74 // registry.private_api
72 } 75 }
73 return registry; 76 return registry;
74 } 77 }
75 78
76 79
77 function InternalSymbol(key) { 80 function InternalSymbol(key) {
78 var registry = GetSymbolRegistry(); 81 var registry = GetSymbolRegistry();
79 if (!(key in registry.internal)) { 82 if (!(key in registry.for_intern)) {
80 registry.internal[key] = %CreateSymbol(key); 83 registry.for_intern[key] = %CreateSymbol(key);
81 } 84 }
82 return registry.internal[key]; 85 return registry.for_intern[key];
83 } 86 }
84 87
85 88
86 function SymbolFor(key) { 89 function SymbolFor(key) {
87 key = TO_STRING_INLINE(key); 90 key = TO_STRING_INLINE(key);
88 var registry = GetSymbolRegistry(); 91 var registry = GetSymbolRegistry();
89 if (!(key in registry.for)) { 92 if (!(key in registry.for)) {
90 var symbol = %CreateSymbol(key); 93 var symbol = %CreateSymbol(key);
91 registry.for[key] = symbol; 94 registry.for[key] = symbol;
92 registry.keyFor[symbol] = key; 95 registry.keyFor[symbol] = key;
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 163
161 function ExtendObject() { 164 function ExtendObject() {
162 %CheckIsBootstrapping(); 165 %CheckIsBootstrapping();
163 166
164 InstallFunctions($Object, DONT_ENUM, $Array( 167 InstallFunctions($Object, DONT_ENUM, $Array(
165 "getOwnPropertySymbols", ObjectGetOwnPropertySymbols 168 "getOwnPropertySymbols", ObjectGetOwnPropertySymbols
166 )); 169 ));
167 } 170 }
168 171
169 ExtendObject(); 172 ExtendObject();
OLDNEW
« src/runtime.cc ('K') | « src/runtime.cc ('k') | test/cctest/test-api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698