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

Side by Side Diff: src/runtime.js

Issue 1130283002: [strong] Disallow implicit conversions for comparison (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: cl feedback Created 5 years, 7 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/ppc/lithium-ppc.h ('k') | src/x64/code-stubs-x64.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 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 files contains runtime support implemented in JavaScript. 5 // This files contains runtime support implemented in JavaScript.
6 6
7 // CAUTION: Some of the functions specified in this file are called 7 // CAUTION: Some of the functions specified in this file are called
8 // directly from compiled code. These are the functions with names in 8 // directly from compiled code. These are the functions with names in
9 // ALL CAPS. The compiled code passes the first argument in 'this'. 9 // ALL CAPS. The compiled code passes the first argument in 'this'.
10 10
11 11
12 /* ----------------------------------- 12 /* -----------------------------------
13 - - - C o m p a r i s o n - - - 13 - - - C o m p a r i s o n - - -
14 ----------------------------------- 14 -----------------------------------
15 */ 15 */
16 16
17 // The following declarations are shared with other native JS files. 17 // The following declarations are shared with other native JS files.
18 // They are all declared at this one spot to avoid redeclaration errors. 18 // They are all declared at this one spot to avoid redeclaration errors.
19 var EQUALS; 19 var EQUALS;
20 var STRICT_EQUALS; 20 var STRICT_EQUALS;
21 var COMPARE; 21 var COMPARE;
22 var COMPARE_STRONG;
22 var ADD; 23 var ADD;
23 var ADD_STRONG; 24 var ADD_STRONG;
24 var STRING_ADD_LEFT; 25 var STRING_ADD_LEFT;
25 var STRING_ADD_LEFT_STRONG; 26 var STRING_ADD_LEFT_STRONG;
26 var STRING_ADD_RIGHT; 27 var STRING_ADD_RIGHT;
27 var STRING_ADD_RIGHT_STRONG; 28 var STRING_ADD_RIGHT_STRONG;
28 var SUB; 29 var SUB;
29 var SUB_STRONG; 30 var SUB_STRONG;
30 var MUL; 31 var MUL;
31 var MUL_STRONG; 32 var MUL_STRONG;
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 if (IS_STRING(left) && IS_STRING(right)) { 197 if (IS_STRING(left) && IS_STRING(right)) {
197 return %_StringCompare(left, right); 198 return %_StringCompare(left, right);
198 } else { 199 } else {
199 var left_number = %$toNumber(left); 200 var left_number = %$toNumber(left);
200 var right_number = %$toNumber(right); 201 var right_number = %$toNumber(right);
201 if (NUMBER_IS_NAN(left_number) || NUMBER_IS_NAN(right_number)) return ncr; 202 if (NUMBER_IS_NAN(left_number) || NUMBER_IS_NAN(right_number)) return ncr;
202 return %NumberCompare(left_number, right_number, ncr); 203 return %NumberCompare(left_number, right_number, ncr);
203 } 204 }
204 } 205 }
205 206
207 // Strong mode COMPARE throws if an implicit conversion would be performed
208 COMPARE_STRONG = function COMPARE_STRONG(x, ncr) {
209 if (IS_STRING(this) && IS_STRING(x)) return %_StringCompare(this, x);
210 if (IS_NUMBER(this) && IS_NUMBER(x)) return %NumberCompare(this, x, ncr);
211
212 throw %MakeTypeError('strong_implicit_cast');
213 }
214
206 215
207 216
208 /* ----------------------------------- 217 /* -----------------------------------
209 - - - A r i t h m e t i c - - - 218 - - - A r i t h m e t i c - - -
210 ----------------------------------- 219 -----------------------------------
211 */ 220 */
212 221
213 // ECMA-262, section 11.6.1, page 50. 222 // ECMA-262, section 11.6.1, page 50.
214 ADD = function ADD(x) { 223 ADD = function ADD(x) {
215 // Fast case: Check for number operands and do the addition. 224 // Fast case: Check for number operands and do the addition.
(...skipping 775 matching lines...) Expand 10 before | Expand all | Expand 10 after
991 $toLength = ToLength; 1000 $toLength = ToLength;
992 $toName = ToName; 1001 $toName = ToName;
993 $toNumber = ToNumber; 1002 $toNumber = ToNumber;
994 $toObject = ToObject; 1003 $toObject = ToObject;
995 $toPositiveInteger = ToPositiveInteger; 1004 $toPositiveInteger = ToPositiveInteger;
996 $toPrimitive = ToPrimitive; 1005 $toPrimitive = ToPrimitive;
997 $toString = ToString; 1006 $toString = ToString;
998 $toUint32 = ToUint32; 1007 $toUint32 = ToUint32;
999 1008
1000 })(); 1009 })();
OLDNEW
« no previous file with comments | « src/ppc/lithium-ppc.h ('k') | src/x64/code-stubs-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698