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

Unified Diff: runtime/vm/assembler_ia32.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_ia32.cc
diff --git a/runtime/vm/assembler_ia32.cc b/runtime/vm/assembler_ia32.cc
index 3b35560d30e25f10dddbce0c94d7052c10073262..55e0f44a715226bb53692fe9a2966e5043f69cad 100644
--- a/runtime/vm/assembler_ia32.cc
+++ b/runtime/vm/assembler_ia32.cc
@@ -10,6 +10,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 {
@@ -2188,15 +2189,16 @@ void Assembler::TryAllocate(const Class& cls,
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) {
- addl(Address(ESP, 0), Immediate(-offset));
+ addl(Address(ESP, 0), Immediate(offset));
}
if (frame_size != 0) {
subl(ESP, Immediate(frame_size));
@@ -2204,6 +2206,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) {
+ addl(Address(ESP, 0), Immediate(offset));
+ }
+ popl(Address(EBP, kPcMarkerSlotFromFp * kWordSize));
+ if (extra_size != 0) {
+ subl(ESP, Immediate(extra_size));
+ }
+}
+
+
void Assembler::EnterStubFrame() {
EnterFrame(0);
pushl(Immediate(0)); // Push 0 in the saved PC area for stub frames.

Powered by Google App Engine
This is Rietveld 408576698