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

Unified Diff: src/typing-asm.cc

Issue 1405993009: Allow constant heap accesses in asm typer. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 1 month 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 92f7c12e8b8e34e7f34d7cb569a5e0f5e87497ff..b267113400c8a6dc7995f0ad0305b35124298d7d 100644
--- a/src/typing-asm.cc
+++ b/src/typing-asm.cc
@@ -610,24 +610,30 @@ void AsmTyper::VisitHeapAccess(Property* expr) {
}
bin->set_bounds(Bounds(cache_.kInt32));
} else {
- BinaryOperation* bin = expr->key()->AsBinaryOperation();
- if (bin == NULL || bin->op() != Token::SAR) {
- FAIL(expr->key(), "expected >> in heap access");
- }
- RECURSE(VisitWithExpectation(bin->left(), cache_.kInt32,
- "array index expected to be integer"));
- Literal* right = bin->right()->AsLiteral();
- if (right == NULL || right->raw_value()->ContainsDot()) {
- FAIL(right, "heap access shift must be integer");
- }
- RECURSE(VisitWithExpectation(bin->right(), cache_.kInt32,
- "array shift expected to be integer"));
- int n = static_cast<int>(right->raw_value()->AsNumber());
- int expected_shift = ElementShiftSize(type);
- if (expected_shift < 0 || n != expected_shift) {
- FAIL(right, "heap access shift must match element size");
+ Literal* literal = expr->key()->AsLiteral();
+ if (literal) {
+ RECURSE(VisitWithExpectation(literal, cache_.kInt32,
+ "array index expected to be integer"));
+ } else {
+ BinaryOperation* bin = expr->key()->AsBinaryOperation();
+ if (bin == NULL || bin->op() != Token::SAR) {
+ FAIL(expr->key(), "expected >> in heap access");
+ }
+ RECURSE(VisitWithExpectation(bin->left(), cache_.kInt32,
+ "array index expected to be integer"));
+ Literal* right = bin->right()->AsLiteral();
+ if (right == NULL || right->raw_value()->ContainsDot()) {
+ FAIL(right, "heap access shift must be integer");
+ }
+ RECURSE(VisitWithExpectation(bin->right(), cache_.kInt32,
+ "array shift expected to be integer"));
+ int n = static_cast<int>(right->raw_value()->AsNumber());
+ int expected_shift = ElementShiftSize(type);
+ if (expected_shift < 0 || n != expected_shift) {
+ FAIL(right, "heap access shift must match element size");
+ }
+ bin->set_bounds(Bounds(cache_.kInt32));
}
- bin->set_bounds(Bounds(cache_.kInt32));
}
IntersectResult(expr, type);
}
« 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