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

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

Issue 2222893002: Move family of MakeError functions to C++ (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix in prologue.js Created 4 years, 4 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
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
11 11
12 var GlobalNumber = global.Number; 12 var GlobalNumber = global.Number;
13 var GlobalObject = global.Object; 13 var GlobalObject = global.Object;
14 var iteratorSymbol = utils.ImportNow("iterator_symbol"); 14 var iteratorSymbol = utils.ImportNow("iterator_symbol");
15 var MakeRangeError;
16 var MakeSyntaxError;
17 var MakeTypeError;
18 var NaN = %GetRootNaN(); 15 var NaN = %GetRootNaN();
19 var ObjectToString = utils.ImportNow("object_to_string"); 16 var ObjectToString = utils.ImportNow("object_to_string");
20 17
21 utils.Import(function(from) {
22 MakeRangeError = from.MakeRangeError;
23 MakeSyntaxError = from.MakeSyntaxError;
24 MakeTypeError = from.MakeTypeError;
25 });
26
27 // ---------------------------------------------------------------------------- 18 // ----------------------------------------------------------------------------
28 19
29 20
30 // ES6 18.2.3 isNaN(number) 21 // ES6 18.2.3 isNaN(number)
31 function GlobalIsNaN(number) { 22 function GlobalIsNaN(number) {
32 number = TO_NUMBER(number); 23 number = TO_NUMBER(number);
33 return NUMBER_IS_NAN(number); 24 return NUMBER_IS_NAN(number);
34 } 25 }
35 26
36 27
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 var O = TO_OBJECT(this); 120 var O = TO_OBJECT(this);
130 return %HasInPrototypeChain(V, O); 121 return %HasInPrototypeChain(V, O);
131 } 122 }
132 123
133 124
134 // ES6 7.3.9 125 // ES6 7.3.9
135 function GetMethod(obj, p) { 126 function GetMethod(obj, p) {
136 var func = obj[p]; 127 var func = obj[p];
137 if (IS_NULL_OR_UNDEFINED(func)) return UNDEFINED; 128 if (IS_NULL_OR_UNDEFINED(func)) return UNDEFINED;
138 if (IS_CALLABLE(func)) return func; 129 if (IS_CALLABLE(func)) return func;
139 throw MakeTypeError(kCalledNonCallable, typeof func); 130 throw %make_type_error(kCalledNonCallable, typeof func);
140 } 131 }
141 132
142 // ES6 section 19.1.2.18. 133 // ES6 section 19.1.2.18.
143 function ObjectSetPrototypeOf(obj, proto) { 134 function ObjectSetPrototypeOf(obj, proto) {
144 CHECK_OBJECT_COERCIBLE(obj, "Object.setPrototypeOf"); 135 CHECK_OBJECT_COERCIBLE(obj, "Object.setPrototypeOf");
145 136
146 if (proto !== null && !IS_RECEIVER(proto)) { 137 if (proto !== null && !IS_RECEIVER(proto)) {
147 throw MakeTypeError(kProtoObjectOrNull, proto); 138 throw %make_type_error(kProtoObjectOrNull, proto);
148 } 139 }
149 140
150 if (IS_RECEIVER(obj)) { 141 if (IS_RECEIVER(obj)) {
151 %SetPrototype(obj, proto); 142 %SetPrototype(obj, proto);
152 } 143 }
153 144
154 return obj; 145 return obj;
155 } 146 }
156 147
157 // ES6 B.2.2.1.1 148 // ES6 B.2.2.1.1
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
282 273
283 // ---------------------------------------------------------------------------- 274 // ----------------------------------------------------------------------------
284 // Iterator related spec functions. 275 // Iterator related spec functions.
285 276
286 // ES6 7.4.1 GetIterator(obj, method) 277 // ES6 7.4.1 GetIterator(obj, method)
287 function GetIterator(obj, method) { 278 function GetIterator(obj, method) {
288 if (IS_UNDEFINED(method)) { 279 if (IS_UNDEFINED(method)) {
289 method = obj[iteratorSymbol]; 280 method = obj[iteratorSymbol];
290 } 281 }
291 if (!IS_CALLABLE(method)) { 282 if (!IS_CALLABLE(method)) {
292 throw MakeTypeError(kNotIterable, obj); 283 throw %make_type_error(kNotIterable, obj);
293 } 284 }
294 var iterator = %_Call(method, obj); 285 var iterator = %_Call(method, obj);
295 if (!IS_RECEIVER(iterator)) { 286 if (!IS_RECEIVER(iterator)) {
296 throw MakeTypeError(kNotAnIterator, iterator); 287 throw %make_type_error(kNotAnIterator, iterator);
297 } 288 }
298 return iterator; 289 return iterator;
299 } 290 }
300 291
301 // ---------------------------------------------------------------------------- 292 // ----------------------------------------------------------------------------
302 // Exports 293 // Exports
303 294
304 utils.Export(function(to) { 295 utils.Export(function(to) {
305 to.GetIterator = GetIterator; 296 to.GetIterator = GetIterator;
306 to.GetMethod = GetMethod; 297 to.GetMethod = GetMethod;
307 to.IsNaN = GlobalIsNaN; 298 to.IsNaN = GlobalIsNaN;
308 to.NumberIsNaN = NumberIsNaN; 299 to.NumberIsNaN = NumberIsNaN;
309 to.NumberIsInteger = NumberIsInteger; 300 to.NumberIsInteger = NumberIsInteger;
310 to.ObjectHasOwnProperty = GlobalObject.prototype.hasOwnProperty; 301 to.ObjectHasOwnProperty = GlobalObject.prototype.hasOwnProperty;
311 }); 302 });
312 303
313 %InstallToContext([ 304 %InstallToContext([
314 "object_value_of", ObjectValueOf, 305 "object_value_of", ObjectValueOf,
315 ]); 306 ]);
316 307
317 }) 308 })
OLDNEW
« src/bootstrapper.cc ('K') | « src/js/typedarray.js ('k') | src/js/weak-collection.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698