[wasm] Move {use_trap_handler} field into {NativeModule}.
The predicate in question is specific to the code generated for a given module, hence specific to the {NativeModule} and independent of the instance. R=ahaas@chromium.org Change-Id: I108ee8126897ed732e8c52b549de170339a125a8 Reviewed-on: https://chromium-review.googlesource.com/1033741 Commit-Queue: Michael Starzinger <mstarzinger@chromium.org> Reviewed-by: Andreas Haas <ahaas@chromium.org> Cr-Commit-Position: refs/heads/master@{#52886}
This commit is contained in:
parent
0600afddd3
commit
c224c67a1a
@ -1517,7 +1517,6 @@ void WasmCompiledModule::WasmCompiledModuleVerify() {
|
||||
VerifyObjectField(kWasmModuleOffset);
|
||||
VerifyObjectField(kNativeModuleOffset);
|
||||
VerifyObjectField(kLazyCompileDataOffset);
|
||||
VerifyObjectField(kUseTrapHandlerOffset);
|
||||
}
|
||||
|
||||
void WasmDebugInfo::WasmDebugInfoVerify() {
|
||||
|
@ -287,8 +287,9 @@ class InstanceBuilder {
|
||||
Counters* counters() const { return async_counters().get(); }
|
||||
|
||||
wasm::UseTrapHandler use_trap_handler() const {
|
||||
return compiled_module_->use_trap_handler() ? kUseTrapHandler
|
||||
: kNoTrapHandler;
|
||||
return compiled_module_->GetNativeModule()->use_trap_handler()
|
||||
? kUseTrapHandler
|
||||
: kNoTrapHandler;
|
||||
}
|
||||
|
||||
// Helper routines to print out errors with imports.
|
||||
@ -489,7 +490,8 @@ ModuleEnv CreateModuleEnvFromCompiledModule(
|
||||
DisallowHeapAllocation no_gc;
|
||||
WasmModule* module = compiled_module->shared()->module();
|
||||
wasm::UseTrapHandler use_trap_handler =
|
||||
compiled_module->use_trap_handler() ? kUseTrapHandler : kNoTrapHandler;
|
||||
compiled_module->GetNativeModule()->use_trap_handler() ? kUseTrapHandler
|
||||
: kNoTrapHandler;
|
||||
return ModuleEnv(module, use_trap_handler, wasm::kRuntimeExceptionSupport);
|
||||
}
|
||||
|
||||
@ -3702,7 +3704,8 @@ void CompileJsToWasmWrappers(Isolate* isolate,
|
||||
isolate);
|
||||
NativeModule* native_module = compiled_module->GetNativeModule();
|
||||
wasm::UseTrapHandler use_trap_handler =
|
||||
compiled_module->use_trap_handler() ? kUseTrapHandler : kNoTrapHandler;
|
||||
compiled_module->GetNativeModule()->use_trap_handler() ? kUseTrapHandler
|
||||
: kNoTrapHandler;
|
||||
for (auto exp : compiled_module->shared()->module()->export_table) {
|
||||
if (exp.kind != kExternalFunction) continue;
|
||||
wasm::WasmCode* wasm_code =
|
||||
|
@ -16,6 +16,7 @@
|
||||
#include "src/globals.h"
|
||||
#include "src/macro-assembler.h"
|
||||
#include "src/objects-inl.h"
|
||||
#include "src/wasm/function-compiler.h"
|
||||
#include "src/wasm/wasm-module.h"
|
||||
#include "src/wasm/wasm-objects-inl.h"
|
||||
#include "src/wasm/wasm-objects.h"
|
||||
@ -338,7 +339,8 @@ NativeModule::NativeModule(uint32_t num_functions, uint32_t num_imports,
|
||||
reinterpret_cast<Isolate*>(code_manager->isolate_), env)),
|
||||
free_memory_(mem->address(), mem->end()),
|
||||
wasm_code_manager_(code_manager),
|
||||
can_request_more_memory_(can_request_more) {
|
||||
can_request_more_memory_(can_request_more),
|
||||
use_trap_handler_(env.use_trap_handler) {
|
||||
VirtualMemory my_mem;
|
||||
owned_memory_.push_back(my_mem);
|
||||
owned_memory_.back().TakeControl(mem);
|
||||
|
@ -269,16 +269,15 @@ class V8_EXPORT_PRIVATE NativeModule final {
|
||||
void SetSharedModuleData(Handle<WasmSharedModuleData>);
|
||||
|
||||
uint32_t num_imported_functions() const { return num_imported_functions_; }
|
||||
|
||||
const std::vector<WasmCode*>& code_table() const { return code_table_; }
|
||||
|
||||
size_t committed_memory() const { return committed_memory_; }
|
||||
bool use_trap_handler() const { return use_trap_handler_; }
|
||||
void set_lazy_compile_frozen(bool frozen) { lazy_compile_frozen_ = frozen; }
|
||||
bool lazy_compile_frozen() const { return lazy_compile_frozen_; }
|
||||
|
||||
const size_t instance_id = 0;
|
||||
~NativeModule();
|
||||
|
||||
void set_lazy_compile_frozen(bool frozen) { frozen_ = frozen; }
|
||||
bool lazy_compile_frozen() const { return frozen_; }
|
||||
|
||||
private:
|
||||
friend class WasmCodeManager;
|
||||
friend class NativeModuleSerializer;
|
||||
@ -343,10 +342,11 @@ class V8_EXPORT_PRIVATE NativeModule final {
|
||||
WasmCodeManager* wasm_code_manager_;
|
||||
base::Mutex allocation_mutex_;
|
||||
size_t committed_memory_ = 0;
|
||||
bool can_request_more_memory_;
|
||||
bool is_executable_ = false;
|
||||
bool frozen_ = false;
|
||||
int modification_scope_depth_ = 0;
|
||||
bool can_request_more_memory_;
|
||||
bool use_trap_handler_;
|
||||
bool is_executable_ = false;
|
||||
bool lazy_compile_frozen_ = false;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(NativeModule);
|
||||
};
|
||||
|
@ -209,15 +209,6 @@ OPTIONAL_ACCESSORS(WasmDebugInfo, c_wasm_entry_map, Managed<wasm::SignatureMap>,
|
||||
#define WCM_OBJECT(TYPE, NAME, OFFSET) \
|
||||
WCM_OBJECT_OR_WEAK(TYPE, NAME, OFFSET, value->Is##TYPE())
|
||||
|
||||
#define WCM_SMALL_CONST_NUMBER(TYPE, NAME, OFFSET) \
|
||||
TYPE WasmCompiledModule::NAME() const { \
|
||||
return static_cast<TYPE>(Smi::ToInt(READ_FIELD(this, OFFSET))); \
|
||||
} \
|
||||
\
|
||||
void WasmCompiledModule::set_##NAME(TYPE value) { \
|
||||
WRITE_FIELD(this, OFFSET, Smi::FromInt(value)); \
|
||||
}
|
||||
|
||||
#define WCM_WEAK_LINK(TYPE, NAME, OFFSET) \
|
||||
WCM_OBJECT_OR_WEAK(WeakCell, weak_##NAME, OFFSET, value->IsWeakCell()) \
|
||||
\
|
||||
@ -235,13 +226,11 @@ WCM_OBJECT(WasmCompiledModule, prev_instance, kPrevInstanceOffset)
|
||||
WCM_WEAK_LINK(WasmInstanceObject, owning_instance, kOwningInstanceOffset)
|
||||
WCM_WEAK_LINK(WasmModuleObject, wasm_module, kWasmModuleOffset)
|
||||
WCM_OBJECT(Foreign, native_module, kNativeModuleOffset)
|
||||
WCM_SMALL_CONST_NUMBER(bool, use_trap_handler, kUseTrapHandlerOffset)
|
||||
ACCESSORS(WasmCompiledModule, raw_next_instance, Object, kNextInstanceOffset);
|
||||
ACCESSORS(WasmCompiledModule, raw_prev_instance, Object, kPrevInstanceOffset);
|
||||
|
||||
#undef WCM_OBJECT_OR_WEAK
|
||||
#undef WCM_OBJECT
|
||||
#undef WCM_SMALL_CONST_NUMBER
|
||||
#undef WCM_WEAK_LINK
|
||||
#undef READ_PRIMITIVE_FIELD
|
||||
#undef WRITE_PRIMITIVE_FIELD
|
||||
|
@ -1369,7 +1369,6 @@ Handle<WasmCompiledModule> WasmCompiledModule::New(
|
||||
Handle<WeakCell> weak_native_context =
|
||||
isolate->factory()->NewWeakCell(isolate->native_context());
|
||||
compiled_module->set_weak_native_context(*weak_native_context);
|
||||
compiled_module->set_use_trap_handler(env.use_trap_handler);
|
||||
if (!export_wrappers.is_null()) {
|
||||
compiled_module->set_export_wrappers(*export_wrappers);
|
||||
}
|
||||
@ -1399,7 +1398,6 @@ Handle<WasmCompiledModule> WasmCompiledModule::Clone(
|
||||
ret->set_weak_wasm_module(module->weak_wasm_module());
|
||||
ret->set_weak_owning_instance(isolate->heap()->empty_weak_cell());
|
||||
ret->set_native_module(module->native_module());
|
||||
ret->set_use_trap_handler(module->use_trap_handler());
|
||||
|
||||
Handle<FixedArray> export_copy = isolate->factory()->CopyFixedArray(
|
||||
handle(module->export_wrappers(), isolate));
|
||||
@ -1431,7 +1429,7 @@ void WasmCompiledModule::Reset(Isolate* isolate,
|
||||
native_module->SetExecutable(false);
|
||||
|
||||
TRACE("Resetting %zu\n", native_module->instance_id);
|
||||
if (compiled_module->use_trap_handler()) {
|
||||
if (native_module->use_trap_handler()) {
|
||||
native_module->ReleaseProtectedInstructions();
|
||||
}
|
||||
|
||||
|
@ -501,7 +501,6 @@ class WasmCompiledModule : public Struct {
|
||||
V(kWasmModuleOffset, kPointerSize) \
|
||||
V(kNativeModuleOffset, kPointerSize) \
|
||||
V(kLazyCompileDataOffset, kPointerSize) \
|
||||
V(kUseTrapHandlerOffset, kPointerSize) \
|
||||
V(kSize, 0)
|
||||
|
||||
DEFINE_FIELD_OFFSET_CONSTANTS(HeapObject::kHeaderSize,
|
||||
@ -522,13 +521,6 @@ class WasmCompiledModule : public Struct {
|
||||
|
||||
#define WCM_CONST_OBJECT(TYPE, NAME) WCM_OBJECT_OR_WEAK(TYPE, NAME, private)
|
||||
|
||||
#define WCM_SMALL_CONST_NUMBER(TYPE, NAME) \
|
||||
public: \
|
||||
inline TYPE NAME() const; \
|
||||
\
|
||||
private: \
|
||||
inline void set_##NAME(TYPE value);
|
||||
|
||||
#define WCM_WEAK_LINK(TYPE, NAME) \
|
||||
WCM_OBJECT_OR_WEAK(WeakCell, weak_##NAME, public) \
|
||||
\
|
||||
@ -547,8 +539,6 @@ class WasmCompiledModule : public Struct {
|
||||
WCM_WEAK_LINK(WasmInstanceObject, owning_instance)
|
||||
WCM_WEAK_LINK(WasmModuleObject, wasm_module)
|
||||
WCM_OBJECT(Foreign, native_module)
|
||||
// TODO(mstarzinger): Make {use_trap_handler} smaller.
|
||||
WCM_SMALL_CONST_NUMBER(bool, use_trap_handler)
|
||||
|
||||
public:
|
||||
static Handle<WasmCompiledModule> New(Isolate* isolate,
|
||||
@ -688,7 +678,6 @@ class WasmDebugInfo : public Struct {
|
||||
#undef WCM_LARGE_NUMBER
|
||||
#undef WCM_OBJECT
|
||||
#undef WCM_OBJECT_OR_WEAK
|
||||
#undef WCM_SMALL_CONST_NUMBER
|
||||
#undef WCM_WEAK_LINK
|
||||
|
||||
#include "src/objects/object-macros-undef.h"
|
||||
|
Loading…
Reference in New Issue
Block a user