Index: src/compiler/ia32/code-generator-ia32.cc |
diff --git a/src/compiler/ia32/code-generator-ia32.cc b/src/compiler/ia32/code-generator-ia32.cc |
index 55f7426a4cbf0d6a630462d92785c7ae5b756026..fabfd0a1c414da6f260d5da03be2000dd26cddcd 100644 |
--- a/src/compiler/ia32/code-generator-ia32.cc |
+++ b/src/compiler/ia32/code-generator-ia32.cc |
@@ -8,6 +8,7 @@ |
#include "src/compiler/gap-resolver.h" |
#include "src/compiler/node-matchers.h" |
#include "src/compiler/node-properties-inl.h" |
+#include "src/compiler/osr.h" |
#include "src/ia32/assembler-ia32.h" |
#include "src/ia32/macro-assembler-ia32.h" |
#include "src/scopes.h" |
@@ -1023,6 +1024,8 @@ void CodeGenerator::AssemblePrologue() { |
frame->SetRegisterSaveAreaSize(register_save_area_size); |
} |
} else if (descriptor->IsJSFunctionCall()) { |
+ // TODO(turbofan): this prologue is redundant with OSR, but needed for |
+ // code aging. |
CompilationInfo* info = this->info(); |
__ Prologue(info->IsCodePreAgingActive()); |
frame->SetRegisterSaveAreaSize( |
@@ -1032,7 +1035,25 @@ void CodeGenerator::AssemblePrologue() { |
frame->SetRegisterSaveAreaSize( |
StandardFrameConstants::kFixedFrameSizeFromFp); |
} |
+ |
+ if (info()->is_osr()) { |
+ // TurboFan OSR-compiled functions cannot be entered directly. |
+ __ Abort(kShouldNotDirectlyEnterOsrFunction); |
+ |
+ // Unoptimized code jumps directly to this entrypoint while the unoptimized |
+ // frame is still on the stack. Optimized code uses OSR values directly from |
+ // the unoptimized frame. Thus, all that needs to be done is to allocate the |
+ // remaining stack slots. |
+ if (FLAG_code_comments) __ RecordComment("-- OSR entrypoint --"); |
+ osr_pc_offset_ = __ pc_offset(); |
+ int unoptimized_slots = |
+ static_cast<int>(OsrHelper(info()).UnoptimizedFrameSlots()); |
+ DCHECK(stack_slots >= unoptimized_slots); |
+ stack_slots -= unoptimized_slots; |
+ } |
+ |
if (stack_slots > 0) { |
+ // Allocate the stack slots used by this frame. |
__ sub(esp, Immediate(stack_slots * kPointerSize)); |
} |
} |