PPC: Make FlushICache part of Assembler(Base) and take Isolate as parameter.
authormbrandy <mbrandy@us.ibm.com>
Fri, 11 Sep 2015 15:09:56 +0000 (08:09 -0700)
committerCommit bot <commit-bot@chromium.org>
Fri, 11 Sep 2015 15:10:01 +0000 (15:10 +0000)
Port 9fc4fc141fa1d1aa1a3ccb901518cdffa0d6d268

R=mlippautz@chromium.org, joransiu@ca.ibm.com, jyan@ca.ibm.com, michael_dawson@ca.ibm.com, dstence@us.ibm.com
BUG=chromium:524425
LOG=N

Review URL: https://codereview.chromium.org/1339673002

Cr-Commit-Position: refs/heads/master@{#30698}

src/ppc/assembler-ppc-inl.h
src/ppc/code-stubs-ppc.h
src/ppc/codegen-ppc.cc
src/ppc/cpu-ppc.cc
src/ppc/macro-assembler-ppc.cc

index 35968fc682a06ec9814a67fc67336572f34b63d1..b1e2825751906820173e64c66f43c54fcbd72ea2 100644 (file)
@@ -698,7 +698,7 @@ void Assembler::set_target_address_at(Address pc, Address constant_pool,
     *(p + 3) = instr4;
     *(p + 4) = instr5;
     if (icache_flush_mode != SKIP_ICACHE_FLUSH) {
-      CpuFeatures::FlushICache(p, 5 * kInstrSize);
+      Assembler::FlushICacheWithoutIsolate(p, 5 * kInstrSize);
     }
 #else
     uint32_t* p = reinterpret_cast<uint32_t*>(pc);
@@ -713,7 +713,7 @@ void Assembler::set_target_address_at(Address pc, Address constant_pool,
     *p = instr1;
     *(p + 1) = instr2;
     if (icache_flush_mode != SKIP_ICACHE_FLUSH) {
-      CpuFeatures::FlushICache(p, 2 * kInstrSize);
+      Assembler::FlushICacheWithoutIsolate(p, 2 * kInstrSize);
     }
 #endif
     return;
index 85f3c9ca98a104e7d65380cc4db0bf07b9be154c..bc6c26b2172ffb03d1eb5cf02a3ada7d9d8f7830 100644 (file)
@@ -147,8 +147,9 @@ class RecordWriteStub : public PlatformCodeStub {
         break;
     }
     DCHECK(GetMode(stub) == mode);
-    CpuFeatures::FlushICache(stub->instruction_start() + Assembler::kInstrSize,
-                             2 * Assembler::kInstrSize);
+    Assembler::FlushICache(stub->GetIsolate(),
+                           stub->instruction_start() + Assembler::kInstrSize,
+                           2 * Assembler::kInstrSize);
   }
 
   DEFINE_NULL_CALL_INTERFACE_DESCRIPTOR();
index 3032da8b19c1a8301cb6a2aeb4db2d8dd4f3e9a4..b313d11bb319c359b8dbb30d0fd2f0992952c9d3 100644 (file)
@@ -62,7 +62,7 @@ UnaryMathFunction CreateExpFunction() {
   DCHECK(!RelocInfo::RequiresRelocation(desc));
 #endif
 
-  CpuFeatures::FlushICache(buffer, actual_size);
+  Assembler::FlushICacheWithoutIsolate(buffer, actual_size);
   base::OS::ProtectCode(buffer, actual_size);
 
 #if !defined(USE_SIMULATOR)
@@ -99,7 +99,7 @@ UnaryMathFunction CreateSqrtFunction() {
   DCHECK(!RelocInfo::RequiresRelocation(desc));
 #endif
 
-  CpuFeatures::FlushICache(buffer, actual_size);
+  Assembler::FlushICacheWithoutIsolate(buffer, actual_size);
   base::OS::ProtectCode(buffer, actual_size);
   return FUNCTION_CAST<UnaryMathFunction>(buffer);
 #endif
@@ -660,7 +660,7 @@ void Code::PatchPlatformCodeAge(Isolate* isolate, byte* sequence, Code::Age age,
   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 {
     // FIXED_SEQUENCE
     Code* stub = GetCodeAgeStub(isolate, age, parity);
index 079aa23403b280c534e91228cf9a0d7f1abc836d..a42fa53960cddf375ad0966b9d0de29dccacf08c 100644 (file)
@@ -8,26 +8,12 @@
 
 #include "src/assembler.h"
 #include "src/macro-assembler.h"
-#include "src/simulator.h"  // for cache flushing.
 
 namespace v8 {
 namespace internal {
 
 void CpuFeatures::FlushICache(void* buffer, size_t size) {
-  // Nothing to do flushing no instructions.
-  if (size == 0) {
-    return;
-  }
-
-#if defined(USE_SIMULATOR)
-  // Not generating PPC instructions for C-code. This means that we are
-  // building an PPC 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(), buffer, size);
-#else
-
+#if !defined(USE_SIMULATOR)
   if (CpuFeatures::IsSupported(INSTR_AND_DATA_CACHE_COHERENCY)) {
     __asm__ __volatile__(
         "sync \n"
@@ -54,7 +40,7 @@ void CpuFeatures::FlushICache(void* buffer, size_t size) {
         : "r"(pointer));
   }
 
-#endif  // USE_SIMULATOR
+#endif  // !USE_SIMULATOR
 }
 }  // namespace internal
 }  // namespace v8
index af9d261b9e969e91c3c6608cc4cc27ef25adfd0a..d7697f0623eb91951cad3807f3a8bb9a6d455b9a 100644 (file)
@@ -4380,7 +4380,7 @@ CodePatcher::CodePatcher(byte* address, int instructions,
 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.