Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5)

Side by Side Diff: src/v8natives.js

Issue 1098223004: Revert of Always optimize for adding properties to native objects. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 %OptimizeObjectForAddingMultipleProperties(object, functions.length >> 1); 20 if (functions.length >= 8) {
21 %OptimizeObjectForAddingMultipleProperties(object, functions.length >> 1);
22 }
21 for (var i = 0; i < functions.length; i += 2) { 23 for (var i = 0; i < functions.length; i += 2) {
22 var key = functions[i]; 24 var key = functions[i];
23 var f = functions[i + 1]; 25 var f = functions[i + 1];
24 %FunctionSetName(f, key); 26 %FunctionSetName(f, key);
25 %FunctionRemovePrototype(f); 27 %FunctionRemovePrototype(f);
26 %AddNamedProperty(object, key, f, attributes); 28 %AddNamedProperty(object, key, f, attributes);
27 %SetNativeFlag(f); 29 %SetNativeFlag(f);
28 } 30 }
29 %ToFastProperties(object); 31 %ToFastProperties(object);
30 } 32 }
(...skipping 29 matching lines...) Expand all
60 %FunctionRemovePrototype(getter); 62 %FunctionRemovePrototype(getter);
61 %FunctionRemovePrototype(setter); 63 %FunctionRemovePrototype(setter);
62 %DefineAccessorPropertyUnchecked(object, name, getter, setter, DONT_ENUM); 64 %DefineAccessorPropertyUnchecked(object, name, getter, setter, DONT_ENUM);
63 %SetNativeFlag(getter); 65 %SetNativeFlag(getter);
64 %SetNativeFlag(setter); 66 %SetNativeFlag(setter);
65 } 67 }
66 68
67 69
68 // Helper function for installing constant properties on objects. 70 // Helper function for installing constant properties on objects.
69 function InstallConstants(object, constants) { 71 function InstallConstants(object, constants) {
70 %OptimizeObjectForAddingMultipleProperties(object, constants.length >> 1); 72 if (constants.length >= 4) {
73 %OptimizeObjectForAddingMultipleProperties(object, constants.length >> 1);
74 }
71 var attributes = DONT_ENUM | DONT_DELETE | READ_ONLY; 75 var attributes = DONT_ENUM | DONT_DELETE | READ_ONLY;
72 for (var i = 0; i < constants.length; i += 2) { 76 for (var i = 0; i < constants.length; i += 2) {
73 var name = constants[i]; 77 var name = constants[i];
74 var k = constants[i + 1]; 78 var k = constants[i + 1];
75 %AddNamedProperty(object, name, k, attributes); 79 %AddNamedProperty(object, name, k, attributes);
76 } 80 }
77 %ToFastProperties(object); 81 %ToFastProperties(object);
78 } 82 }
79 83
80 84
(...skipping 1825 matching lines...) Expand 10 before | Expand all | Expand 10 after
1906 } 1910 }
1907 if (!IS_SPEC_FUNCTION(method)) { 1911 if (!IS_SPEC_FUNCTION(method)) {
1908 throw MakeTypeError(kNotIterable, obj); 1912 throw MakeTypeError(kNotIterable, obj);
1909 } 1913 }
1910 var iterator = %_CallFunction(obj, method); 1914 var iterator = %_CallFunction(obj, method);
1911 if (!IS_SPEC_OBJECT(iterator)) { 1915 if (!IS_SPEC_OBJECT(iterator)) {
1912 throw MakeTypeError(kNotAnIterator, iterator); 1916 throw MakeTypeError(kNotAnIterator, iterator);
1913 } 1917 }
1914 return iterator; 1918 return iterator;
1915 } 1919 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698