Commit 292cc336 authored by Clemens Hammacher's avatar Clemens Hammacher Committed by Commit Bot

[wasm] Make WasmModule* in ModuleEnv non-const

We need to modify that module, e.g. to add signatures to the signature
maps. Hence it cannot be const.

R=titzer@chromium.org
CC=mtrofin@chromium.org

Change-Id: I261af5b4233a0b2ec8031a9cbe0cf9f826316ae0
Reviewed-on: https://chromium-review.googlesource.com/600428Reviewed-by: 's avatarBen Titzer <titzer@chromium.org>
Commit-Queue: Clemens Hammacher <clemensh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#47138}
parent 9dd9419c
...@@ -2321,8 +2321,7 @@ Node* WasmGraphBuilder::CallIndirect(uint32_t sig_index, Node** args, ...@@ -2321,8 +2321,7 @@ Node* WasmGraphBuilder::CallIndirect(uint32_t sig_index, Node** args,
Int32Constant(kPointerSizeLog2)), Int32Constant(kPointerSizeLog2)),
Int32Constant(fixed_offset)), Int32Constant(fixed_offset)),
*effect_, *control_); *effect_, *control_);
auto& map = const_cast<wasm::SignatureMap&>( auto& map = module_->module->function_tables[0].map;
module_->module->function_tables[0].map);
Node* sig_match = graph()->NewNode( Node* sig_match = graph()->NewNode(
machine->WordEqual(), load_sig, machine->WordEqual(), load_sig,
jsgraph()->SmiConstant(static_cast<int>(map.FindOrInsert(sig)))); jsgraph()->SmiConstant(static_cast<int>(map.FindOrInsert(sig))));
...@@ -3822,8 +3821,7 @@ static void RecordFunctionCompilation(CodeEventListener::LogEventsAndTags tag, ...@@ -3822,8 +3821,7 @@ static void RecordFunctionCompilation(CodeEventListener::LogEventsAndTags tag,
*script_str, 0, 0)); *script_str, 0, 0));
} }
Handle<Code> CompileJSToWasmWrapper(Isolate* isolate, Handle<Code> CompileJSToWasmWrapper(Isolate* isolate, wasm::WasmModule* module,
const wasm::WasmModule* module,
Handle<Code> wasm_code, uint32_t index) { Handle<Code> wasm_code, uint32_t index) {
const wasm::WasmFunction* func = &module->functions[index]; const wasm::WasmFunction* func = &module->functions[index];
......
...@@ -114,8 +114,7 @@ Handle<Code> CompileWasmToJSWrapper(Isolate* isolate, Handle<JSReceiver> target, ...@@ -114,8 +114,7 @@ Handle<Code> CompileWasmToJSWrapper(Isolate* isolate, Handle<JSReceiver> target,
wasm::ModuleOrigin origin); wasm::ModuleOrigin origin);
// Wraps a given wasm code object, producing a code object. // Wraps a given wasm code object, producing a code object.
Handle<Code> CompileJSToWasmWrapper(Isolate* isolate, Handle<Code> CompileJSToWasmWrapper(Isolate* isolate, wasm::WasmModule* module,
const wasm::WasmModule* module,
Handle<Code> wasm_code, uint32_t index); Handle<Code> wasm_code, uint32_t index);
// 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
......
...@@ -693,7 +693,7 @@ MaybeHandle<WasmModuleObject> ModuleCompiler::CompileToModuleObjectInternal( ...@@ -693,7 +693,7 @@ MaybeHandle<WasmModuleObject> ModuleCompiler::CompileToModuleObjectInternal(
} }
Handle<Code> JSToWasmWrapperCache::CloneOrCompileJSToWasmWrapper( Handle<Code> JSToWasmWrapperCache::CloneOrCompileJSToWasmWrapper(
Isolate* isolate, const wasm::WasmModule* module, Handle<Code> wasm_code, Isolate* isolate, wasm::WasmModule* module, Handle<Code> wasm_code,
uint32_t index) { uint32_t index) {
const wasm::WasmFunction* func = &module->functions[index]; const wasm::WasmFunction* func = &module->functions[index];
int cached_idx = sig_map_.Find(func->sig); int cached_idx = sig_map_.Find(func->sig);
......
...@@ -185,7 +185,7 @@ class ModuleCompiler { ...@@ -185,7 +185,7 @@ class ModuleCompiler {
class JSToWasmWrapperCache { class JSToWasmWrapperCache {
public: public:
Handle<Code> CloneOrCompileJSToWasmWrapper(Isolate* isolate, Handle<Code> CloneOrCompileJSToWasmWrapper(Isolate* isolate,
const wasm::WasmModule* module, wasm::WasmModule* module,
Handle<Code> wasm_code, Handle<Code> wasm_code,
uint32_t index); uint32_t index);
......
...@@ -227,7 +227,7 @@ typedef Managed<WasmModule> WasmModuleWrapper; ...@@ -227,7 +227,7 @@ typedef Managed<WasmModule> WasmModuleWrapper;
struct WasmInstance { struct WasmInstance {
MOVE_ONLY_NO_DEFAULT_CONSTRUCTOR(WasmInstance); MOVE_ONLY_NO_DEFAULT_CONSTRUCTOR(WasmInstance);
const WasmModule* module; // static representation of the module. WasmModule* module; // static representation of the module.
// -- Heap allocated -------------------------------------------------------- // -- Heap allocated --------------------------------------------------------
std::vector<Handle<FixedArray>> function_tables; // indirect function tables. std::vector<Handle<FixedArray>> function_tables; // indirect function tables.
std::vector<Handle<FixedArray>> std::vector<Handle<FixedArray>>
...@@ -240,7 +240,7 @@ struct WasmInstance { ...@@ -240,7 +240,7 @@ struct WasmInstance {
// -- raw globals ----------------------------------------------------------- // -- raw globals -----------------------------------------------------------
byte* globals_start = nullptr; // start of the globals area. byte* globals_start = nullptr; // start of the globals area.
explicit WasmInstance(const WasmModule* m) explicit WasmInstance(WasmModule* m)
: module(m), : module(m),
function_tables(m->function_tables.size()), function_tables(m->function_tables.size()),
signature_tables(m->function_tables.size()), signature_tables(m->function_tables.size()),
...@@ -323,12 +323,12 @@ struct V8_EXPORT_PRIVATE ModuleWireBytes { ...@@ -323,12 +323,12 @@ struct V8_EXPORT_PRIVATE ModuleWireBytes {
struct V8_EXPORT_PRIVATE ModuleEnv { struct V8_EXPORT_PRIVATE ModuleEnv {
MOVE_ONLY_NO_DEFAULT_CONSTRUCTOR(ModuleEnv); MOVE_ONLY_NO_DEFAULT_CONSTRUCTOR(ModuleEnv);
ModuleEnv(const WasmModule* module, WasmInstance* instance) ModuleEnv(WasmModule* module, WasmInstance* instance)
: module(module), : module(module),
instance(instance), instance(instance),
function_tables(instance ? &instance->function_tables : nullptr), function_tables(instance ? &instance->function_tables : nullptr),
signature_tables(instance ? &instance->signature_tables : nullptr) {} signature_tables(instance ? &instance->signature_tables : nullptr) {}
ModuleEnv(const WasmModule* module, ModuleEnv(WasmModule* module,
std::vector<Handle<FixedArray>>* function_tables, std::vector<Handle<FixedArray>>* function_tables,
std::vector<Handle<FixedArray>>* signature_tables) std::vector<Handle<FixedArray>>* signature_tables)
: module(module), : module(module),
...@@ -336,7 +336,7 @@ struct V8_EXPORT_PRIVATE ModuleEnv { ...@@ -336,7 +336,7 @@ struct V8_EXPORT_PRIVATE ModuleEnv {
function_tables(function_tables), function_tables(function_tables),
signature_tables(signature_tables) {} signature_tables(signature_tables) {}
const WasmModule* module; WasmModule* module;
WasmInstance* instance; WasmInstance* instance;
std::vector<Handle<FixedArray>>* function_tables; std::vector<Handle<FixedArray>>* function_tables;
...@@ -383,10 +383,10 @@ struct V8_EXPORT_PRIVATE ModuleEnv { ...@@ -383,10 +383,10 @@ struct V8_EXPORT_PRIVATE ModuleEnv {
// A ModuleEnv together with ModuleWireBytes. // A ModuleEnv together with ModuleWireBytes.
struct ModuleBytesEnv { struct ModuleBytesEnv {
ModuleBytesEnv(const WasmModule* module, WasmInstance* instance, ModuleBytesEnv(WasmModule* module, WasmInstance* instance,
Vector<const byte> module_bytes) Vector<const byte> module_bytes)
: module_env(module, instance), wire_bytes(module_bytes) {} : module_env(module, instance), wire_bytes(module_bytes) {}
ModuleBytesEnv(const WasmModule* module, WasmInstance* instance, ModuleBytesEnv(WasmModule* module, WasmInstance* instance,
const ModuleWireBytes& wire_bytes) const ModuleWireBytes& wire_bytes)
: module_env(module, instance), wire_bytes(wire_bytes) {} : module_env(module, instance), wire_bytes(wire_bytes) {}
......
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