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, ...@@ -913,7 +913,7 @@ wasm::WasmCode* EnsureExportedLazyDeoptData(Isolate* isolate,
return code; return code;
} }
// Clone the lazy builtin into the native module. // 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 // 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 { ...@@ -86,6 +86,8 @@ class V8_EXPORT_PRIVATE DisjointAllocationPool final {
using ProtectedInstructions = using ProtectedInstructions =
std::vector<trap_handler::ProtectedInstructionData>; std::vector<trap_handler::ProtectedInstructionData>;
enum FlushICache : bool { kFlushICache = true, kNoFlushICache = false };
class V8_EXPORT_PRIVATE WasmCode final { class V8_EXPORT_PRIVATE WasmCode final {
public: public:
enum Kind { enum Kind {
...@@ -239,7 +241,8 @@ class V8_EXPORT_PRIVATE NativeModule final { ...@@ -239,7 +241,8 @@ class V8_EXPORT_PRIVATE NativeModule final {
// builtin. The logic for seeking though frames would change, though. // builtin. The logic for seeking though frames would change, though.
// TODO(mtrofin): perhaps we can do exactly that - either before or after // TODO(mtrofin): perhaps we can do exactly that - either before or after
// this change. // this change.
WasmCode* CloneLazyBuiltinInto(const WasmCode* code, uint32_t); WasmCode* CloneLazyBuiltinInto(const WasmCode* code, uint32_t index,
FlushICache);
bool SetExecutable(bool executable); bool SetExecutable(bool executable);
...@@ -296,10 +299,10 @@ class V8_EXPORT_PRIVATE NativeModule final { ...@@ -296,10 +299,10 @@ class V8_EXPORT_PRIVATE NativeModule final {
WasmCode::Kind kind, size_t constant_pool_offset, WasmCode::Kind kind, size_t constant_pool_offset,
uint32_t stack_slots, size_t safepoint_table_offset, uint32_t stack_slots, size_t safepoint_table_offset,
size_t handler_table_offset, size_t handler_table_offset,
std::shared_ptr<ProtectedInstructions>, std::shared_ptr<ProtectedInstructions>, WasmCode::Tier,
WasmCode::Tier tier, bool flush_icache = true); FlushICache);
WasmCode* CloneCode(const WasmCode*); WasmCode* CloneCode(const WasmCode*, FlushICache);
void CloneTrampolinesAndStubs(const NativeModule* other); void CloneTrampolinesAndStubs(const NativeModule* other, FlushICache);
WasmCode* Lookup(Address); WasmCode* Lookup(Address);
Address GetLocalAddressFor(Handle<Code>); Address GetLocalAddressFor(Handle<Code>);
Address CreateTrampolineTo(Handle<Code>); Address CreateTrampolineTo(Handle<Code>);
...@@ -311,7 +314,11 @@ class V8_EXPORT_PRIVATE NativeModule final { ...@@ -311,7 +314,11 @@ class V8_EXPORT_PRIVATE NativeModule final {
std::vector<WasmCode*> code_table_; std::vector<WasmCode*> code_table_;
uint32_t num_imported_functions_; 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_; 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::unordered_map<uint32_t, WasmCode*> stubs_;
std::unique_ptr<CompilationState, CompilationStateDeleter> compilation_state_; std::unique_ptr<CompilationState, CompilationStateDeleter> compilation_state_;
......
...@@ -552,8 +552,7 @@ bool NativeModuleDeserializer::ReadCode() { ...@@ -552,8 +552,7 @@ bool NativeModuleDeserializer::ReadCode() {
code_buffer, std::move(reloc_info), reloc_size, Just(index_), code_buffer, std::move(reloc_info), reloc_size, Just(index_),
WasmCode::kFunction, constant_pool_offset, stack_slot_count, WasmCode::kFunction, constant_pool_offset, stack_slot_count,
safepoint_table_offset, handler_table_offset, protected_instructions, safepoint_table_offset, handler_table_offset, protected_instructions,
tier, false /* flush_icache */); tier, kNoFlushICache);
if (ret == nullptr) return false;
native_module_->code_table_[index_] = ret; native_module_->code_table_[index_] = ret;
// now relocate the code // 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