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

Side by Side 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 the V8 project authors. All rights reserved. 1 // Copyright 2016 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef WASM_RUN_UTILS_H 5 #ifndef WASM_RUN_UTILS_H
6 #define WASM_RUN_UTILS_H 6 #define WASM_RUN_UTILS_H
7 7
8 #include <setjmp.h> 8 #include <setjmp.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 #include <stdlib.h> 10 #include <stdlib.h>
(...skipping 491 matching lines...) Expand 10 before | Expand all | Expand 10 after
502 MachineOperatorBuilder* machine() { return &main_machine_; } 502 MachineOperatorBuilder* machine() { return &main_machine_; }
503 CallDescriptor* descriptor() { 503 CallDescriptor* descriptor() {
504 if (descriptor_ == nullptr) { 504 if (descriptor_ == nullptr) {
505 descriptor_ = testing_module_->GetWasmCallDescriptor(zone(), sig); 505 descriptor_ = testing_module_->GetWasmCallDescriptor(zone(), sig);
506 } 506 }
507 return descriptor_; 507 return descriptor_;
508 } 508 }
509 uint32_t function_index() { return function_->func_index; } 509 uint32_t function_index() { return function_->func_index; }
510 510
511 void Build(const byte* start, const byte* end) { 511 void Build(const byte* start, const byte* end) {
512 local_decls.Prepend(zone(), &start, &end); 512 size_t locals_size = local_decls.Size();
513 size_t total_size = end - start + locals_size + 1;
514 byte* buffer = static_cast<byte*>(zone()->New(total_size));
515 // Prepend the local decls to the code.
516 local_decls.Emit(buffer);
517 // Emit the code.
518 memcpy(buffer + locals_size, start, end - start);
519 // Append an extra end opcode.
520 buffer[total_size - 1] = kExprEnd;
521
522 start = buffer;
523 end = buffer + total_size;
513 524
514 CHECK_GE(kMaxInt, end - start); 525 CHECK_GE(kMaxInt, end - start);
515 int len = static_cast<int>(end - start); 526 int len = static_cast<int>(end - start);
516 function_->code_start_offset = 527 function_->code_start_offset =
517 testing_module_->AddBytes(Vector<const byte>(start, len)); 528 testing_module_->AddBytes(Vector<const byte>(start, len));
518 function_->code_end_offset = function_->code_start_offset + len; 529 function_->code_end_offset = function_->code_start_offset + len;
519 530
520 if (interpreter_) { 531 if (interpreter_) {
521 // Add the code to the interpreter. 532 // Add the code to the interpreter.
522 CHECK(interpreter_->SetFunctionCodeForTesting(function_, start, end)); 533 CHECK(interpreter_->SetFunctionCodeForTesting(function_, start, end));
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after
800 void RunWasm_##name(WasmExecutionMode execution_mode) 811 void RunWasm_##name(WasmExecutionMode execution_mode)
801 812
802 #define WASM_EXEC_COMPILED_TEST(name) \ 813 #define WASM_EXEC_COMPILED_TEST(name) \
803 void RunWasm_##name(WasmExecutionMode execution_mode); \ 814 void RunWasm_##name(WasmExecutionMode execution_mode); \
804 TEST(RunWasmCompiled_##name) { RunWasm_##name(kExecuteCompiled); } \ 815 TEST(RunWasmCompiled_##name) { RunWasm_##name(kExecuteCompiled); } \
805 void RunWasm_##name(WasmExecutionMode execution_mode) 816 void RunWasm_##name(WasmExecutionMode execution_mode)
806 817
807 } // namespace 818 } // namespace
808 819
809 #endif 820 #endif
OLDNEW
« 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