Commit 73aa5633 authored by Michael Starzinger's avatar Michael Starzinger Committed by Commit Bot

[wasm] Remove support to serialize code stubs.

This removes the support to serialize copies of {CodeStub} codes during
native module serialization. It is still possible to serialize builtins
and all code objects copied from the GC heap are builtins by now.

R=ahaas@chromium.org

Change-Id: If009a82a9d7c7080f70f344040ebb91f20b8cc1a
Reviewed-on: https://chromium-review.googlesource.com/1012081
Commit-Queue: Michael Starzinger <mstarzinger@chromium.org>
Reviewed-by: 's avatarAndreas Haas <ahaas@chromium.org>
Cr-Commit-Position: refs/heads/master@{#52628}
parent 581fd667
......@@ -318,15 +318,13 @@ class NativeModule::CloneCodeHelper {
void SelectForCloning(int32_t code_index);
void CloneAndPatchCode(bool patch_stub_to_stub_calls);
void CloneAndPatchCode();
void PatchTrampolineAndStubCalls(const WasmCode* original_code,
const WasmCode* new_code,
WasmCode::FlushICache flush_icache);
private:
void PatchStubToStubCalls();
NativeModule* source_native_module_;
NativeModule* cloning_native_module_;
std::vector<uint32_t> selection_;
......@@ -344,26 +342,13 @@ NativeModule::CloneCodeHelper::CloneCodeHelper(
Address new_dest = local->second;
reverse_lookup_.emplace(old_dest, new_dest);
}
for (auto& pair : source_native_module_->stubs_) {
Address old_dest = pair.second->instruction_start();
auto local = cloning_native_module_->stubs_.find(pair.first);
DCHECK(local != cloning_native_module_->stubs_.end());
Address new_dest = local->second->instruction_start();
reverse_lookup_.emplace(old_dest, new_dest);
}
}
void NativeModule::CloneCodeHelper::SelectForCloning(int32_t code_index) {
selection_.emplace_back(code_index);
}
void NativeModule::CloneCodeHelper::CloneAndPatchCode(
bool patch_stub_to_stub_calls) {
if (patch_stub_to_stub_calls) {
PatchStubToStubCalls();
}
void NativeModule::CloneCodeHelper::CloneAndPatchCode() {
WasmCode* anonymous_lazy_builtin = nullptr;
for (uint32_t index : selection_) {
const WasmCode* original_code = source_native_module_->GetCode(index);
......@@ -400,14 +385,6 @@ void NativeModule::CloneCodeHelper::CloneAndPatchCode(
}
}
void NativeModule::CloneCodeHelper::PatchStubToStubCalls() {
for (auto& pair : cloning_native_module_->stubs_) {
WasmCode* new_stub = pair.second;
WasmCode* old_stub = source_native_module_->stubs_.find(pair.first)->second;
PatchTrampolineAndStubCalls(old_stub, new_stub, WasmCode::kFlushICache);
}
}
void NativeModule::CloneCodeHelper::PatchTrampolineAndStubCalls(
const WasmCode* original_code, const WasmCode* new_code,
WasmCode::FlushICache flush_icache) {
......@@ -872,11 +849,6 @@ void NativeModule::CloneTrampolinesAndStubs(
DCHECK_NE(local, kNullAddress);
trampolines_.emplace(std::make_pair(key, local));
}
for (auto& pair : other->stubs_) {
uint32_t key = pair.first;
WasmCode* clone = CloneCode(pair.second, flush_icache);
stubs_.emplace(std::make_pair(key, clone));
}
}
WasmCode* NativeModule::CloneCode(const WasmCode* original_code,
......@@ -1137,7 +1109,7 @@ std::unique_ptr<NativeModule> NativeModule::Clone() {
for (uint32_t i = num_imported_functions(), e = FunctionCount(); i < e; ++i) {
helper.SelectForCloning(i);
}
helper.CloneAndPatchCode(true);
helper.CloneAndPatchCode();
return ret;
}
......
......@@ -330,9 +330,6 @@ class V8_EXPORT_PRIVATE NativeModule final {
// start of the trampoline.
std::unordered_map<Address, Address, AddressHasher> trampolines_;
// Maps from stub key to wasm code (containing a copy of that stub).
std::unordered_map<uint32_t, WasmCode*> stubs_;
std::unique_ptr<CompilationState, CompilationStateDeleter> compilation_state_;
// A phantom reference to the {WasmCompiledModule}. It is intentionally not
......
......@@ -292,8 +292,7 @@ size_t NativeModuleSerializer::DrainBuffer(Vector<byte> dest) {
}
size_t NativeModuleSerializer::MeasureCopiedStubs() const {
size_t ret = sizeof(uint32_t) + // number of stubs
native_module_->stubs_.size() * sizeof(uint32_t); // stub keys
size_t ret = sizeof(uint32_t); // number of stubs
for (auto pair : native_module_->trampolines_) {
v8::internal::Code* code = Code::GetCodeFromTargetAddress(pair.first);
int builtin_index = code->builtin_index();
......@@ -315,14 +314,6 @@ void NativeModuleSerializer::BufferCopiedStubs() {
static_cast<uint32_t>((buff_size - sizeof(uint32_t)) / sizeof(uint32_t)));
uint32_t stub_id = kFirstStubId;
for (auto pair : native_module_->stubs_) {
uint32_t key = pair.first;
writer.Write(key);
stub_lookup_.insert(
std::make_pair(pair.second->instruction_start(), stub_id));
++stub_id;
}
for (auto pair : native_module_->trampolines_) {
v8::internal::Code* code = Code::GetCodeFromTargetAddress(pair.first);
int builtin_index = code->builtin_index();
......
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