| OLD | NEW |
| 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_to_runtime = UNDEFINED; | |
| 17 var exports_container = {}; | 16 var exports_container = {}; |
| 18 | 17 |
| 19 // Export to other scripts. | 18 // Export to other scripts. |
| 20 // In normal natives, this exports functions to other normal natives. | 19 // In normal natives, this exports functions to other normal natives. |
| 21 // In experimental natives, this exports to other experimental natives and | 20 // In experimental natives, this exports to other experimental natives and |
| 22 // to normal natives that import using utils.ImportFromExperimental. | 21 // to normal natives that import using utils.ImportFromExperimental. |
| 23 function Export(f) { | 22 function Export(f) { |
| 24 f(exports_container); | 23 f(exports_container); |
| 25 } | 24 } |
| 26 | 25 |
| 27 | 26 |
| 28 // Export to the native context for calls from the runtime. | |
| 29 function ExportToRuntime(f) { | |
| 30 f.next = exports_to_runtime; | |
| 31 exports_to_runtime = f; | |
| 32 } | |
| 33 | |
| 34 | |
| 35 // Import from other scripts. The actual importing happens in PostNatives and | 27 // Import from other scripts. The actual importing happens in PostNatives and |
| 36 // PostExperimental so that we can import from scripts executed later. However, | 28 // PostExperimental so that we can import from scripts executed later. However, |
| 37 // 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 |
| 38 // import needs to be available immediate, use ImportNow. | 30 // import needs to be available immediate, use ImportNow. |
| 39 // In normal natives, this imports from other normal natives. | 31 // In normal natives, this imports from other normal natives. |
| 40 // In experimental natives, this imports from other experimental natives and | 32 // In experimental natives, this imports from other experimental natives and |
| 41 // whitelisted exports from normal natives. | 33 // whitelisted exports from normal natives. |
| 42 function Import(f) { | 34 function Import(f) { |
| 43 f.next = imports; | 35 f.next = imports; |
| 44 imports = f; | 36 imports = f; |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 // ----------------------------------------------------------------------- | 158 // ----------------------------------------------------------------------- |
| 167 // To be called by bootstrapper | 159 // To be called by bootstrapper |
| 168 | 160 |
| 169 function PostNatives(utils) { | 161 function PostNatives(utils) { |
| 170 %CheckIsBootstrapping(); | 162 %CheckIsBootstrapping(); |
| 171 | 163 |
| 172 for ( ; !IS_UNDEFINED(imports); imports = imports.next) { | 164 for ( ; !IS_UNDEFINED(imports); imports = imports.next) { |
| 173 imports(exports_container); | 165 imports(exports_container); |
| 174 } | 166 } |
| 175 | 167 |
| 176 var runtime_container = {}; | |
| 177 for ( ; !IS_UNDEFINED(exports_to_runtime); | |
| 178 exports_to_runtime = exports_to_runtime.next) { | |
| 179 exports_to_runtime(runtime_container); | |
| 180 } | |
| 181 %ImportToRuntime(runtime_container); | |
| 182 | |
| 183 // Whitelist of exports from normal natives to experimental natives and debug. | 168 // Whitelist of exports from normal natives to experimental natives and debug. |
| 184 var expose_list = [ | 169 var expose_list = [ |
| 185 "ArrayToString", | 170 "ArrayToString", |
| 186 "FunctionSourceString", | 171 "FunctionSourceString", |
| 187 "GetIterator", | 172 "GetIterator", |
| 188 "GetMethod", | 173 "GetMethod", |
| 189 "InnerArrayEvery", | 174 "InnerArrayEvery", |
| 190 "InnerArrayFilter", | 175 "InnerArrayFilter", |
| 191 "InnerArrayForEach", | 176 "InnerArrayForEach", |
| 192 "InnerArrayIndexOf", | 177 "InnerArrayIndexOf", |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 228 function PostExperimentals(utils) { | 213 function PostExperimentals(utils) { |
| 229 %CheckIsBootstrapping(); | 214 %CheckIsBootstrapping(); |
| 230 | 215 |
| 231 for ( ; !IS_UNDEFINED(imports); imports = imports.next) { | 216 for ( ; !IS_UNDEFINED(imports); imports = imports.next) { |
| 232 imports(exports_container); | 217 imports(exports_container); |
| 233 } | 218 } |
| 234 for ( ; !IS_UNDEFINED(imports_from_experimental); | 219 for ( ; !IS_UNDEFINED(imports_from_experimental); |
| 235 imports_from_experimental = imports_from_experimental.next) { | 220 imports_from_experimental = imports_from_experimental.next) { |
| 236 imports_from_experimental(exports_container); | 221 imports_from_experimental(exports_container); |
| 237 } | 222 } |
| 238 var runtime_container = {}; | |
| 239 for ( ; !IS_UNDEFINED(exports_to_runtime); | |
| 240 exports_to_runtime = exports_to_runtime.next) { | |
| 241 exports_to_runtime(runtime_container); | |
| 242 } | |
| 243 %ImportExperimentalToRuntime(runtime_container); | |
| 244 | 223 |
| 245 exports_container = UNDEFINED; | 224 exports_container = UNDEFINED; |
| 246 private_symbols = UNDEFINED; | 225 private_symbols = UNDEFINED; |
| 247 | 226 |
| 248 utils.PostExperimentals = UNDEFINED; | 227 utils.PostExperimentals = UNDEFINED; |
| 249 utils.PostDebug = UNDEFINED; | 228 utils.PostDebug = UNDEFINED; |
| 250 utils.Import = UNDEFINED; | 229 utils.Import = UNDEFINED; |
| 251 utils.Export = UNDEFINED; | 230 utils.Export = UNDEFINED; |
| 252 } | 231 } |
| 253 | 232 |
| 254 | 233 |
| 255 function PostDebug(utils) { | 234 function PostDebug(utils) { |
| 256 for ( ; !IS_UNDEFINED(imports); imports = imports.next) { | 235 for ( ; !IS_UNDEFINED(imports); imports = imports.next) { |
| 257 imports(exports_container); | 236 imports(exports_container); |
| 258 } | 237 } |
| 259 | 238 |
| 260 exports_container = UNDEFINED; | 239 exports_container = UNDEFINED; |
| 261 private_symbols = UNDEFINED; | 240 private_symbols = UNDEFINED; |
| 262 | 241 |
| 263 utils.PostDebug = UNDEFINED; | 242 utils.PostDebug = UNDEFINED; |
| 264 utils.PostExperimentals = UNDEFINED; | 243 utils.PostExperimentals = UNDEFINED; |
| 265 utils.Import = UNDEFINED; | 244 utils.Import = UNDEFINED; |
| 266 utils.Export = UNDEFINED; | 245 utils.Export = UNDEFINED; |
| 267 } | 246 } |
| 268 | 247 |
| 269 // ----------------------------------------------------------------------- | 248 // ----------------------------------------------------------------------- |
| 270 | 249 |
| 271 %OptimizeObjectForAddingMultipleProperties(utils, 15); | 250 %OptimizeObjectForAddingMultipleProperties(utils, 14); |
| 272 | 251 |
| 273 utils.Import = Import; | 252 utils.Import = Import; |
| 274 utils.ImportNow = ImportNow; | 253 utils.ImportNow = ImportNow; |
| 275 utils.Export = Export; | 254 utils.Export = Export; |
| 276 utils.ExportToRuntime = ExportToRuntime; | |
| 277 utils.ImportFromExperimental = ImportFromExperimental; | 255 utils.ImportFromExperimental = ImportFromExperimental; |
| 278 utils.GetPrivateSymbol = GetPrivateSymbol; | 256 utils.GetPrivateSymbol = GetPrivateSymbol; |
| 279 utils.SetFunctionName = SetFunctionName; | 257 utils.SetFunctionName = SetFunctionName; |
| 280 utils.InstallConstants = InstallConstants; | 258 utils.InstallConstants = InstallConstants; |
| 281 utils.InstallFunctions = InstallFunctions; | 259 utils.InstallFunctions = InstallFunctions; |
| 282 utils.InstallGetter = InstallGetter; | 260 utils.InstallGetter = InstallGetter; |
| 283 utils.InstallGetterSetter = InstallGetterSetter; | 261 utils.InstallGetterSetter = InstallGetterSetter; |
| 284 utils.SetUpLockedPrototype = SetUpLockedPrototype; | 262 utils.SetUpLockedPrototype = SetUpLockedPrototype; |
| 285 utils.PostNatives = PostNatives; | 263 utils.PostNatives = PostNatives; |
| 286 utils.PostExperimentals = PostExperimentals; | 264 utils.PostExperimentals = PostExperimentals; |
| 287 utils.PostDebug = PostDebug; | 265 utils.PostDebug = PostDebug; |
| 288 | 266 |
| 289 %ToFastProperties(utils); | 267 %ToFastProperties(utils); |
| 290 | 268 |
| 291 }) | 269 }) |
| OLD | NEW |