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 0ee7deb4fcf2615e2265c2f9aba138d74fae5c87..6b9a63f545ca1f28446e94da028e5db822977a8c 100644 |
--- a/test/cctest/wasm/wasm-run-utils.h |
+++ b/test/cctest/wasm/wasm-run-utils.h |
@@ -509,7 +509,18 @@ |
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); |