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

Unified Diff: src/asmjs/asm-wasm-builder.cc

Issue 2630553002: [wasm] Enforce that function bodies end with the \"end\" opcode. (Closed)
Patch Set: Collapse some tests together Created 3 years, 11 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/function-body-decoder.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/asmjs/asm-wasm-builder.cc
diff --git a/src/asmjs/asm-wasm-builder.cc b/src/asmjs/asm-wasm-builder.cc
index bf89ed13872bef8fb6ffa61416a24214ecc9e46f..61214f165c2dd8436dedd76ac6ef8b402203c565 100644
--- a/src/asmjs/asm-wasm-builder.cc
+++ b/src/asmjs/asm-wasm-builder.cc
@@ -101,6 +101,7 @@ class AsmWasmBuilderImpl final : public AstVisitor<AsmWasmBuilderImpl> {
uint32_t index = LookupOrInsertGlobal(fv->var, fv->type);
foreign_init_function_->EmitWithVarInt(kExprSetGlobal, index);
}
+ foreign_init_function_->Emit(kExprEnd);
}
Handle<FixedArray> GetForeignArgs() {
@@ -131,6 +132,7 @@ class AsmWasmBuilderImpl final : public AstVisitor<AsmWasmBuilderImpl> {
return false;
}
BuildForeignInitFunction();
+ init_function_->Emit(kExprEnd); // finish init function.
return true;
}
@@ -543,6 +545,10 @@ class AsmWasmBuilderImpl final : public AstVisitor<AsmWasmBuilderImpl> {
RECURSE(VisitDeclarations(scope->declarations()));
if (typer_failed_) return;
RECURSE(VisitStatements(expr->body()));
+ if (scope_ == kFuncScope) {
+ // Finish the function-body scope block.
+ current_function_builder_->Emit(kExprEnd);
+ }
}
void VisitNativeFunctionLiteral(NativeFunctionLiteral* expr) {
« no previous file with comments | « no previous file | src/wasm/function-body-decoder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698