Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(666)

Unified Diff: runtime/vm/assembler_x64.cc

Issue 16693006: Initial implementation of on-stack replacement (OSR). (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Clean up for review. Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: runtime/vm/assembler_x64.cc
diff --git a/runtime/vm/assembler_x64.cc b/runtime/vm/assembler_x64.cc
index 238574920f2dab52fc0116bf904812c7ebdd5dfc..c1d90dbb034c781a6dc39e3329833a2d5f16e1c5 100644
--- a/runtime/vm/assembler_x64.cc
+++ b/runtime/vm/assembler_x64.cc
@@ -9,6 +9,7 @@
#include "vm/heap.h"
#include "vm/memory_region.h"
#include "vm/runtime_entry.h"
+#include "vm/stack_frame.h"
#include "vm/stub_code.h"
namespace dart {
@@ -2279,15 +2280,16 @@ void Assembler::CallRuntime(const RuntimeEntry& entry) {
void Assembler::EnterDartFrame(intptr_t frame_size) {
- const intptr_t offset = CodeSize();
EnterFrame(0);
Label dart_entry;
call(&dart_entry);
Bind(&dart_entry);
- // Adjust saved PC for any intrinsic code that could have been generated
- // before a frame is created.
+ // The runtime system assumes that the code marker address is
+ // kEntryPointToPcMarkerOffset bytes from the entry. If there is any code
+ // generated before entering the frame, the address needs to be adjusted.
+ const intptr_t offset = kEntryPointToPcMarkerOffset - CodeSize();
if (offset != 0) {
- addq(Address(RSP, 0), Immediate(-offset));
+ addq(Address(RSP, 0), Immediate(offset));
}
if (frame_size != 0) {
subq(RSP, Immediate(frame_size));
@@ -2295,6 +2297,29 @@ void Assembler::EnterDartFrame(intptr_t frame_size) {
}
+// On entry to a function compiled for OSR, the caller's frame pointer, the
+// stack locals, and any copied parameters are already in place. The frame
+// pointer is already set up. The PC marker is not correct for the
+// optimized function and there may be extra space for spill slots to
+// allocate.
+void Assembler::EnterOsrFrame(intptr_t extra_size) {
+ Label dart_entry;
+ call(&dart_entry);
+ Bind(&dart_entry);
+ // The runtime system assumes that the code marker address is
+ // kEntryPointToPcMarkerOffset bytes from the entry. Since there is no
+ // code to set up the frame pointer, the address needs to be adjusted.
+ const intptr_t offset = kEntryPointToPcMarkerOffset - CodeSize();
+ if (offset != 0) {
+ addq(Address(RSP, 0), Immediate(offset));
+ }
+ popq(Address(RBP, kPcMarkerSlotFromFp * kWordSize));
+ if (extra_size != 0) {
+ subq(RSP, Immediate(extra_size));
+ }
+}
+
+
void Assembler::EnterStubFrame() {
EnterFrame(0);
pushq(Immediate(0)); // Push 0 in the saved PC area for stub frames.

Powered by Google App Engine
This is Rietveld 408576698