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

Unified Diff: src/typing-asm.cc

Issue 1692713006: Allow looser heap accesses historically emitted by Emscripten. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: fix 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 | src/wasm/asm-wasm-builder.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 db9558f20837cff8272a356f6342da0a3dfd648f..7594510cd85a79bbcb76e486430fe79b055f545b 100644
--- a/src/typing-asm.cc
+++ b/src/typing-asm.cc
@@ -765,24 +765,28 @@ void AsmTyper::VisitHeapAccess(Property* expr, bool assigning,
RECURSE(VisitWithExpectation(literal, cache_.kAsmSigned,
"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_.kAsmSigned,
- "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_.kAsmSigned,
- "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");
+ if (expected_shift == 0) {
+ RECURSE(Visit(expr->key()));
+ } 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_.kAsmSigned,
+ "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_.kAsmSigned,
+ "array shift expected to be integer"));
+ 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");
+ }
}
- bin->set_bounds(Bounds(cache_.kAsmSigned));
+ expr->key()->set_bounds(Bounds(cache_.kAsmSigned));
}
Type* result_type;
if (type->Is(cache_.kAsmIntArrayElement)) {
@@ -900,7 +904,8 @@ void AsmTyper::VisitProperty(Property* expr) {
// Only recurse at this point so that we avoid needing
// stdlib.Math to have a real type.
- RECURSE(VisitWithExpectation(expr->obj(), Type::Any(), "bad propety object"));
+ RECURSE(
+ VisitWithExpectation(expr->obj(), Type::Any(), "bad property object"));
// For heap view or function table access.
if (computed_type_->IsArray()) {
« no previous file with comments | « no previous file | src/wasm/asm-wasm-builder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698