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

Unified Diff: test/cctest/wasm/wasm-run-utils.h

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 | « test/cctest/wasm/test-wasm-breakpoints.cc ('k') | test/debugger/debug/wasm/frame-inspection.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/wasm/wasm-run-utils.h
diff --git a/test/cctest/wasm/wasm-run-utils.h b/test/cctest/wasm/wasm-run-utils.h
index 533fab41b921da5f0d090857fc9be4b23b546e49..f85f4ca3e2ccec4cd5bdde5371e9128d69c366e6 100644
--- a/test/cctest/wasm/wasm-run-utils.h
+++ b/test/cctest/wasm/wasm-run-utils.h
@@ -509,7 +509,18 @@ class WasmFunctionCompiler : private GraphAndBuilders {
uint32_t function_index() { return function_->func_index; }
void Build(const byte* start, const byte* end) {
- local_decls.Prepend(zone(), &start, &end);
+ size_t locals_size = local_decls.Size();
+ size_t total_size = end - start + locals_size + 1;
+ byte* buffer = static_cast<byte*>(zone()->New(total_size));
+ // Prepend the local decls to the code.
+ local_decls.Emit(buffer);
+ // Emit the code.
+ memcpy(buffer + locals_size, start, end - start);
+ // Append an extra end opcode.
+ buffer[total_size - 1] = kExprEnd;
+
+ start = buffer;
+ end = buffer + total_size;
CHECK_GE(kMaxInt, end - start);
int len = static_cast<int>(end - start);
« no previous file with comments | « test/cctest/wasm/test-wasm-breakpoints.cc ('k') | test/debugger/debug/wasm/frame-inspection.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698