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

Side by Side Diff: src/js/v8natives.js

Issue 2421803002: [builtins] Migrate Object.setPrototypeOf to C++. (Closed)
Patch Set: Created 4 years, 2 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 | « src/builtins/builtins-object.cc ('k') | 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 (function(global, utils) { 5 (function(global, utils) {
6 6
7 %CheckIsBootstrapping(); 7 %CheckIsBootstrapping();
8 8
9 // ---------------------------------------------------------------------------- 9 // ----------------------------------------------------------------------------
10 // Imports 10 // Imports
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 97
98 98
99 // ES6 7.3.9 99 // ES6 7.3.9
100 function GetMethod(obj, p) { 100 function GetMethod(obj, p) {
101 var func = obj[p]; 101 var func = obj[p];
102 if (IS_NULL_OR_UNDEFINED(func)) return UNDEFINED; 102 if (IS_NULL_OR_UNDEFINED(func)) return UNDEFINED;
103 if (IS_CALLABLE(func)) return func; 103 if (IS_CALLABLE(func)) return func;
104 throw %make_type_error(kCalledNonCallable, typeof func); 104 throw %make_type_error(kCalledNonCallable, typeof func);
105 } 105 }
106 106
107 // ES6 section 19.1.2.18.
108 function ObjectSetPrototypeOf(obj, proto) {
109 CHECK_OBJECT_COERCIBLE(obj, "Object.setPrototypeOf");
110
111 if (proto !== null && !IS_RECEIVER(proto)) {
112 throw %make_type_error(kProtoObjectOrNull, proto);
113 }
114
115 if (IS_RECEIVER(obj)) {
116 %SetPrototype(obj, proto);
117 }
118
119 return obj;
120 }
121
122 // ES6 B.2.2.1.1 107 // ES6 B.2.2.1.1
123 function ObjectGetProto() { 108 function ObjectGetProto() {
124 return %object_get_prototype_of(this); 109 return %object_get_prototype_of(this);
125 } 110 }
126 111
127 112
128 // ES6 B.2.2.1.2 113 // ES6 B.2.2.1.2
129 function ObjectSetProto(proto) { 114 function ObjectSetProto(proto) {
130 CHECK_OBJECT_COERCIBLE(this, "Object.prototype.__proto__"); 115 CHECK_OBJECT_COERCIBLE(this, "Object.prototype.__proto__");
131 116
(...skipping 30 matching lines...) Expand all
162 "isPrototypeOf", ObjectIsPrototypeOf, 147 "isPrototypeOf", ObjectIsPrototypeOf,
163 // propertyIsEnumerable is added in bootstrapper.cc. 148 // propertyIsEnumerable is added in bootstrapper.cc.
164 // __defineGetter__ is added in bootstrapper.cc. 149 // __defineGetter__ is added in bootstrapper.cc.
165 // __lookupGetter__ is added in bootstrapper.cc. 150 // __lookupGetter__ is added in bootstrapper.cc.
166 // __defineSetter__ is added in bootstrapper.cc. 151 // __defineSetter__ is added in bootstrapper.cc.
167 // __lookupSetter__ is added in bootstrapper.cc. 152 // __lookupSetter__ is added in bootstrapper.cc.
168 ]); 153 ]);
169 utils.InstallGetterSetter( 154 utils.InstallGetterSetter(
170 GlobalObject.prototype, "__proto__", ObjectGetProto, ObjectSetProto); 155 GlobalObject.prototype, "__proto__", ObjectGetProto, ObjectSetProto);
171 156
172 // Set up non-enumerable functions in the Object object.
173 utils.InstallFunctions(GlobalObject, DONT_ENUM, [
174 "setPrototypeOf", ObjectSetPrototypeOf,
175 // getOwnPropertySymbols is added in symbol.js.
176 // Others are added in bootstrapper.cc.
177 ]);
178
179
180 157
181 // ---------------------------------------------------------------------------- 158 // ----------------------------------------------------------------------------
182 // Number 159 // Number
183 160
184 utils.InstallConstants(GlobalNumber, [ 161 utils.InstallConstants(GlobalNumber, [
185 // ECMA-262 section 15.7.3.1. 162 // ECMA-262 section 15.7.3.1.
186 "MAX_VALUE", 1.7976931348623157e+308, 163 "MAX_VALUE", 1.7976931348623157e+308,
187 // ECMA-262 section 15.7.3.2. 164 // ECMA-262 section 15.7.3.2.
188 "MIN_VALUE", 5e-324, 165 "MIN_VALUE", 5e-324,
189 // ECMA-262 section 15.7.3.3. 166 // ECMA-262 section 15.7.3.3.
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 to.GetIterator = GetIterator; 209 to.GetIterator = GetIterator;
233 to.GetMethod = GetMethod; 210 to.GetMethod = GetMethod;
234 to.ObjectHasOwnProperty = GlobalObject.prototype.hasOwnProperty; 211 to.ObjectHasOwnProperty = GlobalObject.prototype.hasOwnProperty;
235 }); 212 });
236 213
237 %InstallToContext([ 214 %InstallToContext([
238 "object_value_of", ObjectValueOf, 215 "object_value_of", ObjectValueOf,
239 ]); 216 ]);
240 217
241 }) 218 })
OLDNEW
« no previous file with comments | « src/builtins/builtins-object.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698