Skip to content
This repository
Browse code

Abort recording if we hit a heap block overflow.

Upon encountering a heap-overflow during an allocation instruction we
adjust the heap pointer and then try to execute the instruction again.
This caused problems when executing the instruction in recording mode.
Rather than handle this case in the recorder we simply abort recording
and retry another time (at least for now).
  • Loading branch information...
commit 3b79b986752edb5b1a0f70ca73cea2114140b4c0 1 parent a2eebb4
Thomas Schilling authored September 19, 2012
2  vm/capability.cc
@@ -440,6 +440,7 @@ record: {
440 440
   }
441 441
 
442 442
 heapOverflow:
  443
+  if (isRecording()) jit_.requestAbort();
443 444
   --pc;
444 445
   // Convention: If GC is needed, T->pc points to the instruction that
445 446
   // tried to allocate.
@@ -911,6 +912,7 @@ generic_apply: {
911 912
         heap += (wordsof(PapClosure) + pap_size) * sizeof(Word);
912 913
         while (LC_UNLIKELY(heap > heaplim)) {
913 914
           heap -= (wordsof(PapClosure) + pap_size) * sizeof(Word);
  915
+          if (isRecording()) jit_.requestAbort();
914 916
           // PC points after the CALL/CALLT/EVAL. We're setting the
915 917
           // top of stack pointer mask, though, so the GC really only
916 918
           // needs the correct base pointer.
3  vm/jit.cc
@@ -291,6 +291,8 @@ bool Jit::recordGenericApply(uint32_t call_info, Word *base,
291 291
 }
292 292
 
293 293
 bool Jit::recordIns(BcIns *ins, Word *base, const Code *code) {
  294
+  if (LC_UNLIKELY(shouldAbort_))
  295
+    goto abort_recording;
294 296
   buf_.pc_ = ins;
295 297
   buf_.steps_++;
296 298
   DBG(cerr << "REC: " << ins << " " << ins->name() << endl);
@@ -726,6 +728,7 @@ inline void Jit::resetRecorderState() {
726 728
   flags_.clear();
727 729
   targets_.clear();
728 730
   cap_ = NULL;
  731
+  shouldAbort_ = false;
729 732
 }
730 733
 
731 734
 void Jit::finishRecording() {
3  vm/jit.hh
@@ -162,6 +162,8 @@ public:
162 162
 
163 163
   inline bool isRecording() const { return cap_ != NULL; }
164 164
 
  165
+  inline void requestAbort() { shouldAbort_ = true; }
  166
+
165 167
   // Returns the fragment starting at the given PC. NULL, otherwise.
166 168
   inline Fragment *traceAt(BcIns *pc);
167 169
 
@@ -211,6 +213,7 @@ private:
211 213
   CallStack callStack_;
212 214
   BranchTargetBuffer btb_;
213 215
   MCode *exitStubGroup_[16];
  216
+  bool shouldAbort_;
214 217
 
215 218
   static FRAGMENT_MAP fragmentMap_;
216 219
   static std::vector<Fragment*> fragments_;

0 notes on commit 3b79b98

Please sign in to comment.
Something went wrong with that request. Please try again.