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. | 145 // Whitelist of exports from normal natives to debug natives. |
169 var expose_list = [ | 146 var expose_list = [ |
170 "FormatDateToParts", | |
171 "MapEntries", | 147 "MapEntries", |
172 "MapIterator", | |
173 "MapIteratorNext", | 148 "MapIteratorNext", |
149 "SetIteratorNext", | |
150 "SetValues", | |
Yang
2017/02/22 09:38:14
These functions could be pulled directly from Map.
adamk
2017/02/22 20:25:17
Getting ahold of the .next methods isn't possible
| |
151 // Exposed only for tests. | |
adamk
2017/02/21 22:26:49
Sadly there are two mjsunit tests which test these
| |
174 "MaxSimple", | 152 "MaxSimple", |
175 "MinSimple", | 153 "MinSimple", |
154 "MapIterator", | |
176 "SetIterator", | 155 "SetIterator", |
177 "SetIteratorNext", | |
178 "SetValues", | |
179 "ToLocaleLowerCaseI18N", | |
180 "ToLocaleUpperCaseI18N", | |
181 "ToLowerCaseI18N", | |
182 "ToUpperCaseI18N", | |
183 // From runtime: | |
184 "promise_result_symbol", | |
185 "promise_state_symbol", | |
186 "reflect_apply", | |
187 "to_string_tag_symbol", | |
188 ]; | 156 ]; |
189 | 157 |
190 var filtered_exports = {}; | 158 var filtered_exports = {}; |
191 %OptimizeObjectForAddingMultipleProperties( | 159 %OptimizeObjectForAddingMultipleProperties( |
192 filtered_exports, expose_list.length); | 160 filtered_exports, expose_list.length); |
193 for (var key of expose_list) { | 161 for (var key of expose_list) { |
194 filtered_exports[key] = exports_container[key]; | 162 filtered_exports[key] = exports_container[key]; |
195 } | 163 } |
196 %ToFastProperties(filtered_exports); | 164 %ToFastProperties(filtered_exports); |
197 exports_container = filtered_exports; | 165 exports_container = filtered_exports; |
198 | 166 |
199 utils.PostNatives = UNDEFINED; | 167 utils.PostNatives = UNDEFINED; |
200 utils.ImportFromExperimental = UNDEFINED; | |
201 } | 168 } |
202 | 169 |
203 | 170 |
204 function PostExperimentals(utils) { | |
205 %CheckIsBootstrapping(); | |
206 for ( ; !IS_UNDEFINED(imports); imports = imports.next) { | |
207 imports(exports_container); | |
208 } | |
209 for ( ; !IS_UNDEFINED(imports_from_experimental); | |
210 imports_from_experimental = imports_from_experimental.next) { | |
211 imports_from_experimental(exports_container); | |
212 } | |
213 | |
214 utils.Export = UNDEFINED; | |
215 utils.PostDebug = UNDEFINED; | |
adamk
2017/02/21 22:26:49
I don't know if it was important for these to be s
Yang
2017/02/22 09:38:14
It should suffice to just move these over to PostN
adamk
2017/02/22 20:25:17
I can't do this in PostNatives since then the debu
| |
216 utils.PostExperimentals = UNDEFINED; | |
217 typed_array_setup = UNDEFINED; | |
218 } | |
219 | |
220 | |
221 function PostDebug(utils) { | 171 function PostDebug(utils) { |
222 for ( ; !IS_UNDEFINED(imports); imports = imports.next) { | 172 for ( ; !IS_UNDEFINED(imports); imports = imports.next) { |
223 imports(exports_container); | 173 imports(exports_container); |
224 } | 174 } |
225 | 175 |
226 exports_container = UNDEFINED; | 176 exports_container = UNDEFINED; |
227 | 177 |
228 utils.Export = UNDEFINED; | 178 utils.Export = UNDEFINED; |
229 utils.Import = UNDEFINED; | 179 utils.Import = UNDEFINED; |
230 utils.ImportNow = UNDEFINED; | 180 utils.ImportNow = UNDEFINED; |
231 utils.PostDebug = UNDEFINED; | 181 utils.PostDebug = UNDEFINED; |
232 utils.PostExperimentals = UNDEFINED; | |
233 typed_array_setup = UNDEFINED; | |
234 } | 182 } |
235 | 183 |
236 | 184 |
237 function InitializeBuiltinTypedArrays(utils, rng_state, rempio2result) { | |
238 var setup_list = typed_array_setup; | |
239 | |
240 for ( ; !IS_UNDEFINED(setup_list); setup_list = setup_list.next) { | |
241 setup_list(rng_state, rempio2result); | |
242 } | |
243 } | |
244 | |
245 | |
246 // ----------------------------------------------------------------------- | 185 // ----------------------------------------------------------------------- |
247 | 186 |
248 %OptimizeObjectForAddingMultipleProperties(utils, 14); | 187 %OptimizeObjectForAddingMultipleProperties(utils, 14); |
249 | 188 |
250 utils.Import = Import; | 189 utils.Import = Import; |
251 utils.ImportNow = ImportNow; | 190 utils.ImportNow = ImportNow; |
252 utils.Export = Export; | 191 utils.Export = Export; |
253 utils.ImportFromExperimental = ImportFromExperimental; | |
254 utils.SetFunctionName = SetFunctionName; | 192 utils.SetFunctionName = SetFunctionName; |
255 utils.InstallConstants = InstallConstants; | 193 utils.InstallConstants = InstallConstants; |
256 utils.InstallFunctions = InstallFunctions; | 194 utils.InstallFunctions = InstallFunctions; |
257 utils.InstallGetter = InstallGetter; | 195 utils.InstallGetter = InstallGetter; |
258 utils.OverrideFunction = OverrideFunction; | 196 utils.OverrideFunction = OverrideFunction; |
259 utils.SetUpLockedPrototype = SetUpLockedPrototype; | 197 utils.SetUpLockedPrototype = SetUpLockedPrototype; |
260 utils.PostNatives = PostNatives; | 198 utils.PostNatives = PostNatives; |
261 utils.PostExperimentals = PostExperimentals; | |
262 utils.PostDebug = PostDebug; | 199 utils.PostDebug = PostDebug; |
263 | 200 |
264 %ToFastProperties(utils); | 201 %ToFastProperties(utils); |
265 | 202 |
266 // ----------------------------------------------------------------------- | 203 // ----------------------------------------------------------------------- |
267 | 204 |
268 %OptimizeObjectForAddingMultipleProperties(extrasUtils, 7); | 205 %OptimizeObjectForAddingMultipleProperties(extrasUtils, 7); |
269 | 206 |
270 extrasUtils.logStackTrace = function logStackTrace() { | 207 extrasUtils.logStackTrace = function logStackTrace() { |
271 %DebugTrace(); | 208 %DebugTrace(); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
311 %promise_internal_reject(promise, reason, true); | 248 %promise_internal_reject(promise, reason, true); |
312 } | 249 } |
313 | 250 |
314 extrasUtils.markPromiseAsHandled = function markPromiseAsHandled(promise) { | 251 extrasUtils.markPromiseAsHandled = function markPromiseAsHandled(promise) { |
315 %PromiseMarkAsHandled(promise); | 252 %PromiseMarkAsHandled(promise); |
316 }; | 253 }; |
317 | 254 |
318 %ToFastProperties(extrasUtils); | 255 %ToFastProperties(extrasUtils); |
319 | 256 |
320 }) | 257 }) |
OLD | NEW |