Commit 25189ffc authored by bradnelson's avatar bradnelson Committed by Commit bot

[wasm][asm.js] Check that property keys are literals for imports.

BUG=672785
R=titzer@chromium.org

Review-Url: https://codereview.chromium.org/2566683002
Cr-Commit-Position: refs/heads/master@{#41624}
parent 50c5ac57
...@@ -335,6 +335,9 @@ void AsmTyper::InitializeStdlib() { ...@@ -335,6 +335,9 @@ void AsmTyper::InitializeStdlib() {
AsmTyper::VariableInfo* AsmTyper::ImportLookup(Property* import) { AsmTyper::VariableInfo* AsmTyper::ImportLookup(Property* import) {
auto* obj = import->obj(); auto* obj = import->obj();
auto* key = import->key()->AsLiteral(); auto* key = import->key()->AsLiteral();
if (key == nullptr) {
return nullptr;
}
ObjectTypeMap* stdlib = &stdlib_types_; ObjectTypeMap* stdlib = &stdlib_types_;
if (auto* obj_as_property = obj->AsProperty()) { if (auto* obj_as_property = obj->AsProperty()) {
......
...@@ -316,6 +316,17 @@ function assertValidAsm(func) { ...@@ -316,6 +316,17 @@ function assertValidAsm(func) {
assertEquals(3, m.foo(3)); assertEquals(3, m.foo(3));
})(); })();
(function TestBadImport() {
function Module(stdlib) {
"use asm";
var set = 0;
var foo = stdlib[set];
return {};
}
var m = Module(this);
assertFalse(%IsAsmWasmCode(Module));
})();
(function TestBadishBooleanExprAnnotation() { (function TestBadishBooleanExprAnnotation() {
function Module() { function Module() {
"use asm"; "use asm";
......
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