// Copyright 2020 the V8 project authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include #include "src/api/api-inl.h" #include "src/base/macros.h" #include "src/codegen/assembler-inl.h" #include "src/compiler/heap-refs.h" #include "src/debug/debug-evaluate.h" #include "src/debug/debug-interface.h" #include "src/diagnostics/disassembler.h" #include "src/execution/frames-inl.h" #include "src/execution/frames.h" #include "src/objects/js-objects.h" #include "src/objects/property-descriptor.h" #include "src/utils/utils.h" #include "src/utils/vector.h" #include "src/wasm/compilation-environment.h" #include "src/wasm/module-decoder.h" #include "src/wasm/value-type.h" #include "src/wasm/wasm-constants.h" #include "src/wasm/wasm-debug-evaluate.h" #include "src/wasm/wasm-debug.h" #include "src/wasm/wasm-interpreter.h" #include "src/wasm/wasm-module-builder.h" #include "src/wasm/wasm-module.h" #include "src/wasm/wasm-objects-inl.h" #include "src/wasm/wasm-opcodes.h" #include "src/wasm/wasm-tier.h" #include "test/cctest/cctest.h" #include "test/cctest/compiler/value-helper.h" #include "test/cctest/wasm/wasm-run-utils.h" #include "test/common/wasm/test-signatures.h" #include "test/common/wasm/wasm-macro-gen.h" namespace v8 { namespace internal { namespace wasm { namespace { template class TestCode { public: TestCode(WasmRunnerBase* runner, std::initializer_list code, std::initializer_list locals = {}) : compiler_(&runner->NewFunction()), code_(code), locals_(static_cast(locals.size())) { for (ValueType::Kind T : locals) { compiler_->AllocateLocal(ValueType(T)); } compiler_->Build(code.begin(), code.end()); } Handle BreakOnReturn(WasmRunnerBase* runner) { runner->TierDown(); uint32_t return_offset_in_function = locals_ + FindReturn(); int function_index = compiler_->function_index(); int function_offset = runner->builder().GetFunctionAt(function_index)->code.offset(); int return_offset_in_module = function_offset + return_offset_in_function; Handle instance = runner->builder().instance_object(); Handle