Revision: 19607
Author:   [email protected]
Date:     Fri Feb 28 12:41:25 2014 UTC
Log: Fail early when re-entering code that has been patched for lazy deopt

[email protected]

Review URL: https://codereview.chromium.org/184373004
http://code.google.com/p/v8/source/detail?r=19607

Modified:
 /branches/bleeding_edge/src/a64/deoptimizer-a64.cc
 /branches/bleeding_edge/src/arm/deoptimizer-arm.cc
 /branches/bleeding_edge/src/ia32/deoptimizer-ia32.cc
 /branches/bleeding_edge/src/mips/deoptimizer-mips.cc
 /branches/bleeding_edge/src/objects.h
 /branches/bleeding_edge/src/x64/deoptimizer-x64.cc

=======================================
--- /branches/bleeding_edge/src/a64/deoptimizer-a64.cc Wed Feb 12 09:19:30 2014 UTC +++ /branches/bleeding_edge/src/a64/deoptimizer-a64.cc Fri Feb 28 12:41:25 2014 UTC
@@ -50,6 +50,9 @@
   // code patching below, and is not needed any more.
   code->InvalidateRelocation();

+  // TODO(jkummerow): if (FLAG_zap_code_space), make the code object's
+  // entry sequence unusable (see other architectures).
+
   // For each LLazyBailout instruction insert a call to the corresponding
   // deoptimization entry.
   DeoptimizationInputData* deopt_data =
=======================================
--- /branches/bleeding_edge/src/arm/deoptimizer-arm.cc Fri Nov 22 10:21:47 2013 UTC +++ /branches/bleeding_edge/src/arm/deoptimizer-arm.cc Fri Feb 28 12:41:25 2014 UTC
@@ -50,6 +50,26 @@
   // code patching below, and is not needed any more.
   code->InvalidateRelocation();

+  if (FLAG_zap_code_space) {
+    // Fail hard and early if we enter this code object again.
+    byte* pointer = code->FindCodeAgeSequence();
+    if (pointer != NULL) {
+      pointer += kNoCodeAgeSequenceLength;
+    } else {
+      pointer = code->instruction_start();
+    }
+    CodePatcher patcher(pointer, 1);
+    patcher.masm()->bkpt(0);
+
+    DeoptimizationInputData* data =
+        DeoptimizationInputData::cast(code->deoptimization_data());
+    int osr_offset = data->OsrPcOffset()->value();
+    if (osr_offset > 0) {
+      CodePatcher osr_patcher(code->instruction_start() + osr_offset, 1);
+      osr_patcher.masm()->bkpt(0);
+    }
+  }
+
   // For each LLazyBailout instruction insert a call to the corresponding
   // deoptimization entry.
   DeoptimizationInputData* deopt_data =
=======================================
--- /branches/bleeding_edge/src/ia32/deoptimizer-ia32.cc Fri Nov 22 10:21:47 2013 UTC +++ /branches/bleeding_edge/src/ia32/deoptimizer-ia32.cc Fri Feb 28 12:41:25 2014 UTC
@@ -116,6 +116,27 @@

void Deoptimizer::PatchCodeForDeoptimization(Isolate* isolate, Code* code) {
   Address code_start_address = code->instruction_start();
+
+  if (FLAG_zap_code_space) {
+    // Fail hard and early if we enter this code object again.
+    byte* pointer = code->FindCodeAgeSequence();
+    if (pointer != NULL) {
+      pointer += kNoCodeAgeSequenceLength;
+    } else {
+      pointer = code->instruction_start();
+    }
+    CodePatcher patcher(pointer, 1);
+    patcher.masm()->int3();
+
+    DeoptimizationInputData* data =
+        DeoptimizationInputData::cast(code->deoptimization_data());
+    int osr_offset = data->OsrPcOffset()->value();
+    if (osr_offset > 0) {
+      CodePatcher osr_patcher(code->instruction_start() + osr_offset, 1);
+      osr_patcher.masm()->int3();
+    }
+  }
+
   // We will overwrite the code's relocation info in-place. Relocation info
   // is written backward. The relocation info is the payload of a byte
   // array.  Later on we will slide this to the start of the byte array and
=======================================
--- /branches/bleeding_edge/src/mips/deoptimizer-mips.cc Thu Feb 6 01:10:06 2014 UTC +++ /branches/bleeding_edge/src/mips/deoptimizer-mips.cc Fri Feb 28 12:41:25 2014 UTC
@@ -49,6 +49,26 @@
   // code patching below, and is not needed any more.
   code->InvalidateRelocation();

+  if (FLAG_zap_code_space) {
+    // Fail hard and early if we enter this code object again.
+    byte* pointer = code->FindCodeAgeSequence();
+    if (pointer != NULL) {
+      pointer += kNoCodeAgeSequenceLength;
+    } else {
+      pointer = code->instruction_start();
+    }
+    CodePatcher patcher(pointer, 1);
+    patcher.masm()->break_(0xCC);
+
+    DeoptimizationInputData* data =
+        DeoptimizationInputData::cast(code->deoptimization_data());
+    int osr_offset = data->OsrPcOffset()->value();
+    if (osr_offset > 0) {
+      CodePatcher osr_patcher(code->instruction_start() + osr_offset, 1);
+      osr_patcher.masm()->break_(0xCC);
+    }
+  }
+
   // For each LLazyBailout instruction insert a call to the corresponding
   // deoptimization entry.
   DeoptimizationInputData* deopt_data =
=======================================
--- /branches/bleeding_edge/src/objects.h       Fri Feb 28 12:27:31 2014 UTC
+++ /branches/bleeding_edge/src/objects.h       Fri Feb 28 12:41:25 2014 UTC
@@ -5627,6 +5627,7 @@

  private:
   friend class RelocIterator;
+  friend class Deoptimizer;  // For FindCodeAgeSequence.

   void ClearInlineCaches(Kind* kind);

=======================================
--- /branches/bleeding_edge/src/x64/deoptimizer-x64.cc Fri Feb 7 02:21:18 2014 UTC +++ /branches/bleeding_edge/src/x64/deoptimizer-x64.cc Fri Feb 28 12:41:25 2014 UTC
@@ -51,6 +51,26 @@
   // code patching below, and is not needed any more.
   code->InvalidateRelocation();

+  if (FLAG_zap_code_space) {
+    // Fail hard and early if we enter this code object again.
+    byte* pointer = code->FindCodeAgeSequence();
+    if (pointer != NULL) {
+      pointer += kNoCodeAgeSequenceLength;
+    } else {
+      pointer = code->instruction_start();
+    }
+    CodePatcher patcher(pointer, 1);
+    patcher.masm()->int3();
+
+    DeoptimizationInputData* data =
+        DeoptimizationInputData::cast(code->deoptimization_data());
+    int osr_offset = data->OsrPcOffset()->value();
+    if (osr_offset > 0) {
+      CodePatcher osr_patcher(code->instruction_start() + osr_offset, 1);
+      osr_patcher.masm()->int3();
+    }
+  }
+
   // For each LLazyBailout instruction insert a absolute call to the
   // corresponding deoptimization entry, or a short call to an absolute
   // jump if space is short. The absolute jumps are put in a table just

--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to