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

Unified Diff: runtime/vm/assembler_x64.cc

Issue 1192103004: VM: New calling convention for generated code. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: fixed comments Created 5 years, 3 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
« no previous file with comments | « runtime/vm/assembler_x64.h ('k') | runtime/vm/assembler_x64_test.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/assembler_x64.cc
diff --git a/runtime/vm/assembler_x64.cc b/runtime/vm/assembler_x64.cc
index 523f29f9ca8fdc3cc7229e3fe75c955c6445f283..503d3575caea0819f334429f84690b7ea29ece1e 100644
--- a/runtime/vm/assembler_x64.cc
+++ b/runtime/vm/assembler_x64.cc
@@ -93,20 +93,25 @@ void Assembler::call(const ExternalLabel* label) {
void Assembler::CallPatchable(const StubEntry& stub_entry) {
ASSERT(constant_pool_allowed());
+ const Code& target = Code::Handle(stub_entry.code());
intptr_t call_start = buffer_.GetPosition();
const int32_t offset = ObjectPool::element_offset(
- object_pool_wrapper_.FindExternalLabel(&stub_entry.label(), kPatchable));
- call(Address::AddressBaseImm32(PP, offset - kHeapObjectTag));
+ object_pool_wrapper_.FindObject(target, kPatchable));
+ LoadWordFromPoolOffset(CODE_REG, offset - kHeapObjectTag);
+ movq(TMP, FieldAddress(CODE_REG, Code::entry_point_offset()));
+ call(TMP);
ASSERT((buffer_.GetPosition() - call_start) == kCallExternalLabelSize);
}
void Assembler::Call(const StubEntry& stub_entry) {
ASSERT(constant_pool_allowed());
+ const Code& target = Code::Handle(stub_entry.code());
const int32_t offset = ObjectPool::element_offset(
- object_pool_wrapper_.FindExternalLabel(&stub_entry.label(),
- kNotPatchable));
- call(Address::AddressBaseImm32(PP, offset - kHeapObjectTag));
+ object_pool_wrapper_.FindObject(target, kNotPatchable));
+ LoadWordFromPoolOffset(CODE_REG, offset - kHeapObjectTag);
+ movq(TMP, FieldAddress(CODE_REG, Code::entry_point_offset()));
+ call(TMP);
}
@@ -2543,11 +2548,12 @@ void Assembler::j(Condition condition, Label* label, bool near) {
}
-void Assembler::J(Condition condition, const StubEntry& stub_entry,
+void Assembler::J(Condition condition,
+ const StubEntry& stub_entry,
Register pp) {
Label no_jump;
// Negate condition.
- j(static_cast<Condition>(condition ^ 1), &no_jump, Assembler::kNearJump);
+ j(static_cast<Condition>(condition ^ 1), &no_jump, kNearJump);
Jmp(stub_entry, pp);
Bind(&no_jump);
}
@@ -2608,28 +2614,25 @@ void Assembler::jmp(const ExternalLabel* label) {
}
-void Assembler::jmp(const StubEntry& stub_entry) {
- jmp(&stub_entry.label());
-}
-
-
void Assembler::JmpPatchable(const StubEntry& stub_entry, Register pp) {
ASSERT((pp != PP) || constant_pool_allowed());
- intptr_t call_start = buffer_.GetPosition();
+ const Code& target = Code::Handle(stub_entry.code());
const int32_t offset = ObjectPool::element_offset(
- object_pool_wrapper_.FindExternalLabel(&stub_entry.label(), kPatchable));
- // Patchable jumps always use a 32-bit immediate encoding.
- jmp(Address::AddressBaseImm32(pp, offset - kHeapObjectTag));
- ASSERT((buffer_.GetPosition() - call_start) == JumpPattern::kLengthInBytes);
+ object_pool_wrapper_.FindObject(target, kPatchable));
+ movq(CODE_REG, Address::AddressBaseImm32(pp, offset - kHeapObjectTag));
+ movq(TMP, FieldAddress(CODE_REG, Code::entry_point_offset()));
+ jmp(TMP);
}
void Assembler::Jmp(const StubEntry& stub_entry, Register pp) {
ASSERT((pp != PP) || constant_pool_allowed());
+ const Code& target = Code::Handle(stub_entry.code());
const int32_t offset = ObjectPool::element_offset(
- object_pool_wrapper_.FindExternalLabel(&stub_entry.label(),
- kNotPatchable));
- jmp(Address(pp, offset - kHeapObjectTag));
+ object_pool_wrapper_.FindObject(target, kNotPatchable));
+ movq(CODE_REG, FieldAddress(pp, offset));
+ movq(TMP, FieldAddress(CODE_REG, Code::entry_point_offset()));
+ jmp(TMP);
}
@@ -3077,8 +3080,12 @@ void Assembler::StoreIntoObject(Register object,
if (object != RDX) {
movq(RDX, object);
}
+ pushq(CODE_REG);
+ movq(CODE_REG, Address(THR, Thread::update_store_buffer_code_offset()));
movq(TMP, Address(THR, Thread::update_store_buffer_entry_point_offset()));
call(TMP);
+
+ popq(CODE_REG);
if (value != RDX) popq(RDX);
Bind(&done);
}
@@ -3379,27 +3386,29 @@ void Assembler::CallRuntime(const RuntimeEntry& entry,
}
+void Assembler::RestoreCodePointer() {
+ movq(CODE_REG, Address(RBP, kPcMarkerSlotFromFp * kWordSize));
+}
+
+
void Assembler::LoadPoolPointer(Register pp) {
// Load new pool pointer.
- const intptr_t kRIPRelativeMovqSize = 7;
- const intptr_t entry_to_rip_offset = CodeSize() + kRIPRelativeMovqSize;
- const intptr_t object_pool_pc_dist =
- Instructions::HeaderSize() - Instructions::object_pool_offset();
- movq(pp, Address::AddressRIPRelative(
- -entry_to_rip_offset - object_pool_pc_dist));
- ASSERT(CodeSize() == entry_to_rip_offset);
+ CheckCodePointer();
+ movq(pp, FieldAddress(CODE_REG, Code::object_pool_offset()));
set_constant_pool_allowed(pp == PP);
}
-void Assembler::EnterDartFrame(intptr_t frame_size,
- Register new_pp,
- Register pc_marker_override) {
+void Assembler::EnterDartFrame(intptr_t frame_size, Register new_pp) {
ASSERT(!constant_pool_allowed());
EnterFrame(0);
- pushq(pc_marker_override);
+ pushq(CODE_REG);
pushq(PP);
- movq(PP, new_pp);
+ if (new_pp == kNoRegister) {
+ LoadPoolPointer(PP);
+ } else {
+ movq(PP, new_pp);
+ }
set_constant_pool_allowed(true);
if (frame_size != 0) {
subq(RSP, Immediate(frame_size));
@@ -3407,30 +3416,57 @@ void Assembler::EnterDartFrame(intptr_t frame_size,
}
-void Assembler::LeaveDartFrame() {
- set_constant_pool_allowed(false);
+void Assembler::LeaveDartFrame(RestorePP restore_pp) {
// Restore caller's PP register that was pushed in EnterDartFrame.
- movq(PP, Address(RBP, (kSavedCallerPpSlotFromFp * kWordSize)));
+ if (restore_pp == kRestoreCallerPP) {
+ movq(PP, Address(RBP, (kSavedCallerPpSlotFromFp * kWordSize)));
+ set_constant_pool_allowed(false);
+ }
LeaveFrame();
}
+void Assembler::CheckCodePointer() {
+#ifdef DEBUG
+ Label cid_ok, instructions_ok;
+ pushq(RAX);
+ LoadClassId(RAX, CODE_REG);
+ cmpq(RAX, Immediate(kCodeCid));
+ j(EQUAL, &cid_ok);
+ int3();
+ Bind(&cid_ok);
+ {
+ const intptr_t kRIPRelativeLeaqSize = 7;
+ const intptr_t header_to_entry_offset =
+ (Instructions::HeaderSize() - kHeapObjectTag);
+ const intptr_t header_to_rip_offset =
+ CodeSize() + kRIPRelativeLeaqSize + header_to_entry_offset;
+ leaq(RAX, Address::AddressRIPRelative(-header_to_rip_offset));
+ ASSERT(CodeSize() == (header_to_rip_offset - header_to_entry_offset));
+ }
+ cmpq(RAX, FieldAddress(CODE_REG, Code::saved_instructions_offset()));
+ j(EQUAL, &instructions_ok);
+ int3();
+ Bind(&instructions_ok);
+ popq(RAX);
+#endif
+}
+
+
// 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,
- Register new_pp,
- Register pc_marker_override) {
+void Assembler::EnterOsrFrame(intptr_t extra_size) {
ASSERT(!constant_pool_allowed());
if (prologue_offset_ == -1) {
Comment("PrologueOffset = %" Pd "", CodeSize());
prologue_offset_ = CodeSize();
}
- movq(Address(RBP, kPcMarkerSlotFromFp * kWordSize), pc_marker_override);
- movq(PP, new_pp);
- set_constant_pool_allowed(true);
+ RestoreCodePointer();
+ LoadPoolPointer();
+
if (extra_size != 0) {
subq(RSP, Immediate(extra_size));
}
@@ -3438,11 +3474,7 @@ void Assembler::EnterOsrFrame(intptr_t extra_size,
void Assembler::EnterStubFrame() {
- set_constant_pool_allowed(false);
- EnterFrame(0);
- pushq(Immediate(0)); // Push 0 in the saved PC area for stub frames.
- pushq(PP); // Save caller's pool pointer
- LoadPoolPointer();
+ EnterDartFrame(0, kNoRegister);
}
« no previous file with comments | « runtime/vm/assembler_x64.h ('k') | runtime/vm/assembler_x64_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698