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 |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
119 SetFunctionName(getter, name, "get"); | 119 SetFunctionName(getter, name, "get"); |
120 SetFunctionName(setter, name, "set"); | 120 SetFunctionName(setter, name, "set"); |
121 %FunctionRemovePrototype(getter); | 121 %FunctionRemovePrototype(getter); |
122 %FunctionRemovePrototype(setter); | 122 %FunctionRemovePrototype(setter); |
123 %DefineAccessorPropertyUnchecked(object, name, getter, setter, DONT_ENUM); | 123 %DefineAccessorPropertyUnchecked(object, name, getter, setter, DONT_ENUM); |
124 %SetNativeFlag(getter); | 124 %SetNativeFlag(getter); |
125 %SetNativeFlag(setter); | 125 %SetNativeFlag(setter); |
126 } | 126 } |
127 | 127 |
128 | 128 |
129 function OverrideFunction(object, name, f, afterInitialBootstrap) { | |
130 %CheckIsBootstrapping(); | |
131 %ObjectDefineProperty(object, name, { value: f, | |
132 writeable: true, | |
133 configurable: true, | |
134 enumerable: false }); | |
135 SetFunctionName(f, name); | |
136 if (!afterInitialBootstrap) %FunctionRemovePrototype(f); | |
Yang
2016/03/22 12:49:38
Let's omit this optimization. I'm not convinced we
Dan Ehrenberg
2016/03/22 18:26:31
This isn't an optimization--apparently you can't c
| |
137 %SetNativeFlag(f); | |
138 } | |
139 | |
140 | |
129 // Prevents changes to the prototype of a built-in function. | 141 // Prevents changes to the prototype of a built-in function. |
130 // The "prototype" property of the function object is made non-configurable, | 142 // The "prototype" property of the function object is made non-configurable, |
131 // and the prototype object is made non-extensible. The latter prevents | 143 // and the prototype object is made non-extensible. The latter prevents |
132 // changing the __proto__ property. | 144 // changing the __proto__ property. |
133 function SetUpLockedPrototype( | 145 function SetUpLockedPrototype( |
134 constructor, fields, methods) { | 146 constructor, fields, methods) { |
135 %CheckIsBootstrapping(); | 147 %CheckIsBootstrapping(); |
136 var prototype = constructor.prototype; | 148 var prototype = constructor.prototype; |
137 // Install functions first, because this function is used to initialize | 149 // Install functions first, because this function is used to initialize |
138 // PropertyDescriptor itself. | 150 // PropertyDescriptor itself. |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
180 "MapIterator", | 192 "MapIterator", |
181 "MapIteratorNext", | 193 "MapIteratorNext", |
182 "MaxSimple", | 194 "MaxSimple", |
183 "MinSimple", | 195 "MinSimple", |
184 "ObjectDefineProperty", | 196 "ObjectDefineProperty", |
185 "ObserveArrayMethods", | 197 "ObserveArrayMethods", |
186 "ObserveObjectMethods", | 198 "ObserveObjectMethods", |
187 "PromiseChain", | 199 "PromiseChain", |
188 "PromiseDeferred", | 200 "PromiseDeferred", |
189 "PromiseResolved", | 201 "PromiseResolved", |
202 "RegExpSubclassExecJS", | |
203 "RegExpSubclassMatch", | |
204 "RegExpSubclassReplace", | |
205 "RegExpSubclassSearch", | |
206 "RegExpSubclassSplit", | |
207 "RegExpSubclassTest", | |
190 "SetIterator", | 208 "SetIterator", |
191 "SetIteratorNext", | 209 "SetIteratorNext", |
192 "SetValues", | 210 "SetValues", |
193 "SymbolToString", | 211 "SymbolToString", |
194 "ToPositiveInteger", | 212 "ToPositiveInteger", |
195 // From runtime: | 213 // From runtime: |
196 "is_concat_spreadable_symbol", | 214 "is_concat_spreadable_symbol", |
197 "iterator_symbol", | 215 "iterator_symbol", |
198 "promise_status_symbol", | 216 "promise_status_symbol", |
199 "promise_value_symbol", | 217 "promise_value_symbol", |
200 "object_freeze", | 218 "object_freeze", |
201 "object_is_frozen", | 219 "object_is_frozen", |
202 "object_is_sealed", | 220 "object_is_sealed", |
203 "reflect_apply", | 221 "reflect_apply", |
204 "reflect_construct", | 222 "reflect_construct", |
205 "regexp_flags_symbol", | 223 "regexp_flags_symbol", |
206 "to_string_tag_symbol", | 224 "to_string_tag_symbol", |
207 "object_to_string", | 225 "object_to_string", |
208 "species_symbol", | 226 "species_symbol", |
227 "match_symbol", | |
228 "replace_symbol", | |
229 "search_symbol", | |
230 "split_symbol", | |
209 ]; | 231 ]; |
210 | 232 |
211 var filtered_exports = {}; | 233 var filtered_exports = {}; |
212 %OptimizeObjectForAddingMultipleProperties( | 234 %OptimizeObjectForAddingMultipleProperties( |
213 filtered_exports, expose_list.length); | 235 filtered_exports, expose_list.length); |
214 for (var key of expose_list) { | 236 for (var key of expose_list) { |
215 filtered_exports[key] = exports_container[key]; | 237 filtered_exports[key] = exports_container[key]; |
216 } | 238 } |
217 %ToFastProperties(filtered_exports); | 239 %ToFastProperties(filtered_exports); |
218 exports_container = filtered_exports; | 240 exports_container = filtered_exports; |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
277 | 299 |
278 utils.Import = Import; | 300 utils.Import = Import; |
279 utils.ImportNow = ImportNow; | 301 utils.ImportNow = ImportNow; |
280 utils.Export = Export; | 302 utils.Export = Export; |
281 utils.ImportFromExperimental = ImportFromExperimental; | 303 utils.ImportFromExperimental = ImportFromExperimental; |
282 utils.SetFunctionName = SetFunctionName; | 304 utils.SetFunctionName = SetFunctionName; |
283 utils.InstallConstants = InstallConstants; | 305 utils.InstallConstants = InstallConstants; |
284 utils.InstallFunctions = InstallFunctions; | 306 utils.InstallFunctions = InstallFunctions; |
285 utils.InstallGetter = InstallGetter; | 307 utils.InstallGetter = InstallGetter; |
286 utils.InstallGetterSetter = InstallGetterSetter; | 308 utils.InstallGetterSetter = InstallGetterSetter; |
309 utils.OverrideFunction = OverrideFunction; | |
287 utils.SetUpLockedPrototype = SetUpLockedPrototype; | 310 utils.SetUpLockedPrototype = SetUpLockedPrototype; |
288 utils.PostNatives = PostNatives; | 311 utils.PostNatives = PostNatives; |
289 utils.PostExperimentals = PostExperimentals; | 312 utils.PostExperimentals = PostExperimentals; |
290 utils.PostDebug = PostDebug; | 313 utils.PostDebug = PostDebug; |
291 | 314 |
292 %ToFastProperties(utils); | 315 %ToFastProperties(utils); |
293 | 316 |
294 // ----------------------------------------------------------------------- | 317 // ----------------------------------------------------------------------- |
295 | 318 |
296 %OptimizeObjectForAddingMultipleProperties(extrasUtils, 5); | 319 %OptimizeObjectForAddingMultipleProperties(extrasUtils, 5); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
330 | 353 |
331 extrasUtils.uncurryThis = function uncurryThis(func) { | 354 extrasUtils.uncurryThis = function uncurryThis(func) { |
332 return function(thisArg, ...args) { | 355 return function(thisArg, ...args) { |
333 return %reflect_apply(func, thisArg, args); | 356 return %reflect_apply(func, thisArg, args); |
334 }; | 357 }; |
335 }; | 358 }; |
336 | 359 |
337 %ToFastProperties(extrasUtils); | 360 %ToFastProperties(extrasUtils); |
338 | 361 |
339 }) | 362 }) |
OLD | NEW |