From 9fc4fc141fa1d1aa1a3ccb901518cdffa0d6d268 Mon Sep 17 00:00:00 2001 From: mlippautz Date: Fri, 11 Sep 2015 05:59:30 -0700 Subject: [PATCH] Make FlushICache part of Assembler(Base) and take Isolate as parameter. BUG=chromium:524425 LOG=N Review URL: https://codereview.chromium.org/1332283002 Cr-Commit-Position: refs/heads/master@{#30695} --- src/arm/assembler-arm-inl.h | 6 +++--- src/arm/code-stubs-arm.h | 4 ++-- src/arm/codegen-arm.cc | 10 +++++----- src/arm/cpu-arm.cc | 19 +++---------------- src/arm/macro-assembler-arm.cc | 2 +- src/arm64/assembler-arm64-inl.h | 2 +- src/arm64/assembler-arm64.h | 2 +- src/arm64/codegen-arm64.cc | 2 +- src/arm64/cpu-arm64.cc | 13 ++----------- src/arm64/simulator-arm64.h | 7 +++++++ src/assembler.cc | 28 +++++++++++++++++++++++++++- src/assembler.h | 5 +++++ src/deoptimizer.cc | 2 +- src/ia32/assembler-ia32-inl.h | 10 +++++----- src/ia32/code-stubs-ia32.h | 2 +- src/ia32/codegen-ia32.cc | 8 ++++---- src/ia32/macro-assembler-ia32.cc | 2 +- src/objects.cc | 4 ++-- src/snapshot/serialize.cc | 9 +++++---- src/x64/assembler-x64-inl.h | 14 +++++++------- src/x64/code-stubs-x64.h | 2 +- src/x64/codegen-x64.cc | 6 +++--- src/x64/macro-assembler-x64.cc | 2 +- test/cctest/test-assembler-arm64.cc | 12 ++++++------ test/cctest/test-code-stubs-arm.cc | 2 +- test/cctest/test-code-stubs-arm64.cc | 2 +- 26 files changed, 97 insertions(+), 80 deletions(-) diff --git a/src/arm/assembler-arm-inl.h b/src/arm/assembler-arm-inl.h index 523000e..8f8956c 100644 --- a/src/arm/assembler-arm-inl.h +++ b/src/arm/assembler-arm-inl.h @@ -622,7 +622,7 @@ void Assembler::set_target_address_at(Address pc, Address constant_pool, Memory::Address_at(constant_pool_entry_address(pc, constant_pool)) = target; // Intuitively, we would think it is necessary to always flush the // instruction cache after patching a target address in the code as follows: - // CpuFeatures::FlushICache(pc, sizeof(target)); + // Assembler::FlushICacheWithoutIsolate(pc, sizeof(target)); // However, on ARM, no instruction is actually patched in the case // of embedded constants of the form: // ldr ip, [pp, #...] @@ -640,7 +640,7 @@ void Assembler::set_target_address_at(Address pc, Address constant_pool, DCHECK(IsMovW(Memory::int32_at(pc))); DCHECK(IsMovT(Memory::int32_at(pc + kInstrSize))); if (icache_flush_mode != SKIP_ICACHE_FLUSH) { - CpuFeatures::FlushICache(pc, 2 * kInstrSize); + Assembler::FlushICacheWithoutIsolate(pc, 2 * kInstrSize); } } else { // This is an mov / orr immediate load. Patch the immediate embedded in @@ -660,7 +660,7 @@ void Assembler::set_target_address_at(Address pc, Address constant_pool, IsOrrImmed(Memory::int32_at(pc + 2 * kInstrSize)) && IsOrrImmed(Memory::int32_at(pc + 3 * kInstrSize))); if (icache_flush_mode != SKIP_ICACHE_FLUSH) { - CpuFeatures::FlushICache(pc, 4 * kInstrSize); + Assembler::FlushICacheWithoutIsolate(pc, 4 * kInstrSize); } } } diff --git a/src/arm/code-stubs-arm.h b/src/arm/code-stubs-arm.h index b2b2c08..e572fd9 100644 --- a/src/arm/code-stubs-arm.h +++ b/src/arm/code-stubs-arm.h @@ -129,8 +129,8 @@ class RecordWriteStub: public PlatformCodeStub { break; } DCHECK(GetMode(stub) == mode); - CpuFeatures::FlushICache(stub->instruction_start(), - 2 * Assembler::kInstrSize); + Assembler::FlushICache(stub->GetIsolate(), stub->instruction_start(), + 2 * Assembler::kInstrSize); } DEFINE_NULL_CALL_INTERFACE_DESCRIPTOR(); diff --git a/src/arm/codegen-arm.cc b/src/arm/codegen-arm.cc index 91bfe2b..97f1034 100644 --- a/src/arm/codegen-arm.cc +++ b/src/arm/codegen-arm.cc @@ -67,7 +67,7 @@ UnaryMathFunction CreateExpFunction() { masm.GetCode(&desc); DCHECK(!RelocInfo::RequiresRelocation(desc)); - CpuFeatures::FlushICache(buffer, actual_size); + Assembler::FlushICacheWithoutIsolate(buffer, actual_size); base::OS::ProtectCode(buffer, actual_size); #if !defined(USE_SIMULATOR) @@ -227,7 +227,7 @@ MemCopyUint8Function CreateMemCopyUint8Function(MemCopyUint8Function stub) { masm.GetCode(&desc); DCHECK(!RelocInfo::RequiresRelocation(desc)); - CpuFeatures::FlushICache(buffer, actual_size); + Assembler::FlushICacheWithoutIsolate(buffer, actual_size); base::OS::ProtectCode(buffer, actual_size); return FUNCTION_CAST(buffer); #endif @@ -314,7 +314,7 @@ MemCopyUint16Uint8Function CreateMemCopyUint16Uint8Function( CodeDesc desc; masm.GetCode(&desc); - CpuFeatures::FlushICache(buffer, actual_size); + Assembler::FlushICacheWithoutIsolate(buffer, actual_size); base::OS::ProtectCode(buffer, actual_size); return FUNCTION_CAST(buffer); @@ -342,7 +342,7 @@ UnaryMathFunction CreateSqrtFunction() { masm.GetCode(&desc); DCHECK(!RelocInfo::RequiresRelocation(desc)); - CpuFeatures::FlushICache(buffer, actual_size); + Assembler::FlushICacheWithoutIsolate(buffer, actual_size); base::OS::ProtectCode(buffer, actual_size); return FUNCTION_CAST(buffer); #endif @@ -934,7 +934,7 @@ void Code::PatchPlatformCodeAge(Isolate* isolate, uint32_t young_length = isolate->code_aging_helper()->young_sequence_length(); if (age == kNoAgeCodeAge) { isolate->code_aging_helper()->CopyYoungSequenceTo(sequence); - CpuFeatures::FlushICache(sequence, young_length); + Assembler::FlushICache(isolate, sequence, young_length); } else { Code* stub = GetCodeAgeStub(isolate, age, parity); CodePatcher patcher(sequence, young_length / Assembler::kInstrSize); diff --git a/src/arm/cpu-arm.cc b/src/arm/cpu-arm.cc index f291ba9..f5d2ab1 100644 --- a/src/arm/cpu-arm.cc +++ b/src/arm/cpu-arm.cc @@ -16,28 +16,14 @@ #include "src/assembler.h" #include "src/macro-assembler.h" -#include "src/simulator.h" // for cache flushing. namespace v8 { namespace internal { - void CpuFeatures::FlushICache(void* start, size_t size) { - if (size == 0) return; - - if (CpuFeatures::IsSupported(COHERENT_CACHE)) return; - -#if defined(USE_SIMULATOR) - // Not generating ARM instructions for C-code. This means that we are - // building an ARM emulator based target. We should notify the simulator - // that the Icache was flushed. - // None of this code ends up in the snapshot so there are no issues - // around whether or not to generate the code when building snapshots. - Simulator::FlushICache(Isolate::Current()->simulator_i_cache(), start, size); - -#elif V8_OS_QNX +#if !defined(USE_SIMULATOR) +#if V8_OS_QNX msync(start, size, MS_SYNC | MS_INVALIDATE_ICACHE); - #else register uint32_t beg asm("r0") = reinterpret_cast(start); register uint32_t end asm("r1") = beg + size; @@ -73,6 +59,7 @@ void CpuFeatures::FlushICache(void* start, size_t size) { : "memory"); #endif #endif +#endif // !USE_SIMULATOR } } // namespace internal diff --git a/src/arm/macro-assembler-arm.cc b/src/arm/macro-assembler-arm.cc index c0b9773..2d8b298 100644 --- a/src/arm/macro-assembler-arm.cc +++ b/src/arm/macro-assembler-arm.cc @@ -3747,7 +3747,7 @@ CodePatcher::CodePatcher(byte* address, CodePatcher::~CodePatcher() { // Indicate that code has changed. if (flush_cache_ == FLUSH) { - CpuFeatures::FlushICache(address_, size_); + Assembler::FlushICacheWithoutIsolate(address_, size_); } // Check that the code was patched as expected. diff --git a/src/arm64/assembler-arm64-inl.h b/src/arm64/assembler-arm64-inl.h index 3fbb091..f02207f 100644 --- a/src/arm64/assembler-arm64-inl.h +++ b/src/arm64/assembler-arm64-inl.h @@ -665,7 +665,7 @@ void Assembler::set_target_address_at(Address pc, Address constant_pool, Memory::Address_at(target_pointer_address_at(pc)) = target; // Intuitively, we would think it is necessary to always flush the // instruction cache after patching a target address in the code as follows: - // CpuFeatures::FlushICache(pc, sizeof(target)); + // Assembler::FlushICacheWithoutIsolate(pc, sizeof(target)); // However, on ARM, an instruction is actually patched in the case of // embedded constants of the form: // ldr ip, [pc, #...] diff --git a/src/arm64/assembler-arm64.h b/src/arm64/assembler-arm64.h index a7e5a06..f20be83 100644 --- a/src/arm64/assembler-arm64.h +++ b/src/arm64/assembler-arm64.h @@ -2279,7 +2279,7 @@ class PatchingAssembler : public Assembler { DCHECK(IsConstPoolEmpty()); // Flush the Instruction cache. size_t length = buffer_size_ - kGap; - CpuFeatures::FlushICache(buffer_, length); + Assembler::FlushICacheWithoutIsolate(buffer_, length); } // See definition of PatchAdrFar() for details. diff --git a/src/arm64/codegen-arm64.cc b/src/arm64/codegen-arm64.cc index 6efe84c..8e927bf 100644 --- a/src/arm64/codegen-arm64.cc +++ b/src/arm64/codegen-arm64.cc @@ -64,7 +64,7 @@ UnaryMathFunction CreateExpFunction() { masm.GetCode(&desc); DCHECK(!RelocInfo::RequiresRelocation(desc)); - CpuFeatures::FlushICache(buffer, actual_size); + Assembler::FlushICacheWithoutIsolate(buffer, actual_size); base::OS::ProtectCode(buffer, actual_size); #if !defined(USE_SIMULATOR) diff --git a/src/arm64/cpu-arm64.cc b/src/arm64/cpu-arm64.cc index 57180b5..cf2cc57 100644 --- a/src/arm64/cpu-arm64.cc +++ b/src/arm64/cpu-arm64.cc @@ -39,16 +39,7 @@ class CacheLineSizes { void CpuFeatures::FlushICache(void* address, size_t length) { - if (length == 0) return; - - if (CpuFeatures::IsSupported(COHERENT_CACHE)) return; - -#ifdef USE_SIMULATOR - // TODO(all): consider doing some cache simulation to ensure every address - // run has been synced. - USE(address); - USE(length); -#else +#ifdef V8_HOST_ARCH_ARM64 // The code below assumes user space cache operations are allowed. The goal // of this routine is to make sure the code generated is visible to the I // side of the CPU. @@ -115,7 +106,7 @@ void CpuFeatures::FlushICache(void* address, size_t length) { // move this code before the code is generated. : "cc", "memory" ); // NOLINT -#endif +#endif // V8_HOST_ARCH_ARM64 } } // namespace internal diff --git a/src/arm64/simulator-arm64.h b/src/arm64/simulator-arm64.h index 6ff0013..d456bd9 100644 --- a/src/arm64/simulator-arm64.h +++ b/src/arm64/simulator-arm64.h @@ -151,6 +151,13 @@ typedef SimRegisterBase SimFPRegister; // v0-v31 class Simulator : public DecoderVisitor { public: + static void FlushICache(v8::internal::HashMap* i_cache, void* start, + size_t size) { + USE(i_cache); + USE(start); + USE(size); + } + explicit Simulator(Decoder* decoder, Isolate* isolate = NULL, FILE* stream = stderr); diff --git a/src/assembler.cc b/src/assembler.cc index aabc64b..e2e1024 100644 --- a/src/assembler.cc +++ b/src/assembler.cc @@ -54,6 +54,7 @@ #include "src/regexp/regexp-macro-assembler.h" #include "src/regexp/regexp-stack.h" #include "src/runtime/runtime.h" +#include "src/simulator.h" // For flushing instruction cache. #include "src/snapshot/serialize.h" #include "src/token.h" @@ -155,6 +156,31 @@ AssemblerBase::~AssemblerBase() { } +void AssemblerBase::FlushICache(Isolate* isolate, void* start, size_t size) { + if (size == 0) return; + if (CpuFeatures::IsSupported(COHERENT_CACHE)) return; + +#if defined(USE_SIMULATOR) + Simulator::FlushICache(isolate->simulator_i_cache(), start, size); +#else + CpuFeatures::FlushICache(start, size); +#endif // USE_SIMULATOR +} + + +void AssemblerBase::FlushICacheWithoutIsolate(void* start, size_t size) { + // Ideally we would just call Isolate::Current() here. However, this flushes + // out issues because we usually only need the isolate when in the simulator. + Isolate* isolate; +#if defined(USE_SIMULATOR) + isolate = Isolate::Current(); +#else + isolate = nullptr; +#endif // USE_SIMULATOR + FlushICache(isolate, start, size); +} + + // ----------------------------------------------------------------------------- // Implementation of PredictableCodeSizeScope @@ -1024,7 +1050,7 @@ ExternalReference ExternalReference:: ExternalReference ExternalReference::flush_icache_function(Isolate* isolate) { return ExternalReference( - Redirect(isolate, FUNCTION_ADDR(CpuFeatures::FlushICache))); + Redirect(isolate, FUNCTION_ADDR(Assembler::FlushICacheWithoutIsolate))); } diff --git a/src/assembler.h b/src/assembler.h index a4c19e6..9bfda36 100644 --- a/src/assembler.h +++ b/src/assembler.h @@ -101,6 +101,11 @@ class AssemblerBase: public Malloced { static const int kMinimalBufferSize = 4*KB; + static void FlushICache(Isolate* isolate, void* start, size_t size); + + // TODO(all): Help get rid of this one. + static void FlushICacheWithoutIsolate(void* start, size_t size); + protected: // The buffer into which code and relocation info are generated. It could // either be owned by the assembler or be provided externally. diff --git a/src/deoptimizer.cc b/src/deoptimizer.cc index 490237e..b1f1576 100644 --- a/src/deoptimizer.cc +++ b/src/deoptimizer.cc @@ -1852,7 +1852,7 @@ void Deoptimizer::EnsureCodeForDeoptimizationEntry(Isolate* isolate, } CopyBytes(chunk->area_start(), desc.buffer, static_cast(desc.instr_size)); - CpuFeatures::FlushICache(chunk->area_start(), desc.instr_size); + Assembler::FlushICache(isolate, chunk->area_start(), desc.instr_size); data->deopt_entry_code_entries_[type] = entry_count; } diff --git a/src/ia32/assembler-ia32-inl.h b/src/ia32/assembler-ia32-inl.h index 70b7a67..17ae01a 100644 --- a/src/ia32/assembler-ia32-inl.h +++ b/src/ia32/assembler-ia32-inl.h @@ -133,7 +133,7 @@ void RelocInfo::set_target_object(Object* target, DCHECK(IsCodeTarget(rmode_) || rmode_ == EMBEDDED_OBJECT); Memory::Object_at(pc_) = target; if (icache_flush_mode != SKIP_ICACHE_FLUSH) { - CpuFeatures::FlushICache(pc_, sizeof(Address)); + Assembler::FlushICacheWithoutIsolate(pc_, sizeof(Address)); } if (write_barrier_mode == UPDATE_WRITE_BARRIER && host() != NULL && @@ -199,7 +199,7 @@ void RelocInfo::set_target_cell(Cell* cell, Address address = cell->address() + Cell::kValueOffset; Memory::Address_at(pc_) = address; if (icache_flush_mode != SKIP_ICACHE_FLUSH) { - CpuFeatures::FlushICache(pc_, sizeof(Address)); + Assembler::FlushICacheWithoutIsolate(pc_, sizeof(Address)); } if (write_barrier_mode == UPDATE_WRITE_BARRIER && host() != NULL) { // TODO(1550) We are passing NULL as a slot because cell can never be on @@ -280,7 +280,7 @@ void RelocInfo::Visit(Isolate* isolate, ObjectVisitor* visitor) { RelocInfo::Mode mode = rmode(); if (mode == RelocInfo::EMBEDDED_OBJECT) { visitor->VisitEmbeddedPointer(this); - CpuFeatures::FlushICache(pc_, sizeof(Address)); + Assembler::FlushICacheWithoutIsolate(pc_, sizeof(Address)); } else if (RelocInfo::IsCodeTarget(mode)) { visitor->VisitCodeTarget(this); } else if (mode == RelocInfo::CELL) { @@ -305,7 +305,7 @@ void RelocInfo::Visit(Heap* heap) { RelocInfo::Mode mode = rmode(); if (mode == RelocInfo::EMBEDDED_OBJECT) { StaticVisitor::VisitEmbeddedPointer(heap, this); - CpuFeatures::FlushICache(pc_, sizeof(Address)); + Assembler::FlushICacheWithoutIsolate(pc_, sizeof(Address)); } else if (RelocInfo::IsCodeTarget(mode)) { StaticVisitor::VisitCodeTarget(heap, this); } else if (mode == RelocInfo::CELL) { @@ -459,7 +459,7 @@ void Assembler::set_target_address_at(Address pc, Address constant_pool, int32_t* p = reinterpret_cast(pc); *p = target - (pc + sizeof(int32_t)); if (icache_flush_mode != SKIP_ICACHE_FLUSH) { - CpuFeatures::FlushICache(p, sizeof(int32_t)); + Assembler::FlushICacheWithoutIsolate(p, sizeof(int32_t)); } } diff --git a/src/ia32/code-stubs-ia32.h b/src/ia32/code-stubs-ia32.h index 3aa18f2..c09b27b 100644 --- a/src/ia32/code-stubs-ia32.h +++ b/src/ia32/code-stubs-ia32.h @@ -188,7 +188,7 @@ class RecordWriteStub: public PlatformCodeStub { break; } DCHECK(GetMode(stub) == mode); - CpuFeatures::FlushICache(stub->instruction_start(), 7); + Assembler::FlushICache(stub->GetIsolate(), stub->instruction_start(), 7); } DEFINE_NULL_CALL_INTERFACE_DESCRIPTOR(); diff --git a/src/ia32/codegen-ia32.cc b/src/ia32/codegen-ia32.cc index 21a16f6..93f4cee 100644 --- a/src/ia32/codegen-ia32.cc +++ b/src/ia32/codegen-ia32.cc @@ -65,7 +65,7 @@ UnaryMathFunction CreateExpFunction() { masm.GetCode(&desc); DCHECK(!RelocInfo::RequiresRelocation(desc)); - CpuFeatures::FlushICache(buffer, actual_size); + Assembler::FlushICacheWithoutIsolate(buffer, actual_size); base::OS::ProtectCode(buffer, actual_size); return FUNCTION_CAST(buffer); } @@ -94,7 +94,7 @@ UnaryMathFunction CreateSqrtFunction() { masm.GetCode(&desc); DCHECK(!RelocInfo::RequiresRelocation(desc)); - CpuFeatures::FlushICache(buffer, actual_size); + Assembler::FlushICacheWithoutIsolate(buffer, actual_size); base::OS::ProtectCode(buffer, actual_size); return FUNCTION_CAST(buffer); } @@ -505,7 +505,7 @@ MemMoveFunction CreateMemMoveFunction() { CodeDesc desc; masm.GetCode(&desc); DCHECK(!RelocInfo::RequiresRelocation(desc)); - CpuFeatures::FlushICache(buffer, actual_size); + Assembler::FlushICacheWithoutIsolate(buffer, actual_size); base::OS::ProtectCode(buffer, actual_size); // TODO(jkummerow): It would be nice to register this code creation event // with the PROFILE / GDBJIT system. @@ -1032,7 +1032,7 @@ void Code::PatchPlatformCodeAge(Isolate* isolate, uint32_t young_length = isolate->code_aging_helper()->young_sequence_length(); if (age == kNoAgeCodeAge) { isolate->code_aging_helper()->CopyYoungSequenceTo(sequence); - CpuFeatures::FlushICache(sequence, young_length); + Assembler::FlushICache(isolate, sequence, young_length); } else { Code* stub = GetCodeAgeStub(isolate, age, parity); CodePatcher patcher(sequence, young_length); diff --git a/src/ia32/macro-assembler-ia32.cc b/src/ia32/macro-assembler-ia32.cc index 474bb77..76f763d 100644 --- a/src/ia32/macro-assembler-ia32.cc +++ b/src/ia32/macro-assembler-ia32.cc @@ -2845,7 +2845,7 @@ CodePatcher::CodePatcher(byte* address, int size) CodePatcher::~CodePatcher() { // Indicate that code has changed. - CpuFeatures::FlushICache(address_, size_); + Assembler::FlushICacheWithoutIsolate(address_, size_); // Check that the code was patched as expected. DCHECK(masm_.pc_ == address_ + size_); diff --git a/src/objects.cc b/src/objects.cc index 9bf72a6..50551db 100644 --- a/src/objects.cc +++ b/src/objects.cc @@ -11120,7 +11120,7 @@ void Code::Relocate(intptr_t delta) { for (RelocIterator it(this, RelocInfo::kApplyMask); !it.done(); it.next()) { it.rinfo()->apply(delta); } - CpuFeatures::FlushICache(instruction_start(), instruction_size()); + Assembler::FlushICache(GetIsolate(), instruction_start(), instruction_size()); } @@ -11174,7 +11174,7 @@ void Code::CopyFrom(const CodeDesc& desc) { it.rinfo()->apply(delta); } } - CpuFeatures::FlushICache(instruction_start(), instruction_size()); + Assembler::FlushICache(GetIsolate(), instruction_start(), instruction_size()); } diff --git a/src/snapshot/serialize.cc b/src/snapshot/serialize.cc index d66a397..4866995 100644 --- a/src/snapshot/serialize.cc +++ b/src/snapshot/serialize.cc @@ -122,7 +122,7 @@ ExternalReferenceTable::ExternalReferenceTable(Isolate* isolate) { Add(ExternalReference::invoke_accessor_getter_callback(isolate).address(), "InvokeAccessorGetterCallback"); Add(ExternalReference::flush_icache_function(isolate).address(), - "CpuFeatures::FlushICache"); + "Assembler::FlushICacheWithoutIsolate"); Add(ExternalReference::log_enter_external_function(isolate).address(), "Logger::EnterExternal"); Add(ExternalReference::log_leave_external_function(isolate).address(), @@ -505,7 +505,8 @@ void Deserializer::FlushICacheForNewIsolate() { PageIterator it(isolate_->heap()->code_space()); while (it.has_next()) { Page* p = it.next(); - CpuFeatures::FlushICache(p->area_start(), p->area_end() - p->area_start()); + Assembler::FlushICache(isolate_, p->area_start(), + p->area_end() - p->area_start()); } } @@ -513,8 +514,8 @@ void Deserializer::FlushICacheForNewIsolate() { void Deserializer::FlushICacheForNewCodeObjects() { DCHECK(deserializing_user_code_); for (Code* code : new_code_objects_) { - CpuFeatures::FlushICache(code->instruction_start(), - code->instruction_size()); + Assembler::FlushICache(isolate_, code->instruction_start(), + code->instruction_size()); } } diff --git a/src/x64/assembler-x64-inl.h b/src/x64/assembler-x64-inl.h index 74d5d24..c66e86d 100644 --- a/src/x64/assembler-x64-inl.h +++ b/src/x64/assembler-x64-inl.h @@ -277,7 +277,7 @@ void Assembler::set_target_address_at(Address pc, Address constant_pool, ICacheFlushMode icache_flush_mode) { Memory::int32_at(pc) = static_cast(target - pc - 4); if (icache_flush_mode != SKIP_ICACHE_FLUSH) { - CpuFeatures::FlushICache(pc, sizeof(int32_t)); + Assembler::FlushICacheWithoutIsolate(pc, sizeof(int32_t)); } } @@ -404,7 +404,7 @@ void RelocInfo::set_target_object(Object* target, DCHECK(IsCodeTarget(rmode_) || rmode_ == EMBEDDED_OBJECT); Memory::Object_at(pc_) = target; if (icache_flush_mode != SKIP_ICACHE_FLUSH) { - CpuFeatures::FlushICache(pc_, sizeof(Address)); + Assembler::FlushICacheWithoutIsolate(pc_, sizeof(Address)); } if (write_barrier_mode == UPDATE_WRITE_BARRIER && host() != NULL && @@ -451,7 +451,7 @@ void RelocInfo::set_target_cell(Cell* cell, Address address = cell->address() + Cell::kValueOffset; Memory::Address_at(pc_) = address; if (icache_flush_mode != SKIP_ICACHE_FLUSH) { - CpuFeatures::FlushICache(pc_, sizeof(Address)); + Assembler::FlushICacheWithoutIsolate(pc_, sizeof(Address)); } if (write_barrier_mode == UPDATE_WRITE_BARRIER && host() != NULL) { @@ -527,8 +527,8 @@ void RelocInfo::set_debug_call_address(Address target) { DCHECK(IsDebugBreakSlot(rmode()) && IsPatchedDebugBreakSlotSequence()); Memory::Address_at(pc_ + Assembler::kPatchDebugBreakSlotAddressOffset) = target; - CpuFeatures::FlushICache(pc_ + Assembler::kPatchDebugBreakSlotAddressOffset, - sizeof(Address)); + Assembler::FlushICacheWithoutIsolate( + pc_ + Assembler::kPatchDebugBreakSlotAddressOffset, sizeof(Address)); if (host() != NULL) { Object* target_code = Code::GetCodeFromTargetAddress(target); host()->GetHeap()->incremental_marking()->RecordWriteIntoCode( @@ -541,7 +541,7 @@ void RelocInfo::Visit(Isolate* isolate, ObjectVisitor* visitor) { RelocInfo::Mode mode = rmode(); if (mode == RelocInfo::EMBEDDED_OBJECT) { visitor->VisitEmbeddedPointer(this); - CpuFeatures::FlushICache(pc_, sizeof(Address)); + Assembler::FlushICacheWithoutIsolate(pc_, sizeof(Address)); } else if (RelocInfo::IsCodeTarget(mode)) { visitor->VisitCodeTarget(this); } else if (mode == RelocInfo::CELL) { @@ -566,7 +566,7 @@ void RelocInfo::Visit(Heap* heap) { RelocInfo::Mode mode = rmode(); if (mode == RelocInfo::EMBEDDED_OBJECT) { StaticVisitor::VisitEmbeddedPointer(heap, this); - CpuFeatures::FlushICache(pc_, sizeof(Address)); + Assembler::FlushICache(heap->isolate(), pc_, sizeof(Address)); } else if (RelocInfo::IsCodeTarget(mode)) { StaticVisitor::VisitCodeTarget(heap, this); } else if (mode == RelocInfo::CELL) { diff --git a/src/x64/code-stubs-x64.h b/src/x64/code-stubs-x64.h index 09289cf..1344400 100644 --- a/src/x64/code-stubs-x64.h +++ b/src/x64/code-stubs-x64.h @@ -180,7 +180,7 @@ class RecordWriteStub: public PlatformCodeStub { break; } DCHECK(GetMode(stub) == mode); - CpuFeatures::FlushICache(stub->instruction_start(), 7); + Assembler::FlushICache(stub->GetIsolate(), stub->instruction_start(), 7); } DEFINE_NULL_CALL_INTERFACE_DESCRIPTOR(); diff --git a/src/x64/codegen-x64.cc b/src/x64/codegen-x64.cc index ceb0dd4..4f08c7e 100644 --- a/src/x64/codegen-x64.cc +++ b/src/x64/codegen-x64.cc @@ -58,7 +58,7 @@ UnaryMathFunction CreateExpFunction() { masm.GetCode(&desc); DCHECK(!RelocInfo::RequiresRelocation(desc)); - CpuFeatures::FlushICache(buffer, actual_size); + Assembler::FlushICacheWithoutIsolate(buffer, actual_size); base::OS::ProtectCode(buffer, actual_size); return FUNCTION_CAST(buffer); } @@ -81,7 +81,7 @@ UnaryMathFunction CreateSqrtFunction() { masm.GetCode(&desc); DCHECK(!RelocInfo::RequiresRelocation(desc)); - CpuFeatures::FlushICache(buffer, actual_size); + Assembler::FlushICacheWithoutIsolate(buffer, actual_size); base::OS::ProtectCode(buffer, actual_size); return FUNCTION_CAST(buffer); } @@ -692,7 +692,7 @@ void Code::PatchPlatformCodeAge(Isolate* isolate, uint32_t young_length = isolate->code_aging_helper()->young_sequence_length(); if (age == kNoAgeCodeAge) { isolate->code_aging_helper()->CopyYoungSequenceTo(sequence); - CpuFeatures::FlushICache(sequence, young_length); + Assembler::FlushICache(isolate, sequence, young_length); } else { Code* stub = GetCodeAgeStub(isolate, age, parity); CodePatcher patcher(sequence, young_length); diff --git a/src/x64/macro-assembler-x64.cc b/src/x64/macro-assembler-x64.cc index e3ab7c7..39db8eb 100644 --- a/src/x64/macro-assembler-x64.cc +++ b/src/x64/macro-assembler-x64.cc @@ -4755,7 +4755,7 @@ CodePatcher::CodePatcher(byte* address, int size) CodePatcher::~CodePatcher() { // Indicate that code has changed. - CpuFeatures::FlushICache(address_, size_); + Assembler::FlushICacheWithoutIsolate(address_, size_); // Check that the code was patched as expected. DCHECK(masm_.pc_ == address_ + size_); diff --git a/test/cctest/test-assembler-arm64.cc b/test/cctest/test-assembler-arm64.cc index 3c2f840..9b51185 100644 --- a/test/cctest/test-assembler-arm64.cc +++ b/test/cctest/test-assembler-arm64.cc @@ -191,12 +191,12 @@ static void InitializeVM() { RESET(); \ START_AFTER_RESET(); -#define RUN() \ - CpuFeatures::FlushICache(buf, masm.SizeOfGeneratedCode()); \ - { \ - void (*test_function)(void); \ - memcpy(&test_function, &buf, sizeof(buf)); \ - test_function(); \ +#define RUN() \ + Assembler::FlushICache(isolate, buf, masm.SizeOfGeneratedCode()); \ + { \ + void (*test_function)(void); \ + memcpy(&test_function, &buf, sizeof(buf)); \ + test_function(); \ } #define END() \ diff --git a/test/cctest/test-code-stubs-arm.cc b/test/cctest/test-code-stubs-arm.cc index 8040344..3314544 100644 --- a/test/cctest/test-code-stubs-arm.cc +++ b/test/cctest/test-code-stubs-arm.cc @@ -126,7 +126,7 @@ ConvertDToIFunc MakeConvertDToIFuncTrampoline(Isolate* isolate, CodeDesc desc; masm.GetCode(&desc); - CpuFeatures::FlushICache(buffer, actual_size); + Assembler::FlushICache(isolate, buffer, actual_size); return (reinterpret_cast( reinterpret_cast(buffer))); } diff --git a/test/cctest/test-code-stubs-arm64.cc b/test/cctest/test-code-stubs-arm64.cc index 8b38b96..ecb8819 100644 --- a/test/cctest/test-code-stubs-arm64.cc +++ b/test/cctest/test-code-stubs-arm64.cc @@ -122,7 +122,7 @@ ConvertDToIFunc MakeConvertDToIFuncTrampoline(Isolate* isolate, CodeDesc desc; masm.GetCode(&desc); - CpuFeatures::FlushICache(buffer, actual_size); + Assembler::FlushICache(isolate, buffer, actual_size); return (reinterpret_cast( reinterpret_cast(buffer))); } -- 2.7.4