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

Unified Diff: test/cctest/test-asm-validator.cc

Issue 1564393003: Fixing asm validation of switch statements. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 11 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/typing-asm.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/test-asm-validator.cc
diff --git a/test/cctest/test-asm-validator.cc b/test/cctest/test-asm-validator.cc
index 3e6bcd305a2f1f73bb99663978d42bf57daa6e77..b661056d80b9bdeb8657c1d98fd6cabfd82c4a18 100644
--- a/test/cctest/test-asm-validator.cc
+++ b/test/cctest/test-asm-validator.cc
@@ -1932,3 +1932,49 @@ TEST(TypeConsistency) {
CHECK(!cache.kAsmDouble->Is(cache.kAsmFixnum));
CHECK(!cache.kAsmDouble->Is(cache.kAsmFloat));
}
+
+
+TEST(SwitchTest) {
+ CHECK_FUNC_TYPES_BEGIN(
+ "function switcher(x) {\n"
+ " x = x|0;\n"
+ " switch (x|0) {\n"
+ " case 1: return 23;\n"
+ " case 2: return 43;\n"
+ " default: return 66;\n"
+ " }\n"
+ " return 0;\n"
+ "}\n"
+ "function foo() { switcher(1); }") {
+ CHECK_EXPR(FunctionLiteral, FUNC_I2I_TYPE) {
+ CHECK_EXPR(Assignment, Bounds(cache.kAsmInt)) {
+ CHECK_VAR(x, Bounds(cache.kAsmInt));
+ CHECK_EXPR(BinaryOperation, Bounds(cache.kAsmSigned)) {
+ CHECK_VAR(x, Bounds(cache.kAsmInt));
+ CHECK_EXPR(Literal, Bounds(cache.kAsmFixnum));
+ }
+ }
+ CHECK_EXPR(Assignment, Bounds(cache.kAsmInt)) {
+ CHECK_VAR(.switch_tag, Bounds(cache.kAsmInt));
+ CHECK_EXPR(BinaryOperation, Bounds(cache.kAsmSigned)) {
+ CHECK_VAR(x, Bounds(cache.kAsmInt));
+ CHECK_EXPR(Literal, Bounds(cache.kAsmFixnum));
+ }
+ }
+ CHECK_EXPR(Literal, Bounds(Type::Undefined(zone)));
+ CHECK_VAR(.switch_tag, Bounds(cache.kAsmSigned));
+ // case 1: return 23;
+ CHECK_EXPR(Literal, Bounds(cache.kAsmFixnum));
+ CHECK_EXPR(Literal, Bounds(cache.kAsmSigned));
+ // case 2: return 43;
+ CHECK_EXPR(Literal, Bounds(cache.kAsmFixnum));
+ CHECK_EXPR(Literal, Bounds(cache.kAsmSigned));
+ // default: return 66;
+ CHECK_EXPR(Literal, Bounds(cache.kAsmSigned));
+ // return 0;
+ CHECK_EXPR(Literal, Bounds(cache.kAsmSigned));
+ }
+ CHECK_SKIP();
+ }
+ CHECK_FUNC_TYPES_END
+}
« no previous file with comments | « src/typing-asm.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698