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

Unified Diff: src/typing-asm.cc

Issue 1718083004: Allow constant multiply both ways. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: fi Created 4 years, 10 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 ddb608fc2cf3154e12282598bfbfd15f83e67867..b74816f9011292b099262bebc81faa02a87b5f8f 100644
--- a/src/typing-asm.cc
+++ b/src/typing-asm.cc
@@ -690,7 +690,7 @@ void AsmTyper::VisitAssignment(Assignment* expr) {
expected_type_ = target_type;
VisitVariableProxy(expr->target()->AsVariableProxy(), true);
} else if (expr->target()->IsProperty()) {
- int value_intish = intish_;
+ int32_t value_intish = intish_;
Property* property = expr->target()->AsProperty();
RECURSE(VisitWithExpectation(property->obj(), Type::Any(),
"bad propety object"));
@@ -1083,7 +1083,7 @@ void AsmTyper::VisitIntegerBitwiseOperator(BinaryOperation* expr,
Type* result_type, bool conversion) {
RECURSE(VisitWithExpectation(expr->left(), Type::Number(),
"left bitwise operand expected to be a number"));
- int left_intish = intish_;
+ int32_t left_intish = intish_;
Type* left_type = computed_type_;
if (!left_type->Is(left_expected)) {
FAIL(expr->left(), "left bitwise operand expected to be an integer");
@@ -1095,7 +1095,7 @@ void AsmTyper::VisitIntegerBitwiseOperator(BinaryOperation* expr,
RECURSE(
VisitWithExpectation(expr->right(), Type::Number(),
"right bitwise operand expected to be a number"));
- int right_intish = intish_;
+ int32_t right_intish = intish_;
Type* right_type = computed_type_;
if (!right_type->Is(right_expected)) {
FAIL(expr->right(), "right bitwise operand expected to be an integer");
@@ -1204,28 +1204,33 @@ void AsmTyper::VisitBinaryOperation(BinaryOperation* expr) {
expr->left(), Type::Number(),
"left arithmetic operand expected to be number"));
Type* left_type = computed_type_;
- int left_intish = intish_;
+ int32_t left_intish = intish_;
RECURSE(VisitWithExpectation(
expr->right(), Type::Number(),
"right arithmetic operand expected to be number"));
Type* right_type = computed_type_;
- int right_intish = intish_;
+ int32_t right_intish = intish_;
Type* type = Type::Union(left_type, right_type, zone());
if (type->Is(cache_.kAsmInt)) {
if (expr->op() == Token::MUL) {
- Literal* right = expr->right()->AsLiteral();
- if (!right) {
- FAIL(expr, "direct integer multiply forbidden");
- }
- if (!right->value()->IsNumber()) {
- FAIL(expr, "multiply must be by an integer");
- }
int32_t i;
- if (!right->value()->ToInt32(&i)) {
- FAIL(expr, "multiply must be a signed integer");
+ Literal* left = expr->left()->AsLiteral();
+ Literal* right = expr->right()->AsLiteral();
+ if (left != nullptr && left->value()->IsNumber() &&
+ left->value()->ToInt32(&i)) {
+ if (right_intish != 0) {
+ FAIL(expr, "intish not allowed in multiply");
+ }
+ } else if (right != nullptr && right->value()->IsNumber() &&
+ right->value()->ToInt32(&i)) {
+ if (left_intish != 0) {
+ FAIL(expr, "intish not allowed in multiply");
+ }
+ } else {
+ FAIL(expr, "multiply must be by an integer literal");
}
i = abs(i);
- if (i >= 1 << 20) {
+ if (i >= (1 << 20)) {
FAIL(expr, "multiply must be by value in -2^20 < n < 2^20");
}
intish_ = i;
« 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