From a740255899296bf7bf250944c38547ad87504c68 Mon Sep 17 00:00:00 2001 From: Michael Starzinger Date: Tue, 13 Feb 2018 12:46:17 +0100 Subject: [PATCH] [assembler] Make {RelocInfo} independent of the Isolate. Now that instruction cache flushing is process-wide and no longer bound to a specific {Isolate}, we can also make setters on the {RelocInfo} structure equally independent of the {Isolate} and remove the respective parameter everywhere. R=ahaas@chromium.org Change-Id: I7b21f6f79d0d6cf73424019b9e808c3ec76de08e Reviewed-on: https://chromium-review.googlesource.com/915922 Reviewed-by: Andreas Haas Commit-Queue: Michael Starzinger Cr-Commit-Position: refs/heads/master@{#51269} --- src/arm/assembler-arm-inl.h | 22 ++++++------- src/arm/assembler-arm.cc | 14 ++++----- src/arm/assembler-arm.h | 7 ++--- src/arm64/assembler-arm64-inl.h | 21 ++++++------- src/arm64/assembler-arm64.cc | 12 +++---- src/arm64/assembler-arm64.h | 7 ++--- src/assembler.cc | 23 +++++++------- src/assembler.h | 29 +++++++---------- src/builtins/setup-builtins-internal.cc | 2 +- src/deoptimizer.cc | 2 +- src/heap/remembered-set.h | 3 +- src/ia32/assembler-ia32-inl.h | 21 ++++++------- src/ia32/assembler-ia32.cc | 8 ++--- src/ia32/assembler-ia32.h | 7 ++--- src/ia32/codegen-ia32.cc | 4 +-- src/mips/assembler-mips-inl.h | 17 +++++----- src/mips/assembler-mips.cc | 22 +++++-------- src/mips/assembler-mips.h | 15 +++++---- src/mips64/assembler-mips64-inl.h | 17 +++++----- src/mips64/assembler-mips64.cc | 20 +++++------- src/mips64/assembler-mips64.h | 15 +++++---- src/objects.cc | 6 ++-- src/ppc/assembler-ppc-inl.h | 31 +++++++++---------- src/ppc/assembler-ppc.cc | 19 +++++------- src/ppc/assembler-ppc.h | 7 ++--- src/s390/assembler-s390-inl.h | 30 +++++++++--------- src/s390/assembler-s390.cc | 19 +++++------- src/s390/assembler-s390.h | 7 ++--- src/snapshot/deserializer.cc | 8 ++--- src/snapshot/serializer.cc | 2 +- src/wasm/module-compiler.cc | 20 ++++++------ src/wasm/wasm-code-manager.cc | 17 +++++----- src/wasm/wasm-code-specialization.cc | 27 +++++++--------- src/wasm/wasm-code-specialization.h | 1 - src/wasm/wasm-debug.cc | 7 ++--- src/wasm/wasm-serialization.cc | 6 ++-- src/x64/assembler-x64-inl.h | 20 ++++++------ src/x64/assembler-x64.cc | 8 ++--- src/x64/assembler-x64.h | 7 ++--- src/x64/codegen-x64.cc | 2 +- test/cctest/compiler/test-run-machops.cc | 2 +- test/cctest/compiler/test-run-wasm-machops.cc | 3 +- test/cctest/test-run-wasm-relocation-arm.cc | 3 +- test/cctest/test-run-wasm-relocation-arm64.cc | 3 +- test/cctest/test-run-wasm-relocation-ia32.cc | 3 +- test/cctest/test-run-wasm-relocation-x64.cc | 3 +- test/cctest/wasm/test-run-wasm-relocation.cc | 2 +- 47 files changed, 241 insertions(+), 310 deletions(-) diff --git a/src/arm/assembler-arm-inl.h b/src/arm/assembler-arm-inl.h index 64537f47a5..4d7d9895ce 100644 --- a/src/arm/assembler-arm-inl.h +++ b/src/arm/assembler-arm-inl.h @@ -109,7 +109,7 @@ void RelocInfo::set_target_object(HeapObject* target, WriteBarrierMode write_barrier_mode, ICacheFlushMode icache_flush_mode) { DCHECK(IsCodeTarget(rmode_) || rmode_ == EMBEDDED_OBJECT); - Assembler::set_target_address_at(target->GetIsolate(), pc_, constant_pool_, + Assembler::set_target_address_at(pc_, constant_pool_, reinterpret_cast
(target), icache_flush_mode); if (write_barrier_mode == UPDATE_WRITE_BARRIER && host() != nullptr) { @@ -143,22 +143,22 @@ Address RelocInfo::target_runtime_entry(Assembler* origin) { return target_address(); } -void RelocInfo::set_target_runtime_entry(Isolate* isolate, Address target, +void RelocInfo::set_target_runtime_entry(Address target, WriteBarrierMode write_barrier_mode, ICacheFlushMode icache_flush_mode) { DCHECK(IsRuntimeEntry(rmode_)); if (target_address() != target) - set_target_address(isolate, target, write_barrier_mode, icache_flush_mode); + set_target_address(target, write_barrier_mode, icache_flush_mode); } -void RelocInfo::WipeOut(Isolate* isolate) { +void RelocInfo::WipeOut() { DCHECK(IsEmbeddedObject(rmode_) || IsCodeTarget(rmode_) || IsRuntimeEntry(rmode_) || IsExternalReference(rmode_) || IsInternalReference(rmode_)); if (IsInternalReference(rmode_)) { Memory::Address_at(pc_) = nullptr; } else { - Assembler::set_target_address_at(isolate, pc_, constant_pool_, nullptr); + Assembler::set_target_address_at(pc_, constant_pool_, nullptr); } } @@ -273,15 +273,13 @@ Address Assembler::return_address_from_call_start(Address pc) { } } - void Assembler::deserialization_set_special_target_at( - Isolate* isolate, Address constant_pool_entry, Code* code, Address target) { + Address constant_pool_entry, Code* code, Address target) { Memory::Address_at(constant_pool_entry) = target; } - void Assembler::deserialization_set_target_internal_reference_at( - Isolate* isolate, Address pc, Address target, RelocInfo::Mode mode) { + Address pc, Address target, RelocInfo::Mode mode) { Memory::Address_at(pc) = target; } @@ -329,11 +327,9 @@ Address Assembler::target_address_at(Address pc, Address constant_pool) { } } - -void Assembler::set_target_address_at(Isolate* isolate, Address pc, - Address constant_pool, Address target, +void Assembler::set_target_address_at(Address pc, Address constant_pool, + Address target, ICacheFlushMode icache_flush_mode) { - DCHECK_IMPLIES(isolate == nullptr, icache_flush_mode == SKIP_ICACHE_FLUSH); if (is_constant_pool_load(pc)) { // This is a constant pool lookup. Update the entry in the constant pool. Memory::Address_at(constant_pool_entry_address(pc, constant_pool)) = target; diff --git a/src/arm/assembler-arm.cc b/src/arm/assembler-arm.cc index 5b2a16ec0e..bfa54fabaa 100644 --- a/src/arm/assembler-arm.cc +++ b/src/arm/assembler-arm.cc @@ -347,22 +347,20 @@ uint32_t RelocInfo::embedded_size() const { Assembler::target_address_at(pc_, constant_pool_)); } -void RelocInfo::set_embedded_address(Isolate* isolate, Address address, +void RelocInfo::set_embedded_address(Address address, ICacheFlushMode flush_mode) { - Assembler::set_target_address_at(isolate, pc_, constant_pool_, address, - flush_mode); + Assembler::set_target_address_at(pc_, constant_pool_, address, flush_mode); } -void RelocInfo::set_embedded_size(Isolate* isolate, uint32_t size, - ICacheFlushMode flush_mode) { - Assembler::set_target_address_at(isolate, pc_, constant_pool_, +void RelocInfo::set_embedded_size(uint32_t size, ICacheFlushMode flush_mode) { + Assembler::set_target_address_at(pc_, constant_pool_, reinterpret_cast
(size), flush_mode); } -void RelocInfo::set_js_to_wasm_address(Isolate* isolate, Address address, +void RelocInfo::set_js_to_wasm_address(Address address, ICacheFlushMode icache_flush_mode) { DCHECK_EQ(rmode_, JS_TO_WASM_CALL); - set_embedded_address(isolate, address, icache_flush_mode); + set_embedded_address(address, icache_flush_mode); } Address RelocInfo::js_to_wasm_address() const { diff --git a/src/arm/assembler-arm.h b/src/arm/assembler-arm.h index 18b9ed57cb..fa402ca6c0 100644 --- a/src/arm/assembler-arm.h +++ b/src/arm/assembler-arm.h @@ -673,7 +673,7 @@ class Assembler : public AssemblerBase { // The isolate argument is unused (and may be nullptr) when skipping flushing. INLINE(static Address target_address_at(Address pc, Address constant_pool)); INLINE(static void set_target_address_at( - Isolate* isolate, Address pc, Address constant_pool, Address target, + Address pc, Address constant_pool, Address target, ICacheFlushMode icache_flush_mode = FLUSH_ICACHE_IF_NEEDED)); // Return the code target address at a call site from the return address @@ -687,12 +687,11 @@ class Assembler : public AssemblerBase { // This sets the branch destination (which is in the constant pool on ARM). // This is for calls and branches within generated code. inline static void deserialization_set_special_target_at( - Isolate* isolate, Address constant_pool_entry, Code* code, - Address target); + Address constant_pool_entry, Code* code, Address target); // This sets the internal reference at the pc. inline static void deserialization_set_target_internal_reference_at( - Isolate* isolate, Address pc, Address target, + Address pc, Address target, RelocInfo::Mode mode = RelocInfo::INTERNAL_REFERENCE); // Here we are patching the address in the constant pool, not the actual call diff --git a/src/arm64/assembler-arm64-inl.h b/src/arm64/assembler-arm64-inl.h index c50ffb7f28..0c31400d9c 100644 --- a/src/arm64/assembler-arm64-inl.h +++ b/src/arm64/assembler-arm64-inl.h @@ -576,21 +576,18 @@ Address Assembler::return_address_from_call_start(Address pc) { } } - void Assembler::deserialization_set_special_target_at( - Isolate* isolate, Address constant_pool_entry, Code* code, Address target) { + Address constant_pool_entry, Code* code, Address target) { Memory::Address_at(constant_pool_entry) = target; } - void Assembler::deserialization_set_target_internal_reference_at( - Isolate* isolate, Address pc, Address target, RelocInfo::Mode mode) { + Address pc, Address target, RelocInfo::Mode mode) { Memory::Address_at(pc) = target; } - -void Assembler::set_target_address_at(Isolate* isolate, Address pc, - Address constant_pool, Address target, +void Assembler::set_target_address_at(Address pc, Address constant_pool, + Address target, ICacheFlushMode icache_flush_mode) { Memory::Address_at(target_pointer_address_at(pc)) = target; // Intuitively, we would think it is necessary to always flush the @@ -642,7 +639,7 @@ void RelocInfo::set_target_object(HeapObject* target, WriteBarrierMode write_barrier_mode, ICacheFlushMode icache_flush_mode) { DCHECK(IsCodeTarget(rmode_) || rmode_ == EMBEDDED_OBJECT); - Assembler::set_target_address_at(target->GetIsolate(), pc_, constant_pool_, + Assembler::set_target_address_at(pc_, constant_pool_, reinterpret_cast
(target), icache_flush_mode); if (write_barrier_mode == UPDATE_WRITE_BARRIER && host() != nullptr) { @@ -676,23 +673,23 @@ Address RelocInfo::target_runtime_entry(Assembler* origin) { return target_address(); } -void RelocInfo::set_target_runtime_entry(Isolate* isolate, Address target, +void RelocInfo::set_target_runtime_entry(Address target, WriteBarrierMode write_barrier_mode, ICacheFlushMode icache_flush_mode) { DCHECK(IsRuntimeEntry(rmode_)); if (target_address() != target) { - set_target_address(isolate, target, write_barrier_mode, icache_flush_mode); + set_target_address(target, write_barrier_mode, icache_flush_mode); } } -void RelocInfo::WipeOut(Isolate* isolate) { +void RelocInfo::WipeOut() { DCHECK(IsEmbeddedObject(rmode_) || IsCodeTarget(rmode_) || IsRuntimeEntry(rmode_) || IsExternalReference(rmode_) || IsInternalReference(rmode_)); if (IsInternalReference(rmode_)) { Memory::Address_at(pc_) = nullptr; } else { - Assembler::set_target_address_at(isolate, pc_, constant_pool_, nullptr); + Assembler::set_target_address_at(pc_, constant_pool_, nullptr); } } diff --git a/src/arm64/assembler-arm64.cc b/src/arm64/assembler-arm64.cc index 315e599810..8d258d95a5 100644 --- a/src/arm64/assembler-arm64.cc +++ b/src/arm64/assembler-arm64.cc @@ -181,22 +181,20 @@ uint32_t RelocInfo::embedded_size() const { return Memory::uint32_at(Assembler::target_pointer_address_at(pc_)); } -void RelocInfo::set_embedded_address(Isolate* isolate, Address address, +void RelocInfo::set_embedded_address(Address address, ICacheFlushMode flush_mode) { - Assembler::set_target_address_at(isolate, pc_, constant_pool_, address, - flush_mode); + Assembler::set_target_address_at(pc_, constant_pool_, address, flush_mode); } -void RelocInfo::set_embedded_size(Isolate* isolate, uint32_t size, - ICacheFlushMode flush_mode) { +void RelocInfo::set_embedded_size(uint32_t size, ICacheFlushMode flush_mode) { Memory::uint32_at(Assembler::target_pointer_address_at(pc_)) = size; // No icache flushing needed, see comment in set_target_address_at. } -void RelocInfo::set_js_to_wasm_address(Isolate* isolate, Address address, +void RelocInfo::set_js_to_wasm_address(Address address, ICacheFlushMode icache_flush_mode) { DCHECK_EQ(rmode_, JS_TO_WASM_CALL); - set_embedded_address(isolate, address, icache_flush_mode); + set_embedded_address(address, icache_flush_mode); } Address RelocInfo::js_to_wasm_address() const { diff --git a/src/arm64/assembler-arm64.h b/src/arm64/assembler-arm64.h index 069dd1913b..d1f6724d3b 100644 --- a/src/arm64/assembler-arm64.h +++ b/src/arm64/assembler-arm64.h @@ -993,7 +993,7 @@ class Assembler : public AssemblerBase { // The isolate argument is unused (and may be nullptr) when skipping flushing. inline static Address target_address_at(Address pc, Address constant_pool); inline static void set_target_address_at( - Isolate* isolate, Address pc, Address constant_pool, Address target, + Address pc, Address constant_pool, Address target, ICacheFlushMode icache_flush_mode = FLUSH_ICACHE_IF_NEEDED); // Return the code target address at a call site from the return address of @@ -1007,12 +1007,11 @@ class Assembler : public AssemblerBase { // This sets the branch destination (which is in the constant pool on ARM). // This is for calls and branches within generated code. inline static void deserialization_set_special_target_at( - Isolate* isolate, Address constant_pool_entry, Code* code, - Address target); + Address constant_pool_entry, Code* code, Address target); // This sets the internal reference at the pc. inline static void deserialization_set_target_internal_reference_at( - Isolate* isolate, Address pc, Address target, + Address pc, Address target, RelocInfo::Mode mode = RelocInfo::INTERNAL_REFERENCE); // All addresses in the constant pool are the same size as pointers. diff --git a/src/assembler.cc b/src/assembler.cc index d9cfac54c1..5d2c4772ca 100644 --- a/src/assembler.cc +++ b/src/assembler.cc @@ -301,16 +301,16 @@ const int kLastChunkTagBits = 1; const int kLastChunkTagMask = 1; const int kLastChunkTag = 1; -void RelocInfo::set_wasm_context_reference(Isolate* isolate, Address address, +void RelocInfo::set_wasm_context_reference(Address address, ICacheFlushMode icache_flush_mode) { DCHECK(IsWasmContextReference(rmode_)); - set_embedded_address(isolate, address, icache_flush_mode); + set_embedded_address(address, icache_flush_mode); } -void RelocInfo::set_global_handle(Isolate* isolate, Address address, +void RelocInfo::set_global_handle(Address address, ICacheFlushMode icache_flush_mode) { DCHECK_EQ(rmode_, WASM_GLOBAL_HANDLE); - set_embedded_address(isolate, address, icache_flush_mode); + set_embedded_address(address, icache_flush_mode); } Address RelocInfo::wasm_call_address() const { @@ -318,10 +318,10 @@ Address RelocInfo::wasm_call_address() const { return Assembler::target_address_at(pc_, constant_pool_); } -void RelocInfo::set_wasm_call_address(Isolate* isolate, Address address, +void RelocInfo::set_wasm_call_address(Address address, ICacheFlushMode icache_flush_mode) { DCHECK_EQ(rmode_, WASM_CALL); - Assembler::set_target_address_at(isolate, pc_, constant_pool_, address, + Assembler::set_target_address_at(pc_, constant_pool_, address, icache_flush_mode); } @@ -341,17 +341,16 @@ Address RelocInfo::wasm_context_reference() const { } void RelocInfo::update_wasm_function_table_size_reference( - Isolate* isolate, uint32_t old_size, uint32_t new_size, - ICacheFlushMode icache_flush_mode) { + uint32_t old_size, uint32_t new_size, ICacheFlushMode icache_flush_mode) { DCHECK(IsWasmFunctionTableSizeReference(rmode_)); - set_embedded_size(isolate, new_size, icache_flush_mode); + set_embedded_size(new_size, icache_flush_mode); } -void RelocInfo::set_target_address(Isolate* isolate, Address target, +void RelocInfo::set_target_address(Address target, WriteBarrierMode write_barrier_mode, ICacheFlushMode icache_flush_mode) { DCHECK(IsCodeTarget(rmode_) || IsRuntimeEntry(rmode_) || IsWasmCall(rmode_)); - Assembler::set_target_address_at(isolate, pc_, constant_pool_, target, + Assembler::set_target_address_at(pc_, constant_pool_, target, icache_flush_mode); if (write_barrier_mode == UPDATE_WRITE_BARRIER && host() != nullptr && IsCodeTarget(rmode_)) { @@ -601,7 +600,7 @@ RelocIterator::RelocIterator(Vector instructions, // Implementation of RelocInfo #ifdef DEBUG -bool RelocInfo::RequiresRelocation(Isolate* isolate, const CodeDesc& desc) { +bool RelocInfo::RequiresRelocation(const CodeDesc& desc) { // Ensure there are no code targets or embedded objects present in the // deoptimization entries, they would require relocation after code // generation. diff --git a/src/assembler.h b/src/assembler.h index 4a60aaefe4..a8786760c3 100644 --- a/src/assembler.h +++ b/src/assembler.h @@ -512,25 +512,22 @@ class RelocInfo { Address wasm_call_address() const; void set_wasm_context_reference( - Isolate* isolate, Address address, + Address address, ICacheFlushMode icache_flush_mode = FLUSH_ICACHE_IF_NEEDED); void update_wasm_function_table_size_reference( - Isolate* isolate, uint32_t old_base, uint32_t new_base, + uint32_t old_base, uint32_t new_base, ICacheFlushMode icache_flush_mode = FLUSH_ICACHE_IF_NEEDED); void set_target_address( - Isolate* isolate, Address target, + Address target, WriteBarrierMode write_barrier_mode = UPDATE_WRITE_BARRIER, ICacheFlushMode icache_flush_mode = FLUSH_ICACHE_IF_NEEDED); - void set_global_handle( - Isolate* isolate, Address address, - ICacheFlushMode icache_flush_mode = FLUSH_ICACHE_IF_NEEDED); + void set_global_handle(Address address, ICacheFlushMode icache_flush_mode = + FLUSH_ICACHE_IF_NEEDED); void set_wasm_call_address( - Isolate*, Address, - ICacheFlushMode icache_flush_mode = FLUSH_ICACHE_IF_NEEDED); + Address, ICacheFlushMode icache_flush_mode = FLUSH_ICACHE_IF_NEEDED); void set_js_to_wasm_address( - Isolate*, Address, - ICacheFlushMode icache_flush_mode = FLUSH_ICACHE_IF_NEEDED); + Address, ICacheFlushMode icache_flush_mode = FLUSH_ICACHE_IF_NEEDED); // this relocation applies to; // can only be called if IsCodeTarget(rmode_) || IsRuntimeEntry(rmode_) @@ -543,7 +540,7 @@ class RelocInfo { ICacheFlushMode icache_flush_mode = FLUSH_ICACHE_IF_NEEDED)); INLINE(Address target_runtime_entry(Assembler* origin)); INLINE(void set_target_runtime_entry( - Isolate* isolate, Address target, + Address target, WriteBarrierMode write_barrier_mode = UPDATE_WRITE_BARRIER, ICacheFlushMode icache_flush_mode = FLUSH_ICACHE_IF_NEEDED)); INLINE(Cell* target_cell()); @@ -589,7 +586,7 @@ class RelocInfo { // Wipe out a relocation to a fixed value, used for making snapshots // reproducible. - INLINE(void WipeOut(Isolate* isolate)); + INLINE(void WipeOut()); template inline void Visit(ObjectVisitor* v); @@ -597,7 +594,7 @@ class RelocInfo { #ifdef DEBUG // Check whether the given code contains relocation information that // either is position-relative or movable by the garbage collector. - static bool RequiresRelocation(Isolate* isolate, const CodeDesc& desc); + static bool RequiresRelocation(const CodeDesc& desc); #endif #ifdef ENABLE_DISASSEMBLER @@ -613,10 +610,8 @@ class RelocInfo { static const int kApplyMask; // Modes affected by apply. Depends on arch. private: - void set_embedded_address(Isolate* isolate, Address address, - ICacheFlushMode flush_mode); - void set_embedded_size(Isolate* isolate, uint32_t size, - ICacheFlushMode flush_mode); + void set_embedded_address(Address address, ICacheFlushMode flush_mode); + void set_embedded_size(uint32_t size, ICacheFlushMode flush_mode); uint32_t embedded_size() const; Address embedded_address() const; diff --git a/src/builtins/setup-builtins-internal.cc b/src/builtins/setup-builtins-internal.cc index 3cbd23db57..d30cd02ab5 100644 --- a/src/builtins/setup-builtins-internal.cc +++ b/src/builtins/setup-builtins-internal.cc @@ -186,7 +186,7 @@ void SetupIsolateDelegate::ReplacePlaceholders(Isolate* isolate) { if (!target->is_builtin()) continue; Code* new_target = Code::cast(builtins->builtins_[target->builtin_index()]); - rinfo->set_target_address(isolate, new_target->instruction_start(), + rinfo->set_target_address(new_target->instruction_start(), UPDATE_WRITE_BARRIER, SKIP_ICACHE_FLUSH); } else { DCHECK(RelocInfo::IsEmbeddedObject(rinfo->rmode())); diff --git a/src/deoptimizer.cc b/src/deoptimizer.cc index f6ac79954a..892ddf57c5 100644 --- a/src/deoptimizer.cc +++ b/src/deoptimizer.cc @@ -1832,7 +1832,7 @@ void Deoptimizer::EnsureCodeForDeoptimizationEntry(Isolate* isolate, GenerateDeoptimizationEntries(&masm, kMaxNumberOfEntries, type); CodeDesc desc; masm.GetCode(isolate, &desc); - DCHECK(!RelocInfo::RequiresRelocation(isolate, desc)); + DCHECK(!RelocInfo::RequiresRelocation(desc)); // Allocate the code as immovable since the entry addresses will be used // directly and there is no support for relocating them. diff --git a/src/heap/remembered-set.h b/src/heap/remembered-set.h index 454c8a16f2..4e0f259c00 100644 --- a/src/heap/remembered-set.h +++ b/src/heap/remembered-set.h @@ -298,8 +298,7 @@ class UpdateTypedSlotHelper { Object* new_target = old_target; SlotCallbackResult result = callback(&new_target); if (new_target != old_target) { - rinfo->set_target_address(old_target->GetIsolate(), - Code::cast(new_target)->instruction_start()); + rinfo->set_target_address(Code::cast(new_target)->instruction_start()); } return result; } diff --git a/src/ia32/assembler-ia32-inl.h b/src/ia32/assembler-ia32-inl.h index a9bdd18846..c8eb8fff3b 100644 --- a/src/ia32/assembler-ia32-inl.h +++ b/src/ia32/assembler-ia32-inl.h @@ -135,22 +135,22 @@ Address RelocInfo::target_runtime_entry(Assembler* origin) { return reinterpret_cast
(*reinterpret_cast(pc_)); } -void RelocInfo::set_target_runtime_entry(Isolate* isolate, Address target, +void RelocInfo::set_target_runtime_entry(Address target, WriteBarrierMode write_barrier_mode, ICacheFlushMode icache_flush_mode) { DCHECK(IsRuntimeEntry(rmode_)); if (target_address() != target) { - set_target_address(isolate, target, write_barrier_mode, icache_flush_mode); + set_target_address(target, write_barrier_mode, icache_flush_mode); } } -void RelocInfo::WipeOut(Isolate* isolate) { +void RelocInfo::WipeOut() { if (IsEmbeddedObject(rmode_) || IsExternalReference(rmode_) || IsInternalReference(rmode_)) { Memory::Address_at(pc_) = nullptr; } else if (IsCodeTarget(rmode_) || IsRuntimeEntry(rmode_)) { // Effectively write zero into the relocation. - Assembler::set_target_address_at(isolate, pc_, constant_pool_, + Assembler::set_target_address_at(pc_, constant_pool_, pc_ + sizeof(int32_t)); } else { UNREACHABLE(); @@ -246,11 +246,9 @@ Address Assembler::target_address_at(Address pc, Address constant_pool) { return pc + sizeof(int32_t) + *reinterpret_cast(pc); } - -void Assembler::set_target_address_at(Isolate* isolate, Address pc, - Address constant_pool, Address target, +void Assembler::set_target_address_at(Address pc, Address constant_pool, + Address target, ICacheFlushMode icache_flush_mode) { - DCHECK_IMPLIES(isolate == nullptr, icache_flush_mode == SKIP_ICACHE_FLUSH); int32_t* p = reinterpret_cast(pc); *p = target - (pc + sizeof(int32_t)); if (icache_flush_mode != SKIP_ICACHE_FLUSH) { @@ -263,8 +261,8 @@ Address Assembler::target_address_from_return_address(Address pc) { } void Assembler::deserialization_set_special_target_at( - Isolate* isolate, Address instruction_payload, Code* code, Address target) { - set_target_address_at(isolate, instruction_payload, + Address instruction_payload, Code* code, Address target) { + set_target_address_at(instruction_payload, code ? code->constant_pool() : nullptr, target); } @@ -296,9 +294,8 @@ void Assembler::emit_near_disp(Label* L) { *pc_++ = disp; } - void Assembler::deserialization_set_target_internal_reference_at( - Isolate* isolate, Address pc, Address target, RelocInfo::Mode mode) { + Address pc, Address target, RelocInfo::Mode mode) { Memory::Address_at(pc) = target; } diff --git a/src/ia32/assembler-ia32.cc b/src/ia32/assembler-ia32.cc index 96f70c1e70..62fe6a06f4 100644 --- a/src/ia32/assembler-ia32.cc +++ b/src/ia32/assembler-ia32.cc @@ -207,7 +207,7 @@ Address RelocInfo::embedded_address() const { return Memory::Address_at(pc_); } uint32_t RelocInfo::embedded_size() const { return Memory::uint32_at(pc_); } -void RelocInfo::set_embedded_address(Isolate* isolate, Address address, +void RelocInfo::set_embedded_address(Address address, ICacheFlushMode icache_flush_mode) { Memory::Address_at(pc_) = address; if (icache_flush_mode != SKIP_ICACHE_FLUSH) { @@ -215,7 +215,7 @@ void RelocInfo::set_embedded_address(Isolate* isolate, Address address, } } -void RelocInfo::set_embedded_size(Isolate* isolate, uint32_t size, +void RelocInfo::set_embedded_size(uint32_t size, ICacheFlushMode icache_flush_mode) { Memory::uint32_at(pc_) = size; if (icache_flush_mode != SKIP_ICACHE_FLUSH) { @@ -223,10 +223,10 @@ void RelocInfo::set_embedded_size(Isolate* isolate, uint32_t size, } } -void RelocInfo::set_js_to_wasm_address(Isolate* isolate, Address address, +void RelocInfo::set_js_to_wasm_address(Address address, ICacheFlushMode icache_flush_mode) { DCHECK_EQ(rmode_, JS_TO_WASM_CALL); - Assembler::set_target_address_at(isolate, pc_, constant_pool_, address, + Assembler::set_target_address_at(pc_, constant_pool_, address, icache_flush_mode); } diff --git a/src/ia32/assembler-ia32.h b/src/ia32/assembler-ia32.h index 9c0a4bdff3..496b58b652 100644 --- a/src/ia32/assembler-ia32.h +++ b/src/ia32/assembler-ia32.h @@ -513,7 +513,7 @@ class Assembler : public AssemblerBase { // The isolate argument is unused (and may be nullptr) when skipping flushing. inline static Address target_address_at(Address pc, Address constant_pool); inline static void set_target_address_at( - Isolate* isolate, Address pc, Address constant_pool, Address target, + Address pc, Address constant_pool, Address target, ICacheFlushMode icache_flush_mode = FLUSH_ICACHE_IF_NEEDED); // Return the code target address at a call site from the return address @@ -523,12 +523,11 @@ class Assembler : public AssemblerBase { // This sets the branch destination (which is in the instruction on x86). // This is for calls and branches within generated code. inline static void deserialization_set_special_target_at( - Isolate* isolate, Address instruction_payload, Code* code, - Address target); + Address instruction_payload, Code* code, Address target); // This sets the internal reference at the pc. inline static void deserialization_set_target_internal_reference_at( - Isolate* isolate, Address pc, Address target, + Address pc, Address target, RelocInfo::Mode mode = RelocInfo::INTERNAL_REFERENCE); static constexpr int kSpecialTargetSize = kPointerSize; diff --git a/src/ia32/codegen-ia32.cc b/src/ia32/codegen-ia32.cc index 5fbef279f4..ffe3c9150b 100644 --- a/src/ia32/codegen-ia32.cc +++ b/src/ia32/codegen-ia32.cc @@ -35,7 +35,7 @@ UnaryMathFunctionWithIsolate CreateSqrtFunction(Isolate* isolate) { CodeDesc desc; masm.GetCode(isolate, &desc); - DCHECK(!RelocInfo::RequiresRelocation(isolate, desc)); + DCHECK(!RelocInfo::RequiresRelocation(desc)); Assembler::FlushICache(buffer, allocated); CHECK(SetPermissions(buffer, allocated, PageAllocator::kReadExecute)); @@ -447,7 +447,7 @@ MemMoveFunction CreateMemMoveFunction(Isolate* isolate) { CodeDesc desc; masm.GetCode(isolate, &desc); - DCHECK(!RelocInfo::RequiresRelocation(isolate, desc)); + DCHECK(!RelocInfo::RequiresRelocation(desc)); Assembler::FlushICache(buffer, allocated); CHECK(SetPermissions(buffer, allocated, PageAllocator::kReadExecute)); // TODO(jkummerow): It would be nice to register this code creation event diff --git a/src/mips/assembler-mips-inl.h b/src/mips/assembler-mips-inl.h index 4edbe237e3..a5e2335852 100644 --- a/src/mips/assembler-mips-inl.h +++ b/src/mips/assembler-mips-inl.h @@ -125,16 +125,14 @@ Address Assembler::target_address_from_return_address(Address pc) { } void Assembler::deserialization_set_special_target_at( - Isolate* isolate, Address instruction_payload, Code* code, Address target) { + Address instruction_payload, Code* code, Address target) { if (IsMipsArchVariant(kMips32r6)) { // On R6 the address location is shifted by one instruction set_target_address_at( - isolate, instruction_payload - (kInstructionsFor32BitConstant - 1) * kInstrSize, code ? code->constant_pool() : nullptr, target); } else { set_target_address_at( - isolate, instruction_payload - kInstructionsFor32BitConstant * kInstrSize, code ? code->constant_pool() : nullptr, target); } @@ -171,9 +169,8 @@ void Assembler::set_target_internal_reference_encoded_at(Address pc, // after complete deserialization, no need to flush on each reference. } - void Assembler::deserialization_set_target_internal_reference_at( - Isolate* isolate, Address pc, Address target, RelocInfo::Mode mode) { + Address pc, Address target, RelocInfo::Mode mode) { if (mode == RelocInfo::INTERNAL_REFERENCE_ENCODED) { DCHECK(IsLui(instr_at(pc))); set_target_internal_reference_encoded_at(pc, target); @@ -199,7 +196,7 @@ void RelocInfo::set_target_object(HeapObject* target, WriteBarrierMode write_barrier_mode, ICacheFlushMode icache_flush_mode) { DCHECK(IsCodeTarget(rmode_) || rmode_ == EMBEDDED_OBJECT); - Assembler::set_target_address_at(target->GetIsolate(), pc_, constant_pool_, + Assembler::set_target_address_at(pc_, constant_pool_, reinterpret_cast
(target), icache_flush_mode); if (write_barrier_mode == UPDATE_WRITE_BARRIER && host() != nullptr) { @@ -249,15 +246,15 @@ Address RelocInfo::target_runtime_entry(Assembler* origin) { return target_address(); } -void RelocInfo::set_target_runtime_entry(Isolate* isolate, Address target, +void RelocInfo::set_target_runtime_entry(Address target, WriteBarrierMode write_barrier_mode, ICacheFlushMode icache_flush_mode) { DCHECK(IsRuntimeEntry(rmode_)); if (target_address() != target) - set_target_address(isolate, target, write_barrier_mode, icache_flush_mode); + set_target_address(target, write_barrier_mode, icache_flush_mode); } -void RelocInfo::WipeOut(Isolate* isolate) { +void RelocInfo::WipeOut() { DCHECK(IsEmbeddedObject(rmode_) || IsCodeTarget(rmode_) || IsRuntimeEntry(rmode_) || IsExternalReference(rmode_) || IsInternalReference(rmode_) || IsInternalReferenceEncoded(rmode_)); @@ -266,7 +263,7 @@ void RelocInfo::WipeOut(Isolate* isolate) { } else if (IsInternalReferenceEncoded(rmode_)) { Assembler::set_target_internal_reference_encoded_at(pc_, nullptr); } else { - Assembler::set_target_address_at(isolate, pc_, constant_pool_, nullptr); + Assembler::set_target_address_at(pc_, constant_pool_, nullptr); } } diff --git a/src/mips/assembler-mips.cc b/src/mips/assembler-mips.cc index f519464e01..13cd19c515 100644 --- a/src/mips/assembler-mips.cc +++ b/src/mips/assembler-mips.cc @@ -209,22 +209,20 @@ uint32_t RelocInfo::embedded_size() const { Assembler::target_address_at(pc_, constant_pool_)); } -void RelocInfo::set_embedded_address(Isolate* isolate, Address address, +void RelocInfo::set_embedded_address(Address address, ICacheFlushMode flush_mode) { - Assembler::set_target_address_at(isolate, pc_, constant_pool_, address, - flush_mode); + Assembler::set_target_address_at(pc_, constant_pool_, address, flush_mode); } -void RelocInfo::set_embedded_size(Isolate* isolate, uint32_t size, - ICacheFlushMode flush_mode) { - Assembler::set_target_address_at(isolate, pc_, constant_pool_, +void RelocInfo::set_embedded_size(uint32_t size, ICacheFlushMode flush_mode) { + Assembler::set_target_address_at(pc_, constant_pool_, reinterpret_cast
(size), flush_mode); } -void RelocInfo::set_js_to_wasm_address(Isolate* isolate, Address address, +void RelocInfo::set_js_to_wasm_address(Address address, ICacheFlushMode icache_flush_mode) { DCHECK_EQ(rmode_, JS_TO_WASM_CALL); - set_embedded_address(isolate, address, icache_flush_mode); + set_embedded_address(address, icache_flush_mode); } Address RelocInfo::js_to_wasm_address() const { @@ -281,8 +279,7 @@ void Assembler::AllocateAndInstallRequestedHeapObjects(Isolate* isolate) { break; } Address pc = buffer_ + request.offset(); - set_target_value_at(isolate, pc, - reinterpret_cast(object.location())); + set_target_value_at(pc, reinterpret_cast(object.location())); } } @@ -3898,11 +3895,8 @@ void Assembler::QuietNaN(HeapObject* object) { // There is an optimization below, which emits a nop when the address // fits in just 16 bits. This is unlikely to help, and should be benchmarked, // and possibly removed. -void Assembler::set_target_value_at(Isolate* isolate, Address pc, - uint32_t target, +void Assembler::set_target_value_at(Address pc, uint32_t target, ICacheFlushMode icache_flush_mode) { - DCHECK_IMPLIES(isolate == nullptr, icache_flush_mode == SKIP_ICACHE_FLUSH); - Instr instr2 = instr_at(pc + kInstrSize); uint32_t rt_code = GetRtField(instr2); uint32_t* p = reinterpret_cast(pc); diff --git a/src/mips/assembler-mips.h b/src/mips/assembler-mips.h index 8f5d43a213..52adcbe70b 100644 --- a/src/mips/assembler-mips.h +++ b/src/mips/assembler-mips.h @@ -567,9 +567,9 @@ class Assembler : public AssemblerBase { // The isolate argument is unused (and may be nullptr) when skipping flushing. static Address target_address_at(Address pc); INLINE(static void set_target_address_at) - (Isolate* isolate, Address pc, Address target, + (Address pc, Address target, ICacheFlushMode icache_flush_mode = FLUSH_ICACHE_IF_NEEDED) { - set_target_value_at(isolate, pc, reinterpret_cast(target), + set_target_value_at(pc, reinterpret_cast(target), icache_flush_mode); } // On MIPS there is no Constant Pool so we skip that parameter. @@ -577,13 +577,13 @@ class Assembler : public AssemblerBase { return target_address_at(pc); } INLINE(static void set_target_address_at( - Isolate* isolate, Address pc, Address constant_pool, Address target, + Address pc, Address constant_pool, Address target, ICacheFlushMode icache_flush_mode = FLUSH_ICACHE_IF_NEEDED)) { - set_target_address_at(isolate, pc, target, icache_flush_mode); + set_target_address_at(pc, target, icache_flush_mode); } static void set_target_value_at( - Isolate* isolate, Address pc, uint32_t target, + Address pc, uint32_t target, ICacheFlushMode icache_flush_mode = FLUSH_ICACHE_IF_NEEDED); // Return the code target address at a call site from the return address @@ -596,12 +596,11 @@ class Assembler : public AssemblerBase { // This is for calls and branches within generated code. The serializer // has already deserialized the lui/ori instructions etc. inline static void deserialization_set_special_target_at( - Isolate* isolate, Address instruction_payload, Code* code, - Address target); + Address instruction_payload, Code* code, Address target); // This sets the internal reference at the pc. inline static void deserialization_set_target_internal_reference_at( - Isolate* isolate, Address pc, Address target, + Address pc, Address target, RelocInfo::Mode mode = RelocInfo::INTERNAL_REFERENCE); // Size of an instruction. diff --git a/src/mips64/assembler-mips64-inl.h b/src/mips64/assembler-mips64-inl.h index b5fe0da46c..e05082ee40 100644 --- a/src/mips64/assembler-mips64-inl.h +++ b/src/mips64/assembler-mips64-inl.h @@ -119,9 +119,9 @@ Address Assembler::target_address_from_return_address(Address pc) { } void Assembler::deserialization_set_special_target_at( - Isolate* isolate, Address instruction_payload, Code* code, Address target) { + Address instruction_payload, Code* code, Address target) { set_target_address_at( - isolate, instruction_payload - kInstructionsFor64BitConstant * kInstrSize, + instruction_payload - kInstructionsFor64BitConstant * kInstrSize, code ? code->constant_pool() : nullptr, target); } @@ -142,9 +142,8 @@ void Assembler::set_target_internal_reference_encoded_at(Address pc, // after complete deserialization, no need to flush on each reference. } - void Assembler::deserialization_set_target_internal_reference_at( - Isolate* isolate, Address pc, Address target, RelocInfo::Mode mode) { + Address pc, Address target, RelocInfo::Mode mode) { if (mode == RelocInfo::INTERNAL_REFERENCE_ENCODED) { DCHECK(IsJ(instr_at(pc))); set_target_internal_reference_encoded_at(pc, target); @@ -170,7 +169,7 @@ void RelocInfo::set_target_object(HeapObject* target, WriteBarrierMode write_barrier_mode, ICacheFlushMode icache_flush_mode) { DCHECK(IsCodeTarget(rmode_) || rmode_ == EMBEDDED_OBJECT); - Assembler::set_target_address_at(target->GetIsolate(), pc_, constant_pool_, + Assembler::set_target_address_at(pc_, constant_pool_, reinterpret_cast
(target), icache_flush_mode); if (write_barrier_mode == UPDATE_WRITE_BARRIER && host() != nullptr && @@ -215,15 +214,15 @@ Address RelocInfo::target_runtime_entry(Assembler* origin) { return target_address(); } -void RelocInfo::set_target_runtime_entry(Isolate* isolate, Address target, +void RelocInfo::set_target_runtime_entry(Address target, WriteBarrierMode write_barrier_mode, ICacheFlushMode icache_flush_mode) { DCHECK(IsRuntimeEntry(rmode_)); if (target_address() != target) - set_target_address(isolate, target, write_barrier_mode, icache_flush_mode); + set_target_address(target, write_barrier_mode, icache_flush_mode); } -void RelocInfo::WipeOut(Isolate* isolate) { +void RelocInfo::WipeOut() { DCHECK(IsEmbeddedObject(rmode_) || IsCodeTarget(rmode_) || IsRuntimeEntry(rmode_) || IsExternalReference(rmode_) || IsInternalReference(rmode_) || IsInternalReferenceEncoded(rmode_)); @@ -232,7 +231,7 @@ void RelocInfo::WipeOut(Isolate* isolate) { } else if (IsInternalReferenceEncoded(rmode_)) { Assembler::set_target_internal_reference_encoded_at(pc_, nullptr); } else { - Assembler::set_target_address_at(isolate, pc_, constant_pool_, nullptr); + Assembler::set_target_address_at(pc_, constant_pool_, nullptr); } } diff --git a/src/mips64/assembler-mips64.cc b/src/mips64/assembler-mips64.cc index 1c631271f1..66d4f1bf01 100644 --- a/src/mips64/assembler-mips64.cc +++ b/src/mips64/assembler-mips64.cc @@ -187,22 +187,20 @@ uint32_t RelocInfo::embedded_size() const { (Assembler::target_address_at(pc_, constant_pool_)))); } -void RelocInfo::set_embedded_address(Isolate* isolate, Address address, +void RelocInfo::set_embedded_address(Address address, ICacheFlushMode flush_mode) { - Assembler::set_target_address_at(isolate, pc_, constant_pool_, address, - flush_mode); + Assembler::set_target_address_at(pc_, constant_pool_, address, flush_mode); } -void RelocInfo::set_embedded_size(Isolate* isolate, uint32_t size, - ICacheFlushMode flush_mode) { - Assembler::set_target_address_at(isolate, pc_, constant_pool_, +void RelocInfo::set_embedded_size(uint32_t size, ICacheFlushMode flush_mode) { + Assembler::set_target_address_at(pc_, constant_pool_, reinterpret_cast
(size), flush_mode); } -void RelocInfo::set_js_to_wasm_address(Isolate* isolate, Address address, +void RelocInfo::set_js_to_wasm_address(Address address, ICacheFlushMode icache_flush_mode) { DCHECK_EQ(rmode_, JS_TO_WASM_CALL); - set_embedded_address(isolate, address, icache_flush_mode); + set_embedded_address(address, icache_flush_mode); } Address RelocInfo::js_to_wasm_address() const { @@ -260,8 +258,7 @@ void Assembler::AllocateAndInstallRequestedHeapObjects(Isolate* isolate) { break; } Address pc = buffer_ + request.offset(); - set_target_value_at(isolate, pc, - reinterpret_cast(object.location())); + set_target_value_at(pc, reinterpret_cast(object.location())); } } @@ -4226,8 +4223,7 @@ void Assembler::QuietNaN(HeapObject* object) { // There is an optimization below, which emits a nop when the address // fits in just 16 bits. This is unlikely to help, and should be benchmarked, // and possibly removed. -void Assembler::set_target_value_at(Isolate* isolate, Address pc, - uint64_t target, +void Assembler::set_target_value_at(Address pc, uint64_t target, ICacheFlushMode icache_flush_mode) { // There is an optimization where only 4 instructions are used to load address // in code on MIP64 because only 48-bits of address is effectively used. diff --git a/src/mips64/assembler-mips64.h b/src/mips64/assembler-mips64.h index 8fea410cd2..38b4e4e4e1 100644 --- a/src/mips64/assembler-mips64.h +++ b/src/mips64/assembler-mips64.h @@ -575,9 +575,9 @@ class Assembler : public AssemblerBase { // The isolate argument is unused (and may be nullptr) when skipping flushing. static Address target_address_at(Address pc); INLINE(static void set_target_address_at( - Isolate* isolate, Address pc, Address target, + Address pc, Address target, ICacheFlushMode icache_flush_mode = FLUSH_ICACHE_IF_NEEDED)) { - set_target_value_at(isolate, pc, reinterpret_cast(target), + set_target_value_at(pc, reinterpret_cast(target), icache_flush_mode); } // On MIPS there is no Constant Pool so we skip that parameter. @@ -585,13 +585,13 @@ class Assembler : public AssemblerBase { return target_address_at(pc); } INLINE(static void set_target_address_at( - Isolate* isolate, Address pc, Address constant_pool, Address target, + Address pc, Address constant_pool, Address target, ICacheFlushMode icache_flush_mode = FLUSH_ICACHE_IF_NEEDED)) { - set_target_address_at(isolate, pc, target, icache_flush_mode); + set_target_address_at(pc, target, icache_flush_mode); } static void set_target_value_at( - Isolate* isolate, Address pc, uint64_t target, + Address pc, uint64_t target, ICacheFlushMode icache_flush_mode = FLUSH_ICACHE_IF_NEEDED); // Return the code target address at a call site from the return address @@ -606,12 +606,11 @@ class Assembler : public AssemblerBase { // This is for calls and branches within generated code. The serializer // has already deserialized the lui/ori instructions etc. inline static void deserialization_set_special_target_at( - Isolate* isolate, Address instruction_payload, Code* code, - Address target); + Address instruction_payload, Code* code, Address target); // This sets the internal reference at the pc. inline static void deserialization_set_target_internal_reference_at( - Isolate* isolate, Address pc, Address target, + Address pc, Address target, RelocInfo::Mode mode = RelocInfo::INTERNAL_REFERENCE); // Size of an instruction. diff --git a/src/objects.cc b/src/objects.cc index b8dc846ac4..91286a2a77 100644 --- a/src/objects.cc +++ b/src/objects.cc @@ -14066,12 +14066,12 @@ void Code::CopyFrom(const CodeDesc& desc) { // code object Handle p = it.rinfo()->target_object_handle(origin); Code* code = Code::cast(*p); - it.rinfo()->set_target_address(GetIsolate(), code->instruction_start(), + it.rinfo()->set_target_address(code->instruction_start(), UPDATE_WRITE_BARRIER, SKIP_ICACHE_FLUSH); } else if (RelocInfo::IsRuntimeEntry(mode)) { Address p = it.rinfo()->target_runtime_entry(origin); - it.rinfo()->set_target_runtime_entry( - GetIsolate(), p, UPDATE_WRITE_BARRIER, SKIP_ICACHE_FLUSH); + it.rinfo()->set_target_runtime_entry(p, UPDATE_WRITE_BARRIER, + SKIP_ICACHE_FLUSH); } else { intptr_t delta = instruction_start() - desc.buffer; it.rinfo()->apply(delta); diff --git a/src/ppc/assembler-ppc-inl.h b/src/ppc/assembler-ppc-inl.h index b835e064ec..166a854638 100644 --- a/src/ppc/assembler-ppc-inl.h +++ b/src/ppc/assembler-ppc-inl.h @@ -60,8 +60,8 @@ void RelocInfo::apply(intptr_t delta) { // mov sequence DCHECK(IsInternalReferenceEncoded(rmode_)); Address target = Assembler::target_address_at(pc_, constant_pool_); - Assembler::set_target_address_at(nullptr, pc_, constant_pool_, - target + delta, SKIP_ICACHE_FLUSH); + Assembler::set_target_address_at(pc_, constant_pool_, target + delta, + SKIP_ICACHE_FLUSH); } } @@ -176,7 +176,7 @@ void RelocInfo::set_target_object(HeapObject* target, WriteBarrierMode write_barrier_mode, ICacheFlushMode icache_flush_mode) { DCHECK(IsCodeTarget(rmode_) || rmode_ == EMBEDDED_OBJECT); - Assembler::set_target_address_at(target->GetIsolate(), pc_, constant_pool_, + Assembler::set_target_address_at(pc_, constant_pool_, reinterpret_cast
(target), icache_flush_mode); if (write_barrier_mode == UPDATE_WRITE_BARRIER && host() != nullptr) { @@ -198,15 +198,15 @@ Address RelocInfo::target_runtime_entry(Assembler* origin) { return target_address(); } -void RelocInfo::set_target_runtime_entry(Isolate* isolate, Address target, +void RelocInfo::set_target_runtime_entry(Address target, WriteBarrierMode write_barrier_mode, ICacheFlushMode icache_flush_mode) { DCHECK(IsRuntimeEntry(rmode_)); if (target_address() != target) - set_target_address(isolate, target, write_barrier_mode, icache_flush_mode); + set_target_address(target, write_barrier_mode, icache_flush_mode); } -void RelocInfo::WipeOut(Isolate* isolate) { +void RelocInfo::WipeOut() { DCHECK(IsEmbeddedObject(rmode_) || IsCodeTarget(rmode_) || IsRuntimeEntry(rmode_) || IsExternalReference(rmode_) || IsInternalReference(rmode_) || IsInternalReferenceEncoded(rmode_)); @@ -216,10 +216,10 @@ void RelocInfo::WipeOut(Isolate* isolate) { } else if (IsInternalReferenceEncoded(rmode_)) { // mov sequence // Currently used only by deserializer, no need to flush. - Assembler::set_target_address_at(isolate, pc_, constant_pool_, nullptr, + Assembler::set_target_address_at(pc_, constant_pool_, nullptr, SKIP_ICACHE_FLUSH); } else { - Assembler::set_target_address_at(isolate, pc_, constant_pool_, nullptr); + Assembler::set_target_address_at(pc_, constant_pool_, nullptr); } } @@ -413,16 +413,15 @@ Address Assembler::target_constant_pool_address_at( // has already deserialized the mov instructions etc. // There is a FIXED_SEQUENCE assumption here void Assembler::deserialization_set_special_target_at( - Isolate* isolate, Address instruction_payload, Code* code, Address target) { - set_target_address_at(isolate, instruction_payload, + Address instruction_payload, Code* code, Address target) { + set_target_address_at(instruction_payload, code ? code->constant_pool() : nullptr, target); } - void Assembler::deserialization_set_target_internal_reference_at( - Isolate* isolate, Address pc, Address target, RelocInfo::Mode mode) { + Address pc, Address target, RelocInfo::Mode mode) { if (RelocInfo::IsInternalReferenceEncoded(mode)) { - set_target_address_at(isolate, pc, nullptr, target, SKIP_ICACHE_FLUSH); + set_target_address_at(pc, nullptr, target, SKIP_ICACHE_FLUSH); } else { Memory::Address_at(pc) = target; } @@ -430,11 +429,9 @@ void Assembler::deserialization_set_target_internal_reference_at( // This code assumes the FIXED_SEQUENCE of lis/ori -void Assembler::set_target_address_at(Isolate* isolate, Address pc, - Address constant_pool, Address target, +void Assembler::set_target_address_at(Address pc, Address constant_pool, + Address target, ICacheFlushMode icache_flush_mode) { - DCHECK_IMPLIES(isolate == nullptr, icache_flush_mode == SKIP_ICACHE_FLUSH); - if (FLAG_enable_embedded_constant_pool && constant_pool) { ConstantPoolEntry::Access access; if (IsConstantPoolLoadStart(pc, &access)) { diff --git a/src/ppc/assembler-ppc.cc b/src/ppc/assembler-ppc.cc index 788097d3cd..eb16e46505 100644 --- a/src/ppc/assembler-ppc.cc +++ b/src/ppc/assembler-ppc.cc @@ -170,22 +170,20 @@ uint32_t RelocInfo::embedded_size() const { Assembler::target_address_at(pc_, constant_pool_))); } -void RelocInfo::set_embedded_address(Isolate* isolate, Address address, +void RelocInfo::set_embedded_address(Address address, ICacheFlushMode flush_mode) { - Assembler::set_target_address_at(isolate, pc_, constant_pool_, address, - flush_mode); + Assembler::set_target_address_at(pc_, constant_pool_, address, flush_mode); } -void RelocInfo::set_embedded_size(Isolate* isolate, uint32_t size, - ICacheFlushMode flush_mode) { - Assembler::set_target_address_at(isolate, pc_, constant_pool_, +void RelocInfo::set_embedded_size(uint32_t size, ICacheFlushMode flush_mode) { + Assembler::set_target_address_at(pc_, constant_pool_, reinterpret_cast
(size), flush_mode); } -void RelocInfo::set_js_to_wasm_address(Isolate* isolate, Address address, +void RelocInfo::set_js_to_wasm_address(Address address, ICacheFlushMode icache_flush_mode) { DCHECK_EQ(rmode_, JS_TO_WASM_CALL); - set_embedded_address(isolate, address, icache_flush_mode); + set_embedded_address(address, icache_flush_mode); } Address RelocInfo::js_to_wasm_address() const { @@ -240,7 +238,7 @@ void Assembler::AllocateAndInstallRequestedHeapObjects(Isolate* isolate) { } Address pc = buffer_ + request.offset(); Address constant_pool = nullptr; - set_target_address_at(nullptr, pc, constant_pool, + set_target_address_at(pc, constant_pool, reinterpret_cast
(object.location()), SKIP_ICACHE_FLUSH); } @@ -2093,8 +2091,7 @@ void Assembler::EmitRelocations() { } else if (RelocInfo::IsInternalReferenceEncoded(rmode)) { // mov sequence intptr_t pos = reinterpret_cast(target_address_at(pc, nullptr)); - set_target_address_at(nullptr, pc, nullptr, buffer_ + pos, - SKIP_ICACHE_FLUSH); + set_target_address_at(pc, nullptr, buffer_ + pos, SKIP_ICACHE_FLUSH); } reloc_info_writer.Write(&rinfo); diff --git a/src/ppc/assembler-ppc.h b/src/ppc/assembler-ppc.h index f5ad96f379..271c6e69db 100644 --- a/src/ppc/assembler-ppc.h +++ b/src/ppc/assembler-ppc.h @@ -575,7 +575,7 @@ class Assembler : public AssemblerBase { // The isolate argument is unused (and may be nullptr) when skipping flushing. INLINE(static Address target_address_at(Address pc, Address constant_pool)); INLINE(static void set_target_address_at( - Isolate* isolate, Address pc, Address constant_pool, Address target, + Address pc, Address constant_pool, Address target, ICacheFlushMode icache_flush_mode = FLUSH_ICACHE_IF_NEEDED)); // Return the code target address at a call site from the return address @@ -589,12 +589,11 @@ class Assembler : public AssemblerBase { // This sets the branch destination. // This is for calls and branches within generated code. inline static void deserialization_set_special_target_at( - Isolate* isolate, Address instruction_payload, Code* code, - Address target); + Address instruction_payload, Code* code, Address target); // This sets the internal reference at the pc. inline static void deserialization_set_target_internal_reference_at( - Isolate* isolate, Address pc, Address target, + Address pc, Address target, RelocInfo::Mode mode = RelocInfo::INTERNAL_REFERENCE); // Size of an instruction. diff --git a/src/s390/assembler-s390-inl.h b/src/s390/assembler-s390-inl.h index 223805c5db..eac58186d5 100644 --- a/src/s390/assembler-s390-inl.h +++ b/src/s390/assembler-s390-inl.h @@ -70,8 +70,8 @@ void RelocInfo::apply(intptr_t delta) { // mov sequence DCHECK(IsInternalReferenceEncoded(rmode_)); Address target = Assembler::target_address_at(pc_, constant_pool_); - Assembler::set_target_address_at(nullptr, pc_, constant_pool_, - target + delta, SKIP_ICACHE_FLUSH); + Assembler::set_target_address_at(pc_, constant_pool_, target + delta, + SKIP_ICACHE_FLUSH); } } @@ -159,7 +159,7 @@ void RelocInfo::set_target_object(HeapObject* target, WriteBarrierMode write_barrier_mode, ICacheFlushMode icache_flush_mode) { DCHECK(IsCodeTarget(rmode_) || rmode_ == EMBEDDED_OBJECT); - Assembler::set_target_address_at(target->GetIsolate(), pc_, constant_pool_, + Assembler::set_target_address_at(pc_, constant_pool_, reinterpret_cast
(target), icache_flush_mode); if (write_barrier_mode == UPDATE_WRITE_BARRIER && host() != nullptr) { @@ -179,15 +179,15 @@ Address RelocInfo::target_runtime_entry(Assembler* origin) { return target_address(); } -void RelocInfo::set_target_runtime_entry(Isolate* isolate, Address target, +void RelocInfo::set_target_runtime_entry(Address target, WriteBarrierMode write_barrier_mode, ICacheFlushMode icache_flush_mode) { DCHECK(IsRuntimeEntry(rmode_)); if (target_address() != target) - set_target_address(isolate, target, write_barrier_mode, icache_flush_mode); + set_target_address(target, write_barrier_mode, icache_flush_mode); } -void RelocInfo::WipeOut(Isolate* isolate) { +void RelocInfo::WipeOut() { DCHECK(IsEmbeddedObject(rmode_) || IsCodeTarget(rmode_) || IsRuntimeEntry(rmode_) || IsExternalReference(rmode_) || IsInternalReference(rmode_) || IsInternalReferenceEncoded(rmode_)); @@ -197,10 +197,10 @@ void RelocInfo::WipeOut(Isolate* isolate) { } else if (IsInternalReferenceEncoded(rmode_)) { // mov sequence // Currently used only by deserializer, no need to flush. - Assembler::set_target_address_at(isolate, pc_, constant_pool_, nullptr, + Assembler::set_target_address_at(pc_, constant_pool_, nullptr, SKIP_ICACHE_FLUSH); } else { - Assembler::set_target_address_at(isolate, pc_, constant_pool_, nullptr); + Assembler::set_target_address_at(pc_, constant_pool_, nullptr); } } @@ -281,26 +281,24 @@ Address Assembler::target_address_at(Address pc, Address constant_pool) { // has already deserialized the mov instructions etc. // There is a FIXED_SEQUENCE assumption here void Assembler::deserialization_set_special_target_at( - Isolate* isolate, Address instruction_payload, Code* code, Address target) { - set_target_address_at(isolate, instruction_payload, + Address instruction_payload, Code* code, Address target) { + set_target_address_at(instruction_payload, code ? code->constant_pool() : nullptr, target); } void Assembler::deserialization_set_target_internal_reference_at( - Isolate* isolate, Address pc, Address target, RelocInfo::Mode mode) { + Address pc, Address target, RelocInfo::Mode mode) { if (RelocInfo::IsInternalReferenceEncoded(mode)) { - set_target_address_at(isolate, pc, nullptr, target, SKIP_ICACHE_FLUSH); + set_target_address_at(pc, nullptr, target, SKIP_ICACHE_FLUSH); } else { Memory::Address_at(pc) = target; } } // This code assumes the FIXED_SEQUENCE of IIHF/IILF -void Assembler::set_target_address_at(Isolate* isolate, Address pc, - Address constant_pool, Address target, +void Assembler::set_target_address_at(Address pc, Address constant_pool, + Address target, ICacheFlushMode icache_flush_mode) { - DCHECK_IMPLIES(isolate == nullptr, icache_flush_mode == SKIP_ICACHE_FLUSH); - // Check for instructions generated by Asm::mov() Opcode op1 = Instruction::S390OpcodeValue(reinterpret_cast(pc)); SixByteInstr instr_1 = diff --git a/src/s390/assembler-s390.cc b/src/s390/assembler-s390.cc index 166da1c451..56870fd7c0 100644 --- a/src/s390/assembler-s390.cc +++ b/src/s390/assembler-s390.cc @@ -279,22 +279,20 @@ uint32_t RelocInfo::embedded_size() const { Assembler::target_address_at(pc_, constant_pool_))); } -void RelocInfo::set_embedded_address(Isolate* isolate, Address address, +void RelocInfo::set_embedded_address(Address address, ICacheFlushMode flush_mode) { - Assembler::set_target_address_at(isolate, pc_, constant_pool_, address, - flush_mode); + Assembler::set_target_address_at(pc_, constant_pool_, address, flush_mode); } -void RelocInfo::set_embedded_size(Isolate* isolate, uint32_t size, - ICacheFlushMode flush_mode) { - Assembler::set_target_address_at(isolate, pc_, constant_pool_, +void RelocInfo::set_embedded_size(uint32_t size, ICacheFlushMode flush_mode) { + Assembler::set_target_address_at(pc_, constant_pool_, reinterpret_cast
(size), flush_mode); } -void RelocInfo::set_js_to_wasm_address(Isolate* isolate, Address address, +void RelocInfo::set_js_to_wasm_address(Address address, ICacheFlushMode icache_flush_mode) { DCHECK_EQ(rmode_, JS_TO_WASM_CALL); - set_embedded_address(isolate, address, icache_flush_mode); + set_embedded_address(address, icache_flush_mode); } Address RelocInfo::js_to_wasm_address() const { @@ -336,7 +334,7 @@ void Assembler::AllocateAndInstallRequestedHeapObjects(Isolate* isolate) { case HeapObjectRequest::kHeapNumber: object = isolate->factory()->NewHeapNumber(request.heap_number(), IMMUTABLE, TENURED); - set_target_address_at(nullptr, pc, static_cast
(nullptr), + set_target_address_at(pc, static_cast
(nullptr), reinterpret_cast
(object.location()), SKIP_ICACHE_FLUSH); break; @@ -2224,8 +2222,7 @@ void Assembler::EmitRelocations() { } else if (RelocInfo::IsInternalReferenceEncoded(rmode)) { // mov sequence intptr_t pos = reinterpret_cast(target_address_at(pc, nullptr)); - set_target_address_at(nullptr, pc, nullptr, buffer_ + pos, - SKIP_ICACHE_FLUSH); + set_target_address_at(pc, nullptr, buffer_ + pos, SKIP_ICACHE_FLUSH); } reloc_info_writer.Write(&rinfo); diff --git a/src/s390/assembler-s390.h b/src/s390/assembler-s390.h index 3c993de594..b0cc5b8cc4 100644 --- a/src/s390/assembler-s390.h +++ b/src/s390/assembler-s390.h @@ -549,7 +549,7 @@ class Assembler : public AssemblerBase { // The isolate argument is unused (and may be nullptr) when skipping flushing. INLINE(static Address target_address_at(Address pc, Address constant_pool)); INLINE(static void set_target_address_at( - Isolate* isolate, Address pc, Address constant_pool, Address target, + Address pc, Address constant_pool, Address target, ICacheFlushMode icache_flush_mode = FLUSH_ICACHE_IF_NEEDED)); // Return the code target address at a call site from the return address @@ -564,12 +564,11 @@ class Assembler : public AssemblerBase { // This sets the branch destination. // This is for calls and branches within generated code. inline static void deserialization_set_special_target_at( - Isolate* isolate, Address instruction_payload, Code* code, - Address target); + Address instruction_payload, Code* code, Address target); // This sets the internal reference at the pc. inline static void deserialization_set_target_internal_reference_at( - Isolate* isolate, Address pc, Address target, + Address pc, Address target, RelocInfo::Mode mode = RelocInfo::INTERNAL_REFERENCE); // Here we are patching the address in the IIHF/IILF instruction pair. diff --git a/src/snapshot/deserializer.cc b/src/snapshot/deserializer.cc index 21c89f2c37..81fcd71c97 100644 --- a/src/snapshot/deserializer.cc +++ b/src/snapshot/deserializer.cc @@ -480,9 +480,9 @@ bool Deserializer::ReadData(Object** current, Object** limit, Address pc = code->entry() + pc_offset; Address target = code->entry() + target_offset; Assembler::deserialization_set_target_internal_reference_at( - isolate, pc, target, data == kInternalReference - ? RelocInfo::INTERNAL_REFERENCE - : RelocInfo::INTERNAL_REFERENCE_ENCODED); + pc, target, + data == kInternalReference ? RelocInfo::INTERNAL_REFERENCE + : RelocInfo::INTERNAL_REFERENCE_ENCODED); break; } @@ -746,7 +746,7 @@ Object** Deserializer::ReadDataCase(Isolate* isolate, if (how == kFromCode) { Address location_of_branch_data = reinterpret_cast
(current); Assembler::deserialization_set_special_target_at( - isolate, location_of_branch_data, + location_of_branch_data, Code::cast(HeapObject::FromAddress(current_object_address)), reinterpret_cast
(new_object)); location_of_branch_data += Assembler::kSpecialTargetSize; diff --git a/src/snapshot/serializer.cc b/src/snapshot/serializer.cc index 87e4fe8fdc..3f510f428d 100644 --- a/src/snapshot/serializer.cc +++ b/src/snapshot/serializer.cc @@ -885,7 +885,7 @@ void Serializer::ObjectSerializer::OutputCode(int size) { RelocInfo::ModeMask(RelocInfo::INTERNAL_REFERENCE_ENCODED); for (RelocIterator it(code, mode_mask); !it.done(); it.next()) { RelocInfo* rinfo = it.rinfo(); - rinfo->WipeOut(serializer_->isolate()); + rinfo->WipeOut(); } // We need to wipe out the header fields *after* wiping out the // relocations, because some of these fields are needed for the latter. diff --git a/src/wasm/module-compiler.cc b/src/wasm/module-compiler.cc index d7dbcef42f..e9a83fbb1f 100644 --- a/src/wasm/module-compiler.cc +++ b/src/wasm/module-compiler.cc @@ -262,7 +262,7 @@ class JSToWasmWrapperCache { target->builtin_index() == Builtins::kIllegal || target->builtin_index() == Builtins::kWasmCompileLazy) { it.rinfo()->set_target_address( - isolate, wasm_code.GetCode()->instruction_start()); + wasm_code.GetCode()->instruction_start()); break; } } @@ -271,9 +271,9 @@ class JSToWasmWrapperCache { RelocInfo::ModeMask(RelocInfo::JS_TO_WASM_CALL)); DCHECK(!it.done()); it.rinfo()->set_js_to_wasm_address( - isolate, wasm_code.is_null() - ? nullptr - : wasm_code.GetWasmCode()->instructions().start()); + wasm_code.is_null() + ? nullptr + : wasm_code.GetWasmCode()->instructions().start()); } return code; } @@ -862,8 +862,7 @@ const WasmCode* WasmExtractWasmToWasmCallee(const WasmCodeManager* code_manager, ->code_manager() \ ->GetCodeFromStartAddress(it.rinfo()->js_to_wasm_address()) \ ->kind()); \ - it.rinfo()->set_js_to_wasm_address(isolate, \ - new_target->instructions().start()); \ + it.rinfo()->set_js_to_wasm_address(new_target->instructions().start()); \ it.next(); \ DCHECK(it.done()); \ } while (0) @@ -877,7 +876,7 @@ void PatchWasmToWasmWrapper(Isolate* isolate, Code* wasm_to_wasm, DCHECK_EQ(Builtins::kWasmCompileLazy, Code::GetCodeFromTargetAddress(it.rinfo()->target_address()) ->builtin_index()); - it.rinfo()->set_target_address(isolate, new_target->instruction_start()); + it.rinfo()->set_target_address(new_target->instruction_start()); #ifdef DEBUG it.next(); DCHECK(it.done()); @@ -1022,8 +1021,7 @@ Handle LazyCompilationOrchestrator::CompileLazyOnGCHeap( continue; } DCHECK_EQ(Code::WASM_FUNCTION, callee_compiled->kind()); - it.rinfo()->set_target_address(isolate, - callee_compiled->instruction_start()); + it.rinfo()->set_target_address(callee_compiled->instruction_start()); ++patched; } DCHECK_EQ(non_compiled_functions.size(), idx); @@ -1070,7 +1068,7 @@ const wasm::WasmCode* LazyCompilationOrchestrator::CompileFromJsToWasm( ->GetCodeFromStartAddress(it.rinfo()->js_to_wasm_address()) ->kind()); it.rinfo()->set_js_to_wasm_address( - isolate, callee_compiled->instructions().start()); + callee_compiled->instructions().start()); ++patched; } DCHECK_LT(0, patched); @@ -1212,7 +1210,7 @@ const wasm::WasmCode* LazyCompilationOrchestrator::CompileDirectCall( ->GetCodeFromStartAddress(it.rinfo()->wasm_call_address()) ->kind()); it.rinfo()->set_wasm_call_address( - isolate, callee_compiled->instructions().start()); + callee_compiled->instructions().start()); ++patched; } DCHECK_EQ(non_compiled_functions.size(), idx); diff --git a/src/wasm/wasm-code-manager.cc b/src/wasm/wasm-code-manager.cc index 2821450f78..c35af7a8e1 100644 --- a/src/wasm/wasm-code-manager.cc +++ b/src/wasm/wasm-code-manager.cc @@ -70,7 +70,7 @@ void PatchTrampolineAndStubCalls( #else Address new_target = old_target; #endif - it.rinfo()->set_target_address(nullptr, new_target, SKIP_WRITE_BARRIER, + it.rinfo()->set_target_address(new_target, SKIP_WRITE_BARRIER, SKIP_ICACHE_FLUSH); } } @@ -415,8 +415,7 @@ WasmCode* NativeModule::AddAnonymousCode(Handle code, if (RelocInfo::IsCodeTarget(it.rinfo()->rmode())) { Code* call_target = Code::GetCodeFromTargetAddress(orig_it.rinfo()->target_address()); - it.rinfo()->set_target_address(nullptr, - GetLocalAddressFor(handle(call_target)), + it.rinfo()->set_target_address(GetLocalAddressFor(handle(call_target)), SKIP_WRITE_BARRIER, SKIP_ICACHE_FLUSH); } else { if (RelocInfo::IsEmbeddedObject(it.rinfo()->rmode())) { @@ -471,12 +470,12 @@ WasmCode* NativeModule::AddCode( // code object Handle p = it.rinfo()->target_object_handle(origin); Code* code = Code::cast(*p); - it.rinfo()->set_target_address(nullptr, GetLocalAddressFor(handle(code)), + it.rinfo()->set_target_address(GetLocalAddressFor(handle(code)), SKIP_WRITE_BARRIER, SKIP_ICACHE_FLUSH); } else if (RelocInfo::IsRuntimeEntry(mode)) { Address p = it.rinfo()->target_runtime_entry(origin); - it.rinfo()->set_target_runtime_entry( - origin->isolate(), p, SKIP_WRITE_BARRIER, SKIP_ICACHE_FLUSH); + it.rinfo()->set_target_runtime_entry(p, SKIP_WRITE_BARRIER, + SKIP_ICACHE_FLUSH); } else { intptr_t delta = ret->instructions().start() - desc.buffer; it.rinfo()->apply(delta); @@ -564,7 +563,7 @@ void NativeModule::Link(uint32_t index) { if (target == nullptr) continue; Address target_addr = target->instructions().start(); DCHECK_NOT_NULL(target); - it.rinfo()->set_wasm_call_address(nullptr, target_addr, + it.rinfo()->set_wasm_call_address(target_addr, ICacheFlushMode::SKIP_ICACHE_FLUSH); } } @@ -1036,8 +1035,8 @@ void SetWasmCalleeTag(RelocInfo* rinfo, uint32_t tag) { #if V8_TARGET_ARCH_X64 || V8_TARGET_ARCH_IA32 *(reinterpret_cast(rinfo->target_address_address())) = tag; #else - rinfo->set_target_address(nullptr, reinterpret_cast
(tag), - SKIP_WRITE_BARRIER, SKIP_ICACHE_FLUSH); + rinfo->set_target_address(reinterpret_cast
(tag), SKIP_WRITE_BARRIER, + SKIP_ICACHE_FLUSH); #endif } diff --git a/src/wasm/wasm-code-specialization.cc b/src/wasm/wasm-code-specialization.cc index e483b6a23a..f261f44991 100644 --- a/src/wasm/wasm-code-specialization.cc +++ b/src/wasm/wasm-code-specialization.cc @@ -83,8 +83,7 @@ bool IsAtWasmDirectCallTarget(RelocIterator& it) { } // namespace -CodeSpecialization::CodeSpecialization(Isolate* isolate, Zone* zone) - : isolate_(isolate) {} +CodeSpecialization::CodeSpecialization(Isolate* isolate, Zone* zone) {} CodeSpecialization::~CodeSpecialization() {} @@ -172,24 +171,23 @@ bool CodeSpecialization::ApplyToWholeInstance( RelocInfo::Mode mode = it.rinfo()->rmode(); switch (mode) { case RelocInfo::WASM_CONTEXT_REFERENCE: - it.rinfo()->set_wasm_context_reference(export_wrapper->GetIsolate(), - new_wasm_context_address_, + it.rinfo()->set_wasm_context_reference(new_wasm_context_address_, icache_flush_mode); break; case RelocInfo::JS_TO_WASM_CALL: { DCHECK(FLAG_wasm_jit_to_native); const WasmCode* new_code = native_module->GetCode(exp.index); - it.rinfo()->set_js_to_wasm_address( - nullptr, new_code->instructions().start(), SKIP_ICACHE_FLUSH); + it.rinfo()->set_js_to_wasm_address(new_code->instructions().start(), + SKIP_ICACHE_FLUSH); } break; case RelocInfo::CODE_TARGET: { DCHECK(!FLAG_wasm_jit_to_native); // Ignore calls to other builtins like ToNumber. if (!IsAtWasmDirectCallTarget(it)) continue; Code* new_code = Code::cast(code_table->get(exp.index)); - it.rinfo()->set_target_address( - new_code->GetIsolate(), new_code->instruction_start(), - UPDATE_WRITE_BARRIER, SKIP_ICACHE_FLUSH); + it.rinfo()->set_target_address(new_code->instruction_start(), + UPDATE_WRITE_BARRIER, + SKIP_ICACHE_FLUSH); } break; default: UNREACHABLE(); @@ -266,8 +264,7 @@ bool CodeSpecialization::ApplyToWasmCode(WasmCodeWrapper code, FixedArray* code_table = relocate_direct_calls_instance_->compiled_module()->code_table(); Code* new_code = Code::cast(code_table->get(called_func_index)); - it.rinfo()->set_target_address(new_code->GetIsolate(), - new_code->instruction_start(), + it.rinfo()->set_target_address(new_code->instruction_start(), UPDATE_WRITE_BARRIER, icache_flush_mode); changed = true; } break; @@ -291,8 +288,8 @@ bool CodeSpecialization::ApplyToWasmCode(WasmCodeWrapper code, patch_direct_calls_helper->decoder, patch_direct_calls_helper->func_bytes + byte_pos); const WasmCode* new_code = native_module->GetCode(called_func_index); - it.rinfo()->set_wasm_call_address( - isolate_, new_code->instructions().start(), icache_flush_mode); + it.rinfo()->set_wasm_call_address(new_code->instructions().start(), + icache_flush_mode); changed = true; } break; case RelocInfo::WASM_GLOBAL_HANDLE: { @@ -301,14 +298,14 @@ bool CodeSpecialization::ApplyToWasmCode(WasmCodeWrapper code, auto entry = pointers_to_relocate_.find(old_ptr); if (entry != pointers_to_relocate_.end()) { Address new_ptr = entry->second; - it.rinfo()->set_global_handle(isolate_, new_ptr, icache_flush_mode); + it.rinfo()->set_global_handle(new_ptr, icache_flush_mode); changed = true; } } break; case RelocInfo::WASM_FUNCTION_TABLE_SIZE_REFERENCE: DCHECK(patch_table_size); it.rinfo()->update_wasm_function_table_size_reference( - isolate_, old_function_table_size_, new_function_table_size_, + old_function_table_size_, new_function_table_size_, icache_flush_mode); changed = true; break; diff --git a/src/wasm/wasm-code-specialization.h b/src/wasm/wasm-code-specialization.h index 851e8502f7..bed565cf05 100644 --- a/src/wasm/wasm-code-specialization.h +++ b/src/wasm/wasm-code-specialization.h @@ -47,7 +47,6 @@ class CodeSpecialization { ICacheFlushMode = FLUSH_ICACHE_IF_NEEDED); private: - Isolate* isolate_; Address new_wasm_context_address_ = 0; uint32_t old_function_table_size_ = 0; diff --git a/src/wasm/wasm-debug.cc b/src/wasm/wasm-debug.cc index b0d0122178..24fcd3e4ac 100644 --- a/src/wasm/wasm-debug.cc +++ b/src/wasm/wasm-debug.cc @@ -588,8 +588,7 @@ void RedirectCallsitesInCodeGC(Code* code, CodeRelocationMapGC& map) { Code* target = Code::GetCodeFromTargetAddress(it.rinfo()->target_address()); Handle* new_target = map.Find(target); if (!new_target) continue; - it.rinfo()->set_target_address(code->GetIsolate(), - (*new_target)->instruction_start()); + it.rinfo()->set_target_address((*new_target)->instruction_start()); } } @@ -603,7 +602,7 @@ void RedirectCallsitesInCode(Isolate* isolate, const wasm::WasmCode* code, Address target = it.rinfo()->target_address(); auto new_target = map->find(target); if (new_target == map->end()) continue; - it.rinfo()->set_wasm_call_address(isolate, new_target->second); + it.rinfo()->set_wasm_call_address(new_target->second); } } @@ -615,7 +614,7 @@ void RedirectCallsitesInJSWrapperCode(Isolate* isolate, Code* code, Address target = it.rinfo()->js_to_wasm_address(); auto new_target = map->find(target); if (new_target == map->end()) continue; - it.rinfo()->set_js_to_wasm_address(isolate, new_target->second); + it.rinfo()->set_js_to_wasm_address(new_target->second); } } diff --git a/src/wasm/wasm-serialization.cc b/src/wasm/wasm-serialization.cc index 6ed036d9e8..0297e57d2b 100644 --- a/src/wasm/wasm-serialization.cc +++ b/src/wasm/wasm-serialization.cc @@ -633,7 +633,7 @@ bool NativeModuleDeserializer::ReadCode() { case RelocInfo::CODE_TARGET: { uint32_t tag = GetWasmCalleeTag(iter.rinfo()); Address target = GetTrampolineOrStubFromTag(tag); - iter.rinfo()->set_target_address(nullptr, target, SKIP_WRITE_BARRIER, + iter.rinfo()->set_target_address(target, SKIP_WRITE_BARRIER, SKIP_ICACHE_FLUSH); break; } @@ -642,8 +642,8 @@ bool NativeModuleDeserializer::ReadCode() { reinterpret_cast(iter.rinfo()->target_address())); Address address = ExternalReferenceTable::instance(isolate_)->address(orig_target); - iter.rinfo()->set_target_runtime_entry( - nullptr, address, SKIP_WRITE_BARRIER, SKIP_ICACHE_FLUSH); + iter.rinfo()->set_target_runtime_entry(address, SKIP_WRITE_BARRIER, + SKIP_ICACHE_FLUSH); break; } default: diff --git a/src/x64/assembler-x64-inl.h b/src/x64/assembler-x64-inl.h index 7b11c35d25..ee69ffe0cb 100644 --- a/src/x64/assembler-x64-inl.h +++ b/src/x64/assembler-x64-inl.h @@ -265,11 +265,9 @@ Address Assembler::target_address_at(Address pc, Address constant_pool) { return Memory::int32_at(pc) + pc + 4; } - -void Assembler::set_target_address_at(Isolate* isolate, Address pc, - Address constant_pool, Address target, +void Assembler::set_target_address_at(Address pc, Address constant_pool, + Address target, ICacheFlushMode icache_flush_mode) { - DCHECK_IMPLIES(isolate == nullptr, icache_flush_mode == SKIP_ICACHE_FLUSH); Memory::int32_at(pc) = static_cast(target - pc - 4); if (icache_flush_mode != SKIP_ICACHE_FLUSH) { Assembler::FlushICache(pc, sizeof(int32_t)); @@ -277,7 +275,7 @@ void Assembler::set_target_address_at(Isolate* isolate, Address pc, } void Assembler::deserialization_set_target_internal_reference_at( - Isolate* isolate, Address pc, Address target, RelocInfo::Mode mode) { + Address pc, Address target, RelocInfo::Mode mode) { Memory::Address_at(pc) = target; } @@ -287,8 +285,8 @@ Address Assembler::target_address_from_return_address(Address pc) { } void Assembler::deserialization_set_special_target_at( - Isolate* isolate, Address instruction_payload, Code* code, Address target) { - set_target_address_at(isolate, instruction_payload, + Address instruction_payload, Code* code, Address target) { + set_target_address_at(instruction_payload, code ? code->constant_pool() : nullptr, target); } @@ -392,22 +390,22 @@ Address RelocInfo::target_runtime_entry(Assembler* origin) { return origin->runtime_entry_at(pc_); } -void RelocInfo::set_target_runtime_entry(Isolate* isolate, Address target, +void RelocInfo::set_target_runtime_entry(Address target, WriteBarrierMode write_barrier_mode, ICacheFlushMode icache_flush_mode) { DCHECK(IsRuntimeEntry(rmode_)); if (target_address() != target) { - set_target_address(isolate, target, write_barrier_mode, icache_flush_mode); + set_target_address(target, write_barrier_mode, icache_flush_mode); } } -void RelocInfo::WipeOut(Isolate* isolate) { +void RelocInfo::WipeOut() { if (IsEmbeddedObject(rmode_) || IsExternalReference(rmode_) || IsInternalReference(rmode_)) { Memory::Address_at(pc_) = nullptr; } else if (IsCodeTarget(rmode_) || IsRuntimeEntry(rmode_)) { // Effectively write zero into the relocation. - Assembler::set_target_address_at(isolate, pc_, constant_pool_, + Assembler::set_target_address_at(pc_, constant_pool_, pc_ + sizeof(int32_t)); } else { UNREACHABLE(); diff --git a/src/x64/assembler-x64.cc b/src/x64/assembler-x64.cc index 6814b50f13..863e4217b8 100644 --- a/src/x64/assembler-x64.cc +++ b/src/x64/assembler-x64.cc @@ -127,7 +127,7 @@ Address RelocInfo::embedded_address() const { return Memory::Address_at(pc_); } uint32_t RelocInfo::embedded_size() const { return Memory::uint32_at(pc_); } -void RelocInfo::set_embedded_address(Isolate* isolate, Address address, +void RelocInfo::set_embedded_address(Address address, ICacheFlushMode icache_flush_mode) { Memory::Address_at(pc_) = address; if (icache_flush_mode != SKIP_ICACHE_FLUSH) { @@ -135,7 +135,7 @@ void RelocInfo::set_embedded_address(Isolate* isolate, Address address, } } -void RelocInfo::set_embedded_size(Isolate* isolate, uint32_t size, +void RelocInfo::set_embedded_size(uint32_t size, ICacheFlushMode icache_flush_mode) { Memory::uint32_at(pc_) = size; if (icache_flush_mode != SKIP_ICACHE_FLUSH) { @@ -143,10 +143,10 @@ void RelocInfo::set_embedded_size(Isolate* isolate, uint32_t size, } } -void RelocInfo::set_js_to_wasm_address(Isolate* isolate, Address address, +void RelocInfo::set_js_to_wasm_address(Address address, ICacheFlushMode icache_flush_mode) { DCHECK_EQ(rmode_, JS_TO_WASM_CALL); - set_embedded_address(isolate, address, icache_flush_mode); + set_embedded_address(address, icache_flush_mode); } Address RelocInfo::js_to_wasm_address() const { diff --git a/src/x64/assembler-x64.h b/src/x64/assembler-x64.h index 5836376fb2..a48be534c4 100644 --- a/src/x64/assembler-x64.h +++ b/src/x64/assembler-x64.h @@ -475,7 +475,7 @@ class Assembler : public AssemblerBase { // The isolate argument is unused (and may be nullptr) when skipping flushing. static inline Address target_address_at(Address pc, Address constant_pool); static inline void set_target_address_at( - Isolate* isolate, Address pc, Address constant_pool, Address target, + Address pc, Address constant_pool, Address target, ICacheFlushMode icache_flush_mode = FLUSH_ICACHE_IF_NEEDED); // Return the code target address at a call site from the return address @@ -485,12 +485,11 @@ class Assembler : public AssemblerBase { // This sets the branch destination (which is in the instruction on x64). // This is for calls and branches within generated code. inline static void deserialization_set_special_target_at( - Isolate* isolate, Address instruction_payload, Code* code, - Address target); + Address instruction_payload, Code* code, Address target); // This sets the internal reference at the pc. inline static void deserialization_set_target_internal_reference_at( - Isolate* isolate, Address pc, Address target, + Address pc, Address target, RelocInfo::Mode mode = RelocInfo::INTERNAL_REFERENCE); inline Handle code_target_object_handle_at(Address pc); diff --git a/src/x64/codegen-x64.cc b/src/x64/codegen-x64.cc index 52fb1dd83b..ee2cfd5e8b 100644 --- a/src/x64/codegen-x64.cc +++ b/src/x64/codegen-x64.cc @@ -28,7 +28,7 @@ UnaryMathFunctionWithIsolate CreateSqrtFunction(Isolate* isolate) { CodeDesc desc; masm.GetCode(isolate, &desc); - DCHECK(!RelocInfo::RequiresRelocation(isolate, desc)); + DCHECK(!RelocInfo::RequiresRelocation(desc)); Assembler::FlushICache(buffer, allocated); CHECK(SetPermissions(buffer, allocated, PageAllocator::kReadExecute)); diff --git a/test/cctest/compiler/test-run-machops.cc b/test/cctest/compiler/test-run-machops.cc index 98ced2470f..0fc4d66e99 100644 --- a/test/cctest/compiler/test-run-machops.cc +++ b/test/cctest/compiler/test-run-machops.cc @@ -6916,7 +6916,7 @@ TEST(Regression6640) { // TODO(6792): No longer needed once WebAssembly code is off heap. CodeSpaceMemoryModificationScope modification_scope(code->GetHeap()); it.rinfo()->update_wasm_function_table_size_reference( - code->GetIsolate(), old_value, new_value, FLUSH_ICACHE_IF_NEEDED); + old_value, new_value, FLUSH_ICACHE_IF_NEEDED); } CHECK(m.Call()); diff --git a/test/cctest/compiler/test-run-wasm-machops.cc b/test/cctest/compiler/test-run-wasm-machops.cc index e40e2c80ba..30bdad59e6 100644 --- a/test/cctest/compiler/test-run-wasm-machops.cc +++ b/test/cctest/compiler/test-run-wasm-machops.cc @@ -32,8 +32,7 @@ static void UpdateFunctionTableSizeReferences(Handle code, for (RelocIterator it(*code, mode_mask); !it.done(); it.next()) { RelocInfo::Mode mode = it.rinfo()->rmode(); if (RelocInfo::IsWasmFunctionTableSizeReference(mode)) { - it.rinfo()->update_wasm_function_table_size_reference(isolate, old_size, - new_size); + it.rinfo()->update_wasm_function_table_size_reference(old_size, new_size); modified = true; } } diff --git a/test/cctest/test-run-wasm-relocation-arm.cc b/test/cctest/test-run-wasm-relocation-arm.cc index 000cf34c87..69af784c85 100644 --- a/test/cctest/test-run-wasm-relocation-arm.cc +++ b/test/cctest/test-run-wasm-relocation-arm.cc @@ -59,8 +59,7 @@ TEST(WasmRelocationArmContextReference) { CodeSpaceMemoryModificationScope modification_scope(isolate->heap()); DCHECK(RelocInfo::IsWasmContextReference(it.rinfo()->rmode())); it.rinfo()->set_wasm_context_reference( - isolate, it.rinfo()->wasm_context_reference() + offset, - SKIP_ICACHE_FLUSH); + it.rinfo()->wasm_context_reference() + offset, SKIP_ICACHE_FLUSH); } // Call into relocated code object diff --git a/test/cctest/test-run-wasm-relocation-arm64.cc b/test/cctest/test-run-wasm-relocation-arm64.cc index 59f38e1554..7cb24e539f 100644 --- a/test/cctest/test-run-wasm-relocation-arm64.cc +++ b/test/cctest/test-run-wasm-relocation-arm64.cc @@ -64,8 +64,7 @@ TEST(WasmRelocationArm64ContextReference) { CodeSpaceMemoryModificationScope modification_scope(isolate->heap()); DCHECK(RelocInfo::IsWasmContextReference(it.rinfo()->rmode())); it.rinfo()->set_wasm_context_reference( - isolate, it.rinfo()->wasm_context_reference() + offset, - SKIP_ICACHE_FLUSH); + it.rinfo()->wasm_context_reference() + offset, SKIP_ICACHE_FLUSH); } // Call into relocated code object diff --git a/test/cctest/test-run-wasm-relocation-ia32.cc b/test/cctest/test-run-wasm-relocation-ia32.cc index 080da36a47..d9e2cac6ee 100644 --- a/test/cctest/test-run-wasm-relocation-ia32.cc +++ b/test/cctest/test-run-wasm-relocation-ia32.cc @@ -68,8 +68,7 @@ TEST(WasmRelocationIa32ContextReference) { CodeSpaceMemoryModificationScope modification_scope(isolate->heap()); DCHECK(RelocInfo::IsWasmContextReference(it.rinfo()->rmode())); it.rinfo()->set_wasm_context_reference( - isolate, it.rinfo()->wasm_context_reference() + offset, - SKIP_ICACHE_FLUSH); + it.rinfo()->wasm_context_reference() + offset, SKIP_ICACHE_FLUSH); } // Check if immediate is updated correctly diff --git a/test/cctest/test-run-wasm-relocation-x64.cc b/test/cctest/test-run-wasm-relocation-x64.cc index 0526ce25a2..f290920ddc 100644 --- a/test/cctest/test-run-wasm-relocation-x64.cc +++ b/test/cctest/test-run-wasm-relocation-x64.cc @@ -64,8 +64,7 @@ TEST(WasmRelocationX64ContextReference) { CodeSpaceMemoryModificationScope modification_scope(isolate->heap()); DCHECK(RelocInfo::IsWasmContextReference(it.rinfo()->rmode())); it.rinfo()->set_wasm_context_reference( - isolate, it.rinfo()->wasm_context_reference() + offset, - SKIP_ICACHE_FLUSH); + it.rinfo()->wasm_context_reference() + offset, SKIP_ICACHE_FLUSH); } // Check if immediate is updated correctly diff --git a/test/cctest/wasm/test-run-wasm-relocation.cc b/test/cctest/wasm/test-run-wasm-relocation.cc index ccda26cf12..eb7d01b2c4 100644 --- a/test/cctest/wasm/test-run-wasm-relocation.cc +++ b/test/cctest/wasm/test-run-wasm-relocation.cc @@ -50,7 +50,7 @@ WASM_COMPILED_EXEC_TEST(RunPatchWasmContext) { for (RelocIterator it(*code, filter); !it.done(); it.next()) { CHECK_EQ(old_wasm_context_address, it.rinfo()->wasm_context_reference()); it.rinfo()->set_wasm_context_reference( - isolate, reinterpret_cast
(&new_wasm_context)); + reinterpret_cast
(&new_wasm_context)); patched = true; } CHECK(patched);