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

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: 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 | « no previous file | 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..18b9fe6ace71da3d37523992612699388941b237 100644
--- a/src/typing-asm.cc
+++ b/src/typing-asm.cc
@@ -1213,19 +1213,24 @@ void AsmTyper::VisitBinaryOperation(BinaryOperation* expr) {
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 literal integer");
titzer 2016/02/23 15:52:18 by "an integer literal" ?
bradn 2016/02/23 16:27:09 Done.
}
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 | « no previous file | test/cctest/test-asm-validator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698