| 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; |
| 15 var exports_container = %ExportFromRuntime({}); | 16 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 } |
| 16 | 25 |
| 17 // Export to other scripts. | 26 // 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. |
| 18 function Export(f) { | 30 function Export(f) { |
| 19 f(exports_container); | 31 f(exports_container); |
| 20 } | 32 } |
| 21 | 33 |
| 22 | 34 |
| 23 // Import from other scripts. The actual importing happens in PostNatives so | 35 // Import from other scripts. The actual importing happens in PostNatives and |
| 24 // that we can import from scripts executed later. However, that means that | 36 // PostExperimental so that we can import from scripts executed later. However, |
| 25 // the import is not available until the very end. If the import needs to be | 37 // that means that the import is not available until the very end. If the |
| 26 // available immediately, use ImportNow. | 38 // import needs to be available immediate, 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. |
| 27 function Import(f) { | 42 function Import(f) { |
| 28 f.next = imports; | 43 f.next = imports; |
| 29 imports = f; | 44 imports = f; |
| 30 } | 45 } |
| 31 | 46 |
| 32 | 47 |
| 33 // Import immediately from exports of previous scripts. We need this for | 48 // Import immediately from exports of previous scripts. We need this for |
| 34 // functions called during bootstrapping. Hooking up imports in PostNatives | 49 // functions called during bootstrapping. Hooking up imports in PostNatives |
| 35 // would be too late. | 50 // would be too late. |
| 36 function ImportNow(name) { | 51 function ImportNow(name) { |
| 37 return exports_container[name]; | 52 return exports_container[name]; |
| 38 } | 53 } |
| 39 | 54 |
| 40 | 55 |
| 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 |
| 41 function SetFunctionName(f, name, prefix) { | 64 function SetFunctionName(f, name, prefix) { |
| 42 if (IS_SYMBOL(name)) { | 65 if (IS_SYMBOL(name)) { |
| 43 name = "[" + %SymbolDescription(name) + "]"; | 66 name = "[" + %SymbolDescription(name) + "]"; |
| 44 } | 67 } |
| 45 if (IS_UNDEFINED(prefix)) { | 68 if (IS_UNDEFINED(prefix)) { |
| 46 %FunctionSetName(f, name); | 69 %FunctionSetName(f, name); |
| 47 } else { | 70 } else { |
| 48 %FunctionSetName(f, prefix + " " + name); | 71 %FunctionSetName(f, prefix + " " + name); |
| 49 } | 72 } |
| 50 } | 73 } |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 // ----------------------------------------------------------------------- | 158 // ----------------------------------------------------------------------- |
| 136 // To be called by bootstrapper | 159 // To be called by bootstrapper |
| 137 | 160 |
| 138 function PostNatives(utils) { | 161 function PostNatives(utils) { |
| 139 %CheckIsBootstrapping(); | 162 %CheckIsBootstrapping(); |
| 140 | 163 |
| 141 for ( ; !IS_UNDEFINED(imports); imports = imports.next) { | 164 for ( ; !IS_UNDEFINED(imports); imports = imports.next) { |
| 142 imports(exports_container); | 165 imports(exports_container); |
| 143 } | 166 } |
| 144 | 167 |
| 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 |
| 145 exports_container = UNDEFINED; | 224 exports_container = UNDEFINED; |
| 225 |
| 146 utils.Export = UNDEFINED; | 226 utils.Export = UNDEFINED; |
| 147 utils.Import = UNDEFINED; | 227 utils.Import = UNDEFINED; |
| 148 utils.ImportNow = UNDEFINED; | 228 utils.ImportNow = UNDEFINED; |
| 149 utils.PostNatives = UNDEFINED; | 229 utils.PostDebug = UNDEFINED; |
| 230 utils.PostExperimentals = UNDEFINED; |
| 231 typed_array_setup = UNDEFINED; |
| 150 } | 232 } |
| 151 | 233 |
| 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 |
| 152 // ----------------------------------------------------------------------- | 244 // ----------------------------------------------------------------------- |
| 153 | 245 |
| 154 %OptimizeObjectForAddingMultipleProperties(utils, 14); | 246 %OptimizeObjectForAddingMultipleProperties(utils, 14); |
| 155 | 247 |
| 156 utils.Import = Import; | 248 utils.Import = Import; |
| 157 utils.ImportNow = ImportNow; | 249 utils.ImportNow = ImportNow; |
| 158 utils.Export = Export; | 250 utils.Export = Export; |
| 251 utils.ImportFromExperimental = ImportFromExperimental; |
| 159 utils.SetFunctionName = SetFunctionName; | 252 utils.SetFunctionName = SetFunctionName; |
| 160 utils.InstallConstants = InstallConstants; | 253 utils.InstallConstants = InstallConstants; |
| 161 utils.InstallFunctions = InstallFunctions; | 254 utils.InstallFunctions = InstallFunctions; |
| 162 utils.InstallGetter = InstallGetter; | 255 utils.InstallGetter = InstallGetter; |
| 163 utils.OverrideFunction = OverrideFunction; | 256 utils.OverrideFunction = OverrideFunction; |
| 164 utils.SetUpLockedPrototype = SetUpLockedPrototype; | 257 utils.SetUpLockedPrototype = SetUpLockedPrototype; |
| 165 utils.PostNatives = PostNatives; | 258 utils.PostNatives = PostNatives; |
| 259 utils.PostExperimentals = PostExperimentals; |
| 260 utils.PostDebug = PostDebug; |
| 166 | 261 |
| 167 %ToFastProperties(utils); | 262 %ToFastProperties(utils); |
| 168 | 263 |
| 169 // ----------------------------------------------------------------------- | 264 // ----------------------------------------------------------------------- |
| 170 | 265 |
| 171 %OptimizeObjectForAddingMultipleProperties(extrasUtils, 7); | 266 %OptimizeObjectForAddingMultipleProperties(extrasUtils, 7); |
| 172 | 267 |
| 173 extrasUtils.logStackTrace = function logStackTrace() { | 268 extrasUtils.logStackTrace = function logStackTrace() { |
| 174 %DebugTrace(); | 269 %DebugTrace(); |
| 175 }; | 270 }; |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 214 %promise_internal_reject(promise, reason, true); | 309 %promise_internal_reject(promise, reason, true); |
| 215 } | 310 } |
| 216 | 311 |
| 217 extrasUtils.markPromiseAsHandled = function markPromiseAsHandled(promise) { | 312 extrasUtils.markPromiseAsHandled = function markPromiseAsHandled(promise) { |
| 218 %PromiseMarkAsHandled(promise); | 313 %PromiseMarkAsHandled(promise); |
| 219 }; | 314 }; |
| 220 | 315 |
| 221 %ToFastProperties(extrasUtils); | 316 %ToFastProperties(extrasUtils); |
| 222 | 317 |
| 223 }) | 318 }) |
| OLD | NEW |