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

Unified 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/runtime.js
diff --git a/src/runtime.js b/src/runtime.js
index 004f9bf61bcdd1a088f12696b7216c0ead17f1c6..fbe50c95a461f4f86f139074793a2dab9e23948d 100644
--- a/src/runtime.js
+++ b/src/runtime.js
@@ -19,6 +19,7 @@
var EQUALS;
var STRICT_EQUALS;
var COMPARE;
+var COMPARE_STRONG;
var ADD;
var ADD_STRONG;
var STRING_ADD_LEFT;
@@ -203,6 +204,14 @@ COMPARE = function COMPARE(x, ncr) {
}
}
+// Strong mode COMPARE throws if an implicit conversion would be performed
+COMPARE_STRONG = function COMPARE_STRONG(x, ncr) {
+ if (IS_STRING(this) && IS_STRING(x)) return %_StringCompare(this, x);
+ if (IS_NUMBER(this) && IS_NUMBER(x)) return %NumberCompare(this, x, ncr);
+
+ throw %MakeTypeError('strong_implicit_cast');
+}
+
/* -----------------------------------
« 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