Commit 575f7423 authored by Michael Starzinger's avatar Michael Starzinger Committed by Commit Bot

[wasm] Remove unused {WasmCompiledModule::code_table} field.

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

Change-Id: I90bd4cf8ed31f46d475cd46de868e483c84c6aba
Reviewed-on: https://chromium-review.googlesource.com/959013Reviewed-by: 's avatarClemens Hammacher <clemensh@chromium.org>
Commit-Queue: Michael Starzinger <mstarzinger@chromium.org>
Cr-Commit-Position: refs/heads/master@{#51889}
parent b68db45b
...@@ -1487,7 +1487,6 @@ void WasmCompiledModule::WasmCompiledModuleVerify() { ...@@ -1487,7 +1487,6 @@ void WasmCompiledModule::WasmCompiledModuleVerify() {
VerifyObjectField(kNativeModuleOffset); VerifyObjectField(kNativeModuleOffset);
VerifyObjectField(kLazyCompileDataOffset); VerifyObjectField(kLazyCompileDataOffset);
VerifyObjectField(kUseTrapHandlerOffset); VerifyObjectField(kUseTrapHandlerOffset);
VerifyObjectField(kCodeTableOffset);
VerifyObjectField(kFunctionTablesOffset); VerifyObjectField(kFunctionTablesOffset);
VerifyObjectField(kEmptyFunctionTablesOffset); VerifyObjectField(kEmptyFunctionTablesOffset);
} }
......
...@@ -393,8 +393,7 @@ class InstanceBuilder { ...@@ -393,8 +393,7 @@ class InstanceBuilder {
// Process the imports, including functions, tables, globals, and memory, in // Process the imports, including functions, tables, globals, and memory, in
// order, loading them from the {ffi_} object. Returns the number of imported // order, loading them from the {ffi_} object. Returns the number of imported
// functions. // functions.
int ProcessImports(Handle<FixedArray> code_table, int ProcessImports(Handle<WasmInstanceObject> instance);
Handle<WasmInstanceObject> instance);
template <typename T> template <typename T>
T* GetRawGlobalPtr(WasmGlobal& global); T* GetRawGlobalPtr(WasmGlobal& global);
...@@ -415,8 +414,7 @@ class InstanceBuilder { ...@@ -415,8 +414,7 @@ class InstanceBuilder {
void InitializeTables(Handle<WasmInstanceObject> instance, void InitializeTables(Handle<WasmInstanceObject> instance,
CodeSpecialization* code_specialization); CodeSpecialization* code_specialization);
void LoadTableSegments(Handle<FixedArray> code_table, void LoadTableSegments(Handle<WasmInstanceObject> instance);
Handle<WasmInstanceObject> instance);
}; };
// This is used in ProcessImports. // This is used in ProcessImports.
...@@ -691,19 +689,6 @@ int AdvanceSourcePositionTableIterator(SourcePositionTableIterator& iterator, ...@@ -691,19 +689,6 @@ int AdvanceSourcePositionTableIterator(SourcePositionTableIterator& iterator,
return byte_pos; return byte_pos;
} }
Code* ExtractWasmToWasmCallee(Code* wasm_to_wasm) {
DCHECK_EQ(Code::WASM_TO_WASM_FUNCTION, wasm_to_wasm->kind());
// Find the one code target in this wrapper.
RelocIterator it(wasm_to_wasm, RelocInfo::kCodeTargetMask);
DCHECK(!it.done());
Code* callee = Code::GetCodeFromTargetAddress(it.rinfo()->target_address());
#ifdef DEBUG
it.next();
DCHECK(it.done());
#endif
return callee;
}
const WasmCode* WasmExtractWasmToWasmCallee(const WasmCodeManager* code_manager, const WasmCode* WasmExtractWasmToWasmCallee(const WasmCodeManager* code_manager,
const WasmCode* wasm_to_wasm) { const WasmCode* wasm_to_wasm) {
DCHECK_EQ(WasmCode::kWasmToWasmWrapper, wasm_to_wasm->kind()); DCHECK_EQ(WasmCode::kWasmToWasmWrapper, wasm_to_wasm->kind());
...@@ -742,172 +727,8 @@ const WasmCode* WasmExtractWasmToWasmCallee(const WasmCodeManager* code_manager, ...@@ -742,172 +727,8 @@ const WasmCode* WasmExtractWasmToWasmCallee(const WasmCodeManager* code_manager,
DCHECK(it.done()); \ DCHECK(it.done()); \
} while (0) } while (0)
void PatchWasmToWasmWrapper(Isolate* isolate, Code* wasm_to_wasm,
Code* new_target) {
DCHECK_EQ(Code::WASM_TO_WASM_FUNCTION, wasm_to_wasm->kind());
// Find the one code target in this wrapper.
RelocIterator it(wasm_to_wasm, RelocInfo::kCodeTargetMask);
DCHECK(!it.done());
DCHECK_EQ(Builtins::kWasmCompileLazy,
Code::GetCodeFromTargetAddress(it.rinfo()->target_address())
->builtin_index());
it.rinfo()->set_target_address(new_target->instruction_start());
#ifdef DEBUG
it.next();
DCHECK(it.done());
#endif
}
} // namespace } // namespace
Handle<Code> LazyCompilationOrchestrator::CompileLazyOnGCHeap(
Isolate* isolate, Handle<WasmInstanceObject> instance, Handle<Code> caller,
int call_offset, int exported_func_index, bool patch_caller) {
struct NonCompiledFunction {
int offset;
int func_index;
};
std::vector<NonCompiledFunction> non_compiled_functions;
int func_to_return_idx = exported_func_index;
Decoder decoder(nullptr, nullptr);
bool is_js_to_wasm = caller->kind() == Code::JS_TO_WASM_FUNCTION;
Handle<WasmCompiledModule> compiled_module(instance->compiled_module(),
isolate);
TRACE_LAZY(
"Starting lazy compilation (func %d @%d, js-to-wasm: %d, "
"patch caller: %d).\n",
exported_func_index, call_offset, is_js_to_wasm, patch_caller);
// If this lazy compile stub is being called through a wasm-to-wasm wrapper,
// remember that code object.
Handle<Code> wasm_to_wasm_callee;
// For js-to-wasm wrappers, don't iterate the reloc info. There is just one
// call site in there anyway.
if (patch_caller && !is_js_to_wasm) {
DisallowHeapAllocation no_gc;
SourcePositionTableIterator source_pos_iterator(
caller->SourcePositionTable());
auto caller_func_info = GetWasmFunctionInfo(isolate, caller);
Handle<WasmCompiledModule> caller_module(
caller_func_info.instance.ToHandleChecked()->compiled_module(),
isolate);
SeqOneByteString* module_bytes = caller_module->shared()->module_bytes();
const byte* func_bytes =
module_bytes->GetChars() + caller_module->shared()
->module()
->functions[caller_func_info.func_index]
.code.offset();
Code* lazy_callee = nullptr;
for (RelocIterator it(*caller, RelocInfo::kCodeTargetMask); !it.done();
it.next()) {
Code* callee =
Code::GetCodeFromTargetAddress(it.rinfo()->target_address());
// TODO(clemensh): Introduce safe_cast<T, bool> which (D)CHECKS
// (depending on the bool) against limits of T and then static_casts.
size_t offset_l = it.rinfo()->pc() - caller->instruction_start();
DCHECK_GE(kMaxInt, offset_l);
int offset = static_cast<int>(offset_l);
// Call offset points to the instruction after the call. Remember the last
// called code object before that offset.
if (offset < call_offset) lazy_callee = callee;
if (callee->builtin_index() != Builtins::kWasmCompileLazy) continue;
int byte_pos =
AdvanceSourcePositionTableIterator(source_pos_iterator, offset);
int called_func_index =
ExtractDirectCallIndex(decoder, func_bytes + byte_pos);
non_compiled_functions.push_back({offset, called_func_index});
if (offset < call_offset) func_to_return_idx = called_func_index;
}
TRACE_LAZY("Found %zu non-compiled functions in caller.\n",
non_compiled_functions.size());
DCHECK_NOT_NULL(lazy_callee);
if (lazy_callee->kind() == Code::WASM_TO_WASM_FUNCTION) {
TRACE_LAZY("Callee is a wasm-to-wasm.\n");
wasm_to_wasm_callee = handle(lazy_callee, isolate);
// If we call a wasm-to-wasm wrapper, then this wrapper actually
// tail-called the lazy compile stub. Find it in the wrapper.
lazy_callee = ExtractWasmToWasmCallee(lazy_callee);
// This lazy compile stub belongs to the instance that was passed.
DCHECK_EQ(*instance,
*GetWasmFunctionInfo(isolate, handle(lazy_callee, isolate))
.instance.ToHandleChecked());
DCHECK_LE(2, lazy_callee->deoptimization_data()->length());
func_to_return_idx =
Smi::ToInt(lazy_callee->deoptimization_data()->get(1));
}
DCHECK_EQ(Builtins::kWasmCompileLazy, lazy_callee->builtin_index());
// There must be at least one call to patch (the one that lead to calling
// the lazy compile stub).
DCHECK(!non_compiled_functions.empty() || !wasm_to_wasm_callee.is_null());
}
// TODO(clemensh): compile all functions in non_compiled_functions in
// background, wait for func_to_return_idx.
CompileFunction(isolate, instance, func_to_return_idx);
Handle<Code> compiled_function(
Code::cast(compiled_module->code_table()->get(func_to_return_idx)),
isolate);
DCHECK_EQ(Code::WASM_FUNCTION, compiled_function->kind());
if (patch_caller || is_js_to_wasm) {
DisallowHeapAllocation no_gc;
// TODO(6792): No longer needed once WebAssembly code is off heap.
CodeSpaceMemoryModificationScope modification_scope(isolate->heap());
// Now patch the code object with all functions which are now compiled.
int idx = 0;
int patched = 0;
for (RelocIterator it(*caller, RelocInfo::kCodeTargetMask); !it.done();
it.next()) {
Code* callee =
Code::GetCodeFromTargetAddress(it.rinfo()->target_address());
if (callee->builtin_index() != Builtins::kWasmCompileLazy) {
// If the callee is the wasm-to-wasm wrapper triggering this lazy
// compilation, patch it. If is_js_to_wasm is set, we did not set the
// wasm_to_wasm_callee, so just check the code kind (this is the only
// call in that wrapper anyway).
if ((is_js_to_wasm && callee->kind() == Code::WASM_TO_WASM_FUNCTION) ||
(!wasm_to_wasm_callee.is_null() &&
callee == *wasm_to_wasm_callee)) {
TRACE_LAZY("Patching wasm-to-wasm wrapper.\n");
PatchWasmToWasmWrapper(isolate, callee, *compiled_function);
++patched;
}
continue;
}
int called_func_index = func_to_return_idx;
if (!is_js_to_wasm) {
DCHECK_GT(non_compiled_functions.size(), idx);
called_func_index = non_compiled_functions[idx].func_index;
DCHECK_EQ(non_compiled_functions[idx].offset,
it.rinfo()->pc() - caller->instruction_start());
++idx;
}
// Check that the callee agrees with our assumed called_func_index.
DCHECK_IMPLIES(callee->deoptimization_data()->length() > 0,
Smi::ToInt(callee->deoptimization_data()->get(1)) ==
called_func_index);
Handle<Code> callee_compiled(
Code::cast(compiled_module->code_table()->get(called_func_index)));
if (callee_compiled->builtin_index() == Builtins::kWasmCompileLazy) {
DCHECK_NE(func_to_return_idx, called_func_index);
continue;
}
DCHECK_EQ(Code::WASM_FUNCTION, callee_compiled->kind());
it.rinfo()->set_target_address(callee_compiled->instruction_start());
++patched;
}
DCHECK_EQ(non_compiled_functions.size(), idx);
TRACE_LAZY("Patched %d location(s) in the caller.\n", patched);
DCHECK_LT(0, patched);
USE(patched);
}
return compiled_function;
}
const wasm::WasmCode* LazyCompilationOrchestrator::CompileFromJsToWasm( const wasm::WasmCode* LazyCompilationOrchestrator::CompileFromJsToWasm(
Isolate* isolate, Handle<WasmInstanceObject> instance, Isolate* isolate, Handle<WasmInstanceObject> instance,
Handle<Code> js_to_wasm_caller, uint32_t exported_func_index) { Handle<Code> js_to_wasm_caller, uint32_t exported_func_index) {
...@@ -1462,11 +1283,7 @@ void RecordStats(const wasm::NativeModule* native_module, Counters* counters) { ...@@ -1462,11 +1283,7 @@ void RecordStats(const wasm::NativeModule* native_module, Counters* counters) {
// deoptimization data attached. This is needed for lazy compile stubs which are // deoptimization data attached. This is needed for lazy compile stubs which are
// called from JS_TO_WASM functions or via exported function tables. The deopt // called from JS_TO_WASM functions or via exported function tables. The deopt
// data is used to determine which function this lazy compile stub belongs to. // data is used to determine which function this lazy compile stub belongs to.
// TODO(mstarzinger): remove the instance and code_table members once we remove
// the FLAG_wasm_jit_to_native
WasmCodeWrapper EnsureExportedLazyDeoptData(Isolate* isolate, WasmCodeWrapper EnsureExportedLazyDeoptData(Isolate* isolate,
Handle<WasmInstanceObject> instance,
Handle<FixedArray> code_table,
wasm::NativeModule* native_module, wasm::NativeModule* native_module,
uint32_t func_index) { uint32_t func_index) {
wasm::WasmCode* code = native_module->GetCode(func_index); wasm::WasmCode* code = native_module->GetCode(func_index);
...@@ -1483,16 +1300,12 @@ WasmCodeWrapper EnsureExportedLazyDeoptData(Isolate* isolate, ...@@ -1483,16 +1300,12 @@ WasmCodeWrapper EnsureExportedLazyDeoptData(Isolate* isolate,
// deoptimization data attached. This is needed for lazy compile stubs which are // deoptimization data attached. This is needed for lazy compile stubs which are
// called from JS_TO_WASM functions or via exported function tables. The deopt // called from JS_TO_WASM functions or via exported function tables. The deopt
// data is used to determine which function this lazy compile stub belongs to. // data is used to determine which function this lazy compile stub belongs to.
// TODO(mstarzinger): remove the instance and code_table members once we remove
// the FLAG_wasm_jit_to_native
WasmCodeWrapper EnsureTableExportLazyDeoptData( WasmCodeWrapper EnsureTableExportLazyDeoptData(
Isolate* isolate, Handle<WasmInstanceObject> instance, Isolate* isolate, wasm::NativeModule* native_module, uint32_t func_index,
Handle<FixedArray> code_table, wasm::NativeModule* native_module, Handle<FixedArray> export_table, int export_index,
uint32_t func_index, Handle<FixedArray> export_table, int export_index,
std::unordered_map<uint32_t, uint32_t>* num_table_exports) { std::unordered_map<uint32_t, uint32_t>* num_table_exports) {
const wasm::WasmCode* code = const wasm::WasmCode* code =
EnsureExportedLazyDeoptData(isolate, instance, code_table, native_module, EnsureExportedLazyDeoptData(isolate, native_module, func_index)
func_index)
.GetWasmCode(); .GetWasmCode();
if (code == nullptr || code->kind() != wasm::WasmCode::kLazyStub) if (code == nullptr || code->kind() != wasm::WasmCode::kLazyStub)
return WasmCodeWrapper(code); return WasmCodeWrapper(code);
...@@ -1615,15 +1428,12 @@ std::unique_ptr<compiler::ModuleEnv> CreateDefaultModuleEnv( ...@@ -1615,15 +1428,12 @@ std::unique_ptr<compiler::ModuleEnv> CreateDefaultModuleEnv(
use_trap_handler); use_trap_handler);
} }
// TODO(mstarzinger): remove code_table when we don't need
// FLAG_wasm_jit_to_native
Handle<WasmCompiledModule> NewCompiledModule(Isolate* isolate, Handle<WasmCompiledModule> NewCompiledModule(Isolate* isolate,
WasmModule* module, WasmModule* module,
Handle<FixedArray> code_table,
Handle<FixedArray> export_wrappers, Handle<FixedArray> export_wrappers,
compiler::ModuleEnv* env) { compiler::ModuleEnv* env) {
Handle<WasmCompiledModule> compiled_module = Handle<WasmCompiledModule> compiled_module =
WasmCompiledModule::New(isolate, module, code_table, export_wrappers, WasmCompiledModule::New(isolate, module, export_wrappers,
env->function_tables, env->use_trap_handler); env->function_tables, env->use_trap_handler);
return compiled_module; return compiled_module;
} }
...@@ -1699,19 +1509,9 @@ MaybeHandle<WasmModuleObject> ModuleCompiler::CompileToModuleObjectInternal( ...@@ -1699,19 +1509,9 @@ MaybeHandle<WasmModuleObject> ModuleCompiler::CompileToModuleObjectInternal(
? BUILTIN_CODE(isolate_, WasmCompileLazy) ? BUILTIN_CODE(isolate_, WasmCompileLazy)
: BUILTIN_CODE(isolate_, Illegal); : BUILTIN_CODE(isolate_, Illegal);
// TODO(mstarzinger): remove code_table and code_table_size when we don't
// need FLAG_wasm_jit_to_native anymore. Keep export_wrappers.
int code_table_size = static_cast<int>(module_->functions.size());
int export_wrappers_size = static_cast<int>(module_->num_exported_functions); int export_wrappers_size = static_cast<int>(module_->num_exported_functions);
Handle<FixedArray> code_table =
factory->NewFixedArray(static_cast<int>(code_table_size), TENURED);
Handle<FixedArray> export_wrappers = Handle<FixedArray> export_wrappers =
factory->NewFixedArray(static_cast<int>(export_wrappers_size), TENURED); factory->NewFixedArray(static_cast<int>(export_wrappers_size), TENURED);
// Initialize the code table.
for (int i = 0, e = code_table->length(); i < e; ++i) {
code_table->set(i, *init_builtin);
}
for (int i = 0, e = export_wrappers->length(); i < e; ++i) { for (int i = 0, e = export_wrappers->length(); i < e; ++i) {
export_wrappers->set(i, *init_builtin); export_wrappers->set(i, *init_builtin);
} }
...@@ -1721,8 +1521,8 @@ MaybeHandle<WasmModuleObject> ModuleCompiler::CompileToModuleObjectInternal( ...@@ -1721,8 +1521,8 @@ MaybeHandle<WasmModuleObject> ModuleCompiler::CompileToModuleObjectInternal(
// and information needed at instantiation time. This object needs to be // and information needed at instantiation time. This object needs to be
// serializable. Instantiation may occur off a deserialized version of this // serializable. Instantiation may occur off a deserialized version of this
// object. // object.
Handle<WasmCompiledModule> compiled_module = NewCompiledModule( Handle<WasmCompiledModule> compiled_module =
isolate_, shared->module(), code_table, export_wrappers, env.get()); NewCompiledModule(isolate_, shared->module(), export_wrappers, env.get());
native_module_ = compiled_module->GetNativeModule(); native_module_ = compiled_module->GetNativeModule();
compiled_module->OnWasmModuleDecodingComplete(shared); compiled_module->OnWasmModuleDecodingComplete(shared);
if (lazy_compile) { if (lazy_compile) {
...@@ -1822,9 +1622,6 @@ MaybeHandle<WasmInstanceObject> InstanceBuilder::Build() { ...@@ -1822,9 +1622,6 @@ MaybeHandle<WasmInstanceObject> InstanceBuilder::Build() {
//-------------------------------------------------------------------------- //--------------------------------------------------------------------------
// Reuse the compiled module (if no owner), otherwise clone. // Reuse the compiled module (if no owner), otherwise clone.
//-------------------------------------------------------------------------- //--------------------------------------------------------------------------
// TODO(mstarzinger): remove code_table
// when FLAG_wasm_jit_to_native is not needed
Handle<FixedArray> code_table;
Handle<FixedArray> wrapper_table; Handle<FixedArray> wrapper_table;
MaybeHandle<WasmInstanceObject> owner; MaybeHandle<WasmInstanceObject> owner;
// native_module is the one we're building now, old_module // native_module is the one we're building now, old_module
...@@ -1928,7 +1725,7 @@ MaybeHandle<WasmInstanceObject> InstanceBuilder::Build() { ...@@ -1928,7 +1725,7 @@ MaybeHandle<WasmInstanceObject> InstanceBuilder::Build() {
//-------------------------------------------------------------------------- //--------------------------------------------------------------------------
// Process the imports for the module. // Process the imports for the module.
//-------------------------------------------------------------------------- //--------------------------------------------------------------------------
int num_imported_functions = ProcessImports(code_table, instance); int num_imported_functions = ProcessImports(instance);
if (num_imported_functions < 0) return {}; if (num_imported_functions < 0) return {};
//-------------------------------------------------------------------------- //--------------------------------------------------------------------------
...@@ -2034,7 +1831,7 @@ MaybeHandle<WasmInstanceObject> InstanceBuilder::Build() { ...@@ -2034,7 +1831,7 @@ MaybeHandle<WasmInstanceObject> InstanceBuilder::Build() {
// Initialize the indirect function tables. // Initialize the indirect function tables.
//-------------------------------------------------------------------------- //--------------------------------------------------------------------------
if (function_table_count > 0) { if (function_table_count > 0) {
LoadTableSegments(code_table, instance); LoadTableSegments(instance);
} }
//-------------------------------------------------------------------------- //--------------------------------------------------------------------------
...@@ -2099,8 +1896,8 @@ MaybeHandle<WasmInstanceObject> InstanceBuilder::Build() { ...@@ -2099,8 +1896,8 @@ MaybeHandle<WasmInstanceObject> InstanceBuilder::Build() {
//-------------------------------------------------------------------------- //--------------------------------------------------------------------------
if (module_->start_function_index >= 0) { if (module_->start_function_index >= 0) {
int start_index = module_->start_function_index; int start_index = module_->start_function_index;
WasmCodeWrapper start_code = EnsureExportedLazyDeoptData( WasmCodeWrapper start_code =
isolate_, instance, code_table, native_module, start_index); EnsureExportedLazyDeoptData(isolate_, native_module, start_index);
FunctionSig* sig = module_->functions[start_index].sig; FunctionSig* sig = module_->functions[start_index].sig;
Handle<Code> wrapper_code = js_to_wasm_cache_.CloneOrCompileJSToWasmWrapper( Handle<Code> wrapper_code = js_to_wasm_cache_.CloneOrCompileJSToWasmWrapper(
isolate_, module_, start_code, start_index, isolate_, module_, start_code, start_index,
...@@ -2324,8 +2121,7 @@ Handle<FixedArray> InstanceBuilder::SetupWasmToJSImportsTable( ...@@ -2324,8 +2121,7 @@ Handle<FixedArray> InstanceBuilder::SetupWasmToJSImportsTable(
// Process the imports, including functions, tables, globals, and memory, in // Process the imports, including functions, tables, globals, and memory, in
// order, loading them from the {ffi_} object. Returns the number of imported // order, loading them from the {ffi_} object. Returns the number of imported
// functions. // functions.
int InstanceBuilder::ProcessImports(Handle<FixedArray> code_table, int InstanceBuilder::ProcessImports(Handle<WasmInstanceObject> instance) {
Handle<WasmInstanceObject> instance) {
using compiler::kFunctionTableSignatureOffset; using compiler::kFunctionTableSignatureOffset;
using compiler::kFunctionTableCodeOffset; using compiler::kFunctionTableCodeOffset;
using compiler::kFunctionTableEntrySize; using compiler::kFunctionTableEntrySize;
...@@ -2870,8 +2666,7 @@ void InstanceBuilder::InitializeTables( ...@@ -2870,8 +2666,7 @@ void InstanceBuilder::InitializeTables(
} }
} }
void InstanceBuilder::LoadTableSegments(Handle<FixedArray> code_table, void InstanceBuilder::LoadTableSegments(Handle<WasmInstanceObject> instance) {
Handle<WasmInstanceObject> instance) {
wasm::NativeModule* native_module = compiled_module_->GetNativeModule(); wasm::NativeModule* native_module = compiled_module_->GetNativeModule();
int function_table_count = static_cast<int>(module_->function_tables.size()); int function_table_count = static_cast<int>(module_->function_tables.size());
for (int index = 0; index < function_table_count; ++index) { for (int index = 0; index < function_table_count; ++index) {
...@@ -2916,8 +2711,8 @@ void InstanceBuilder::LoadTableSegments(Handle<FixedArray> code_table, ...@@ -2916,8 +2711,8 @@ void InstanceBuilder::LoadTableSegments(Handle<FixedArray> code_table,
compiler::FunctionTableSigOffset(table_index), compiler::FunctionTableSigOffset(table_index),
Smi::FromInt(sig_id)); Smi::FromInt(sig_id));
WasmCodeWrapper wasm_code = EnsureTableExportLazyDeoptData( WasmCodeWrapper wasm_code = EnsureTableExportLazyDeoptData(
isolate_, instance, code_table, native_module, func_index, isolate_, native_module, func_index, table_instance.function_table,
table_instance.function_table, table_index, &num_table_exports); table_index, &num_table_exports);
Handle<Object> value_to_update_with; Handle<Object> value_to_update_with;
if (!wasm_code.IsCodeObject()) { if (!wasm_code.IsCodeObject()) {
Handle<Foreign> as_foreign = isolate_->factory()->NewForeign( Handle<Foreign> as_foreign = isolate_->factory()->NewForeign(
...@@ -3253,13 +3048,8 @@ class AsyncCompileJob::PrepareAndStartCompile : public CompileStep { ...@@ -3253,13 +3048,8 @@ class AsyncCompileJob::PrepareAndStartCompile : public CompileStep {
void RunInForeground() override { void RunInForeground() override {
TRACE_COMPILE("(2) Prepare and start compile...\n"); TRACE_COMPILE("(2) Prepare and start compile...\n");
Isolate* isolate = job_->isolate_; Isolate* isolate = job_->isolate_;
Factory* factory = isolate->factory();
Handle<Code> illegal_builtin = BUILTIN_CODE(isolate, Illegal); Handle<Code> illegal_builtin = BUILTIN_CODE(isolate, Illegal);
// Just makes it easier to deal with code that wants code_table, while
// we have FLAG_wasm_jit_to_native around.
job_->code_table_ = factory->NewFixedArray(0, TENURED);
job_->module_env_ = job_->module_env_ =
CreateDefaultModuleEnv(isolate, module_, illegal_builtin); CreateDefaultModuleEnv(isolate, module_, illegal_builtin);
...@@ -3272,7 +3062,6 @@ class AsyncCompileJob::PrepareAndStartCompile : public CompileStep { ...@@ -3272,7 +3062,6 @@ class AsyncCompileJob::PrepareAndStartCompile : public CompileStep {
DeferredHandleScope deferred(isolate); DeferredHandleScope deferred(isolate);
centry_stub = Handle<Code>(*centry_stub, isolate); centry_stub = Handle<Code>(*centry_stub, isolate);
job_->code_table_ = Handle<FixedArray>(*job_->code_table_, isolate);
compiler::ModuleEnv* env = job_->module_env_.get(); compiler::ModuleEnv* env = job_->module_env_.get();
ReopenHandles(isolate, env->function_code); ReopenHandles(isolate, env->function_code);
Handle<Code>* mut = Handle<Code>* mut =
...@@ -3291,9 +3080,8 @@ class AsyncCompileJob::PrepareAndStartCompile : public CompileStep { ...@@ -3291,9 +3080,8 @@ class AsyncCompileJob::PrepareAndStartCompile : public CompileStep {
Handle<FixedArray> export_wrappers = Handle<FixedArray> export_wrappers =
job_->isolate_->factory()->NewFixedArray(export_wrapper_size, TENURED); job_->isolate_->factory()->NewFixedArray(export_wrapper_size, TENURED);
job_->compiled_module_ = job_->compiled_module_ = NewCompiledModule(
NewCompiledModule(job_->isolate_, module_, job_->code_table_, job_->isolate_, module_, export_wrappers, job_->module_env_.get());
export_wrappers, job_->module_env_.get());
job_->compiler_.reset( job_->compiler_.reset(
new ModuleCompiler(isolate, module_, centry_stub, new ModuleCompiler(isolate, module_, centry_stub,
...@@ -3400,9 +3188,6 @@ class AsyncCompileJob::ExecuteAndFinishCompilationUnits : public CompileStep { ...@@ -3400,9 +3188,6 @@ class AsyncCompileJob::ExecuteAndFinishCompilationUnits : public CompileStep {
break; break;
} else { } else {
DCHECK_LE(0, func_index); DCHECK_LE(0, func_index);
if (result.IsCodeObject()) {
job_->code_table_->set(func_index, *result.GetCode());
}
--job_->outstanding_units_; --job_->outstanding_units_;
} }
...@@ -3705,13 +3490,11 @@ void CompileJsToWasmWrappers(Isolate* isolate, ...@@ -3705,13 +3490,11 @@ void CompileJsToWasmWrappers(Isolate* isolate,
int wrapper_index = 0; int wrapper_index = 0;
Handle<FixedArray> export_wrappers(compiled_module->export_wrappers(), Handle<FixedArray> export_wrappers(compiled_module->export_wrappers(),
isolate); isolate);
Handle<FixedArray> code_table(compiled_module->code_table(), isolate);
NativeModule* native_module = compiled_module->GetNativeModule(); NativeModule* native_module = compiled_module->GetNativeModule();
for (auto exp : compiled_module->shared()->module()->export_table) { for (auto exp : compiled_module->shared()->module()->export_table) {
if (exp.kind != kExternalFunction) continue; if (exp.kind != kExternalFunction) continue;
WasmCodeWrapper wasm_code = WasmCodeWrapper wasm_code =
EnsureExportedLazyDeoptData(isolate, Handle<WasmInstanceObject>::null(), EnsureExportedLazyDeoptData(isolate, native_module, exp.index);
code_table, native_module, exp.index);
Handle<Code> wrapper_code = js_to_wasm_cache.CloneOrCompileJSToWasmWrapper( Handle<Code> wrapper_code = js_to_wasm_cache.CloneOrCompileJSToWasmWrapper(
isolate, compiled_module->shared()->module(), wasm_code, exp.index, isolate, compiled_module->shared()->module(), wasm_code, exp.index,
compiled_module->use_trap_handler()); compiled_module->use_trap_handler());
......
...@@ -64,9 +64,6 @@ class LazyCompilationOrchestrator { ...@@ -64,9 +64,6 @@ class LazyCompilationOrchestrator {
int func_index); int func_index);
public: public:
Handle<Code> CompileLazyOnGCHeap(Isolate*, Handle<WasmInstanceObject>,
Handle<Code> caller, int call_offset,
int exported_func_index, bool patch_caller);
const wasm::WasmCode* CompileFromJsToWasm(Isolate*, const wasm::WasmCode* CompileFromJsToWasm(Isolate*,
Handle<WasmInstanceObject>, Handle<WasmInstanceObject>,
Handle<Code> caller, Handle<Code> caller,
...@@ -178,7 +175,6 @@ class AsyncCompileJob { ...@@ -178,7 +175,6 @@ class AsyncCompileJob {
std::vector<DeferredHandles*> deferred_handles_; std::vector<DeferredHandles*> deferred_handles_;
Handle<WasmModuleObject> module_object_; Handle<WasmModuleObject> module_object_;
Handle<WasmCompiledModule> compiled_module_; Handle<WasmCompiledModule> compiled_module_;
Handle<FixedArray> code_table_;
size_t outstanding_units_ = 0; size_t outstanding_units_ = 0;
std::unique_ptr<CompileStep> step_; std::unique_ptr<CompileStep> step_;
CancelableTaskManager background_task_manager_; CancelableTaskManager background_task_manager_;
......
...@@ -669,8 +669,6 @@ void WasmDebugInfo::RedirectToInterpreter(Handle<WasmDebugInfo> debug_info, ...@@ -669,8 +669,6 @@ void WasmDebugInfo::RedirectToInterpreter(Handle<WasmDebugInfo> debug_info,
wasm::WasmModule* module = instance->module(); wasm::WasmModule* module = instance->module();
CodeRelocationMap code_to_relocate; CodeRelocationMap code_to_relocate;
Handle<FixedArray> code_table(instance->compiled_module()->code_table(),
isolate);
// We may modify js wrappers, as well as wasm functions. Hence the 2 // We may modify js wrappers, as well as wasm functions. Hence the 2
// modification scopes. // modification scopes.
CodeSpaceMemoryModificationScope modification_scope(isolate->heap()); CodeSpaceMemoryModificationScope modification_scope(isolate->heap());
......
...@@ -1021,13 +1021,6 @@ class CodeMap { ...@@ -1021,13 +1021,6 @@ class CodeMap {
return native_module->GetCode(function_index); return native_module->GetCode(function_index);
} }
Code* GetImportedFunctionGC(uint32_t function_index) {
DCHECK(has_instance());
DCHECK_GT(module_->num_imported_functions, function_index);
FixedArray* code_table = instance()->compiled_module()->code_table();
return Code::cast(code_table->get(static_cast<int>(function_index)));
}
InterpreterCode* GetCode(const WasmFunction* function) { InterpreterCode* GetCode(const WasmFunction* function) {
InterpreterCode* code = GetCode(function->func_index); InterpreterCode* code = GetCode(function->func_index);
DCHECK_EQ(function, code->function); DCHECK_EQ(function, code->function);
......
...@@ -138,7 +138,6 @@ WCM_OBJECT(FixedArray, source_positions, kSourcePositionsOffset) ...@@ -138,7 +138,6 @@ WCM_OBJECT(FixedArray, source_positions, kSourcePositionsOffset)
WCM_OBJECT(Foreign, native_module, kNativeModuleOffset) WCM_OBJECT(Foreign, native_module, kNativeModuleOffset)
WCM_OBJECT(FixedArray, lazy_compile_data, kLazyCompileDataOffset) WCM_OBJECT(FixedArray, lazy_compile_data, kLazyCompileDataOffset)
WCM_SMALL_CONST_NUMBER(bool, use_trap_handler, kUseTrapHandlerOffset) WCM_SMALL_CONST_NUMBER(bool, use_trap_handler, kUseTrapHandlerOffset)
WCM_OBJECT(FixedArray, code_table, kCodeTableOffset)
WCM_OBJECT(FixedArray, function_tables, kFunctionTablesOffset) WCM_OBJECT(FixedArray, function_tables, kFunctionTablesOffset)
WCM_OBJECT(FixedArray, empty_function_tables, kEmptyFunctionTablesOffset) WCM_OBJECT(FixedArray, empty_function_tables, kEmptyFunctionTablesOffset)
ACCESSORS(WasmCompiledModule, raw_next_instance, Object, kNextInstanceOffset); ACCESSORS(WasmCompiledModule, raw_next_instance, Object, kNextInstanceOffset);
...@@ -153,11 +152,6 @@ uint32_t WasmTableObject::current_length() { return functions()->length(); } ...@@ -153,11 +152,6 @@ uint32_t WasmTableObject::current_length() { return functions()->length(); }
bool WasmMemoryObject::has_maximum_pages() { return maximum_pages() >= 0; } bool WasmMemoryObject::has_maximum_pages() { return maximum_pages() >= 0; }
void WasmCompiledModule::ReplaceCodeTableForTesting(
Handle<FixedArray> testing_table) {
set_code_table(*testing_table);
}
#include "src/objects/object-macros-undef.h" #include "src/objects/object-macros-undef.h"
} // namespace internal } // namespace internal
......
...@@ -1181,8 +1181,7 @@ MaybeHandle<FixedArray> WasmSharedModuleData::CheckBreakPoints( ...@@ -1181,8 +1181,7 @@ MaybeHandle<FixedArray> WasmSharedModuleData::CheckBreakPoints(
} }
Handle<WasmCompiledModule> WasmCompiledModule::New( Handle<WasmCompiledModule> WasmCompiledModule::New(
Isolate* isolate, WasmModule* module, Handle<FixedArray> code_table, Isolate* isolate, WasmModule* module, Handle<FixedArray> export_wrappers,
Handle<FixedArray> export_wrappers,
const std::vector<GlobalHandleAddress>& function_tables, const std::vector<GlobalHandleAddress>& function_tables,
bool use_trap_handler) { bool use_trap_handler) {
Handle<WasmCompiledModule> compiled_module = Handle<WasmCompiledModule>::cast( Handle<WasmCompiledModule> compiled_module = Handle<WasmCompiledModule>::cast(
...@@ -1210,10 +1209,6 @@ Handle<WasmCompiledModule> WasmCompiledModule::New( ...@@ -1210,10 +1209,6 @@ Handle<WasmCompiledModule> WasmCompiledModule::New(
v8::WeakCallbackType::kFinalizer); v8::WeakCallbackType::kFinalizer);
compiled_module->GetNativeModule()->SetCompiledModule(weak_link); compiled_module->GetNativeModule()->SetCompiledModule(weak_link);
} }
// This is here just because it's easier for APIs that need to work with
// either code_table or native_module. Otherwise we need to check if
// has_code_table and pass undefined.
compiled_module->set_code_table(*code_table);
int function_count = static_cast<int>(module->functions.size()); int function_count = static_cast<int>(module->functions.size());
Handle<FixedArray> source_positions = Handle<FixedArray> source_positions =
...@@ -1239,7 +1234,6 @@ Handle<WasmCompiledModule> WasmCompiledModule::Clone( ...@@ -1239,7 +1234,6 @@ Handle<WasmCompiledModule> WasmCompiledModule::Clone(
ret->set_lazy_compile_data(module->lazy_compile_data()); ret->set_lazy_compile_data(module->lazy_compile_data());
} }
ret->set_use_trap_handler(module->use_trap_handler()); ret->set_use_trap_handler(module->use_trap_handler());
ret->set_code_table(module->code_table());
if (module->has_function_tables()) { if (module->has_function_tables()) {
ret->set_function_tables(module->function_tables()); ret->set_function_tables(module->function_tables());
} }
......
...@@ -434,7 +434,6 @@ class WasmCompiledModule : public Struct { ...@@ -434,7 +434,6 @@ class WasmCompiledModule : public Struct {
V(kNativeModuleOffset, kPointerSize) \ V(kNativeModuleOffset, kPointerSize) \
V(kLazyCompileDataOffset, kPointerSize) \ V(kLazyCompileDataOffset, kPointerSize) \
V(kUseTrapHandlerOffset, kPointerSize) \ V(kUseTrapHandlerOffset, kPointerSize) \
V(kCodeTableOffset, kPointerSize) \
V(kFunctionTablesOffset, kPointerSize) \ V(kFunctionTablesOffset, kPointerSize) \
V(kEmptyFunctionTablesOffset, kPointerSize) \ V(kEmptyFunctionTablesOffset, kPointerSize) \
V(kSize, 0) V(kSize, 0)
...@@ -487,13 +486,12 @@ class WasmCompiledModule : public Struct { ...@@ -487,13 +486,12 @@ class WasmCompiledModule : public Struct {
WCM_OBJECT(FixedArray, lazy_compile_data) WCM_OBJECT(FixedArray, lazy_compile_data)
// TODO(mstarzinger): Make {use_trap_handler} smaller. // TODO(mstarzinger): Make {use_trap_handler} smaller.
WCM_SMALL_CONST_NUMBER(bool, use_trap_handler) WCM_SMALL_CONST_NUMBER(bool, use_trap_handler)
WCM_CONST_OBJECT(FixedArray, code_table)
WCM_OBJECT(FixedArray, function_tables) WCM_OBJECT(FixedArray, function_tables)
WCM_CONST_OBJECT(FixedArray, empty_function_tables) WCM_CONST_OBJECT(FixedArray, empty_function_tables)
public: public:
static Handle<WasmCompiledModule> New( static Handle<WasmCompiledModule> New(
Isolate* isolate, wasm::WasmModule* module, Handle<FixedArray> code_table, Isolate* isolate, wasm::WasmModule* module,
Handle<FixedArray> export_wrappers, Handle<FixedArray> export_wrappers,
const std::vector<wasm::GlobalHandleAddress>& function_tables, const std::vector<wasm::GlobalHandleAddress>& function_tables,
bool use_trap_hander); bool use_trap_hander);
...@@ -524,16 +522,12 @@ class WasmCompiledModule : public Struct { ...@@ -524,16 +522,12 @@ class WasmCompiledModule : public Struct {
static bool SetBreakPoint(Handle<WasmCompiledModule>, int* position, static bool SetBreakPoint(Handle<WasmCompiledModule>, int* position,
Handle<BreakPoint> break_point); Handle<BreakPoint> break_point);
inline void ReplaceCodeTableForTesting(
std::vector<wasm::WasmCode*>&& testing_table);
// TODO(mstarzinger): following 4 unnecessary after we're done with // TODO(mstarzinger): following 4 unnecessary after we're done with
// FLAG_wasm_jit_to_native // FLAG_wasm_jit_to_native
static void SetTableValue(Isolate* isolate, Handle<FixedArray> table, static void SetTableValue(Isolate* isolate, Handle<FixedArray> table,
int index, Address value); int index, Address value);
static void UpdateTableValue(FixedArray* table, int index, Address value); static void UpdateTableValue(FixedArray* table, int index, Address value);
static Address GetTableValue(FixedArray* table, int index); static Address GetTableValue(FixedArray* table, int index);
inline void ReplaceCodeTableForTesting(Handle<FixedArray> testing_table);
void LogWasmCodes(Isolate* isolate); void LogWasmCodes(Isolate* isolate);
......
...@@ -654,9 +654,9 @@ MaybeHandle<WasmCompiledModule> DeserializeNativeModule( ...@@ -654,9 +654,9 @@ MaybeHandle<WasmCompiledModule> DeserializeNativeModule(
Handle<FixedArray> export_wrappers = isolate->factory()->NewFixedArray( Handle<FixedArray> export_wrappers = isolate->factory()->NewFixedArray(
static_cast<int>(export_wrappers_size), TENURED); static_cast<int>(export_wrappers_size), TENURED);
Handle<WasmCompiledModule> compiled_module = WasmCompiledModule::New( Handle<WasmCompiledModule> compiled_module =
isolate, shared->module(), isolate->factory()->empty_fixed_array(), WasmCompiledModule::New(isolate, shared->module(), export_wrappers,
export_wrappers, std::vector<wasm::GlobalHandleAddress>(), std::vector<wasm::GlobalHandleAddress>(),
trap_handler::IsTrapHandlerEnabled()); trap_handler::IsTrapHandlerEnabled());
compiled_module->OnWasmModuleDecodingComplete(shared); compiled_module->OnWasmModuleDecodingComplete(shared);
script->set_wasm_compiled_module(*compiled_module); script->set_wasm_compiled_module(*compiled_module);
......
...@@ -230,10 +230,9 @@ Handle<WasmInstanceObject> TestingModuleBuilder::InitInstanceObject() { ...@@ -230,10 +230,9 @@ Handle<WasmInstanceObject> TestingModuleBuilder::InitInstanceObject() {
Handle<WasmSharedModuleData> shared_module_data = Handle<WasmSharedModuleData> shared_module_data =
WasmSharedModuleData::New(isolate_, module_wrapper, empty_string, script, WasmSharedModuleData::New(isolate_, module_wrapper, empty_string, script,
Handle<ByteArray>::null()); Handle<ByteArray>::null());
Handle<FixedArray> code_table = isolate_->factory()->NewFixedArray(0);
Handle<FixedArray> export_wrappers = isolate_->factory()->NewFixedArray(0); Handle<FixedArray> export_wrappers = isolate_->factory()->NewFixedArray(0);
Handle<WasmCompiledModule> compiled_module = WasmCompiledModule::New( Handle<WasmCompiledModule> compiled_module = WasmCompiledModule::New(
isolate_, test_module_ptr_, code_table, export_wrappers, function_tables_, isolate_, test_module_ptr_, export_wrappers, function_tables_,
trap_handler::IsTrapHandlerEnabled()); trap_handler::IsTrapHandlerEnabled());
compiled_module->OnWasmModuleDecodingComplete(shared_module_data); compiled_module->OnWasmModuleDecodingComplete(shared_module_data);
// This method is called when we initialize TestEnvironment. We don't // This method is called when we initialize TestEnvironment. We don't
......
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