| Index: src/prologue.js
|
| diff --git a/src/prologue.js b/src/prologue.js
|
| index 3153db6e157aba04288fabef4ff7f6e2d6cf6b42..4906d41f3da2ccc5032ff8a697933f99743f2e2a 100644
|
| --- a/src/prologue.js
|
| +++ b/src/prologue.js
|
| @@ -12,17 +12,16 @@
|
| // Utils
|
|
|
| var imports = UNDEFINED;
|
| -var exports = UNDEFINED;
|
| var imports_from_experimental = UNDEFINED;
|
| var exports_to_runtime = UNDEFINED;
|
| +var exports_container = {};
|
|
|
| // Export to other scripts.
|
| // In normal natives, this exports functions to other normal natives.
|
| // In experimental natives, this exports to other experimental natives and
|
| // to normal natives that import using utils.ImportFromExperimental.
|
| function Export(f) {
|
| - f.next = exports;
|
| - exports = f;
|
| + f(exports_container);
|
| }
|
|
|
|
|
| @@ -32,7 +31,11 @@ function ExportToRuntime(f) {
|
| exports_to_runtime = f;
|
| }
|
|
|
| -// Import from other scripts.
|
| +
|
| +// Import from other scripts. The actual importing happens in PostNatives and
|
| +// PostExperimental so that we can import from scripts executed later. However,
|
| +// that means that the import is not available until the very end. If the
|
| +// import needs to be available immediate, use ImportNow.
|
| // In normal natives, this imports from other normal natives.
|
| // In experimental natives, this imports from other experimental natives and
|
| // whitelisted exports from normal natives.
|
| @@ -41,6 +44,13 @@ function Import(f) {
|
| imports = f;
|
| }
|
|
|
| +// Import immediately from exports of previous scripts. We need this for
|
| +// functions called during bootstrapping. Hooking up imports in PostNatives
|
| +// would be too late.
|
| +function ImportNow(f) {
|
| + f(exports_container);
|
| +}
|
| +
|
|
|
| // In normal natives, import from experimental natives.
|
| // Not callable from experimental natives.
|
| @@ -149,14 +159,12 @@ function SetUpLockedPrototype(
|
| // -----------------------------------------------------------------------
|
| // To be called by bootstrapper
|
|
|
| -var experimental_exports = UNDEFINED;
|
| -
|
| function PostNatives(utils) {
|
| %CheckIsBootstrapping();
|
|
|
| - var container = {};
|
| - for ( ; !IS_UNDEFINED(exports); exports = exports.next) exports(container);
|
| - for ( ; !IS_UNDEFINED(imports); imports = imports.next) imports(container);
|
| + for ( ; !IS_UNDEFINED(imports); imports = imports.next) {
|
| + imports(exports_container);
|
| + }
|
|
|
| var runtime_container = {};
|
| for ( ; !IS_UNDEFINED(exports_to_runtime);
|
| @@ -165,9 +173,10 @@ function PostNatives(utils) {
|
| }
|
| %ImportToRuntime(runtime_container);
|
|
|
| - // Whitelist of exports from normal natives to experimental natives.
|
| - var expose_to_experimental = [
|
| + // Whitelist of exports from normal natives to experimental natives and debug.
|
| + var expose_list = [
|
| "ArrayToString",
|
| + "FunctionSourceString",
|
| "GetIterator",
|
| "GetMethod",
|
| "InnerArrayEvery",
|
| @@ -190,15 +199,19 @@ function PostNatives(utils) {
|
| "ObjectDefineProperty",
|
| "OwnPropertyKeys",
|
| "ToNameArray",
|
| + "ToBoolean",
|
| + "ToNumber",
|
| + "ToString",
|
| ];
|
| - experimental_exports = {};
|
| +
|
| + var filtered_exports = {};
|
| %OptimizeObjectForAddingMultipleProperties(
|
| - experimental_exports, expose_to_experimental.length);
|
| - for (var key of expose_to_experimental) {
|
| - experimental_exports[key] = container[key];
|
| + filtered_exports, expose_list.length);
|
| + for (var key of expose_list) {
|
| + filtered_exports[key] = exports_container[key];
|
| }
|
| - %ToFastProperties(experimental_exports);
|
| - container = UNDEFINED;
|
| + %ToFastProperties(filtered_exports);
|
| + exports_container = filtered_exports;
|
|
|
| utils.PostNatives = UNDEFINED;
|
| utils.ImportFromExperimental = UNDEFINED;
|
| @@ -208,15 +221,12 @@ function PostNatives(utils) {
|
| function PostExperimentals(utils) {
|
| %CheckIsBootstrapping();
|
|
|
| - for ( ; !IS_UNDEFINED(exports); exports = exports.next) {
|
| - exports(experimental_exports);
|
| - }
|
| for ( ; !IS_UNDEFINED(imports); imports = imports.next) {
|
| - imports(experimental_exports);
|
| + imports(exports_container);
|
| }
|
| for ( ; !IS_UNDEFINED(imports_from_experimental);
|
| imports_from_experimental = imports_from_experimental.next) {
|
| - imports_from_experimental(experimental_exports);
|
| + imports_from_experimental(exports_container);
|
| }
|
| var runtime_container = {};
|
| for ( ; !IS_UNDEFINED(exports_to_runtime);
|
| @@ -225,7 +235,7 @@ function PostExperimentals(utils) {
|
| }
|
| %ImportExperimentalToRuntime(runtime_container);
|
|
|
| - experimental_exports = UNDEFINED;
|
| + exports_container = UNDEFINED;
|
|
|
| utils.PostExperimentals = UNDEFINED;
|
| utils.PostDebug = UNDEFINED;
|
| @@ -235,13 +245,12 @@ function PostExperimentals(utils) {
|
|
|
|
|
| function PostDebug(utils) {
|
| - for ( ; !IS_UNDEFINED(exports); exports = exports.next) {
|
| - exports(experimental_exports);
|
| - }
|
| for ( ; !IS_UNDEFINED(imports); imports = imports.next) {
|
| - imports(experimental_exports);
|
| + imports(exports_container);
|
| }
|
|
|
| + exports_container = UNDEFINED;
|
| +
|
| utils.PostDebug = UNDEFINED;
|
| utils.PostExperimentals = UNDEFINED;
|
| utils.Import = UNDEFINED;
|
| @@ -250,9 +259,10 @@ function PostDebug(utils) {
|
|
|
| // -----------------------------------------------------------------------
|
|
|
| -%OptimizeObjectForAddingMultipleProperties(utils, 13);
|
| +%OptimizeObjectForAddingMultipleProperties(utils, 14);
|
|
|
| utils.Import = Import;
|
| +utils.ImportNow = ImportNow;
|
| utils.Export = Export;
|
| utils.ExportToRuntime = ExportToRuntime;
|
| utils.ImportFromExperimental = ImportFromExperimental;
|
|
|