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 imports_from_experimental = UNDEFINED; |
16 var exports_container = %ExportFromRuntime({}); | 16 var exports_container = %ExportFromRuntime({}); |
17 var typed_array_setup = UNDEFINED; | 17 var typed_array_setup = UNDEFINED; |
| 18 var InstallExperimentalArrayFunctions; |
| 19 |
| 20 Import(function(from) { |
| 21 InstallExperimentalArrayFunctions = from.InstallExperimentalArrayFunctions; |
| 22 }); |
18 | 23 |
19 // Register context value to be initialized with a typed array in | 24 // Register context value to be initialized with a typed array in |
20 // Genesis::InitializeBuiltinTypedArrays. | 25 // Genesis::InitializeBuiltinTypedArrays. |
21 function SetupTypedArray(f) { | 26 function SetupTypedArray(f) { |
22 f.next = typed_array_setup; | 27 f.next = typed_array_setup; |
23 typed_array_setup = f; | 28 typed_array_setup = f; |
24 } | 29 } |
25 | 30 |
26 // Export to other scripts. | 31 // Export to other scripts. |
27 // In normal natives, this exports functions to other normal natives. | 32 // In normal natives, this exports functions to other normal natives. |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 var attributes = DONT_ENUM | DONT_DELETE | READ_ONLY; | 84 var attributes = DONT_ENUM | DONT_DELETE | READ_ONLY; |
80 for (var i = 0; i < constants.length; i += 2) { | 85 for (var i = 0; i < constants.length; i += 2) { |
81 var name = constants[i]; | 86 var name = constants[i]; |
82 var k = constants[i + 1]; | 87 var k = constants[i + 1]; |
83 %AddNamedProperty(object, name, k, attributes); | 88 %AddNamedProperty(object, name, k, attributes); |
84 } | 89 } |
85 %ToFastProperties(object); | 90 %ToFastProperties(object); |
86 } | 91 } |
87 | 92 |
88 | 93 |
89 function InstallFunctions(object, attributes, functions) { | 94 function InstallFunctions(object, attributes, functions, |
| 95 remove_prototype = true) { |
90 %CheckIsBootstrapping(); | 96 %CheckIsBootstrapping(); |
91 %OptimizeObjectForAddingMultipleProperties(object, functions.length >> 1); | 97 %OptimizeObjectForAddingMultipleProperties(object, functions.length >> 1); |
92 for (var i = 0; i < functions.length; i += 2) { | 98 for (var i = 0; i < functions.length; i += 2) { |
93 var key = functions[i]; | 99 var key = functions[i]; |
94 var f = functions[i + 1]; | 100 var f = functions[i + 1]; |
95 SetFunctionName(f, key); | 101 SetFunctionName(f, key); |
96 %FunctionRemovePrototype(f); | 102 if (remove_prototype) { |
| 103 %FunctionRemovePrototype(f); |
| 104 } |
97 %AddNamedProperty(object, key, f, attributes); | 105 %AddNamedProperty(object, key, f, attributes); |
98 %SetNativeFlag(f); | 106 %SetNativeFlag(f); |
99 } | 107 } |
100 %ToFastProperties(object); | 108 %ToFastProperties(object); |
101 } | 109 } |
102 | 110 |
103 | 111 |
104 // Helper function to install a getter-only accessor property. | 112 // Helper function to install a getter-only accessor property. |
105 function InstallGetter(object, name, getter, attributes, prefix) { | 113 function InstallGetter(object, name, getter, attributes, prefix) { |
106 %CheckIsBootstrapping(); | 114 %CheckIsBootstrapping(); |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 for (var key of expose_list) { | 201 for (var key of expose_list) { |
194 filtered_exports[key] = exports_container[key]; | 202 filtered_exports[key] = exports_container[key]; |
195 } | 203 } |
196 %ToFastProperties(filtered_exports); | 204 %ToFastProperties(filtered_exports); |
197 exports_container = filtered_exports; | 205 exports_container = filtered_exports; |
198 | 206 |
199 utils.PostNatives = UNDEFINED; | 207 utils.PostNatives = UNDEFINED; |
200 utils.ImportFromExperimental = UNDEFINED; | 208 utils.ImportFromExperimental = UNDEFINED; |
201 } | 209 } |
202 | 210 |
203 | |
204 function PostExperimentals(utils) { | 211 function PostExperimentals(utils) { |
205 %CheckIsBootstrapping(); | 212 %CheckIsBootstrapping(); |
206 %ExportExperimentalFromRuntime(exports_container); | 213 %ExportExperimentalFromRuntime(exports_container); |
207 for ( ; !IS_UNDEFINED(imports); imports = imports.next) { | 214 for ( ; !IS_UNDEFINED(imports); imports = imports.next) { |
208 imports(exports_container); | 215 imports(exports_container); |
209 } | 216 } |
210 for ( ; !IS_UNDEFINED(imports_from_experimental); | 217 for ( ; !IS_UNDEFINED(imports_from_experimental); |
211 imports_from_experimental = imports_from_experimental.next) { | 218 imports_from_experimental = imports_from_experimental.next) { |
212 imports_from_experimental(exports_container); | 219 imports_from_experimental(exports_container); |
213 } | 220 } |
214 | 221 |
215 utils.Export = UNDEFINED; | 222 utils.Export = UNDEFINED; |
216 utils.PostDebug = UNDEFINED; | 223 utils.PostDebug = UNDEFINED; |
217 utils.PostExperimentals = UNDEFINED; | 224 utils.PostExperimentals = UNDEFINED; |
218 typed_array_setup = UNDEFINED; | 225 typed_array_setup = UNDEFINED; |
| 226 |
| 227 InstallExperimentalArrayFunctions(); |
219 } | 228 } |
220 | 229 |
221 | 230 |
222 function PostDebug(utils) { | 231 function PostDebug(utils) { |
223 for ( ; !IS_UNDEFINED(imports); imports = imports.next) { | 232 for ( ; !IS_UNDEFINED(imports); imports = imports.next) { |
224 imports(exports_container); | 233 imports(exports_container); |
225 } | 234 } |
226 | 235 |
227 exports_container = UNDEFINED; | 236 exports_container = UNDEFINED; |
228 | 237 |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
312 %promise_internal_reject(promise, reason, true); | 321 %promise_internal_reject(promise, reason, true); |
313 } | 322 } |
314 | 323 |
315 extrasUtils.markPromiseAsHandled = function markPromiseAsHandled(promise) { | 324 extrasUtils.markPromiseAsHandled = function markPromiseAsHandled(promise) { |
316 %PromiseMarkAsHandled(promise); | 325 %PromiseMarkAsHandled(promise); |
317 }; | 326 }; |
318 | 327 |
319 %ToFastProperties(extrasUtils); | 328 %ToFastProperties(extrasUtils); |
320 | 329 |
321 }) | 330 }) |
OLD | NEW |