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

Unified Diff: src/typing-asm.cc

Issue 2106683003: [wasm] Making compare and conditionals more correct. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix Created 4 years, 6 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.h ('k') | test/cctest/test-asm-validator.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/typing-asm.cc
diff --git a/src/typing-asm.cc b/src/typing-asm.cc
index 26a85442360066ff3435a0fbb4dd4d14b65d6c31..e8c013a3373776dab29c87b716b3ff4d81856678 100644
--- a/src/typing-asm.cc
+++ b/src/typing-asm.cc
@@ -540,20 +540,22 @@ void AsmTyper::VisitConditional(Conditional* expr) {
expr->then_expression(), expected_type_,
"conditional then branch type mismatch with enclosing expression"));
Type* then_type = StorageType(computed_type_);
- if (intish_ != 0 || !then_type->Is(cache_.kAsmComparable)) {
- FAIL(expr->then_expression(), "invalid type in ? then expression");
- }
+ int then_intish = intish_;
RECURSE(VisitWithExpectation(
expr->else_expression(), expected_type_,
"conditional else branch type mismatch with enclosing expression"));
Type* else_type = StorageType(computed_type_);
- if (intish_ != 0 || !else_type->Is(cache_.kAsmComparable)) {
- FAIL(expr->else_expression(), "invalid type in ? else expression");
- }
+ int else_intish = intish_;
- if (!then_type->Is(else_type) || !else_type->Is(then_type)) {
- FAIL(expr, "then and else expressions in ? must have the same type");
+ if (then_intish != 0 || else_intish != 0 ||
+ !((then_type->Is(cache_.kAsmInt) && else_type->Is(cache_.kAsmInt)) ||
+ (then_type->Is(cache_.kAsmFloat) && else_type->Is(cache_.kAsmFloat)) ||
+ (then_type->Is(cache_.kAsmDouble) &&
+ else_type->Is(cache_.kAsmDouble)))) {
+ FAIL(expr,
+ "then and else expressions in ? must have the same type "
+ "and be int, float, or double");
}
RECURSE(IntersectResult(expr, then_type));
@@ -1379,20 +1381,25 @@ void AsmTyper::VisitCompareOperation(CompareOperation* expr) {
VisitWithExpectation(expr->left(), Type::Number(),
"left comparison operand expected to be number"));
Type* left_type = computed_type_;
- if (!left_type->Is(cache_.kAsmComparable)) {
- FAIL(expr->left(), "bad type on left side of comparison");
- }
+ int left_intish = intish_;
RECURSE(
VisitWithExpectation(expr->right(), Type::Number(),
"right comparison operand expected to be number"));
Type* right_type = computed_type_;
- if (!right_type->Is(cache_.kAsmComparable)) {
- FAIL(expr->right(), "bad type on right side of comparison");
- }
-
- if (!left_type->Is(right_type) && !right_type->Is(left_type)) {
- FAIL(expr, "left and right side of comparison must match");
+ int right_intish = intish_;
+
+ if (left_intish != 0 || right_intish != 0 ||
+ !((left_type->Is(cache_.kAsmUnsigned) &&
+ right_type->Is(cache_.kAsmUnsigned)) ||
+ (left_type->Is(cache_.kAsmSigned) &&
+ right_type->Is(cache_.kAsmSigned)) ||
+ (left_type->Is(cache_.kAsmFloat) && right_type->Is(cache_.kAsmFloat)) ||
+ (left_type->Is(cache_.kAsmDouble) &&
+ right_type->Is(cache_.kAsmDouble)))) {
+ FAIL(expr,
+ "left and right side of comparison must match type "
+ "and be signed, unsigned, float, or double");
}
RECURSE(IntersectResult(expr, cache_.kAsmSigned));
« no previous file with comments | « src/typing-asm.h ('k') | test/cctest/test-asm-validator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698