Commit c047ba73 authored by Ben L. Titzer's avatar Ben L. Titzer Committed by Commit Bot

[wasm] Inline the WasmCodeManager::SetCodeTable() method

R=ahaas@chromium.org

Bug: v8:7310
Change-Id: I7f4f4f7990a202232a0871f5d73dd8025306e96e
Reviewed-on: https://chromium-review.googlesource.com/934262
Commit-Queue: Ben Titzer <titzer@chromium.org>
Reviewed-by: 's avatarAndreas Haas <ahaas@chromium.org>
Cr-Commit-Position: refs/heads/master@{#51508}
parent 0ef07c95
...@@ -353,7 +353,7 @@ WasmCode* NativeModule::AddOwnedCode( ...@@ -353,7 +353,7 @@ WasmCode* NativeModule::AddOwnedCode(
WasmCode* NativeModule::AddCodeCopy(Handle<Code> code, WasmCode::Kind kind, WasmCode* NativeModule::AddCodeCopy(Handle<Code> code, WasmCode::Kind kind,
uint32_t index) { uint32_t index) {
WasmCode* ret = AddAnonymousCode(code, kind); WasmCode* ret = AddAnonymousCode(code, kind);
SetCodeTable(index, ret); code_table_[index] = ret;
ret->index_ = Just(index); ret->index_ = Just(index);
compiled_module()->source_positions()->set(static_cast<int>(index), compiled_module()->source_positions()->set(static_cast<int>(index),
code->source_position_table()); code->source_position_table());
...@@ -372,7 +372,7 @@ WasmCode* NativeModule::AddInterpreterWrapper(Handle<Code> code, ...@@ -372,7 +372,7 @@ WasmCode* NativeModule::AddInterpreterWrapper(Handle<Code> code,
void NativeModule::SetLazyBuiltin(Handle<Code> code) { void NativeModule::SetLazyBuiltin(Handle<Code> code) {
WasmCode* lazy_builtin = AddAnonymousCode(code, WasmCode::kLazyStub); WasmCode* lazy_builtin = AddAnonymousCode(code, WasmCode::kLazyStub);
for (uint32_t i = num_imported_functions(), e = FunctionCount(); i < e; ++i) { for (uint32_t i = num_imported_functions(), e = FunctionCount(); i < e; ++i) {
SetCodeTable(i, lazy_builtin); code_table_[i] = lazy_builtin;
} }
} }
...@@ -448,7 +448,7 @@ WasmCode* NativeModule::AddCode( ...@@ -448,7 +448,7 @@ WasmCode* NativeModule::AddCode(
is_liftoff); is_liftoff);
if (ret == nullptr) return nullptr; if (ret == nullptr) return nullptr;
SetCodeTable(index, ret); code_table_[index] = ret;
// TODO(mtrofin): this is a copy and paste from Code::CopyFrom. // TODO(mtrofin): this is a copy and paste from Code::CopyFrom.
int mode_mask = RelocInfo::kCodeTargetMask | int mode_mask = RelocInfo::kCodeTargetMask |
RelocInfo::ModeMask(RelocInfo::EMBEDDED_OBJECT) | RelocInfo::ModeMask(RelocInfo::EMBEDDED_OBJECT) |
...@@ -662,7 +662,7 @@ WasmCode* NativeModule::CloneLazyBuiltinInto(const WasmCode* code, ...@@ -662,7 +662,7 @@ WasmCode* NativeModule::CloneLazyBuiltinInto(const WasmCode* code,
uint32_t index) { uint32_t index) {
DCHECK_EQ(wasm::WasmCode::kLazyStub, code->kind()); DCHECK_EQ(wasm::WasmCode::kLazyStub, code->kind());
WasmCode* ret = CloneCode(code); WasmCode* ret = CloneCode(code);
SetCodeTable(index, ret); code_table_[index] = ret;
ret->index_ = Just(index); ret->index_ = Just(index);
return ret; return ret;
} }
...@@ -699,7 +699,7 @@ WasmCode* NativeModule::CloneCode(const WasmCode* original_code) { ...@@ -699,7 +699,7 @@ WasmCode* NativeModule::CloneCode(const WasmCode* original_code) {
original_code->protected_instructions_, original_code->is_liftoff()); original_code->protected_instructions_, original_code->is_liftoff());
if (ret == nullptr) return nullptr; if (ret == nullptr) return nullptr;
if (!ret->IsAnonymous()) { if (!ret->IsAnonymous()) {
SetCodeTable(ret->index(), ret); code_table_[ret->index()] = ret;
} }
intptr_t delta = intptr_t delta =
ret->instructions().start() - original_code->instructions().start(); ret->instructions().start() - original_code->instructions().start();
...@@ -711,10 +711,6 @@ WasmCode* NativeModule::CloneCode(const WasmCode* original_code) { ...@@ -711,10 +711,6 @@ WasmCode* NativeModule::CloneCode(const WasmCode* original_code) {
return ret; return ret;
} }
void NativeModule::SetCodeTable(uint32_t index, wasm::WasmCode* code) {
code_table_[index] = code;
}
NativeModule::~NativeModule() { NativeModule::~NativeModule() {
TRACE_HEAP("Deleting native module: %p\n", reinterpret_cast<void*>(this)); TRACE_HEAP("Deleting native module: %p\n", reinterpret_cast<void*>(this));
wasm_code_manager_->FreeNativeModuleMemories(this); wasm_code_manager_->FreeNativeModuleMemories(this);
...@@ -939,7 +935,7 @@ std::unique_ptr<NativeModule> NativeModule::Clone() { ...@@ -939,7 +935,7 @@ std::unique_ptr<NativeModule> NativeModule::Clone() {
PatchTrampolineAndStubCalls(original_code, new_code, reverse_lookup); PatchTrampolineAndStubCalls(original_code, new_code, reverse_lookup);
anonymous_lazy_builtin = new_code; anonymous_lazy_builtin = new_code;
} }
ret->SetCodeTable(i, anonymous_lazy_builtin); ret->code_table_[i] = anonymous_lazy_builtin;
} break; } break;
case WasmCode::kFunction: { case WasmCode::kFunction: {
WasmCode* new_code = ret->CloneCode(original_code); WasmCode* new_code = ret->CloneCode(original_code);
......
...@@ -286,7 +286,6 @@ class V8_EXPORT_PRIVATE NativeModule final { ...@@ -286,7 +286,6 @@ class V8_EXPORT_PRIVATE NativeModule final {
uint32_t stack_slots, size_t safepoint_table_offset, uint32_t stack_slots, size_t safepoint_table_offset,
std::shared_ptr<ProtectedInstructions>, std::shared_ptr<ProtectedInstructions>,
bool is_liftoff); bool is_liftoff);
void SetCodeTable(uint32_t, wasm::WasmCode*);
WasmCode* CloneCode(const WasmCode*); WasmCode* CloneCode(const WasmCode*);
bool CloneTrampolinesAndStubs(const NativeModule* other); bool CloneTrampolinesAndStubs(const NativeModule* other);
WasmCode* Lookup(Address); WasmCode* Lookup(Address);
......
...@@ -591,7 +591,7 @@ bool NativeModuleDeserializer::ReadCode() { ...@@ -591,7 +591,7 @@ bool NativeModuleDeserializer::ReadCode() {
WasmCode::kFunction, constant_pool_offset, stack_slot_count, WasmCode::kFunction, constant_pool_offset, stack_slot_count,
safepoint_table_offset, protected_instructions, is_liftoff); safepoint_table_offset, protected_instructions, is_liftoff);
if (ret == nullptr) return false; if (ret == nullptr) return false;
native_module_->SetCodeTable(index_, ret); native_module_->code_table_[index_] = ret;
// now relocate the code // now relocate the code
int mask = RelocInfo::ModeMask(RelocInfo::EMBEDDED_OBJECT) | int mask = RelocInfo::ModeMask(RelocInfo::EMBEDDED_OBJECT) |
......
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