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

Unified Diff: test/mjsunit/strong/implicit-conversions-inlining.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 | « test/mjsunit/strong/implicit-conversions.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/strong/implicit-conversions-inlining.js
diff --git a/test/mjsunit/strong/implicit-conversions-inlining.js b/test/mjsunit/strong/implicit-conversions-inlining.js
index f1cb9cd36d50a4d9a612e8d4df72735437062ea3..15997a37aa1ff37f24983f4fa2adcaa865d5718f 100644
--- a/test/mjsunit/strong/implicit-conversions-inlining.js
+++ b/test/mjsunit/strong/implicit-conversions-inlining.js
@@ -6,6 +6,8 @@
"use strict";
+//******************************************************************************
+// Number function declarations
function inline_add_strong(x, y) {
"use strong";
return x + y;
@@ -105,6 +107,42 @@ function inline_sar_strong_outer(x, y) {
return inline_sar_strong(x, y);
}
+function inline_less_strong(x, y) {
+ "use strong";
+ return x < y;
+}
+
+function inline_less_strong_outer(x, y) {
+ return inline_less_strong(x, y);
+}
+
+function inline_greater_strong(x, y) {
+ "use strong";
+ return x > y;
+}
+
+function inline_greater_strong_outer(x, y) {
+ return inline_greater_strong(x, y);
+}
+
+function inline_less_equal_strong(x, y) {
+ "use strong";
+ return x <= y;
+}
+
+function inline_less_equal_strong_outer(x, y) {
+ return inline_less_equal_strong(x, y);
+}
+
+function inline_greater_equal_strong(x, y) {
+ "use strong";
+ return x >= y;
+}
+
+function inline_greater_equal_strong_outer(x, y) {
+ return inline_greater_equal_strong(x, y);
+}
+
function inline_add(x, y) {
return x + y;
}
@@ -204,19 +242,170 @@ function inline_sar_outer_strong(x, y) {
return inline_sar(x, y);
}
-let strong_inner_funcs = [inline_add_strong_outer, inline_sub_strong_outer,
- inline_mul_strong_outer, inline_div_strong_outer,
- inline_mod_strong_outer, inline_or_strong_outer,
- inline_and_strong_outer, inline_xor_strong_outer,
- inline_shl_strong_outer, inline_shr_strong_outer];
+function inline_less(x, y) {
+ return x < y;
+}
+
+function inline_less_outer_strong(x, y) {
+ "use strong";
+ return inline_less(x, y);
+}
+
+function inline_greater(x, y) {
+ return x > y;
+}
+
+function inline_greater_outer_strong(x, y) {
+ "use strong";
+ return inline_greater(x, y);
+}
-let strong_outer_funcs = [inline_add_outer_strong, inline_sub_outer_strong,
- inline_mul_outer_strong, inline_div_outer_strong,
- inline_mod_outer_strong, inline_or_outer_strong,
- inline_and_outer_strong, inline_xor_outer_strong,
- inline_shl_outer_strong, inline_shr_outer_strong];
+function inline_less_equal(x, y) {
+ return x <= y;
+}
+
+function inline_less_equal_outer_strong(x, y) {
+ "use strong";
+ return inline_less_equal(x, y);
+}
+
+function inline_greater_equal(x, y) {
+ return x >>> y;
+}
+
+function inline_greater_equal_outer_strong(x, y) {
+ "use strong";
+ return inline_greater_equal(x, y);
+}
+
+//******************************************************************************
+// String function declarations
+function inline_add_string_strong(x, y) {
+ "use strong";
+ return x + y;
+}
+
+function inline_add_string_strong_outer(x, y) {
+ return inline_add_string_strong(x, y);
+}
+
+function inline_less_string_strong(x, y) {
+ "use strong";
+ return x < y;
+}
+
+function inline_less_string_strong_outer(x, y) {
+ return inline_less_string_strong(x, y);
+}
-for (let strong_inner_func of strong_inner_funcs) {
+function inline_greater_string_strong(x, y) {
+ "use strong";
+ return x > y;
+}
+
+function inline_greater_string_strong_outer(x, y) {
+ return inline_greater_string_strong(x, y);
+}
+
+function inline_less_equal_string_strong(x, y) {
+ "use strong";
+ return x <= y;
+}
+
+function inline_less_equal_string_strong_outer(x, y) {
+ return inline_less_equal_string_strong(x, y);
+}
+
+function inline_greater_equal_string_strong(x, y) {
+ "use strong";
+ return x >= y;
+}
+
+function inline_greater_equal_string_strong_outer(x, y) {
+ return inline_greater_equal_string_strong(x, y);
+}
+
+function inline_add_string(x, y) {
+ return x + y;
+}
+
+function inline_add_string_outer_strong(x, y) {
+ "use strong";
+ return inline_add_string(x, y);
+}
+
+function inline_less_string(x, y) {
+ return x < y;
+}
+
+function inline_less_string_outer_strong(x, y) {
+ "use strong";
+ return inline_less_string(x, y);
+}
+
+function inline_greater_string(x, y) {
+ return x > y;
+}
+
+function inline_greater_string_outer_strong(x, y) {
+ "use strong";
+ return inline_greater_string(x, y);
+}
+
+function inline_less_equal_string(x, y) {
+ return x <= y;
+}
+
+function inline_less_equal_string_outer_strong(x, y) {
+ "use strong";
+ return inline_less_equal_string(x, y);
+}
+
+function inline_greater_equal_string(x, y) {
+ return x >= y;
+}
+
+function inline_greater_equal_string_outer_strong(x, y) {
+ "use strong";
+ return inline_greater_equal_string(x, y);
+}
+
+
+//******************************************************************************
+// Testing
+let strong_inner_funcs_num = [inline_add_strong_outer, inline_sub_strong_outer,
+ inline_mul_strong_outer, inline_div_strong_outer,
+ inline_mod_strong_outer, inline_or_strong_outer,
+ inline_and_strong_outer, inline_xor_strong_outer,
+ inline_shl_strong_outer, inline_shr_strong_outer,
+ inline_less_strong_outer,
+ inline_greater_strong_outer,
+ inline_less_equal_strong_outer,
+ inline_greater_equal_strong_outer];
+
+let strong_outer_funcs_num = [inline_add_outer_strong, inline_sub_outer_strong,
+ inline_mul_outer_strong, inline_div_outer_strong,
+ inline_mod_outer_strong, inline_or_outer_strong,
+ inline_and_outer_strong, inline_xor_outer_strong,
+ inline_shl_outer_strong, inline_shr_outer_strong,
+ inline_less_outer_strong,
+ inline_greater_outer_strong,
+ inline_less_equal_outer_strong,
+ inline_greater_equal_outer_strong];
+
+let strong_inner_funcs_string = [inline_add_string_strong_outer,
+ inline_less_string_strong_outer,
+ inline_greater_string_strong_outer,
+ inline_less_equal_string_strong_outer,
+ inline_greater_equal_string_strong_outer];
+
+let strong_outer_funcs_string = [inline_add_string_outer_strong,
+ inline_less_string_outer_strong,
+ inline_greater_string_outer_strong,
+ inline_less_equal_string_outer_strong,
+ inline_greater_equal_string_outer_strong];
+
+for (let strong_inner_func of strong_inner_funcs_num) {
assertThrows(function(){strong_inner_func(1, {})}, TypeError);
for (var i = 0; i < 100; i++) {
strong_inner_func(1, 2);
@@ -225,7 +414,7 @@ for (let strong_inner_func of strong_inner_funcs) {
assertThrows(function(){strong_inner_func(1, {})}, TypeError);
}
-for (let strong_outer_func of strong_outer_funcs) {
+for (let strong_outer_func of strong_outer_funcs_num) {
assertDoesNotThrow(function(){strong_outer_func(1, {})});
for (var i = 0; i < 100; i++) {
strong_outer_func(1, 2);
@@ -233,3 +422,21 @@ for (let strong_outer_func of strong_outer_funcs) {
%OptimizeFunctionOnNextCall(strong_outer_func);
assertDoesNotThrow(function(){strong_outer_func(1, {})});
}
+
+for (let strong_inner_func of strong_inner_funcs_string) {
+ assertThrows(function(){strong_inner_func("foo", {})}, TypeError);
+ for (var i = 0; i < 100; i++) {
+ strong_inner_func("foo", "bar");
+ }
+ %OptimizeFunctionOnNextCall(strong_inner_func);
+ assertThrows(function(){strong_inner_func("foo", {})}, TypeError);
+}
+
+for (let strong_outer_func of strong_outer_funcs_string) {
+ assertDoesNotThrow(function(){strong_outer_func("foo", {})});
+ for (var i = 0; i < 100; i++) {
+ strong_outer_func("foo", "bar");
+ }
+ %OptimizeFunctionOnNextCall(strong_outer_func);
+ assertDoesNotThrow(function(){strong_outer_func("foo", {})});
+}
« no previous file with comments | « test/mjsunit/strong/implicit-conversions.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698