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

Unified Diff: src/x64/assembler-x64.cc

Issue 114085: X64: Implement CEntryStub and JSEntryTrampoline. (Closed)
Patch Set: Addressed review comments Created 11 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: src/x64/assembler-x64.cc
diff --git a/src/x64/assembler-x64.cc b/src/x64/assembler-x64.cc
index 77bbf524053722d4450dc4a8ceb18448c4abcbd3..2357353ee1ba894594da133e7b265e1b880d721a 100644
--- a/src/x64/assembler-x64.cc
+++ b/src/x64/assembler-x64.cc
@@ -72,7 +72,49 @@ XMMRegister xmm13 = { 13 };
XMMRegister xmm14 = { 14 };
XMMRegister xmm15 = { 15 };
+
+Operand::Operand(Register base, int32_t disp) {
+ len_ = 1;
+ if (base.is(rsp) || base.is(r12)) {
+ // SIB byte is needed to encode (rsp + offset) or (r12 + offset).
+ set_sib(kTimes1, rsp, base);
+ }
+
+ if (disp == 0 && !base.is(rbp) && !base.is(r13)) {
+ set_modrm(0, rsp);
+ } else if (is_int8(disp)) {
+ set_modrm(1, base);
+ set_disp8(disp);
+ } else {
+ set_modrm(2, base);
+ set_disp32(disp);
+ }
+}
+
+
+Operand::Operand(Register base,
+ Register index,
+ ScaleFactor scale,
+ int32_t disp) {
+ ASSERT(!index.is(rsp) && !index.is(r12));
+ len_ = 1;
+ set_sib(scale, index, base);
+ if (disp == 0 && !base.is(rbp) && !base.is(r13)) {
+ // The call to set_modrm doesn't overwrite the REX.B bit possibly set
+ // by set_sib.
+ set_modrm(0, rsp);
+ } else if (is_int8(disp)) {
+ set_modrm(1, rsp);
+ set_disp8(disp);
+ } else {
+ set_modrm(2, rsp);
+ set_disp32(disp);
+ }
+}
+
+
// Safe default is no features.
+// TODO(X64): Safe defaults include SSE2 for X64.
uint64_t CpuFeatures::supported_ = 0;
uint64_t CpuFeatures::enabled_ = 0;
@@ -486,6 +528,7 @@ void Assembler::call(Register adr) {
emit_modrm(0x2, adr);
}
+
void Assembler::cpuid() {
ASSERT(CpuFeatures::IsEnabled(CpuFeatures::CPUID));
EnsureSpace ensure_space(this);
@@ -843,6 +886,31 @@ void Assembler::movq(Register dst, ExternalReference ref) {
}
+void Assembler::movq(const Operand& dst, Immediate value) {
+ EnsureSpace ensure_space(this);
+ last_pc_ = pc_;
+ emit_rex_64(dst);
+ emit(0xC7);
+ emit_operand(0, dst);
+ emit(value);
+}
+
+
+void Assembler::movq(Register dst, Handle<Object> value, RelocInfo::Mode mode) {
+ EnsureSpace ensure_space(this);
+ last_pc_ = pc_;
+ ASSERT(!Heap::InNewSpace(*value));
William Hesse 2009/06/10 08:09:09 Is this from the ia32 code? I didn't know this.
+ emit_rex_64(dst);
+ emit(0xB8 | dst.code() & 0x7);
+ if (value->IsHeapObject()) {
+ emitq(reinterpret_cast<uintptr_t>(value.location()), mode);
+ } else {
+ ASSERT_EQ(RelocInfo::NONE, mode);
+ emitq(reinterpret_cast<uintptr_t>(*value), RelocInfo::NONE);
+ }
+}
+
+
void Assembler::mul(Register src) {
EnsureSpace ensure_space(this);
last_pc_ = pc_;
@@ -1128,6 +1196,7 @@ void Assembler::store_rax(ExternalReference ref) {
void Assembler::testb(Register reg, Immediate mask) {
+ ASSERT(is_int8(mask.value_));
EnsureSpace ensure_space(this);
last_pc_ = pc_;
if (reg.is(rax)) {
@@ -1146,6 +1215,7 @@ void Assembler::testb(Register reg, Immediate mask) {
void Assembler::testb(const Operand& op, Immediate mask) {
+ ASSERT(is_int8(mask.value_));
EnsureSpace ensure_space(this);
last_pc_ = pc_;
emit_optional_rex_32(rax, op);
@@ -1198,6 +1268,22 @@ void Assembler::testq(Register dst, Register src) {
}
+void Assembler::testq(Register dst, Immediate mask) {
+ EnsureSpace ensure_space(this);
+ last_pc_ = pc_;
+ if (dst.is(rax)) {
+ emit_rex_64();
+ emit(0xA9);
+ emit(mask);
+ } else {
+ emit_rex_64(dst);
+ emit(0xF7);
+ emit_modrm(0, dst);
+ emit(mask);
+ }
+}
+
+
// Relocation information implementations
void Assembler::RecordRelocInfo(RelocInfo::Mode rmode, intptr_t data) {

Powered by Google App Engine
This is Rietveld 408576698