Index: src/deoptimizer.cc |
diff --git a/src/deoptimizer.cc b/src/deoptimizer.cc |
index a3d2002178fc625045307f41dd653bcdde02a60f..e6742fe01be43f14f59193bd64671aa62981b428 100644 |
--- a/src/deoptimizer.cc |
+++ b/src/deoptimizer.cc |
@@ -810,6 +810,25 @@ bool Deoptimizer::DoOsrTranslateCommand(TranslationIterator* iterator, |
} |
+void Deoptimizer::PatchStackCheckCode(Code* unoptimized_code, |
+ Code* check_code, |
+ Code* replacement_code) { |
+ // Iterate over the stack check table and patch every stack check |
+ // call to an unconditional call to the replacement code. |
+ ASSERT(unoptimized_code->kind() == Code::FUNCTION); |
+ Address stack_check_cursor = unoptimized_code->instruction_start() + |
+ unoptimized_code->stack_check_table_start(); |
+ uint32_t table_length = Memory::uint32_at(stack_check_cursor); |
+ stack_check_cursor += kIntSize; |
+ for (uint32_t i = 0; i < table_length; ++i) { |
+ uint32_t pc_offset = Memory::uint32_at(stack_check_cursor + kIntSize); |
+ Address pc_after = unoptimized_code->instruction_start() + pc_offset; |
+ PatchStackCheckAt(pc_after, check_code, replacement_code); |
+ stack_check_cursor += 2 * kIntSize; |
+ } |
+} |
+ |
+ |
unsigned Deoptimizer::ComputeInputFrameSize() const { |
unsigned fixed_size = ComputeFixedSize(function_); |
// The fp-to-sp delta already takes the context and the function |