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

Side by Side Diff: src/prologue.js

Issue 1293493003: Do not export natives to runtime via js builtins object. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 4 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/object-observe.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 exports = UNDEFINED; 15 var exports = UNDEFINED;
16 var imports_from_experimental = UNDEFINED; 16 var imports_from_experimental = UNDEFINED;
17 17 var exports_to_runtime = UNDEFINED;
18 18
19 // Export to other scripts. 19 // Export to other scripts.
20 // In normal natives, this exports functions to other normal natives. 20 // In normal natives, this exports functions to other normal natives.
21 // In experimental natives, this exports to other experimental natives and 21 // In experimental natives, this exports to other experimental natives and
22 // to normal natives that import using utils.ImportFromExperimental. 22 // to normal natives that import using utils.ImportFromExperimental.
23 function Export(f) { 23 function Export(f) {
24 f.next = exports; 24 f.next = exports;
25 exports = f; 25 exports = f;
26 }; 26 };
27 27
28 28
29 // Export to the native context for calls from the runtime.
30 function ExportToRuntime(f) {
31 f.next = exports_to_runtime;
32 exports_to_runtime = f;
33 }
34
29 // Import from other scripts. 35 // Import from other scripts.
30 // In normal natives, this imports from other normal natives. 36 // In normal natives, this imports from other normal natives.
31 // In experimental natives, this imports from other experimental natives and 37 // In experimental natives, this imports from other experimental natives and
32 // whitelisted exports from normal natives. 38 // whitelisted exports from normal natives.
33 function Import(f) { 39 function Import(f) {
34 f.next = imports; 40 f.next = imports;
35 imports = f; 41 imports = f;
36 }; 42 };
37 43
38 44
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 151
146 var experimental_exports = UNDEFINED; 152 var experimental_exports = UNDEFINED;
147 153
148 function PostNatives(utils) { 154 function PostNatives(utils) {
149 %CheckIsBootstrapping(); 155 %CheckIsBootstrapping();
150 156
151 var container = {}; 157 var container = {};
152 for ( ; !IS_UNDEFINED(exports); exports = exports.next) exports(container); 158 for ( ; !IS_UNDEFINED(exports); exports = exports.next) exports(container);
153 for ( ; !IS_UNDEFINED(imports); imports = imports.next) imports(container); 159 for ( ; !IS_UNDEFINED(imports); imports = imports.next) imports(container);
154 160
161 var runtime_container = {};
162 for ( ; !IS_UNDEFINED(exports_to_runtime);
163 exports_to_runtime = exports_to_runtime.next) {
164 exports_to_runtime(runtime_container);
165 }
166 %ImportToRuntime(runtime_container);
167
155 // Whitelist of exports from normal natives to experimental natives. 168 // Whitelist of exports from normal natives to experimental natives.
156 var expose_to_experimental = [ 169 var expose_to_experimental = [
157 "ArrayToString", 170 "ArrayToString",
158 "GetIterator", 171 "GetIterator",
159 "GetMethod", 172 "GetMethod",
160 "InnerArrayEvery", 173 "InnerArrayEvery",
161 "InnerArrayFilter", 174 "InnerArrayFilter",
162 "InnerArrayForEach", 175 "InnerArrayForEach",
163 "InnerArrayIndexOf", 176 "InnerArrayIndexOf",
164 "InnerArrayJoin", 177 "InnerArrayJoin",
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 for ( ; !IS_UNDEFINED(exports); exports = exports.next) { 211 for ( ; !IS_UNDEFINED(exports); exports = exports.next) {
199 exports(experimental_exports); 212 exports(experimental_exports);
200 } 213 }
201 for ( ; !IS_UNDEFINED(imports); imports = imports.next) { 214 for ( ; !IS_UNDEFINED(imports); imports = imports.next) {
202 imports(experimental_exports); 215 imports(experimental_exports);
203 } 216 }
204 for ( ; !IS_UNDEFINED(imports_from_experimental); 217 for ( ; !IS_UNDEFINED(imports_from_experimental);
205 imports_from_experimental = imports_from_experimental.next) { 218 imports_from_experimental = imports_from_experimental.next) {
206 imports_from_experimental(experimental_exports); 219 imports_from_experimental(experimental_exports);
207 } 220 }
221 var runtime_container = {};
222 for ( ; !IS_UNDEFINED(exports_to_runtime);
223 exports_to_runtime = exports_to_runtime.next) {
224 exports_to_runtime(runtime_container);
225 }
226 %ImportExperimentalToRuntime(runtime_container);
208 227
209 experimental_exports = UNDEFINED; 228 experimental_exports = UNDEFINED;
210 229
211 utils.PostExperimentals = UNDEFINED; 230 utils.PostExperimentals = UNDEFINED;
212 utils.PostDebug = UNDEFINED; 231 utils.PostDebug = UNDEFINED;
213 utils.Import = UNDEFINED; 232 utils.Import = UNDEFINED;
214 utils.Export = UNDEFINED; 233 utils.Export = UNDEFINED;
215 }; 234 };
216 235
217 236
218 function PostDebug(utils) { 237 function PostDebug(utils) {
219 for ( ; !IS_UNDEFINED(exports); exports = exports.next) { 238 for ( ; !IS_UNDEFINED(exports); exports = exports.next) {
220 exports(experimental_exports); 239 exports(experimental_exports);
221 } 240 }
222 for ( ; !IS_UNDEFINED(imports); imports = imports.next) { 241 for ( ; !IS_UNDEFINED(imports); imports = imports.next) {
223 imports(experimental_exports); 242 imports(experimental_exports);
224 } 243 }
225 244
226 utils.PostDebug = UNDEFINED; 245 utils.PostDebug = UNDEFINED;
227 utils.PostExperimentals = UNDEFINED; 246 utils.PostExperimentals = UNDEFINED;
228 utils.Import = UNDEFINED; 247 utils.Import = UNDEFINED;
229 utils.Export = UNDEFINED; 248 utils.Export = UNDEFINED;
230 }; 249 };
231 250
232 // ----------------------------------------------------------------------- 251 // -----------------------------------------------------------------------
233 252
234 InstallFunctions(utils, NONE, [ 253 InstallFunctions(utils, NONE, [
235 "Import", Import, 254 "Import", Import,
236 "Export", Export, 255 "Export", Export,
256 "ExportToRuntime", ExportToRuntime,
237 "ImportFromExperimental", ImportFromExperimental, 257 "ImportFromExperimental", ImportFromExperimental,
238 "SetFunctionName", SetFunctionName, 258 "SetFunctionName", SetFunctionName,
239 "InstallConstants", InstallConstants, 259 "InstallConstants", InstallConstants,
240 "InstallFunctions", InstallFunctions, 260 "InstallFunctions", InstallFunctions,
241 "InstallGetter", InstallGetter, 261 "InstallGetter", InstallGetter,
242 "InstallGetterSetter", InstallGetterSetter, 262 "InstallGetterSetter", InstallGetterSetter,
243 "SetUpLockedPrototype", SetUpLockedPrototype, 263 "SetUpLockedPrototype", SetUpLockedPrototype,
244 "PostNatives", PostNatives, 264 "PostNatives", PostNatives,
245 "PostExperimentals", PostExperimentals, 265 "PostExperimentals", PostExperimentals,
246 "PostDebug", PostDebug, 266 "PostDebug", PostDebug,
247 ]); 267 ]);
248 268
269 // TODO(yangguo): run prologue.js before runtime.js
270 ExportToRuntime(function(to) {
271 to.ToNumber = $toNumber;
272 to.ToString = $toString;
273 to.ToDetailString = $toDetailString;
274 to.ToInteger = $toInteger;
275 to.ToLength = $toLength;
276 });
277
249 }) 278 })
OLDNEW
« no previous file with comments | « src/object-observe.js ('k') | src/promise.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698