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,
Int32Constant(kPointerSizeLog2)),
Int32Constant(fixed_offset)),
*effect_, *control_);
auto& map = const_cast<wasm::SignatureMap&>(
module_->module->function_tables[0].map);
auto& map = module_->module->function_tables[0].map;
Node* sig_match = graph()->NewNode(
machine->WordEqual(), load_sig,
jsgraph()->SmiConstant(static_cast<int>(map.FindOrInsert(sig))));
......@@ -3822,8 +3821,7 @@ static void RecordFunctionCompilation(CodeEventListener::LogEventsAndTags tag,
*script_str, 0, 0));
}
Handle<Code> CompileJSToWasmWrapper(Isolate* isolate,
const wasm::WasmModule* module,
Handle<Code> CompileJSToWasmWrapper(Isolate* isolate, wasm::WasmModule* module,
Handle<Code> wasm_code, uint32_t index) {
const wasm::WasmFunction* func = &module->functions[index];
......
......@@ -114,8 +114,7 @@ Handle<Code> CompileWasmToJSWrapper(Isolate* isolate, Handle<JSReceiver> target,
wasm::ModuleOrigin origin);
// Wraps a given wasm code object, producing a code object.
Handle<Code> CompileJSToWasmWrapper(Isolate* isolate,
const wasm::WasmModule* module,
Handle<Code> CompileJSToWasmWrapper(Isolate* isolate, wasm::WasmModule* module,
Handle<Code> wasm_code, uint32_t index);
// Compiles a stub that redirects a call to a wasm function to the wasm
......
......@@ -693,7 +693,7 @@ MaybeHandle<WasmModuleObject> ModuleCompiler::CompileToModuleObjectInternal(
}
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) {
const wasm::WasmFunction* func = &module->functions[index];
int cached_idx = sig_map_.Find(func->sig);
......
......@@ -185,7 +185,7 @@ class ModuleCompiler {
class JSToWasmWrapperCache {
public:
Handle<Code> CloneOrCompileJSToWasmWrapper(Isolate* isolate,
const wasm::WasmModule* module,
wasm::WasmModule* module,
Handle<Code> wasm_code,
uint32_t index);
......
......@@ -227,7 +227,7 @@ typedef Managed<WasmModule> WasmModuleWrapper;
struct WasmInstance {
MOVE_ONLY_NO_DEFAULT_CONSTRUCTOR(WasmInstance);
const WasmModule* module; // static representation of the module.
WasmModule* module; // static representation of the module.
// -- Heap allocated --------------------------------------------------------
std::vector<Handle<FixedArray>> function_tables; // indirect function tables.
std::vector<Handle<FixedArray>>
......@@ -240,7 +240,7 @@ struct WasmInstance {
// -- raw globals -----------------------------------------------------------
byte* globals_start = nullptr; // start of the globals area.
explicit WasmInstance(const WasmModule* m)
explicit WasmInstance(WasmModule* m)
: module(m),
function_tables(m->function_tables.size()),
signature_tables(m->function_tables.size()),
......@@ -323,12 +323,12 @@ struct V8_EXPORT_PRIVATE ModuleWireBytes {
struct V8_EXPORT_PRIVATE ModuleEnv {
MOVE_ONLY_NO_DEFAULT_CONSTRUCTOR(ModuleEnv);
ModuleEnv(const WasmModule* module, WasmInstance* instance)
ModuleEnv(WasmModule* module, WasmInstance* instance)
: module(module),
instance(instance),
function_tables(instance ? &instance->function_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>>* signature_tables)
: module(module),
......@@ -336,7 +336,7 @@ struct V8_EXPORT_PRIVATE ModuleEnv {
function_tables(function_tables),
signature_tables(signature_tables) {}
const WasmModule* module;
WasmModule* module;
WasmInstance* instance;
std::vector<Handle<FixedArray>>* function_tables;
......@@ -383,10 +383,10 @@ struct V8_EXPORT_PRIVATE ModuleEnv {
// A ModuleEnv together with ModuleWireBytes.
struct ModuleBytesEnv {
ModuleBytesEnv(const WasmModule* module, WasmInstance* instance,
ModuleBytesEnv(WasmModule* module, WasmInstance* instance,
Vector<const byte> 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)
: 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