Commit f3897c7e authored by Eric Holk's avatar Eric Holk Committed by Commit Bot

[wasm] cleanup after https://crrev.com/c/802322

Bug: v8:7143
Change-Id: Ie8eee40ba1761a5790dc67a8ce03d2b2cb949722
Reviewed-on: https://chromium-review.googlesource.com/815677
Commit-Queue: Eric Holk <eholk@chromium.org>
Reviewed-by: 's avatarMircea Trofin <mtrofin@chromium.org>
Reviewed-by: 's avatarClemens Hammacher <clemensh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#49975}
parent 70598c50
...@@ -72,8 +72,8 @@ void MergeControlToEnd(JSGraph* jsgraph, Node* node) { ...@@ -72,8 +72,8 @@ void MergeControlToEnd(JSGraph* jsgraph, Node* node) {
} // namespace } // namespace
WasmGraphBuilder::WasmGraphBuilder( WasmGraphBuilder::WasmGraphBuilder(
const ModuleEnv* env, bool use_trap_handler, Zone* zone, JSGraph* jsgraph, ModuleEnv* env, Zone* zone, JSGraph* jsgraph, Handle<Code> centry_stub,
Handle<Code> centry_stub, wasm::FunctionSig* sig, wasm::FunctionSig* sig,
compiler::SourcePositionTable* source_position_table, compiler::SourcePositionTable* source_position_table,
RuntimeExceptionSupport exception_support) RuntimeExceptionSupport exception_support)
: zone_(zone), : zone_(zone),
...@@ -85,11 +85,10 @@ WasmGraphBuilder::WasmGraphBuilder( ...@@ -85,11 +85,10 @@ WasmGraphBuilder::WasmGraphBuilder(
function_table_sizes_(zone), function_table_sizes_(zone),
cur_buffer_(def_buffer_), cur_buffer_(def_buffer_),
cur_bufsize_(kDefaultBufferSize), cur_bufsize_(kDefaultBufferSize),
use_trap_handler_(use_trap_handler),
runtime_exception_support_(exception_support), runtime_exception_support_(exception_support),
sig_(sig), sig_(sig),
source_position_table_(source_position_table) { source_position_table_(source_position_table) {
DCHECK_IMPLIES(use_trap_handler_, trap_handler::IsTrapHandlerEnabled()); DCHECK_IMPLIES(use_trap_handler(), trap_handler::IsTrapHandlerEnabled());
for (size_t i = sig->parameter_count(); i > 0 && !has_simd_; --i) { for (size_t i = sig->parameter_count(); i > 0 && !has_simd_; --i) {
if (sig->GetParam(i - 1) == wasm::kWasmS128) has_simd_ = true; if (sig->GetParam(i - 1) == wasm::kWasmS128) has_simd_ = true;
} }
...@@ -3344,7 +3343,7 @@ void WasmGraphBuilder::EnsureFunctionTableNodes() { ...@@ -3344,7 +3343,7 @@ void WasmGraphBuilder::EnsureFunctionTableNodes() {
Node* WasmGraphBuilder::BuildModifyThreadInWasmFlag(bool new_value) { Node* WasmGraphBuilder::BuildModifyThreadInWasmFlag(bool new_value) {
// TODO(eholk): generate code to modify the thread-local storage directly, // TODO(eholk): generate code to modify the thread-local storage directly,
// rather than calling the runtime. // rather than calling the runtime.
if (!UseTrapHandler()) { if (!use_trap_handler()) {
return *control_; return *control_;
} }
...@@ -3557,13 +3556,13 @@ Node* WasmGraphBuilder::LoadMem(wasm::ValueType type, MachineType memtype, ...@@ -3557,13 +3556,13 @@ Node* WasmGraphBuilder::LoadMem(wasm::ValueType type, MachineType memtype,
graph()->NewNode(jsgraph()->machine()->ChangeUint32ToUint64(), index); graph()->NewNode(jsgraph()->machine()->ChangeUint32ToUint64(), index);
} }
// Wasm semantics throw on OOB. Introduce explicit bounds check. // Wasm semantics throw on OOB. Introduce explicit bounds check.
if (!UseTrapHandler()) { if (!use_trap_handler()) {
BoundsCheckMem(memtype, index, offset, position); BoundsCheckMem(memtype, index, offset, position);
} }
if (memtype.representation() == MachineRepresentation::kWord8 || if (memtype.representation() == MachineRepresentation::kWord8 ||
jsgraph()->machine()->UnalignedLoadSupported(memtype.representation())) { jsgraph()->machine()->UnalignedLoadSupported(memtype.representation())) {
if (UseTrapHandler()) { if (use_trap_handler()) {
load = graph()->NewNode(jsgraph()->machine()->ProtectedLoad(memtype), load = graph()->NewNode(jsgraph()->machine()->ProtectedLoad(memtype),
MemBuffer(offset), index, *effect_, *control_); MemBuffer(offset), index, *effect_, *control_);
SetSourcePosition(load, position); SetSourcePosition(load, position);
...@@ -3573,7 +3572,7 @@ Node* WasmGraphBuilder::LoadMem(wasm::ValueType type, MachineType memtype, ...@@ -3573,7 +3572,7 @@ Node* WasmGraphBuilder::LoadMem(wasm::ValueType type, MachineType memtype,
} }
} else { } else {
// TODO(eholk): Support unaligned loads with trap handlers. // TODO(eholk): Support unaligned loads with trap handlers.
DCHECK(!UseTrapHandler()); DCHECK(!use_trap_handler());
load = graph()->NewNode(jsgraph()->machine()->UnalignedLoad(memtype), load = graph()->NewNode(jsgraph()->machine()->UnalignedLoad(memtype),
MemBuffer(offset), index, *effect_, *control_); MemBuffer(offset), index, *effect_, *control_);
} }
...@@ -3616,7 +3615,7 @@ Node* WasmGraphBuilder::StoreMem(MachineType memtype, Node* index, ...@@ -3616,7 +3615,7 @@ Node* WasmGraphBuilder::StoreMem(MachineType memtype, Node* index,
graph()->NewNode(jsgraph()->machine()->ChangeUint32ToUint64(), index); graph()->NewNode(jsgraph()->machine()->ChangeUint32ToUint64(), index);
} }
// Wasm semantics throw on OOB. Introduce explicit bounds check. // Wasm semantics throw on OOB. Introduce explicit bounds check.
if (!UseTrapHandler()) { if (!use_trap_handler()) {
BoundsCheckMem(memtype, index, offset, position); BoundsCheckMem(memtype, index, offset, position);
} }
...@@ -3626,7 +3625,7 @@ Node* WasmGraphBuilder::StoreMem(MachineType memtype, Node* index, ...@@ -3626,7 +3625,7 @@ Node* WasmGraphBuilder::StoreMem(MachineType memtype, Node* index,
if (memtype.representation() == MachineRepresentation::kWord8 || if (memtype.representation() == MachineRepresentation::kWord8 ||
jsgraph()->machine()->UnalignedStoreSupported(memtype.representation())) { jsgraph()->machine()->UnalignedStoreSupported(memtype.representation())) {
if (UseTrapHandler()) { if (use_trap_handler()) {
store = graph()->NewNode( store = graph()->NewNode(
jsgraph()->machine()->ProtectedStore(memtype.representation()), jsgraph()->machine()->ProtectedStore(memtype.representation()),
MemBuffer(offset), index, val, *effect_, *control_); MemBuffer(offset), index, val, *effect_, *control_);
...@@ -3639,7 +3638,7 @@ Node* WasmGraphBuilder::StoreMem(MachineType memtype, Node* index, ...@@ -3639,7 +3638,7 @@ Node* WasmGraphBuilder::StoreMem(MachineType memtype, Node* index,
} }
} else { } else {
// TODO(eholk): Support unaligned stores with trap handlers. // TODO(eholk): Support unaligned stores with trap handlers.
DCHECK(!UseTrapHandler()); DCHECK(!use_trap_handler());
UnalignedStoreRepresentation rep(memtype.representation()); UnalignedStoreRepresentation rep(memtype.representation());
store = store =
graph()->NewNode(jsgraph()->machine()->UnalignedStore(rep), graph()->NewNode(jsgraph()->machine()->UnalignedStore(rep),
...@@ -4389,7 +4388,8 @@ Handle<Code> CompileWasmToJSWrapper( ...@@ -4389,7 +4388,8 @@ Handle<Code> CompileWasmToJSWrapper(
origin == wasm::kAsmJsOrigin ? new (&zone) SourcePositionTable(&graph) origin == wasm::kAsmJsOrigin ? new (&zone) SourcePositionTable(&graph)
: nullptr; : nullptr;
WasmGraphBuilder builder(use_trap_handler, &zone, &jsgraph, ModuleEnv env = {nullptr, {}, {}, {}, Handle<Code>(), use_trap_handler};
WasmGraphBuilder builder(&env, &zone, &jsgraph,
CEntryStub(isolate, 1).GetCode(), sig, CEntryStub(isolate, 1).GetCode(), sig,
source_position_table); source_position_table);
builder.set_control_ptr(&control); builder.set_control_ptr(&control);
...@@ -4459,8 +4459,7 @@ Handle<Code> CompileWasmToJSWrapper( ...@@ -4459,8 +4459,7 @@ Handle<Code> CompileWasmToJSWrapper(
Handle<Code> CompileWasmToWasmWrapper(Isolate* isolate, WasmCodeWrapper target, Handle<Code> CompileWasmToWasmWrapper(Isolate* isolate, WasmCodeWrapper target,
wasm::FunctionSig* sig, wasm::FunctionSig* sig,
Address new_wasm_context_address, Address new_wasm_context_address) {
bool use_trap_handler) {
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
// Create the Graph // Create the Graph
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
...@@ -4476,8 +4475,14 @@ Handle<Code> CompileWasmToWasmWrapper(Isolate* isolate, WasmCodeWrapper target, ...@@ -4476,8 +4475,14 @@ Handle<Code> CompileWasmToWasmWrapper(Isolate* isolate, WasmCodeWrapper target,
Node* control = nullptr; Node* control = nullptr;
Node* effect = nullptr; Node* effect = nullptr;
WasmGraphBuilder builder(use_trap_handler, &zone, &jsgraph, Handle<Code>(), ModuleEnv env = {
sig); nullptr,
{},
{},
{},
Handle<Code>(),
!target.IsCodeObject() && target.GetWasmCode()->HasTrapHandlerIndex()};
WasmGraphBuilder builder(&env, &zone, &jsgraph, Handle<Code>(), sig);
builder.set_control_ptr(&control); builder.set_control_ptr(&control);
builder.set_effect_ptr(&effect); builder.set_effect_ptr(&effect);
builder.BuildWasmToWasmWrapper(target, new_wasm_context_address); builder.BuildWasmToWasmWrapper(target, new_wasm_context_address);
...@@ -4547,7 +4552,7 @@ Handle<Code> CompileWasmInterpreterEntry(Isolate* isolate, uint32_t func_index, ...@@ -4547,7 +4552,7 @@ Handle<Code> CompileWasmInterpreterEntry(Isolate* isolate, uint32_t func_index,
Node* control = nullptr; Node* control = nullptr;
Node* effect = nullptr; Node* effect = nullptr;
WasmGraphBuilder builder(instance->UseTrapHandler(), &zone, &jsgraph, WasmGraphBuilder builder(nullptr, &zone, &jsgraph,
CEntryStub(isolate, 1).GetCode(), sig); CEntryStub(isolate, 1).GetCode(), sig);
builder.set_control_ptr(&control); builder.set_control_ptr(&control);
builder.set_effect_ptr(&effect); builder.set_effect_ptr(&effect);
...@@ -4614,8 +4619,8 @@ Handle<Code> CompileCWasmEntry(Isolate* isolate, wasm::FunctionSig* sig, ...@@ -4614,8 +4619,8 @@ Handle<Code> CompileCWasmEntry(Isolate* isolate, wasm::FunctionSig* sig,
Node* control = nullptr; Node* control = nullptr;
Node* effect = nullptr; Node* effect = nullptr;
WasmGraphBuilder builder(trap_handler::IsTrapHandlerEnabled(), &zone, WasmGraphBuilder builder(nullptr, &zone, &jsgraph,
&jsgraph, CEntryStub(isolate, 1).GetCode(), sig); CEntryStub(isolate, 1).GetCode(), sig);
builder.set_control_ptr(&control); builder.set_control_ptr(&control);
builder.set_effect_ptr(&effect); builder.set_effect_ptr(&effect);
builder.BuildCWasmEntry(wasm_context_address); builder.BuildCWasmEntry(wasm_context_address);
...@@ -4754,11 +4759,9 @@ WasmCompilationUnit::WasmCompilationUnit( ...@@ -4754,11 +4759,9 @@ WasmCompilationUnit::WasmCompilationUnit(
runtime_exception_support_(exception_support), runtime_exception_support_(exception_support),
native_module_(native_module), native_module_(native_module),
lower_simd_(lower_simd), lower_simd_(lower_simd),
use_trap_handler_(env && env->use_trap_handler),
protected_instructions_( protected_instructions_(
new std::vector<trap_handler::ProtectedInstructionData>()), new std::vector<trap_handler::ProtectedInstructionData>()),
mode_(mode) { mode_(mode) {
DCHECK_IMPLIES(use_trap_handler_, trap_handler::IsTrapHandlerEnabled());
switch (mode_) { switch (mode_) {
case WasmCompilationUnit::CompilationMode::kLiftoff: case WasmCompilationUnit::CompilationMode::kLiftoff:
new (&liftoff_) LiftoffData(isolate); new (&liftoff_) LiftoffData(isolate);
...@@ -5011,14 +5014,7 @@ WasmCodeWrapper WasmCompilationUnit::FinishLiftoffCompilation( ...@@ -5011,14 +5014,7 @@ WasmCodeWrapper WasmCompilationUnit::FinishLiftoffCompilation(
WasmCodeWrapper ret; WasmCodeWrapper ret;
if (!FLAG_wasm_jit_to_native) { if (!FLAG_wasm_jit_to_native) {
Handle<Code> code; Handle<Code> code;
code = isolate_->factory()->NewCode( code = isolate_->factory()->NewCode(desc, Code::WASM_FUNCTION, code);
desc, Code::WASM_FUNCTION, code, Builtins::kNoBuiltinId,
MaybeHandle<HandlerTable>(), MaybeHandle<ByteArray>(),
MaybeHandle<DeoptimizationData>(), kMovable,
0, // stub_key
false, // is_turbofanned
liftoff_.asm_.GetTotalFrameSlotCount(), // stack_slots
liftoff_.safepoint_table_offset_);
#ifdef ENABLE_DISASSEMBLER #ifdef ENABLE_DISASSEMBLER
if (FLAG_print_code || FLAG_print_wasm_code) { if (FLAG_print_code || FLAG_print_wasm_code) {
// TODO(wasm): Use proper log files, here and elsewhere. // TODO(wasm): Use proper log files, here and elsewhere.
......
...@@ -112,8 +112,6 @@ class WasmCompilationUnit final { ...@@ -112,8 +112,6 @@ class WasmCompilationUnit final {
size_t memory_cost() const { return memory_cost_; } size_t memory_cost() const { return memory_cost_; }
bool UseTrapHandler() const { return use_trap_handler_; }
private: private:
void PackProtectedInstructions(Handle<Code> code) const; void PackProtectedInstructions(Handle<Code> code) const;
...@@ -157,7 +155,6 @@ class WasmCompilationUnit final { ...@@ -157,7 +155,6 @@ class WasmCompilationUnit final {
size_t memory_cost_ = 0; size_t memory_cost_ = 0;
wasm::NativeModule* native_module_; wasm::NativeModule* native_module_;
bool lower_simd_; bool lower_simd_;
const bool use_trap_handler_;
std::shared_ptr<std::vector<trap_handler::ProtectedInstructionData>> std::shared_ptr<std::vector<trap_handler::ProtectedInstructionData>>
protected_instructions_; protected_instructions_;
CompilationMode mode_; CompilationMode mode_;
...@@ -191,8 +188,7 @@ V8_EXPORT_PRIVATE Handle<Code> CompileJSToWasmWrapper( ...@@ -191,8 +188,7 @@ V8_EXPORT_PRIVATE Handle<Code> CompileJSToWasmWrapper(
// wasm instances (the WasmContext address must be changed). // wasm instances (the WasmContext address must be changed).
Handle<Code> CompileWasmToWasmWrapper(Isolate* isolate, WasmCodeWrapper target, Handle<Code> CompileWasmToWasmWrapper(Isolate* isolate, WasmCodeWrapper target,
wasm::FunctionSig* sig, wasm::FunctionSig* sig,
Address new_wasm_context_address, Address new_wasm_context_address);
bool use_trap_handler);
// Compiles a stub that redirects a call to a wasm function to the wasm // Compiles a stub that redirects a call to a wasm function to the wasm
// interpreter. It's ABI compatible with the compiled wasm function. // interpreter. It's ABI compatible with the compiled wasm function.
...@@ -218,22 +214,10 @@ Handle<Code> CompileCWasmEntry(Isolate* isolate, wasm::FunctionSig* sig, ...@@ -218,22 +214,10 @@ Handle<Code> CompileCWasmEntry(Isolate* isolate, wasm::FunctionSig* sig,
typedef ZoneVector<Node*> NodeVector; typedef ZoneVector<Node*> NodeVector;
class WasmGraphBuilder { class WasmGraphBuilder {
public: public:
WasmGraphBuilder(const ModuleEnv* env, Zone* zone, JSGraph* graph, WasmGraphBuilder(ModuleEnv* env, Zone* zone, JSGraph* graph,
Handle<Code> centry_stub, wasm::FunctionSig* sig,
compiler::SourcePositionTable* spt = nullptr,
RuntimeExceptionSupport res = kRuntimeExceptionSupport)
: WasmGraphBuilder(env, (env && env->use_trap_handler), zone, graph,
centry_stub, sig, spt, res) {
DCHECK_NOT_NULL(env);
}
// Same as above, but when no module environment is available.
WasmGraphBuilder(bool use_trap_handler, Zone* zone, JSGraph* graph,
Handle<Code> centry_stub, wasm::FunctionSig* sig, Handle<Code> centry_stub, wasm::FunctionSig* sig,
compiler::SourcePositionTable* spt = nullptr, compiler::SourcePositionTable* spt = nullptr,
RuntimeExceptionSupport res = kRuntimeExceptionSupport) RuntimeExceptionSupport res = kRuntimeExceptionSupport);
: WasmGraphBuilder(nullptr, use_trap_handler, zone, graph, centry_stub,
sig, spt, res) {}
Node** Buffer(size_t count) { Node** Buffer(size_t count) {
if (count > cur_bufsize_) { if (count > cur_bufsize_) {
...@@ -412,7 +396,7 @@ class WasmGraphBuilder { ...@@ -412,7 +396,7 @@ class WasmGraphBuilder {
const wasm::WasmModule* module() { return env_ ? env_->module : nullptr; } const wasm::WasmModule* module() { return env_ ? env_->module : nullptr; }
bool UseTrapHandler() const { return use_trap_handler_; } bool use_trap_handler() const { return env_ && env_->use_trap_handler; }
private: private:
static const int kDefaultBufferSize = 16; static const int kDefaultBufferSize = 16;
...@@ -420,7 +404,9 @@ class WasmGraphBuilder { ...@@ -420,7 +404,9 @@ class WasmGraphBuilder {
Zone* zone_; Zone* zone_;
JSGraph* jsgraph_; JSGraph* jsgraph_;
Node* centry_stub_node_; Node* centry_stub_node_;
const ModuleEnv* env_ = nullptr; // env_ == nullptr means we're not compiling Wasm functions, such as for
// wrappers or interpreter stubs.
ModuleEnv* env_ = nullptr;
Node* wasm_context_ = nullptr; Node* wasm_context_ = nullptr;
NodeVector signature_tables_; NodeVector signature_tables_;
NodeVector function_tables_; NodeVector function_tables_;
...@@ -435,7 +421,6 @@ class WasmGraphBuilder { ...@@ -435,7 +421,6 @@ class WasmGraphBuilder {
Node* def_buffer_[kDefaultBufferSize]; Node* def_buffer_[kDefaultBufferSize];
bool has_simd_ = false; bool has_simd_ = false;
bool needs_stack_check_ = false; bool needs_stack_check_ = false;
const bool use_trap_handler_;
// If the runtime doesn't support exception propagation, // If the runtime doesn't support exception propagation,
// we won't generate stack checks, and trap handling will also // we won't generate stack checks, and trap handling will also
// be generated differently. // be generated differently.
...@@ -446,10 +431,6 @@ class WasmGraphBuilder { ...@@ -446,10 +431,6 @@ class WasmGraphBuilder {
compiler::SourcePositionTable* source_position_table_ = nullptr; compiler::SourcePositionTable* source_position_table_ = nullptr;
WasmGraphBuilder(const ModuleEnv*, bool use_trap_handler, Zone*, JSGraph*,
Handle<Code> centry_stub_, wasm::FunctionSig*,
compiler::SourcePositionTable*, RuntimeExceptionSupport);
// Internal helper methods. // Internal helper methods.
JSGraph* jsgraph() { return jsgraph_; } JSGraph* jsgraph() { return jsgraph_; }
Graph* graph(); Graph* graph();
......
...@@ -342,7 +342,7 @@ class InstanceBuilder { ...@@ -342,7 +342,7 @@ class InstanceBuilder {
} }
Counters* counters() const { return async_counters().get(); } Counters* counters() const { return async_counters().get(); }
bool UseTrapHandler() const { return compiled_module_->use_trap_handler(); } bool use_trap_handler() const { return compiled_module_->use_trap_handler(); }
// Helper routines to print out errors with imports. // Helper routines to print out errors with imports.
#define ERROR_THROWER_WITH_MESSAGE(TYPE) \ #define ERROR_THROWER_WITH_MESSAGE(TYPE) \
...@@ -1935,7 +1935,7 @@ WasmCodeWrapper MakeWasmToWasmWrapper( ...@@ -1935,7 +1935,7 @@ WasmCodeWrapper MakeWasmToWasmWrapper(
if (!FLAG_wasm_jit_to_native) { if (!FLAG_wasm_jit_to_native) {
Handle<Code> wrapper_code = compiler::CompileWasmToWasmWrapper( Handle<Code> wrapper_code = compiler::CompileWasmToWasmWrapper(
isolate, imported_function->GetWasmCode(), *sig, isolate, imported_function->GetWasmCode(), *sig,
new_wasm_context_address, instance->UseTrapHandler()); new_wasm_context_address);
// Set the deoptimization data for the WasmToWasm wrapper. This is // Set the deoptimization data for the WasmToWasm wrapper. This is
// needed by the interpreter to find the imported instance for // needed by the interpreter to find the imported instance for
// a cross-instance call. // a cross-instance call.
...@@ -1945,7 +1945,7 @@ WasmCodeWrapper MakeWasmToWasmWrapper( ...@@ -1945,7 +1945,7 @@ WasmCodeWrapper MakeWasmToWasmWrapper(
} else { } else {
Handle<Code> code = compiler::CompileWasmToWasmWrapper( Handle<Code> code = compiler::CompileWasmToWasmWrapper(
isolate, imported_function->GetWasmCode(), *sig, isolate, imported_function->GetWasmCode(), *sig,
new_wasm_context_address, instance->UseTrapHandler()); new_wasm_context_address);
return WasmCodeWrapper( return WasmCodeWrapper(
instance->compiled_module()->GetNativeModule()->AddCodeCopy( instance->compiled_module()->GetNativeModule()->AddCodeCopy(
code, wasm::WasmCode::kWasmToWasmWrapper, index)); code, wasm::WasmCode::kWasmToWasmWrapper, index));
...@@ -1967,15 +1967,15 @@ WasmCodeWrapper UnwrapExportOrCompileImportWrapper( ...@@ -1967,15 +1967,15 @@ WasmCodeWrapper UnwrapExportOrCompileImportWrapper(
// signature. // signature.
if (FLAG_wasm_jit_to_native) { if (FLAG_wasm_jit_to_native) {
Handle<Code> temp_code = compiler::CompileWasmToJSWrapper( Handle<Code> temp_code = compiler::CompileWasmToJSWrapper(
isolate, target, sig, import_index, origin, instance->UseTrapHandler(), isolate, target, sig, import_index, origin,
js_imports_table); instance->compiled_module()->use_trap_handler(), js_imports_table);
return WasmCodeWrapper( return WasmCodeWrapper(
instance->compiled_module()->GetNativeModule()->AddCodeCopy( instance->compiled_module()->GetNativeModule()->AddCodeCopy(
temp_code, wasm::WasmCode::kWasmToJsWrapper, import_index)); temp_code, wasm::WasmCode::kWasmToJsWrapper, import_index));
} else { } else {
return WasmCodeWrapper(compiler::CompileWasmToJSWrapper( return WasmCodeWrapper(compiler::CompileWasmToJSWrapper(
isolate, target, sig, import_index, origin, instance->UseTrapHandler(), isolate, target, sig, import_index, origin,
js_imports_table)); instance->compiled_module()->use_trap_handler(), js_imports_table));
} }
} }
...@@ -2436,7 +2436,7 @@ MaybeHandle<WasmInstanceObject> InstanceBuilder::Build() { ...@@ -2436,7 +2436,7 @@ MaybeHandle<WasmInstanceObject> InstanceBuilder::Build() {
// Set externally passed ArrayBuffer non neuterable. // Set externally passed ArrayBuffer non neuterable.
memory->set_is_neuterable(false); memory->set_is_neuterable(false);
DCHECK_IMPLIES(UseTrapHandler(), DCHECK_IMPLIES(use_trap_handler(),
module_->is_asm_js() || memory->has_guard_region()); module_->is_asm_js() || memory->has_guard_region());
} else if (initial_pages > 0) { } else if (initial_pages > 0) {
memory_ = AllocateMemory(initial_pages); memory_ = AllocateMemory(initial_pages);
...@@ -2564,7 +2564,7 @@ MaybeHandle<WasmInstanceObject> InstanceBuilder::Build() { ...@@ -2564,7 +2564,7 @@ MaybeHandle<WasmInstanceObject> InstanceBuilder::Build() {
//-------------------------------------------------------------------------- //--------------------------------------------------------------------------
// Unpack and notify signal handler of protected instructions. // Unpack and notify signal handler of protected instructions.
//-------------------------------------------------------------------------- //--------------------------------------------------------------------------
if (UseTrapHandler()) { if (use_trap_handler()) {
if (FLAG_wasm_jit_to_native) { if (FLAG_wasm_jit_to_native) {
UnpackAndRegisterProtectedInstructions(isolate_, native_module); UnpackAndRegisterProtectedInstructions(isolate_, native_module);
} else { } else {
...@@ -2986,8 +2986,7 @@ int InstanceBuilder::ProcessImports(Handle<FixedArray> code_table, ...@@ -2986,8 +2986,7 @@ int InstanceBuilder::ProcessImports(Handle<FixedArray> code_table,
imported_instance->wasm_context()->get(); imported_instance->wasm_context()->get();
Handle<Code> wrapper = compiler::CompileWasmToWasmWrapper( Handle<Code> wrapper = compiler::CompileWasmToWasmWrapper(
isolate_, target->GetWasmCode(), sig, isolate_, target->GetWasmCode(), sig,
reinterpret_cast<Address>(other_context), reinterpret_cast<Address>(other_context));
instance->UseTrapHandler());
set_of_native_module_scopes.Add(exporting_module); set_of_native_module_scopes.Add(exporting_module);
wrapper_code = exporting_module->AddExportedWrapper( wrapper_code = exporting_module->AddExportedWrapper(
wrapper, exported_code->index()); wrapper, exported_code->index());
...@@ -3153,7 +3152,7 @@ Handle<JSArrayBuffer> InstanceBuilder::AllocateMemory(uint32_t num_pages) { ...@@ -3153,7 +3152,7 @@ Handle<JSArrayBuffer> InstanceBuilder::AllocateMemory(uint32_t num_pages) {
thrower_->RangeError("Out of memory: wasm memory too large"); thrower_->RangeError("Out of memory: wasm memory too large");
return Handle<JSArrayBuffer>::null(); return Handle<JSArrayBuffer>::null();
} }
const bool enable_guard_regions = UseTrapHandler(); const bool enable_guard_regions = use_trap_handler();
Handle<JSArrayBuffer> mem_buffer = NewArrayBuffer( Handle<JSArrayBuffer> mem_buffer = NewArrayBuffer(
isolate_, num_pages * WasmModule::kPageSize, enable_guard_regions); isolate_, num_pages * WasmModule::kPageSize, enable_guard_regions);
...@@ -3546,7 +3545,7 @@ void InstanceBuilder::LoadTableSegments(Handle<FixedArray> code_table, ...@@ -3546,7 +3545,7 @@ void InstanceBuilder::LoadTableSegments(Handle<FixedArray> code_table,
Handle<Code> wrapper_code = Handle<Code> wrapper_code =
js_to_wasm_cache_.CloneOrCompileJSToWasmWrapper( js_to_wasm_cache_.CloneOrCompileJSToWasmWrapper(
isolate_, module_, wasm_code, func_index, isolate_, module_, wasm_code, func_index,
instance->UseTrapHandler()); instance->compiled_module()->use_trap_handler());
MaybeHandle<String> func_name; MaybeHandle<String> func_name;
if (module_->is_asm_js()) { if (module_->is_asm_js()) {
// For modules arising from asm.js, honor the names section. // For modules arising from asm.js, honor the names section.
......
...@@ -345,8 +345,7 @@ void WasmTableObject::Set(Isolate* isolate, Handle<WasmTableObject> table, ...@@ -345,8 +345,7 @@ void WasmTableObject::Set(Isolate* isolate, Handle<WasmTableObject> table,
native_module->GetExportedWrapper(wasm_code.GetWasmCode()->index()); native_module->GetExportedWrapper(wasm_code.GetWasmCode()->index());
if (exported_wrapper == nullptr) { if (exported_wrapper == nullptr) {
Handle<Code> new_wrapper = compiler::CompileWasmToWasmWrapper( Handle<Code> new_wrapper = compiler::CompileWasmToWasmWrapper(
isolate, wasm_code, wasm_function->sig, new_context_address, isolate, wasm_code, wasm_function->sig, new_context_address);
exported_function->instance()->UseTrapHandler());
exported_wrapper = native_module->AddExportedWrapper( exported_wrapper = native_module->AddExportedWrapper(
new_wrapper, wasm_code.GetWasmCode()->index()); new_wrapper, wasm_code.GetWasmCode()->index());
} }
...@@ -357,8 +356,7 @@ void WasmTableObject::Set(Isolate* isolate, Handle<WasmTableObject> table, ...@@ -357,8 +356,7 @@ void WasmTableObject::Set(Isolate* isolate, Handle<WasmTableObject> table,
isolate); isolate);
int func_index = exported_function->function_index(); int func_index = exported_function->function_index();
code = compiler::CompileWasmToWasmWrapper( code = compiler::CompileWasmToWasmWrapper(
isolate, wasm_code, wasm_function->sig, new_context_address, isolate, wasm_code, wasm_function->sig, new_context_address);
instance->UseTrapHandler());
// TODO(6792): No longer needed once WebAssembly code is off heap. // TODO(6792): No longer needed once WebAssembly code is off heap.
CodeSpaceMemoryModificationScope modification_scope(isolate->heap()); CodeSpaceMemoryModificationScope modification_scope(isolate->heap());
AttachWasmFunctionInfo(isolate, Handle<Code>::cast(code), instance, AttachWasmFunctionInfo(isolate, Handle<Code>::cast(code), instance,
...@@ -560,10 +558,6 @@ int32_t WasmMemoryObject::Grow(Isolate* isolate, ...@@ -560,10 +558,6 @@ int32_t WasmMemoryObject::Grow(Isolate* isolate,
return old_size / WasmModule::kPageSize; return old_size / WasmModule::kPageSize;
} }
bool WasmInstanceObject::UseTrapHandler() const {
return compiled_module()->use_trap_handler();
}
WasmModuleObject* WasmInstanceObject::module_object() { WasmModuleObject* WasmInstanceObject::module_object() {
return *compiled_module()->wasm_module(); return *compiled_module()->wasm_module();
} }
......
...@@ -214,8 +214,6 @@ class WasmInstanceObject : public JSObject { ...@@ -214,8 +214,6 @@ class WasmInstanceObject : public JSObject {
WasmModuleObject* module_object(); WasmModuleObject* module_object();
V8_EXPORT_PRIVATE wasm::WasmModule* module(); V8_EXPORT_PRIVATE wasm::WasmModule* module();
bool UseTrapHandler() const;
// Get the debug info associated with the given wasm object. // Get the debug info associated with the given wasm object.
// If no debug info exists yet, it is created automatically. // If no debug info exists yet, it is created automatically.
static Handle<WasmDebugInfo> GetOrCreateDebugInfo(Handle<WasmInstanceObject>); static Handle<WasmDebugInfo> GetOrCreateDebugInfo(Handle<WasmInstanceObject>);
......
...@@ -300,9 +300,8 @@ void TestBuildingGraph( ...@@ -300,9 +300,8 @@ void TestBuildingGraph(
TestBuildingGraphWithBuilder(&builder, zone, sig, start, end); TestBuildingGraphWithBuilder(&builder, zone, sig, start, end);
} else { } else {
compiler::WasmGraphBuilder builder( compiler::WasmGraphBuilder builder(
trap_handler::IsTrapHandlerEnabled(), zone, jsgraph, nullptr, zone, jsgraph, CEntryStub(jsgraph->isolate(), 1).GetCode(),
CEntryStub(jsgraph->isolate(), 1).GetCode(), sig, source_position_table, sig, source_position_table, runtime_exception_support);
runtime_exception_support);
TestBuildingGraphWithBuilder(&builder, zone, sig, start, end); TestBuildingGraphWithBuilder(&builder, zone, sig, start, end);
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment