Commit cd95c600 authored by aseemgarg's avatar aseemgarg Committed by Commit bot

[wasm] allow array access with unsigned indices

BUG=618608
R=bradnelson@chromium.org
TEST=regress-618608.js

Review-Url: https://codereview.chromium.org/2138243002
Cr-Commit-Position: refs/heads/master@{#37693}
parent 81f42220
......@@ -763,14 +763,14 @@ void AsmTyper::VisitHeapAccess(Property* expr, bool assigning,
// FAIL(right, "call mask must match function table");
// }
// bin->set_bounds(Bounds(cache_.kAsmSigned));
RECURSE(VisitWithExpectation(expr->key(), cache_.kAsmSigned,
"must be integer"));
RECURSE(
VisitWithExpectation(expr->key(), cache_.kAsmSigned, "must be int"));
RECURSE(IntersectResult(expr, type));
} else {
Literal* literal = expr->key()->AsLiteral();
if (literal) {
RECURSE(VisitWithExpectation(literal, cache_.kAsmSigned,
"array index expected to be integer"));
RECURSE(VisitWithExpectation(literal, cache_.kAsmUnsigned,
"array index expected to be unsigned"));
} else {
int expected_shift = ElementShiftSize(type);
if (expected_shift == 0) {
......@@ -780,20 +780,20 @@ void AsmTyper::VisitHeapAccess(Property* expr, bool assigning,
if (bin == nullptr || bin->op() != Token::SAR) {
FAIL(expr->key(), "expected >> in heap access");
}
RECURSE(VisitWithExpectation(bin->left(), cache_.kAsmSigned,
RECURSE(VisitWithExpectation(bin->left(), cache_.kAsmInt,
"array index expected to be integer"));
Literal* right = bin->right()->AsLiteral();
if (right == nullptr || right->raw_value()->ContainsDot()) {
FAIL(bin->right(), "heap access shift must be integer");
}
RECURSE(VisitWithExpectation(bin->right(), cache_.kAsmSigned,
"array shift expected to be integer"));
RECURSE(VisitWithExpectation(bin->right(), cache_.kAsmFixnum,
"array shift expected to be Fixnum"));
int n = static_cast<int>(right->raw_value()->AsNumber());
if (expected_shift < 0 || n != expected_shift) {
FAIL(right, "heap access shift must match element size");
}
}
bounds_.set(expr->key(), Bounds(cache_.kAsmSigned));
bounds_.set(expr->key(), Bounds(cache_.kAsmUnsigned));
}
Type* result_type;
if (type->Is(cache_.kAsmIntArrayElement)) {
......
......@@ -203,8 +203,8 @@ TEST(ValidateMinimum) {
CHECK_VAR(log, FUNC_D2D_TYPE);
CHECK_EXPR(Property, Bounds(cache.kAsmDouble)) {
CHECK_VAR(values, FLOAT64_ARRAY_TYPE);
CHECK_EXPR(BinaryOperation, Bounds(cache.kAsmSigned)) {
CHECK_VAR(p, Bounds(cache.kAsmSigned));
CHECK_EXPR(BinaryOperation, Bounds(cache.kAsmUnsigned)) {
CHECK_VAR(p, Bounds(cache.kAsmInt));
CHECK_EXPR(Literal, Bounds(cache.kAsmFixnum));
}
}
......@@ -1453,7 +1453,7 @@ TEST(Load1) {
CHECK_EXPR(BinaryOperation, Bounds(cache.kAsmSigned)) {
CHECK_EXPR(Property, Bounds(cache.kAsmInt)) {
CHECK_VAR(i8, Bounds(cache.kInt8Array));
CHECK_EXPR(BinaryOperation, Bounds(cache.kAsmSigned)) {
CHECK_EXPR(BinaryOperation, Bounds(cache.kAsmUnsigned)) {
CHECK_VAR(x, Bounds(cache.kAsmInt));
CHECK_EXPR(Literal, Bounds(cache.kAsmFixnum));
}
......@@ -1486,8 +1486,8 @@ TEST(LoadDouble) {
CHECK_EXPR(BinaryOperation, Bounds(cache.kAsmDouble)) {
CHECK_EXPR(Property, Bounds(cache.kAsmDouble)) {
CHECK_VAR(f64, Bounds(cache.kFloat64Array));
CHECK_EXPR(BinaryOperation, Bounds(cache.kAsmSigned)) {
CHECK_VAR(x, Bounds(cache.kAsmSigned));
CHECK_EXPR(BinaryOperation, Bounds(cache.kAsmUnsigned)) {
CHECK_VAR(x, Bounds(cache.kAsmInt));
CHECK_EXPR(Literal, Bounds(cache.kAsmFixnum));
}
}
......@@ -1513,7 +1513,7 @@ TEST(Store1) {
CHECK_EXPR(Assignment, Bounds(cache.kAsmInt)) {
CHECK_EXPR(Property, Bounds::Unbounded()) {
CHECK_VAR(i8, Bounds(cache.kInt8Array));
CHECK_EXPR(BinaryOperation, Bounds(cache.kAsmSigned)) {
CHECK_EXPR(BinaryOperation, Bounds(cache.kAsmUnsigned)) {
CHECK_VAR(x, Bounds(cache.kAsmInt));
CHECK_EXPR(Literal, Bounds(cache.kAsmFixnum));
}
......@@ -1962,7 +1962,7 @@ TEST(ByteArray) {
CHECK_EXPR(Assignment, Bounds(cache.kAsmInt)) {
CHECK_EXPR(Property, Bounds::Unbounded()) {
CHECK_VAR(i8, Bounds(cache.kInt8Array));
CHECK_VAR(x, Bounds(cache.kAsmSigned));
CHECK_VAR(x, Bounds(cache.kAsmUnsigned));
}
CHECK_EXPR(Literal, Bounds(cache.kAsmFixnum));
}
......@@ -2077,7 +2077,7 @@ TEST(NestedAssignmentInHeap) {
CHECK_EXPR(Assignment, Bounds(cache.kAsmInt)) {
CHECK_EXPR(Property, Bounds::Unbounded()) {
CHECK_VAR(i8, Bounds(cache.kInt8Array));
CHECK_EXPR(BinaryOperation, Bounds(cache.kAsmSigned)) {
CHECK_EXPR(BinaryOperation, Bounds(cache.kAsmUnsigned)) {
CHECK_EXPR(Assignment, Bounds(cache.kAsmInt)) {
CHECK_VAR(x, Bounds(cache.kAsmInt));
CHECK_EXPR(Literal, Bounds(cache.kAsmFixnum));
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment