OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 // This file relies on the fact that the following declarations have been made | 5 // This file relies on the fact that the following declarations have been made |
6 // in runtime.js: | 6 // in runtime.js: |
7 // var $Object = global.Object; | 7 // var $Object = global.Object; |
8 // var $Boolean = global.Boolean; | 8 // var $Boolean = global.Boolean; |
9 // var $Number = global.Number; | 9 // var $Number = global.Number; |
10 // var $Function = global.Function; | 10 // var $Function = global.Function; |
11 // var $Array = global.Array; | 11 // var $Array = global.Array; |
12 | 12 |
13 var $isNaN = GlobalIsNaN; | 13 var $isNaN = GlobalIsNaN; |
14 var $isFinite = GlobalIsFinite; | 14 var $isFinite = GlobalIsFinite; |
15 | 15 |
16 // ---------------------------------------------------------------------------- | 16 // ---------------------------------------------------------------------------- |
17 | 17 |
18 // Helper function used to install functions on objects. | 18 // Helper function used to install functions on objects. |
19 function InstallFunctions(object, attributes, functions) { | 19 function InstallFunctions(object, attributes, functions) { |
20 if (functions.length >= 8) { | 20 %OptimizeObjectForAddingMultipleProperties(object, functions.length >> 1); |
21 %OptimizeObjectForAddingMultipleProperties(object, functions.length >> 1); | |
22 } | |
23 for (var i = 0; i < functions.length; i += 2) { | 21 for (var i = 0; i < functions.length; i += 2) { |
24 var key = functions[i]; | 22 var key = functions[i]; |
25 var f = functions[i + 1]; | 23 var f = functions[i + 1]; |
26 %FunctionSetName(f, key); | 24 %FunctionSetName(f, key); |
27 %FunctionRemovePrototype(f); | 25 %FunctionRemovePrototype(f); |
28 %AddNamedProperty(object, key, f, attributes); | 26 %AddNamedProperty(object, key, f, attributes); |
29 %SetNativeFlag(f); | 27 %SetNativeFlag(f); |
30 } | 28 } |
31 %ToFastProperties(object); | 29 %ToFastProperties(object); |
32 } | 30 } |
(...skipping 29 matching lines...) Expand all Loading... |
62 %FunctionRemovePrototype(getter); | 60 %FunctionRemovePrototype(getter); |
63 %FunctionRemovePrototype(setter); | 61 %FunctionRemovePrototype(setter); |
64 %DefineAccessorPropertyUnchecked(object, name, getter, setter, DONT_ENUM); | 62 %DefineAccessorPropertyUnchecked(object, name, getter, setter, DONT_ENUM); |
65 %SetNativeFlag(getter); | 63 %SetNativeFlag(getter); |
66 %SetNativeFlag(setter); | 64 %SetNativeFlag(setter); |
67 } | 65 } |
68 | 66 |
69 | 67 |
70 // Helper function for installing constant properties on objects. | 68 // Helper function for installing constant properties on objects. |
71 function InstallConstants(object, constants) { | 69 function InstallConstants(object, constants) { |
72 if (constants.length >= 4) { | 70 %OptimizeObjectForAddingMultipleProperties(object, constants.length >> 1); |
73 %OptimizeObjectForAddingMultipleProperties(object, constants.length >> 1); | |
74 } | |
75 var attributes = DONT_ENUM | DONT_DELETE | READ_ONLY; | 71 var attributes = DONT_ENUM | DONT_DELETE | READ_ONLY; |
76 for (var i = 0; i < constants.length; i += 2) { | 72 for (var i = 0; i < constants.length; i += 2) { |
77 var name = constants[i]; | 73 var name = constants[i]; |
78 var k = constants[i + 1]; | 74 var k = constants[i + 1]; |
79 %AddNamedProperty(object, name, k, attributes); | 75 %AddNamedProperty(object, name, k, attributes); |
80 } | 76 } |
81 %ToFastProperties(object); | 77 %ToFastProperties(object); |
82 } | 78 } |
83 | 79 |
84 | 80 |
(...skipping 1825 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1910 } | 1906 } |
1911 if (!IS_SPEC_FUNCTION(method)) { | 1907 if (!IS_SPEC_FUNCTION(method)) { |
1912 throw MakeTypeError(kNotIterable, obj); | 1908 throw MakeTypeError(kNotIterable, obj); |
1913 } | 1909 } |
1914 var iterator = %_CallFunction(obj, method); | 1910 var iterator = %_CallFunction(obj, method); |
1915 if (!IS_SPEC_OBJECT(iterator)) { | 1911 if (!IS_SPEC_OBJECT(iterator)) { |
1916 throw MakeTypeError(kNotAnIterator, iterator); | 1912 throw MakeTypeError(kNotAnIterator, iterator); |
1917 } | 1913 } |
1918 return iterator; | 1914 return iterator; |
1919 } | 1915 } |
OLD | NEW |