Commit 836ff8cc authored by Michael Starzinger's avatar Michael Starzinger Committed by Commit Bot

[wasm] Remove obsolete {function_code} from {ModuleEnv}.

R=clemensh@chromium.org
BUG=v8:7549

Change-Id: I2d3d063d9e34e8a0fd6e1f760a7d8ec9f4692789
Reviewed-on: https://chromium-review.googlesource.com/960025Reviewed-by: 's avatarClemens Hammacher <clemensh@chromium.org>
Commit-Queue: Michael Starzinger <mstarzinger@chromium.org>
Cr-Commit-Position: refs/heads/master@{#51906}
parent 5d312f02
......@@ -4661,11 +4661,7 @@ Handle<Code> CompileJSToWasmWrapper(Isolate* isolate, wasm::WasmModule* module,
Node* effect = nullptr;
// TODO(titzer): compile JS to WASM wrappers without a {ModuleEnv}.
ModuleEnv env(module,
// TODO(mstarzinger): remove the Illegal builtin when we don't
// need FLAG_wasm_jit_to_native
BUILTIN_CODE(isolate, Illegal), // default_function_code
use_trap_handler);
ModuleEnv env(module, use_trap_handler);
WasmGraphBuilder builder(&env, &zone, &jsgraph,
CEntryStub(isolate, 1).GetCode(), func->sig);
......@@ -4778,7 +4774,7 @@ Handle<Code> CompileWasmToJSWrapper(
origin == wasm::kAsmJsOrigin ? new (&zone) SourcePositionTable(&graph)
: nullptr;
ModuleEnv env(nullptr, Handle<Code>::null(), use_trap_handler);
ModuleEnv env(nullptr, use_trap_handler);
WasmGraphBuilder builder(&env, &zone, &jsgraph,
CEntryStub(isolate, 1).GetCode(), sig,
source_position_table);
......@@ -4865,9 +4861,8 @@ Handle<Code> CompileWasmToWasmWrapper(Isolate* isolate, WasmCodeWrapper target,
Node* control = nullptr;
Node* effect = nullptr;
ModuleEnv env(
nullptr, Handle<Code>::null(),
!target.IsCodeObject() && target.GetWasmCode()->HasTrapHandlerIndex());
ModuleEnv env(nullptr, !target.IsCodeObject() &&
target.GetWasmCode()->HasTrapHandlerIndex());
WasmGraphBuilder builder(&env, &zone, &jsgraph, Handle<Code>(), sig);
builder.set_control_ptr(&control);
builder.set_effect_ptr(&effect);
......
......@@ -72,31 +72,17 @@ struct ModuleEnv {
// FixedArray.
const std::vector<Address> function_tables;
// TODO(mstarzinger): remove these 2 once we don't need
// FLAG_wasm_jit_to_native
// Contains the code objects to call for each direct call.
// (the same length as module.functions)
const std::vector<Handle<Code>> function_code;
// If the default code is not a null handle, always use it for direct calls.
const Handle<Code> default_function_code;
// True if trap handling should be used in compiled code, rather than
// compiling in bounds checks for each memory access.
const bool use_trap_handler;
ModuleEnv(const wasm::WasmModule* module, Handle<Code> default_function_code,
bool use_trap_handler)
: module(module),
default_function_code(default_function_code),
use_trap_handler(use_trap_handler) {}
ModuleEnv(const wasm::WasmModule* module, bool use_trap_handler)
: module(module), use_trap_handler(use_trap_handler) {}
ModuleEnv(const wasm::WasmModule* module,
std::vector<Address> function_tables,
std::vector<Handle<Code>> function_code,
Handle<Code> default_function_code, bool use_trap_handler)
std::vector<Address> function_tables, bool use_trap_handler)
: module(module),
function_tables(std::move(function_tables)),
function_code(std::move(function_code)),
default_function_code(default_function_code),
use_trap_handler(use_trap_handler) {}
};
......
......@@ -588,8 +588,6 @@ compiler::ModuleEnv CreateModuleEnvFromCompiledModule(
DisallowHeapAllocation no_gc;
WasmModule* module = compiled_module->shared()->module();
compiler::ModuleEnv result(module, std::vector<Address>{},
std::vector<Handle<Code>>{},
BUILTIN_CODE(isolate, WasmCompileLazy),
compiled_module->use_trap_handler());
return result;
}
......@@ -1409,7 +1407,7 @@ void FunctionTableFinalizer(const v8::WeakCallbackInfo<void>& data) {
}
std::unique_ptr<compiler::ModuleEnv> CreateDefaultModuleEnv(
Isolate* isolate, WasmModule* module, Handle<Code> illegal_builtin) {
Isolate* isolate, WasmModule* module) {
std::vector<GlobalHandleAddress> function_tables;
for (size_t i = module->function_tables.size(); i > 0; --i) {
......@@ -1423,9 +1421,8 @@ std::unique_ptr<compiler::ModuleEnv> CreateDefaultModuleEnv(
// TODO(kschimpf): Add module-specific policy handling here (see v8:7143)?
bool use_trap_handler = trap_handler::IsTrapHandlerEnabled();
return base::make_unique<compiler::ModuleEnv>(
module, function_tables, std::vector<Handle<Code>>{}, illegal_builtin,
use_trap_handler);
return base::make_unique<compiler::ModuleEnv>(module, function_tables,
use_trap_handler);
}
Handle<WasmCompiledModule> NewCompiledModule(Isolate* isolate,
......@@ -1438,14 +1435,6 @@ Handle<WasmCompiledModule> NewCompiledModule(Isolate* isolate,
return compiled_module;
}
template <typename T>
void ReopenHandles(Isolate* isolate, const std::vector<Handle<T>>& vec) {
auto& mut = const_cast<std::vector<Handle<T>>&>(vec);
for (size_t i = 0; i < mut.size(); i++) {
mut[i] = Handle<T>(*mut[i], isolate);
}
}
} // namespace
MaybeHandle<WasmModuleObject> ModuleCompiler::CompileToModuleObjectInternal(
......@@ -1515,7 +1504,7 @@ MaybeHandle<WasmModuleObject> ModuleCompiler::CompileToModuleObjectInternal(
for (int i = 0, e = export_wrappers->length(); i < e; ++i) {
export_wrappers->set(i, *init_builtin);
}
auto env = CreateDefaultModuleEnv(isolate_, module_, init_builtin);
auto env = CreateDefaultModuleEnv(isolate_, module_);
// Create the compiled module object and populate with compiled functions
// and information needed at instantiation time. This object needs to be
......@@ -3049,9 +3038,7 @@ class AsyncCompileJob::PrepareAndStartCompile : public CompileStep {
TRACE_COMPILE("(2) Prepare and start compile...\n");
Isolate* isolate = job_->isolate_;
Handle<Code> illegal_builtin = BUILTIN_CODE(isolate, Illegal);
job_->module_env_ =
CreateDefaultModuleEnv(isolate, module_, illegal_builtin);
job_->module_env_ = CreateDefaultModuleEnv(isolate, module_);
// Transfer ownership of the {WasmModule} to the {ModuleCompiler}, but
// keep a pointer.
......@@ -3062,11 +3049,6 @@ class AsyncCompileJob::PrepareAndStartCompile : public CompileStep {
DeferredHandleScope deferred(isolate);
centry_stub = Handle<Code>(*centry_stub, isolate);
compiler::ModuleEnv* env = job_->module_env_.get();
ReopenHandles(isolate, env->function_code);
Handle<Code>* mut =
const_cast<Handle<Code>*>(&env->default_function_code);
*mut = Handle<Code>(**mut, isolate);
job_->deferred_handles_.push_back(deferred.Detach());
}
......
......@@ -80,7 +80,6 @@ uint32_t TestingModuleBuilder::AddFunction(FunctionSig* sig, const char* name) {
test_module_.functions.back().name = {
AddBytes(name_vec), static_cast<uint32_t>(name_vec.length())};
}
function_code_.push_back(Handle<Code>::null());
if (interpreter_) {
interpreter_->AddFunctionForTesting(&test_module_.functions.back());
}
......@@ -202,7 +201,7 @@ uint32_t TestingModuleBuilder::AddBytes(Vector<const byte> bytes) {
}
compiler::ModuleEnv TestingModuleBuilder::CreateModuleEnv() {
return {&test_module_, function_tables_, function_code_, Handle<Code>::null(),
return {&test_module_, function_tables_,
trap_handler::IsTrapHandlerEnabled()};
}
......
......@@ -181,10 +181,6 @@ class TestingModuleBuilder {
Handle<JSFunction> WrapCode(uint32_t index);
void SetFunctionCode(uint32_t index, Handle<Code> code) {
function_code_[index] = code;
}
void AddIndirectFunctionTable(const uint16_t* function_indexes,
uint32_t table_size);
......@@ -204,9 +200,6 @@ class TestingModuleBuilder {
WasmCodeWrapper GetFunctionCode(uint32_t index) {
return WasmCodeWrapper(native_module_->GetCode(index));
}
void SetFunctionCode(int index, Handle<Code> code) {
function_code_[index] = code;
}
Address globals_start() { return reinterpret_cast<Address>(globals_data_); }
void Link() {
if (!linked_) {
......@@ -231,7 +224,6 @@ class TestingModuleBuilder {
uint32_t global_offset;
byte* mem_start_;
uint32_t mem_size_;
std::vector<Handle<Code>> function_code_;
std::vector<GlobalHandleAddress> function_tables_;
V8_ALIGNED(16) byte globals_data_[kMaxGlobalsSize];
WasmInterpreter* interpreter_;
......
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