Allow constant heap accesses in asm typer.
BUG= https://code.google.com/p/v8/issues/detail?id=4203 TEST=test-asm-validator R=titzer@chromium.org,aseemgarg@chromium.org LOG=N Review URL: https://codereview.chromium.org/1405993009 Cr-Commit-Position: refs/heads/master@{#31908}
This commit is contained in:
parent
ec0f891d1e
commit
318bcbee31
@ -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");
|
||||
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));
|
||||
}
|
||||
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));
|
||||
}
|
||||
IntersectResult(expr, type);
|
||||
}
|
||||
|
@ -927,6 +927,32 @@ TEST(Load1) {
|
||||
}
|
||||
|
||||
|
||||
TEST(Load1Constant) {
|
||||
CHECK_FUNC_TYPES_BEGIN(
|
||||
"function bar() { var x = 1; var y = i8[5]|0; }\n"
|
||||
"function foo() { bar(); }") {
|
||||
CHECK_EXPR(FunctionLiteral, FUNC_V_TYPE) {
|
||||
CHECK_EXPR(Assignment, Bounds(cache.kInt32)) {
|
||||
CHECK_VAR(x, Bounds(cache.kInt32));
|
||||
CHECK_EXPR(Literal, Bounds(cache.kInt32));
|
||||
}
|
||||
CHECK_EXPR(Assignment, Bounds(cache.kInt32)) {
|
||||
CHECK_VAR(y, Bounds(cache.kInt32));
|
||||
CHECK_EXPR(BinaryOperation, Bounds(cache.kInt32)) {
|
||||
CHECK_EXPR(Property, Bounds(cache.kInt8)) {
|
||||
CHECK_VAR(i8, Bounds(cache.kInt8Array));
|
||||
CHECK_EXPR(Literal, Bounds(cache.kInt32));
|
||||
}
|
||||
CHECK_EXPR(Literal, Bounds(cache.kInt32));
|
||||
}
|
||||
}
|
||||
}
|
||||
CHECK_SKIP();
|
||||
}
|
||||
CHECK_FUNC_TYPES_END
|
||||
}
|
||||
|
||||
|
||||
TEST(FunctionTables) {
|
||||
CHECK_FUNC_TYPES_BEGIN(
|
||||
"function func1(x) { x = x | 0; return (x * 5) | 0; }\n"
|
||||
|
Loading…
Reference in New Issue
Block a user