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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « no previous file | test/cctest/test-asm-validator.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/typing-asm.h" 5 #include "src/typing-asm.h"
6 6
7 #include <limits> 7 #include <limits>
8 8
9 #include "src/v8.h" 9 #include "src/v8.h"
10 10
(...skipping 1191 matching lines...) Expand 10 before | Expand all | Expand 10 after
1202 case Token::MOD: { 1202 case Token::MOD: {
1203 RECURSE(VisitWithExpectation( 1203 RECURSE(VisitWithExpectation(
1204 expr->left(), Type::Number(), 1204 expr->left(), Type::Number(),
1205 "left arithmetic operand expected to be number")); 1205 "left arithmetic operand expected to be number"));
1206 Type* left_type = computed_type_; 1206 Type* left_type = computed_type_;
1207 int left_intish = intish_; 1207 int left_intish = intish_;
1208 RECURSE(VisitWithExpectation( 1208 RECURSE(VisitWithExpectation(
1209 expr->right(), Type::Number(), 1209 expr->right(), Type::Number(),
1210 "right arithmetic operand expected to be number")); 1210 "right arithmetic operand expected to be number"));
1211 Type* right_type = computed_type_; 1211 Type* right_type = computed_type_;
1212 int right_intish = intish_; 1212 int right_intish = intish_;
titzer 2016/02/23 15:52:18 probably want int32_t here?
bradn 2016/02/23 16:27:09 I suppose. Done.
1213 Type* type = Type::Union(left_type, right_type, zone()); 1213 Type* type = Type::Union(left_type, right_type, zone());
1214 if (type->Is(cache_.kAsmInt)) { 1214 if (type->Is(cache_.kAsmInt)) {
1215 if (expr->op() == Token::MUL) { 1215 if (expr->op() == Token::MUL) {
1216 int32_t i;
1217 Literal* left = expr->left()->AsLiteral();
1216 Literal* right = expr->right()->AsLiteral(); 1218 Literal* right = expr->right()->AsLiteral();
1217 if (!right) { 1219 if (left != nullptr && left->value()->IsNumber() &&
1218 FAIL(expr, "direct integer multiply forbidden"); 1220 left->value()->ToInt32(&i)) {
1219 } 1221 if (right_intish != 0) {
1220 if (!right->value()->IsNumber()) { 1222 FAIL(expr, "intish not allowed in multiply");
1221 FAIL(expr, "multiply must be by an integer"); 1223 }
1222 } 1224 } else if (right != nullptr && right->value()->IsNumber() &&
1223 int32_t i; 1225 right->value()->ToInt32(&i)) {
1224 if (!right->value()->ToInt32(&i)) { 1226 if (left_intish != 0) {
1225 FAIL(expr, "multiply must be a signed integer"); 1227 FAIL(expr, "intish not allowed in multiply");
1228 }
1229 } else {
1230 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.
1226 } 1231 }
1227 i = abs(i); 1232 i = abs(i);
1228 if (i >= 1 << 20) { 1233 if (i >= (1 << 20)) {
1229 FAIL(expr, "multiply must be by value in -2^20 < n < 2^20"); 1234 FAIL(expr, "multiply must be by value in -2^20 < n < 2^20");
1230 } 1235 }
1231 intish_ = i; 1236 intish_ = i;
1232 IntersectResult(expr, cache_.kAsmInt); 1237 IntersectResult(expr, cache_.kAsmInt);
1233 return; 1238 return;
1234 } else { 1239 } else {
1235 intish_ = left_intish + right_intish + 1; 1240 intish_ = left_intish + right_intish + 1;
1236 if (expr->op() == Token::ADD || expr->op() == Token::SUB) { 1241 if (expr->op() == Token::ADD || expr->op() == Token::SUB) {
1237 if (intish_ > kMaxUncombinedAdditiveSteps) { 1242 if (intish_ > kMaxUncombinedAdditiveSteps) {
1238 FAIL(expr, "too many consecutive additive ops"); 1243 FAIL(expr, "too many consecutive additive ops");
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after
1555 } 1560 }
1556 1561
1557 1562
1558 void AsmTyper::VisitRewritableExpression(RewritableExpression* expr) { 1563 void AsmTyper::VisitRewritableExpression(RewritableExpression* expr) {
1559 RECURSE(Visit(expr->expression())); 1564 RECURSE(Visit(expr->expression()));
1560 } 1565 }
1561 1566
1562 1567
1563 } // namespace internal 1568 } // namespace internal
1564 } // namespace v8 1569 } // namespace v8
OLDNEW
« 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