| 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, extrasUtils) { | 5 (function(global, utils, extrasUtils) { |
| 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; | |
| 16 var exports_container = %ExportFromRuntime({}); | 15 var exports_container = %ExportFromRuntime({}); |
| 17 var typed_array_setup = UNDEFINED; | |
| 18 | |
| 19 // Register context value to be initialized with a typed array in | |
| 20 // Genesis::InitializeBuiltinTypedArrays. | |
| 21 function SetupTypedArray(f) { | |
| 22 f.next = typed_array_setup; | |
| 23 typed_array_setup = f; | |
| 24 } | |
| 25 | 16 |
| 26 // Export to other scripts. | 17 // Export to other scripts. |
| 27 // In normal natives, this exports functions to other normal natives. | |
| 28 // In experimental natives, this exports to other experimental natives and | |
| 29 // to normal natives that import using utils.ImportFromExperimental. | |
| 30 function Export(f) { | 18 function Export(f) { |
| 31 f(exports_container); | 19 f(exports_container); |
| 32 } | 20 } |
| 33 | 21 |
| 34 | 22 |
| 35 // Import from other scripts. The actual importing happens in PostNatives and | 23 // Import from other scripts. The actual importing happens in PostNatives so |
| 36 // PostExperimental so that we can import from scripts executed later. However, | 24 // that we can import from scripts executed later. However, that means that |
| 37 // that means that the import is not available until the very end. If the | 25 // the import is not available until the very end. If the import needs to be |
| 38 // import needs to be available immediate, use ImportNow. | 26 // available immediately, use ImportNow. |
| 39 // In normal natives, this imports from other normal natives. | |
| 40 // In experimental natives, this imports from other experimental natives and | |
| 41 // whitelisted exports from normal natives. | |
| 42 function Import(f) { | 27 function Import(f) { |
| 43 f.next = imports; | 28 f.next = imports; |
| 44 imports = f; | 29 imports = f; |
| 45 } | 30 } |
| 46 | 31 |
| 47 | 32 |
| 48 // Import immediately from exports of previous scripts. We need this for | 33 // Import immediately from exports of previous scripts. We need this for |
| 49 // functions called during bootstrapping. Hooking up imports in PostNatives | 34 // functions called during bootstrapping. Hooking up imports in PostNatives |
| 50 // would be too late. | 35 // would be too late. |
| 51 function ImportNow(name) { | 36 function ImportNow(name) { |
| 52 return exports_container[name]; | 37 return exports_container[name]; |
| 53 } | 38 } |
| 54 | 39 |
| 55 | 40 |
| 56 // In normal natives, import from experimental natives. | |
| 57 // Not callable from experimental natives. | |
| 58 function ImportFromExperimental(f) { | |
| 59 f.next = imports_from_experimental; | |
| 60 imports_from_experimental = f; | |
| 61 } | |
| 62 | |
| 63 | |
| 64 function SetFunctionName(f, name, prefix) { | 41 function SetFunctionName(f, name, prefix) { |
| 65 if (IS_SYMBOL(name)) { | 42 if (IS_SYMBOL(name)) { |
| 66 name = "[" + %SymbolDescription(name) + "]"; | 43 name = "[" + %SymbolDescription(name) + "]"; |
| 67 } | 44 } |
| 68 if (IS_UNDEFINED(prefix)) { | 45 if (IS_UNDEFINED(prefix)) { |
| 69 %FunctionSetName(f, name); | 46 %FunctionSetName(f, name); |
| 70 } else { | 47 } else { |
| 71 %FunctionSetName(f, prefix + " " + name); | 48 %FunctionSetName(f, prefix + " " + name); |
| 72 } | 49 } |
| 73 } | 50 } |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 // ----------------------------------------------------------------------- | 135 // ----------------------------------------------------------------------- |
| 159 // To be called by bootstrapper | 136 // To be called by bootstrapper |
| 160 | 137 |
| 161 function PostNatives(utils) { | 138 function PostNatives(utils) { |
| 162 %CheckIsBootstrapping(); | 139 %CheckIsBootstrapping(); |
| 163 | 140 |
| 164 for ( ; !IS_UNDEFINED(imports); imports = imports.next) { | 141 for ( ; !IS_UNDEFINED(imports); imports = imports.next) { |
| 165 imports(exports_container); | 142 imports(exports_container); |
| 166 } | 143 } |
| 167 | 144 |
| 168 // Whitelist of exports from normal natives to experimental natives and debug. | |
| 169 var expose_list = [ | |
| 170 "FormatDateToParts", | |
| 171 "MapEntries", | |
| 172 "MapIteratorNext", | |
| 173 "MaxSimple", | |
| 174 "MinSimple", | |
| 175 "SetIteratorNext", | |
| 176 "SetValues", | |
| 177 "ToLocaleLowerCaseI18N", | |
| 178 "ToLocaleUpperCaseI18N", | |
| 179 "ToLowerCaseI18N", | |
| 180 "ToUpperCaseI18N", | |
| 181 // From runtime: | |
| 182 "promise_result_symbol", | |
| 183 "promise_state_symbol", | |
| 184 "reflect_apply", | |
| 185 "to_string_tag_symbol", | |
| 186 ]; | |
| 187 | |
| 188 var filtered_exports = {}; | |
| 189 %OptimizeObjectForAddingMultipleProperties( | |
| 190 filtered_exports, expose_list.length); | |
| 191 for (var key of expose_list) { | |
| 192 filtered_exports[key] = exports_container[key]; | |
| 193 } | |
| 194 %ToFastProperties(filtered_exports); | |
| 195 exports_container = filtered_exports; | |
| 196 | |
| 197 utils.PostNatives = UNDEFINED; | |
| 198 utils.ImportFromExperimental = UNDEFINED; | |
| 199 } | |
| 200 | |
| 201 | |
| 202 function PostExperimentals(utils) { | |
| 203 %CheckIsBootstrapping(); | |
| 204 for ( ; !IS_UNDEFINED(imports); imports = imports.next) { | |
| 205 imports(exports_container); | |
| 206 } | |
| 207 for ( ; !IS_UNDEFINED(imports_from_experimental); | |
| 208 imports_from_experimental = imports_from_experimental.next) { | |
| 209 imports_from_experimental(exports_container); | |
| 210 } | |
| 211 | |
| 212 utils.Export = UNDEFINED; | |
| 213 utils.PostDebug = UNDEFINED; | |
| 214 utils.PostExperimentals = UNDEFINED; | |
| 215 typed_array_setup = UNDEFINED; | |
| 216 } | |
| 217 | |
| 218 | |
| 219 function PostDebug(utils) { | |
| 220 for ( ; !IS_UNDEFINED(imports); imports = imports.next) { | |
| 221 imports(exports_container); | |
| 222 } | |
| 223 | |
| 224 exports_container = UNDEFINED; | 145 exports_container = UNDEFINED; |
| 225 | |
| 226 utils.Export = UNDEFINED; | 146 utils.Export = UNDEFINED; |
| 227 utils.Import = UNDEFINED; | 147 utils.Import = UNDEFINED; |
| 228 utils.ImportNow = UNDEFINED; | 148 utils.ImportNow = UNDEFINED; |
| 229 utils.PostDebug = UNDEFINED; | 149 utils.PostNatives = UNDEFINED; |
| 230 utils.PostExperimentals = UNDEFINED; | |
| 231 typed_array_setup = UNDEFINED; | |
| 232 } | 150 } |
| 233 | 151 |
| 234 | |
| 235 function InitializeBuiltinTypedArrays(utils, rng_state, rempio2result) { | |
| 236 var setup_list = typed_array_setup; | |
| 237 | |
| 238 for ( ; !IS_UNDEFINED(setup_list); setup_list = setup_list.next) { | |
| 239 setup_list(rng_state, rempio2result); | |
| 240 } | |
| 241 } | |
| 242 | |
| 243 | |
| 244 // ----------------------------------------------------------------------- | 152 // ----------------------------------------------------------------------- |
| 245 | 153 |
| 246 %OptimizeObjectForAddingMultipleProperties(utils, 14); | 154 %OptimizeObjectForAddingMultipleProperties(utils, 14); |
| 247 | 155 |
| 248 utils.Import = Import; | 156 utils.Import = Import; |
| 249 utils.ImportNow = ImportNow; | 157 utils.ImportNow = ImportNow; |
| 250 utils.Export = Export; | 158 utils.Export = Export; |
| 251 utils.ImportFromExperimental = ImportFromExperimental; | |
| 252 utils.SetFunctionName = SetFunctionName; | 159 utils.SetFunctionName = SetFunctionName; |
| 253 utils.InstallConstants = InstallConstants; | 160 utils.InstallConstants = InstallConstants; |
| 254 utils.InstallFunctions = InstallFunctions; | 161 utils.InstallFunctions = InstallFunctions; |
| 255 utils.InstallGetter = InstallGetter; | 162 utils.InstallGetter = InstallGetter; |
| 256 utils.OverrideFunction = OverrideFunction; | 163 utils.OverrideFunction = OverrideFunction; |
| 257 utils.SetUpLockedPrototype = SetUpLockedPrototype; | 164 utils.SetUpLockedPrototype = SetUpLockedPrototype; |
| 258 utils.PostNatives = PostNatives; | 165 utils.PostNatives = PostNatives; |
| 259 utils.PostExperimentals = PostExperimentals; | |
| 260 utils.PostDebug = PostDebug; | |
| 261 | 166 |
| 262 %ToFastProperties(utils); | 167 %ToFastProperties(utils); |
| 263 | 168 |
| 264 // ----------------------------------------------------------------------- | 169 // ----------------------------------------------------------------------- |
| 265 | 170 |
| 266 %OptimizeObjectForAddingMultipleProperties(extrasUtils, 7); | 171 %OptimizeObjectForAddingMultipleProperties(extrasUtils, 7); |
| 267 | 172 |
| 268 extrasUtils.logStackTrace = function logStackTrace() { | 173 extrasUtils.logStackTrace = function logStackTrace() { |
| 269 %DebugTrace(); | 174 %DebugTrace(); |
| 270 }; | 175 }; |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 309 %promise_internal_reject(promise, reason, true); | 214 %promise_internal_reject(promise, reason, true); |
| 310 } | 215 } |
| 311 | 216 |
| 312 extrasUtils.markPromiseAsHandled = function markPromiseAsHandled(promise) { | 217 extrasUtils.markPromiseAsHandled = function markPromiseAsHandled(promise) { |
| 313 %PromiseMarkAsHandled(promise); | 218 %PromiseMarkAsHandled(promise); |
| 314 }; | 219 }; |
| 315 | 220 |
| 316 %ToFastProperties(extrasUtils); | 221 %ToFastProperties(extrasUtils); |
| 317 | 222 |
| 318 }) | 223 }) |
| OLD | NEW |