Version 3.22.2

Performance and stability improvements on all platforms.

git-svn-id: http://v8.googlecode.com/svn/trunk@16953 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
diff --git a/src/full-codegen.cc b/src/full-codegen.cc
index f1877fb..c4ae1d7 100644
--- a/src/full-codegen.cc
+++ b/src/full-codegen.cc
@@ -1618,8 +1618,7 @@
 void BackEdgeTable::Patch(Isolate* isolate,
                           Code* unoptimized) {
   DisallowHeapAllocation no_gc;
-  Code* replacement_code =
-      isolate->builtins()->builtin(Builtins::kOnStackReplacement);
+  Code* patch = isolate->builtins()->builtin(Builtins::kOnStackReplacement);
 
   // Iterate over the back edge table and patch every interrupt
   // call to an unconditional call to the replacement code.
@@ -1631,7 +1630,7 @@
       ASSERT_EQ(INTERRUPT, GetBackEdgeState(isolate,
                                             unoptimized,
                                             back_edges.pc(i)));
-      PatchAt(unoptimized, back_edges.pc(i), replacement_code);
+      PatchAt(unoptimized, back_edges.pc(i), ON_STACK_REPLACEMENT, patch);
     }
   }
 
@@ -1643,8 +1642,7 @@
 void BackEdgeTable::Revert(Isolate* isolate,
                            Code* unoptimized) {
   DisallowHeapAllocation no_gc;
-  Code* interrupt_code =
-      isolate->builtins()->builtin(Builtins::kInterruptCheck);
+  Code* patch = isolate->builtins()->builtin(Builtins::kInterruptCheck);
 
   // Iterate over the back edge table and revert the patched interrupt calls.
   ASSERT(unoptimized->back_edges_patched_for_osr());
@@ -1653,10 +1651,10 @@
   BackEdgeTable back_edges(unoptimized, &no_gc);
   for (uint32_t i = 0; i < back_edges.length(); i++) {
     if (static_cast<int>(back_edges.loop_depth(i)) <= loop_nesting_level) {
-      ASSERT_EQ(ON_STACK_REPLACEMENT, GetBackEdgeState(isolate,
-                                                       unoptimized,
-                                                       back_edges.pc(i)));
-      RevertAt(unoptimized, back_edges.pc(i), interrupt_code);
+      ASSERT_NE(INTERRUPT, GetBackEdgeState(isolate,
+                                            unoptimized,
+                                            back_edges.pc(i)));
+      PatchAt(unoptimized, back_edges.pc(i), INTERRUPT, patch);
     }
   }
 
@@ -1667,6 +1665,29 @@
 }
 
 
+void BackEdgeTable::AddStackCheck(CompilationInfo* info) {
+  DisallowHeapAllocation no_gc;
+  Isolate* isolate = info->isolate();
+  Code* code = info->shared_info()->code();
+  Address pc = code->instruction_start() + info->osr_pc_offset();
+  ASSERT_EQ(ON_STACK_REPLACEMENT, GetBackEdgeState(isolate, code, pc));
+  Code* patch = isolate->builtins()->builtin(Builtins::kOsrAfterStackCheck);
+  PatchAt(code, pc, OSR_AFTER_STACK_CHECK, patch);
+}
+
+
+void BackEdgeTable::RemoveStackCheck(CompilationInfo* info) {
+  DisallowHeapAllocation no_gc;
+  Isolate* isolate = info->isolate();
+  Code* code = info->shared_info()->code();
+  Address pc = code->instruction_start() + info->osr_pc_offset();
+  if (GetBackEdgeState(isolate, code, pc) == OSR_AFTER_STACK_CHECK) {
+    Code* patch = isolate->builtins()->builtin(Builtins::kOnStackReplacement);
+    PatchAt(code, pc, ON_STACK_REPLACEMENT, patch);
+  }
+}
+
+
 #ifdef DEBUG
 bool BackEdgeTable::Verify(Isolate* isolate,
                            Code* unoptimized,