Commit 6357ad84 authored by bradnelson's avatar bradnelson Committed by Commit bot

Support blocks in asm->wasm global section.

The parser can fold together comma separated declarations
into a single block. The AsmWasmBuilder needs to support
this case in order to handle asm.js modules that use this form.

BUG= https://code.google.com/p/v8/issues/detail?id=4203
TEST=mjsunit/asm-wasm
R=aseemgarg@chromium.org,titzer@chromium.org
LOG=N

Review URL: https://codereview.chromium.org/1697423003

Cr-Commit-Position: refs/heads/master@{#34048}
parent f4f19408
......@@ -110,11 +110,15 @@ class AsmWasmBuilderImpl : public AstVisitor {
}
}
}
DCHECK(in_function_);
BlockVisitor visitor(this, stmt->AsBreakableStatement(), kExprBlock, false,
static_cast<byte>(stmt->statements()->length()));
RECURSE(VisitStatements(stmt->statements()));
DCHECK(block_size_ >= 0);
if (in_function_) {
BlockVisitor visitor(this, stmt->AsBreakableStatement(), kExprBlock,
false,
static_cast<byte>(stmt->statements()->length()));
RECURSE(VisitStatements(stmt->statements()));
DCHECK(block_size_ >= 0);
} else {
RECURSE(VisitStatements(stmt->statements()));
}
}
class BlockVisitor {
......
......@@ -1222,6 +1222,26 @@ TestForeignVariables();
})();
(function TestGlobalBlock() {
function Module(stdlib, foreign, buffer) {
"use asm";
var x = foreign.x | 0, y = foreign.y | 0;
function test() {
return (x + y) | 0;
}
return {test: test};
}
var m = _WASMEXP_.instantiateModuleFromAsm(
Module.toString(), { x: 4, y: 11 });
m.__init__();
assertEquals(15, m.test());
})();
(function TestComma() {
function CommaModule() {
"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