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

Side by Side Diff: src/prologue.js

Issue 1318043002: Native context: do not put public symbols and flags on the js builtins object. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: fix and rebase Created 5 years, 3 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
« no previous file with comments | « src/messages.js ('k') | src/promise.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 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 (function(global, utils) { 5 (function(global, utils) {
6 6
7 "use strict"; 7 "use strict";
8 8
9 %CheckIsBootstrapping(); 9 %CheckIsBootstrapping();
10 10
11 // ----------------------------------------------------------------------- 11 // -----------------------------------------------------------------------
12 // Utils 12 // Utils
13 13
14 var imports = UNDEFINED; 14 var imports = UNDEFINED;
15 var imports_from_experimental = UNDEFINED; 15 var imports_from_experimental = UNDEFINED;
16 var exports_container = {}; 16 var exports_container = %ExportFromRuntime({});
17 17
18 // Export to other scripts. 18 // Export to other scripts.
19 // In normal natives, this exports functions to other normal natives. 19 // In normal natives, this exports functions to other normal natives.
20 // In experimental natives, this exports to other experimental natives and 20 // In experimental natives, this exports to other experimental natives and
21 // to normal natives that import using utils.ImportFromExperimental. 21 // to normal natives that import using utils.ImportFromExperimental.
22 function Export(f) { 22 function Export(f) {
23 f(exports_container); 23 f(exports_container);
24 } 24 }
25 25
26 26
27 // Import from other scripts. The actual importing happens in PostNatives and 27 // Import from other scripts. The actual importing happens in PostNatives and
28 // PostExperimental so that we can import from scripts executed later. However, 28 // PostExperimental so that we can import from scripts executed later. However,
29 // that means that the import is not available until the very end. If the 29 // that means that the import is not available until the very end. If the
30 // import needs to be available immediate, use ImportNow. 30 // import needs to be available immediate, use ImportNow.
31 // In normal natives, this imports from other normal natives. 31 // In normal natives, this imports from other normal natives.
32 // In experimental natives, this imports from other experimental natives and 32 // In experimental natives, this imports from other experimental natives and
33 // whitelisted exports from normal natives. 33 // whitelisted exports from normal natives.
34 function Import(f) { 34 function Import(f) {
35 f.next = imports; 35 f.next = imports;
36 imports = f; 36 imports = f;
37 } 37 }
38 38
39
39 // Import immediately from exports of previous scripts. We need this for 40 // Import immediately from exports of previous scripts. We need this for
40 // functions called during bootstrapping. Hooking up imports in PostNatives 41 // functions called during bootstrapping. Hooking up imports in PostNatives
41 // would be too late. 42 // would be too late.
42 function ImportNow(f) { 43 function ImportNow(name) {
43 f(exports_container); 44 return exports_container[name];
44 } 45 }
45 46
46 47
47 // In normal natives, import from experimental natives. 48 // In normal natives, import from experimental natives.
48 // Not callable from experimental natives. 49 // Not callable from experimental natives.
49 function ImportFromExperimental(f) { 50 function ImportFromExperimental(f) {
50 f.next = imports_from_experimental; 51 f.next = imports_from_experimental;
51 imports_from_experimental = f; 52 imports_from_experimental = f;
52 } 53 }
53 54
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 var key = methods[i]; 143 var key = methods[i];
143 var f = methods[i + 1]; 144 var f = methods[i + 1];
144 %AddNamedProperty(prototype, key, f, DONT_ENUM | DONT_DELETE | READ_ONLY); 145 %AddNamedProperty(prototype, key, f, DONT_ENUM | DONT_DELETE | READ_ONLY);
145 %SetNativeFlag(f); 146 %SetNativeFlag(f);
146 } 147 }
147 %InternalSetPrototype(prototype, null); 148 %InternalSetPrototype(prototype, null);
148 %ToFastProperties(prototype); 149 %ToFastProperties(prototype);
149 } 150 }
150 151
151 152
152 var private_symbols = %ExportPrivateSymbols({});
153
154 function GetPrivateSymbol(name) {
155 return private_symbols[name];
156 }
157
158 // ----------------------------------------------------------------------- 153 // -----------------------------------------------------------------------
159 // To be called by bootstrapper 154 // To be called by bootstrapper
160 155
161 function PostNatives(utils) { 156 function PostNatives(utils) {
162 %CheckIsBootstrapping(); 157 %CheckIsBootstrapping();
163 158
164 for ( ; !IS_UNDEFINED(imports); imports = imports.next) { 159 for ( ; !IS_UNDEFINED(imports); imports = imports.next) {
165 imports(exports_container); 160 imports(exports_container);
166 } 161 }
167 162
(...skipping 15 matching lines...) Expand all
183 "InnerArrayReverse", 178 "InnerArrayReverse",
184 "InnerArraySome", 179 "InnerArraySome",
185 "InnerArraySort", 180 "InnerArraySort",
186 "InnerArrayToLocaleString", 181 "InnerArrayToLocaleString",
187 "IsNaN", 182 "IsNaN",
188 "MathMax", 183 "MathMax",
189 "MathMin", 184 "MathMin",
190 "ObjectIsFrozen", 185 "ObjectIsFrozen",
191 "ObjectDefineProperty", 186 "ObjectDefineProperty",
192 "OwnPropertyKeys", 187 "OwnPropertyKeys",
188 "SymbolToString",
193 "ToNameArray", 189 "ToNameArray",
194 "ToBoolean", 190 "ToBoolean",
195 "ToNumber", 191 "ToNumber",
196 "ToString", 192 "ToString",
193 // From runtime:
194 "is_concat_spreadable_symbol",
195 "iterator_symbol",
196 "promise_status_symbol",
197 "promise_value_symbol",
198 "reflect_apply",
199 "reflect_construct",
200 "to_string_tag_symbol",
197 ]; 201 ];
198 202
199 var filtered_exports = {}; 203 var filtered_exports = {};
200 %OptimizeObjectForAddingMultipleProperties( 204 %OptimizeObjectForAddingMultipleProperties(
201 filtered_exports, expose_list.length); 205 filtered_exports, expose_list.length);
202 for (var key of expose_list) { 206 for (var key of expose_list) {
203 filtered_exports[key] = exports_container[key]; 207 filtered_exports[key] = exports_container[key];
204 } 208 }
205 %ToFastProperties(filtered_exports); 209 %ToFastProperties(filtered_exports);
206 exports_container = filtered_exports; 210 exports_container = filtered_exports;
207 211
208 utils.PostNatives = UNDEFINED; 212 utils.PostNatives = UNDEFINED;
209 utils.ImportFromExperimental = UNDEFINED; 213 utils.ImportFromExperimental = UNDEFINED;
210 } 214 }
211 215
212 216
213 function PostExperimentals(utils) { 217 function PostExperimentals(utils) {
214 %CheckIsBootstrapping(); 218 %CheckIsBootstrapping();
215 219 %ExportExperimentalFromRuntime(exports_container);
216 for ( ; !IS_UNDEFINED(imports); imports = imports.next) { 220 for ( ; !IS_UNDEFINED(imports); imports = imports.next) {
217 imports(exports_container); 221 imports(exports_container);
218 } 222 }
219 for ( ; !IS_UNDEFINED(imports_from_experimental); 223 for ( ; !IS_UNDEFINED(imports_from_experimental);
220 imports_from_experimental = imports_from_experimental.next) { 224 imports_from_experimental = imports_from_experimental.next) {
221 imports_from_experimental(exports_container); 225 imports_from_experimental(exports_container);
222 } 226 }
223 227
224 exports_container = UNDEFINED; 228 exports_container = UNDEFINED;
225 private_symbols = UNDEFINED;
226 229
227 utils.PostExperimentals = UNDEFINED; 230 utils.PostExperimentals = UNDEFINED;
228 utils.PostDebug = UNDEFINED; 231 utils.PostDebug = UNDEFINED;
229 utils.Import = UNDEFINED; 232 utils.Import = UNDEFINED;
230 utils.Export = UNDEFINED; 233 utils.Export = UNDEFINED;
231 } 234 }
232 235
233 236
234 function PostDebug(utils) { 237 function PostDebug(utils) {
235 for ( ; !IS_UNDEFINED(imports); imports = imports.next) { 238 for ( ; !IS_UNDEFINED(imports); imports = imports.next) {
236 imports(exports_container); 239 imports(exports_container);
237 } 240 }
238 241
239 exports_container = UNDEFINED; 242 exports_container = UNDEFINED;
240 private_symbols = UNDEFINED;
241 243
242 utils.PostDebug = UNDEFINED; 244 utils.PostDebug = UNDEFINED;
243 utils.PostExperimentals = UNDEFINED; 245 utils.PostExperimentals = UNDEFINED;
244 utils.Import = UNDEFINED; 246 utils.Import = UNDEFINED;
245 utils.Export = UNDEFINED; 247 utils.Export = UNDEFINED;
246 } 248 }
247 249
248 // ----------------------------------------------------------------------- 250 // -----------------------------------------------------------------------
249 251
250 %OptimizeObjectForAddingMultipleProperties(utils, 14); 252 %OptimizeObjectForAddingMultipleProperties(utils, 13);
251 253
252 utils.Import = Import; 254 utils.Import = Import;
253 utils.ImportNow = ImportNow; 255 utils.ImportNow = ImportNow;
254 utils.Export = Export; 256 utils.Export = Export;
255 utils.ImportFromExperimental = ImportFromExperimental; 257 utils.ImportFromExperimental = ImportFromExperimental;
256 utils.GetPrivateSymbol = GetPrivateSymbol;
257 utils.SetFunctionName = SetFunctionName; 258 utils.SetFunctionName = SetFunctionName;
258 utils.InstallConstants = InstallConstants; 259 utils.InstallConstants = InstallConstants;
259 utils.InstallFunctions = InstallFunctions; 260 utils.InstallFunctions = InstallFunctions;
260 utils.InstallGetter = InstallGetter; 261 utils.InstallGetter = InstallGetter;
261 utils.InstallGetterSetter = InstallGetterSetter; 262 utils.InstallGetterSetter = InstallGetterSetter;
262 utils.SetUpLockedPrototype = SetUpLockedPrototype; 263 utils.SetUpLockedPrototype = SetUpLockedPrototype;
263 utils.PostNatives = PostNatives; 264 utils.PostNatives = PostNatives;
264 utils.PostExperimentals = PostExperimentals; 265 utils.PostExperimentals = PostExperimentals;
265 utils.PostDebug = PostDebug; 266 utils.PostDebug = PostDebug;
266 267
267 %ToFastProperties(utils); 268 %ToFastProperties(utils);
268 269
269 }) 270 })
OLDNEW
« no previous file with comments | « src/messages.js ('k') | src/promise.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698