Commit b9c46e3f authored by Clemens Hammacher's avatar Clemens Hammacher Committed by Commit Bot

[wasm] Avoid redundant icache flushing

Code is often being patched after creating, thus we don't need to flush
the icache right away.
This CL introduces a new enum to specify whether the icache should be
flushed or not, and uses this in all methods which don't always need to
flush.

Drive-by: Fix a but where SKIP_ICACHE_FLUSH was interpreted as boolean
value.

R=mstarzinger@chromium.org

Change-Id: I13ac71d2a7168a065b8a4a1086c590816de8ca28
Reviewed-on: https://chromium-review.googlesource.com/971881Reviewed-by: 's avatarMichael Starzinger <mstarzinger@chromium.org>
Commit-Queue: Clemens Hammacher <clemensh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#52102}
parent d8735757
......@@ -913,7 +913,7 @@ wasm::WasmCode* EnsureExportedLazyDeoptData(Isolate* isolate,
return code;
}
// Clone the lazy builtin into the native module.
return native_module->CloneLazyBuiltinInto(code, func_index);
return native_module->CloneLazyBuiltinInto(code, func_index, kFlushICache);
}
// Ensure that the code object in <code_table> at offset <func_index> has
......
This diff is collapsed.
......@@ -86,6 +86,8 @@ class V8_EXPORT_PRIVATE DisjointAllocationPool final {
using ProtectedInstructions =
std::vector<trap_handler::ProtectedInstructionData>;
enum FlushICache : bool { kFlushICache = true, kNoFlushICache = false };
class V8_EXPORT_PRIVATE WasmCode final {
public:
enum Kind {
......@@ -239,7 +241,8 @@ class V8_EXPORT_PRIVATE NativeModule final {
// builtin. The logic for seeking though frames would change, though.
// TODO(mtrofin): perhaps we can do exactly that - either before or after
// this change.
WasmCode* CloneLazyBuiltinInto(const WasmCode* code, uint32_t);
WasmCode* CloneLazyBuiltinInto(const WasmCode* code, uint32_t index,
FlushICache);
bool SetExecutable(bool executable);
......@@ -296,10 +299,10 @@ class V8_EXPORT_PRIVATE NativeModule final {
WasmCode::Kind kind, size_t constant_pool_offset,
uint32_t stack_slots, size_t safepoint_table_offset,
size_t handler_table_offset,
std::shared_ptr<ProtectedInstructions>,
WasmCode::Tier tier, bool flush_icache = true);
WasmCode* CloneCode(const WasmCode*);
void CloneTrampolinesAndStubs(const NativeModule* other);
std::shared_ptr<ProtectedInstructions>, WasmCode::Tier,
FlushICache);
WasmCode* CloneCode(const WasmCode*, FlushICache);
void CloneTrampolinesAndStubs(const NativeModule* other, FlushICache);
WasmCode* Lookup(Address);
Address GetLocalAddressFor(Handle<Code>);
Address CreateTrampolineTo(Handle<Code>);
......@@ -311,7 +314,11 @@ class V8_EXPORT_PRIVATE NativeModule final {
std::vector<WasmCode*> code_table_;
uint32_t num_imported_functions_;
// Maps from instruction start of an immovable code object to instruction
// 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_;
......
......@@ -552,8 +552,7 @@ bool NativeModuleDeserializer::ReadCode() {
code_buffer, std::move(reloc_info), reloc_size, Just(index_),
WasmCode::kFunction, constant_pool_offset, stack_slot_count,
safepoint_table_offset, handler_table_offset, protected_instructions,
tier, false /* flush_icache */);
if (ret == nullptr) return false;
tier, kNoFlushICache);
native_module_->code_table_[index_] = ret;
// now relocate the code
......
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