Commit 9b4312fd authored by sgjesse@chromium.org's avatar sgjesse@chromium.org

Fixed random style violations.

Review URL: http://codereview.chromium.org/574009

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@3801 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 4bf7a6c0
...@@ -264,9 +264,9 @@ MemOperand::MemOperand(Register rn, Register rm, ...@@ -264,9 +264,9 @@ MemOperand::MemOperand(Register rn, Register rm,
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// Implementation of Assembler // Implementation of Assembler.
// Instruction encoding bits // Instruction encoding bits.
enum { enum {
H = 1 << 5, // halfword (or byte) H = 1 << 5, // halfword (or byte)
S6 = 1 << 6, // signed (or unsigned) S6 = 1 << 6, // signed (or unsigned)
...@@ -299,14 +299,14 @@ enum { ...@@ -299,14 +299,14 @@ enum {
B26 = 1 << 26, B26 = 1 << 26,
B27 = 1 << 27, B27 = 1 << 27,
// Instruction bit masks // Instruction bit masks.
RdMask = 15 << 12, // in str instruction RdMask = 15 << 12, // in str instruction
CondMask = 15 << 28, CondMask = 15 << 28,
CoprocessorMask = 15 << 8, CoprocessorMask = 15 << 8,
OpCodeMask = 15 << 21, // in data-processing instructions OpCodeMask = 15 << 21, // in data-processing instructions
Imm24Mask = (1 << 24) - 1, Imm24Mask = (1 << 24) - 1,
Off12Mask = (1 << 12) - 1, Off12Mask = (1 << 12) - 1,
// Reserved condition // Reserved condition.
nv = 15 << 28 nv = 15 << 28
}; };
...@@ -327,13 +327,13 @@ const Instr kMovLrPc = al | 13*B21 | pc.code() | lr.code() * B12; ...@@ -327,13 +327,13 @@ const Instr kMovLrPc = al | 13*B21 | pc.code() | lr.code() * B12;
// ldr pc, [pc, #XXX] // ldr pc, [pc, #XXX]
const Instr kLdrPCPattern = al | B26 | L | pc.code() * B16; const Instr kLdrPCPattern = al | B26 | L | pc.code() * B16;
// spare_buffer_ // Spare buffer.
static const int kMinimalBufferSize = 4*KB; static const int kMinimalBufferSize = 4*KB;
static byte* spare_buffer_ = NULL; static byte* spare_buffer_ = NULL;
Assembler::Assembler(void* buffer, int buffer_size) { Assembler::Assembler(void* buffer, int buffer_size) {
if (buffer == NULL) { if (buffer == NULL) {
// do our own buffer management // Do our own buffer management.
if (buffer_size <= kMinimalBufferSize) { if (buffer_size <= kMinimalBufferSize) {
buffer_size = kMinimalBufferSize; buffer_size = kMinimalBufferSize;
...@@ -351,14 +351,14 @@ Assembler::Assembler(void* buffer, int buffer_size) { ...@@ -351,14 +351,14 @@ Assembler::Assembler(void* buffer, int buffer_size) {
own_buffer_ = true; own_buffer_ = true;
} else { } else {
// use externally provided buffer instead // Use externally provided buffer instead.
ASSERT(buffer_size > 0); ASSERT(buffer_size > 0);
buffer_ = static_cast<byte*>(buffer); buffer_ = static_cast<byte*>(buffer);
buffer_size_ = buffer_size; buffer_size_ = buffer_size;
own_buffer_ = false; own_buffer_ = false;
} }
// setup buffer pointers // Setup buffer pointers.
ASSERT(buffer_ != NULL); ASSERT(buffer_ != NULL);
pc_ = buffer_; pc_ = buffer_;
reloc_info_writer.Reposition(buffer_ + buffer_size, pc_); reloc_info_writer.Reposition(buffer_ + buffer_size, pc_);
...@@ -386,11 +386,11 @@ Assembler::~Assembler() { ...@@ -386,11 +386,11 @@ Assembler::~Assembler() {
void Assembler::GetCode(CodeDesc* desc) { void Assembler::GetCode(CodeDesc* desc) {
// emit constant pool if necessary // Emit constant pool if necessary.
CheckConstPool(true, false); CheckConstPool(true, false);
ASSERT(num_prinfo_ == 0); ASSERT(num_prinfo_ == 0);
// setup desc // Setup code descriptor.
desc->buffer = buffer_; desc->buffer = buffer_;
desc->buffer_size = buffer_size_; desc->buffer_size = buffer_size_;
desc->instr_size = pc_offset(); desc->instr_size = pc_offset();
...@@ -539,7 +539,7 @@ void Assembler::bind_to(Label* L, int pos) { ...@@ -539,7 +539,7 @@ void Assembler::bind_to(Label* L, int pos) {
void Assembler::link_to(Label* L, Label* appendix) { void Assembler::link_to(Label* L, Label* appendix) {
if (appendix->is_linked()) { if (appendix->is_linked()) {
if (L->is_linked()) { if (L->is_linked()) {
// append appendix to L's list // Append appendix to L's list.
int fixup_pos; int fixup_pos;
int link = L->pos(); int link = L->pos();
do { do {
...@@ -549,7 +549,7 @@ void Assembler::link_to(Label* L, Label* appendix) { ...@@ -549,7 +549,7 @@ void Assembler::link_to(Label* L, Label* appendix) {
ASSERT(link == kEndOfChain); ASSERT(link == kEndOfChain);
target_at_put(fixup_pos, appendix->pos()); target_at_put(fixup_pos, appendix->pos());
} else { } else {
// L is empty, simply use appendix // L is empty, simply use appendix.
*L = *appendix; *L = *appendix;
} }
} }
...@@ -575,12 +575,12 @@ void Assembler::next(Label* L) { ...@@ -575,12 +575,12 @@ void Assembler::next(Label* L) {
} }
// Low-level code emission routines depending on the addressing mode // Low-level code emission routines depending on the addressing mode.
static bool fits_shifter(uint32_t imm32, static bool fits_shifter(uint32_t imm32,
uint32_t* rotate_imm, uint32_t* rotate_imm,
uint32_t* immed_8, uint32_t* immed_8,
Instr* instr) { Instr* instr) {
// imm32 must be unsigned // imm32 must be unsigned.
for (int rot = 0; rot < 16; rot++) { for (int rot = 0; rot < 16; rot++) {
uint32_t imm8 = (imm32 << 2*rot) | (imm32 >> (32 - 2*rot)); uint32_t imm8 = (imm32 << 2*rot) | (imm32 >> (32 - 2*rot));
if ((imm8 <= 0xff)) { if ((imm8 <= 0xff)) {
...@@ -589,7 +589,7 @@ static bool fits_shifter(uint32_t imm32, ...@@ -589,7 +589,7 @@ static bool fits_shifter(uint32_t imm32,
return true; return true;
} }
} }
// if the opcode is mov or mvn and if ~imm32 fits, change the opcode // If the opcode is mov or mvn and if ~imm32 fits, change the opcode.
if (instr != NULL && (*instr & 0xd*B21) == 0xd*B21) { if (instr != NULL && (*instr & 0xd*B21) == 0xd*B21) {
if (fits_shifter(~imm32, rotate_imm, immed_8, NULL)) { if (fits_shifter(~imm32, rotate_imm, immed_8, NULL)) {
*instr ^= 0x2*B21; *instr ^= 0x2*B21;
...@@ -626,7 +626,7 @@ void Assembler::addrmod1(Instr instr, ...@@ -626,7 +626,7 @@ void Assembler::addrmod1(Instr instr,
CheckBuffer(); CheckBuffer();
ASSERT((instr & ~(CondMask | OpCodeMask | S)) == 0); ASSERT((instr & ~(CondMask | OpCodeMask | S)) == 0);
if (!x.rm_.is_valid()) { if (!x.rm_.is_valid()) {
// immediate // Immediate.
uint32_t rotate_imm; uint32_t rotate_imm;
uint32_t immed_8; uint32_t immed_8;
if (MustUseIp(x.rmode_) || if (MustUseIp(x.rmode_) ||
...@@ -634,7 +634,7 @@ void Assembler::addrmod1(Instr instr, ...@@ -634,7 +634,7 @@ void Assembler::addrmod1(Instr instr,
// The immediate operand cannot be encoded as a shifter operand, so load // The immediate operand cannot be encoded as a shifter operand, so load
// it first to register ip and change the original instruction to use ip. // it first to register ip and change the original instruction to use ip.
// However, if the original instruction is a 'mov rd, x' (not setting the // However, if the original instruction is a 'mov rd, x' (not setting the
// condition code), then replace it with a 'ldr rd, [pc]' // condition code), then replace it with a 'ldr rd, [pc]'.
RecordRelocInfo(x.rmode_, x.imm32_); RecordRelocInfo(x.rmode_, x.imm32_);
CHECK(!rn.is(ip)); // rn should never be ip, or will be trashed CHECK(!rn.is(ip)); // rn should never be ip, or will be trashed
Condition cond = static_cast<Condition>(instr & CondMask); Condition cond = static_cast<Condition>(instr & CondMask);
...@@ -648,16 +648,16 @@ void Assembler::addrmod1(Instr instr, ...@@ -648,16 +648,16 @@ void Assembler::addrmod1(Instr instr,
} }
instr |= I | rotate_imm*B8 | immed_8; instr |= I | rotate_imm*B8 | immed_8;
} else if (!x.rs_.is_valid()) { } else if (!x.rs_.is_valid()) {
// immediate shift // Immediate shift.
instr |= x.shift_imm_*B7 | x.shift_op_ | x.rm_.code(); instr |= x.shift_imm_*B7 | x.shift_op_ | x.rm_.code();
} else { } else {
// register shift // Register shift.
ASSERT(!rn.is(pc) && !rd.is(pc) && !x.rm_.is(pc) && !x.rs_.is(pc)); ASSERT(!rn.is(pc) && !rd.is(pc) && !x.rm_.is(pc) && !x.rs_.is(pc));
instr |= x.rs_.code()*B8 | x.shift_op_ | B4 | x.rm_.code(); instr |= x.rs_.code()*B8 | x.shift_op_ | B4 | x.rm_.code();
} }
emit(instr | rn.code()*B16 | rd.code()*B12); emit(instr | rn.code()*B16 | rd.code()*B12);
if (rn.is(pc) || x.rm_.is(pc)) if (rn.is(pc) || x.rm_.is(pc))
// block constant pool emission for one instruction after reading pc // Block constant pool emission for one instruction after reading pc.
BlockConstPoolBefore(pc_offset() + kInstrSize); BlockConstPoolBefore(pc_offset() + kInstrSize);
} }
...@@ -666,15 +666,15 @@ void Assembler::addrmod2(Instr instr, Register rd, const MemOperand& x) { ...@@ -666,15 +666,15 @@ void Assembler::addrmod2(Instr instr, Register rd, const MemOperand& x) {
ASSERT((instr & ~(CondMask | B | L)) == B26); ASSERT((instr & ~(CondMask | B | L)) == B26);
int am = x.am_; int am = x.am_;
if (!x.rm_.is_valid()) { if (!x.rm_.is_valid()) {
// immediate offset // Immediate offset.
int offset_12 = x.offset_; int offset_12 = x.offset_;
if (offset_12 < 0) { if (offset_12 < 0) {
offset_12 = -offset_12; offset_12 = -offset_12;
am ^= U; am ^= U;
} }
if (!is_uint12(offset_12)) { if (!is_uint12(offset_12)) {
// immediate offset cannot be encoded, load it first to register ip // Immediate offset cannot be encoded, load it first to register ip
// rn (and rd in a load) should never be ip, or will be trashed // rn (and rd in a load) should never be ip, or will be trashed.
ASSERT(!x.rn_.is(ip) && ((instr & L) == L || !rd.is(ip))); ASSERT(!x.rn_.is(ip) && ((instr & L) == L || !rd.is(ip)));
mov(ip, Operand(x.offset_), LeaveCC, mov(ip, Operand(x.offset_), LeaveCC,
static_cast<Condition>(instr & CondMask)); static_cast<Condition>(instr & CondMask));
...@@ -684,9 +684,9 @@ void Assembler::addrmod2(Instr instr, Register rd, const MemOperand& x) { ...@@ -684,9 +684,9 @@ void Assembler::addrmod2(Instr instr, Register rd, const MemOperand& x) {
ASSERT(offset_12 >= 0); // no masking needed ASSERT(offset_12 >= 0); // no masking needed
instr |= offset_12; instr |= offset_12;
} else { } else {
// register offset (shift_imm_ and shift_op_ are 0) or scaled // Register offset (shift_imm_ and shift_op_ are 0) or scaled
// register offset the constructors make sure than both shift_imm_ // register offset the constructors make sure than both shift_imm_
// and shift_op_ are initialized // and shift_op_ are initialized.
ASSERT(!x.rm_.is(pc)); ASSERT(!x.rm_.is(pc));
instr |= B25 | x.shift_imm_*B7 | x.shift_op_ | x.rm_.code(); instr |= B25 | x.shift_imm_*B7 | x.shift_op_ | x.rm_.code();
} }
...@@ -700,15 +700,15 @@ void Assembler::addrmod3(Instr instr, Register rd, const MemOperand& x) { ...@@ -700,15 +700,15 @@ void Assembler::addrmod3(Instr instr, Register rd, const MemOperand& x) {
ASSERT(x.rn_.is_valid()); ASSERT(x.rn_.is_valid());
int am = x.am_; int am = x.am_;
if (!x.rm_.is_valid()) { if (!x.rm_.is_valid()) {
// immediate offset // Immediate offset.
int offset_8 = x.offset_; int offset_8 = x.offset_;
if (offset_8 < 0) { if (offset_8 < 0) {
offset_8 = -offset_8; offset_8 = -offset_8;
am ^= U; am ^= U;
} }
if (!is_uint8(offset_8)) { if (!is_uint8(offset_8)) {
// immediate offset cannot be encoded, load it first to register ip // Immediate offset cannot be encoded, load it first to register ip
// rn (and rd in a load) should never be ip, or will be trashed // rn (and rd in a load) should never be ip, or will be trashed.
ASSERT(!x.rn_.is(ip) && ((instr & L) == L || !rd.is(ip))); ASSERT(!x.rn_.is(ip) && ((instr & L) == L || !rd.is(ip)));
mov(ip, Operand(x.offset_), LeaveCC, mov(ip, Operand(x.offset_), LeaveCC,
static_cast<Condition>(instr & CondMask)); static_cast<Condition>(instr & CondMask));
...@@ -718,15 +718,15 @@ void Assembler::addrmod3(Instr instr, Register rd, const MemOperand& x) { ...@@ -718,15 +718,15 @@ void Assembler::addrmod3(Instr instr, Register rd, const MemOperand& x) {
ASSERT(offset_8 >= 0); // no masking needed ASSERT(offset_8 >= 0); // no masking needed
instr |= B | (offset_8 >> 4)*B8 | (offset_8 & 0xf); instr |= B | (offset_8 >> 4)*B8 | (offset_8 & 0xf);
} else if (x.shift_imm_ != 0) { } else if (x.shift_imm_ != 0) {
// scaled register offset not supported, load index first // Scaled register offset not supported, load index first
// rn (and rd in a load) should never be ip, or will be trashed // rn (and rd in a load) should never be ip, or will be trashed.
ASSERT(!x.rn_.is(ip) && ((instr & L) == L || !rd.is(ip))); ASSERT(!x.rn_.is(ip) && ((instr & L) == L || !rd.is(ip)));
mov(ip, Operand(x.rm_, x.shift_op_, x.shift_imm_), LeaveCC, mov(ip, Operand(x.rm_, x.shift_op_, x.shift_imm_), LeaveCC,
static_cast<Condition>(instr & CondMask)); static_cast<Condition>(instr & CondMask));
addrmod3(instr, rd, MemOperand(x.rn_, ip, x.am_)); addrmod3(instr, rd, MemOperand(x.rn_, ip, x.am_));
return; return;
} else { } else {
// register offset // Register offset.
ASSERT((am & (P|W)) == P || !x.rm_.is(pc)); // no pc index with writeback ASSERT((am & (P|W)) == P || !x.rm_.is(pc)); // no pc index with writeback
instr |= x.rm_.code(); instr |= x.rm_.code();
} }
...@@ -744,7 +744,7 @@ void Assembler::addrmod4(Instr instr, Register rn, RegList rl) { ...@@ -744,7 +744,7 @@ void Assembler::addrmod4(Instr instr, Register rn, RegList rl) {
void Assembler::addrmod5(Instr instr, CRegister crd, const MemOperand& x) { void Assembler::addrmod5(Instr instr, CRegister crd, const MemOperand& x) {
// unindexed addressing is not encoded by this function // Unindexed addressing is not encoded by this function.
ASSERT_EQ((B27 | B26), ASSERT_EQ((B27 | B26),
(instr & ~(CondMask | CoprocessorMask | P | U | N | W | L))); (instr & ~(CondMask | CoprocessorMask | P | U | N | W | L)));
ASSERT(x.rn_.is_valid() && !x.rm_.is_valid()); ASSERT(x.rn_.is_valid() && !x.rm_.is_valid());
...@@ -759,7 +759,7 @@ void Assembler::addrmod5(Instr instr, CRegister crd, const MemOperand& x) { ...@@ -759,7 +759,7 @@ void Assembler::addrmod5(Instr instr, CRegister crd, const MemOperand& x) {
ASSERT(is_uint8(offset_8)); // unsigned word offset must fit in a byte ASSERT(is_uint8(offset_8)); // unsigned word offset must fit in a byte
ASSERT((am & (P|W)) == P || !x.rn_.is(pc)); // no pc base with writeback ASSERT((am & (P|W)) == P || !x.rn_.is(pc)); // no pc base with writeback
// post-indexed addressing requires W == 1; different than in addrmod2/3 // Post-indexed addressing requires W == 1; different than in addrmod2/3.
if ((am & P) == 0) if ((am & P) == 0)
am |= W; am |= W;
...@@ -782,7 +782,7 @@ int Assembler::branch_offset(Label* L, bool jump_elimination_allowed) { ...@@ -782,7 +782,7 @@ int Assembler::branch_offset(Label* L, bool jump_elimination_allowed) {
} }
// Block the emission of the constant pool, since the branch instruction must // Block the emission of the constant pool, since the branch instruction must
// be emitted at the pc offset recorded by the label // be emitted at the pc offset recorded by the label.
BlockConstPoolBefore(pc_offset() + kInstrSize); BlockConstPoolBefore(pc_offset() + kInstrSize);
return target_pos - (pc_offset() + kPcLoadDelta); return target_pos - (pc_offset() + kPcLoadDelta);
} }
...@@ -804,7 +804,7 @@ void Assembler::label_at_put(Label* L, int at_offset) { ...@@ -804,7 +804,7 @@ void Assembler::label_at_put(Label* L, int at_offset) {
} }
// Branch instructions // Branch instructions.
void Assembler::b(int branch_offset, Condition cond) { void Assembler::b(int branch_offset, Condition cond) {
ASSERT((branch_offset & 3) == 0); ASSERT((branch_offset & 3) == 0);
int imm24 = branch_offset >> 2; int imm24 = branch_offset >> 2;
...@@ -812,7 +812,7 @@ void Assembler::b(int branch_offset, Condition cond) { ...@@ -812,7 +812,7 @@ void Assembler::b(int branch_offset, Condition cond) {
emit(cond | B27 | B25 | (imm24 & Imm24Mask)); emit(cond | B27 | B25 | (imm24 & Imm24Mask));
if (cond == al) if (cond == al)
// dead code is a good location to emit the constant pool // Dead code is a good location to emit the constant pool.
CheckConstPool(false, false); CheckConstPool(false, false);
} }
...@@ -849,7 +849,7 @@ void Assembler::bx(Register target, Condition cond) { // v5 and above, plus v4t ...@@ -849,7 +849,7 @@ void Assembler::bx(Register target, Condition cond) { // v5 and above, plus v4t
} }
// Data-processing instructions // Data-processing instructions.
void Assembler::and_(Register dst, Register src1, const Operand& src2, void Assembler::and_(Register dst, Register src1, const Operand& src2,
SBit s, Condition cond) { SBit s, Condition cond) {
addrmod1(cond | 0*B21 | s, src1, dst, src2); addrmod1(cond | 0*B21 | s, src1, dst, src2);
...@@ -886,7 +886,7 @@ void Assembler::add(Register dst, Register src1, const Operand& src2, ...@@ -886,7 +886,7 @@ void Assembler::add(Register dst, Register src1, const Operand& src2,
if (FLAG_push_pop_elimination && if (FLAG_push_pop_elimination &&
last_bound_pos_ <= (pc_offset() - pattern_size) && last_bound_pos_ <= (pc_offset() - pattern_size) &&
reloc_info_writer.last_pc() <= (pc_ - pattern_size) && reloc_info_writer.last_pc() <= (pc_ - pattern_size) &&
// pattern // Pattern.
instr_at(pc_ - 1 * kInstrSize) == kPopInstruction && instr_at(pc_ - 1 * kInstrSize) == kPopInstruction &&
(instr_at(pc_ - 2 * kInstrSize) & ~RdMask) == kPushRegPattern) { (instr_at(pc_ - 2 * kInstrSize) & ~RdMask) == kPushRegPattern) {
pc_ -= 2 * kInstrSize; pc_ -= 2 * kInstrSize;
...@@ -960,7 +960,7 @@ void Assembler::mvn(Register dst, const Operand& src, SBit s, Condition cond) { ...@@ -960,7 +960,7 @@ void Assembler::mvn(Register dst, const Operand& src, SBit s, Condition cond) {
} }
// Multiply instructions // Multiply instructions.
void Assembler::mla(Register dst, Register src1, Register src2, Register srcA, void Assembler::mla(Register dst, Register src1, Register src2, Register srcA,
SBit s, Condition cond) { SBit s, Condition cond) {
ASSERT(!dst.is(pc) && !src1.is(pc) && !src2.is(pc) && !srcA.is(pc)); ASSERT(!dst.is(pc) && !src1.is(pc) && !src2.is(pc) && !srcA.is(pc));
...@@ -1029,7 +1029,7 @@ void Assembler::umull(Register dstL, ...@@ -1029,7 +1029,7 @@ void Assembler::umull(Register dstL,
} }
// Miscellaneous arithmetic instructions // Miscellaneous arithmetic instructions.
void Assembler::clz(Register dst, Register src, Condition cond) { void Assembler::clz(Register dst, Register src, Condition cond) {
// v5 and above. // v5 and above.
ASSERT(!dst.is(pc) && !src.is(pc)); ASSERT(!dst.is(pc) && !src.is(pc));
...@@ -1038,7 +1038,7 @@ void Assembler::clz(Register dst, Register src, Condition cond) { ...@@ -1038,7 +1038,7 @@ void Assembler::clz(Register dst, Register src, Condition cond) {
} }
// Status register access instructions // Status register access instructions.
void Assembler::mrs(Register dst, SRegister s, Condition cond) { void Assembler::mrs(Register dst, SRegister s, Condition cond) {
ASSERT(!dst.is(pc)); ASSERT(!dst.is(pc));
emit(cond | B24 | s | 15*B16 | dst.code()*B12); emit(cond | B24 | s | 15*B16 | dst.code()*B12);
...@@ -1050,12 +1050,12 @@ void Assembler::msr(SRegisterFieldMask fields, const Operand& src, ...@@ -1050,12 +1050,12 @@ void Assembler::msr(SRegisterFieldMask fields, const Operand& src,
ASSERT(fields >= B16 && fields < B20); // at least one field set ASSERT(fields >= B16 && fields < B20); // at least one field set
Instr instr; Instr instr;
if (!src.rm_.is_valid()) { if (!src.rm_.is_valid()) {
// immediate // Immediate.
uint32_t rotate_imm; uint32_t rotate_imm;
uint32_t immed_8; uint32_t immed_8;
if (MustUseIp(src.rmode_) || if (MustUseIp(src.rmode_) ||
!fits_shifter(src.imm32_, &rotate_imm, &immed_8, NULL)) { !fits_shifter(src.imm32_, &rotate_imm, &immed_8, NULL)) {
// immediate operand cannot be encoded, load it first to register ip // Immediate operand cannot be encoded, load it first to register ip.
RecordRelocInfo(src.rmode_, src.imm32_); RecordRelocInfo(src.rmode_, src.imm32_);
ldr(ip, MemOperand(pc, 0), cond); ldr(ip, MemOperand(pc, 0), cond);
msr(fields, Operand(ip), cond); msr(fields, Operand(ip), cond);
...@@ -1070,7 +1070,7 @@ void Assembler::msr(SRegisterFieldMask fields, const Operand& src, ...@@ -1070,7 +1070,7 @@ void Assembler::msr(SRegisterFieldMask fields, const Operand& src,
} }
// Load/Store instructions // Load/Store instructions.
void Assembler::ldr(Register dst, const MemOperand& src, Condition cond) { void Assembler::ldr(Register dst, const MemOperand& src, Condition cond) {
if (dst.is(pc)) { if (dst.is(pc)) {
WriteRecordedPositions(); WriteRecordedPositions();
...@@ -1085,7 +1085,7 @@ void Assembler::ldr(Register dst, const MemOperand& src, Condition cond) { ...@@ -1085,7 +1085,7 @@ void Assembler::ldr(Register dst, const MemOperand& src, Condition cond) {
if (FLAG_push_pop_elimination && if (FLAG_push_pop_elimination &&
last_bound_pos_ <= (pc_offset() - pattern_size) && last_bound_pos_ <= (pc_offset() - pattern_size) &&
reloc_info_writer.last_pc() <= (pc_ - pattern_size) && reloc_info_writer.last_pc() <= (pc_ - pattern_size) &&
// pattern // Pattern.
instr_at(pc_ - 1 * kInstrSize) == (kPopRegPattern | dst.code() * B12) && instr_at(pc_ - 1 * kInstrSize) == (kPopRegPattern | dst.code() * B12) &&
instr_at(pc_ - 2 * kInstrSize) == (kPushRegPattern | dst.code() * B12)) { instr_at(pc_ - 2 * kInstrSize) == (kPushRegPattern | dst.code() * B12)) {
pc_ -= 2 * kInstrSize; pc_ -= 2 * kInstrSize;
...@@ -1106,6 +1106,7 @@ void Assembler::str(Register src, const MemOperand& dst, Condition cond) { ...@@ -1106,6 +1106,7 @@ void Assembler::str(Register src, const MemOperand& dst, Condition cond) {
if (FLAG_push_pop_elimination && if (FLAG_push_pop_elimination &&
last_bound_pos_ <= (pc_offset() - pattern_size) && last_bound_pos_ <= (pc_offset() - pattern_size) &&
reloc_info_writer.last_pc() <= (pc_ - pattern_size) && reloc_info_writer.last_pc() <= (pc_ - pattern_size) &&
// Pattern.
instr_at(pc_ - 1 * kInstrSize) == (kPushRegPattern | src.code() * B12) && instr_at(pc_ - 1 * kInstrSize) == (kPushRegPattern | src.code() * B12) &&
instr_at(pc_ - 2 * kInstrSize) == kPopInstruction) { instr_at(pc_ - 2 * kInstrSize) == kPopInstruction) {
pc_ -= 2 * kInstrSize; pc_ -= 2 * kInstrSize;
...@@ -1147,17 +1148,17 @@ void Assembler::ldrsh(Register dst, const MemOperand& src, Condition cond) { ...@@ -1147,17 +1148,17 @@ void Assembler::ldrsh(Register dst, const MemOperand& src, Condition cond) {
} }
// Load/Store multiple instructions // Load/Store multiple instructions.
void Assembler::ldm(BlockAddrMode am, void Assembler::ldm(BlockAddrMode am,
Register base, Register base,
RegList dst, RegList dst,
Condition cond) { Condition cond) {
// ABI stack constraint: ldmxx base, {..sp..} base != sp is not restartable // ABI stack constraint: ldmxx base, {..sp..} base != sp is not restartable.
ASSERT(base.is(sp) || (dst & sp.bit()) == 0); ASSERT(base.is(sp) || (dst & sp.bit()) == 0);
addrmod4(cond | B27 | am | L, base, dst); addrmod4(cond | B27 | am | L, base, dst);
// emit the constant pool after a function return implemented by ldm ..{..pc} // Emit the constant pool after a function return implemented by ldm ..{..pc}.
if (cond == al && (dst & pc.bit()) != 0) { if (cond == al && (dst & pc.bit()) != 0) {
// There is a slight chance that the ldm instruction was actually a call, // There is a slight chance that the ldm instruction was actually a call,
// in which case it would be wrong to return into the constant pool; we // in which case it would be wrong to return into the constant pool; we
...@@ -1177,7 +1178,7 @@ void Assembler::stm(BlockAddrMode am, ...@@ -1177,7 +1178,7 @@ void Assembler::stm(BlockAddrMode am,
} }
// Semaphore instructions // Semaphore instructions.
void Assembler::swp(Register dst, Register src, Register base, Condition cond) { void Assembler::swp(Register dst, Register src, Register base, Condition cond) {
ASSERT(!dst.is(pc) && !src.is(pc) && !base.is(pc)); ASSERT(!dst.is(pc) && !src.is(pc) && !base.is(pc));
ASSERT(!dst.is(base) && !src.is(base)); ASSERT(!dst.is(base) && !src.is(base));
...@@ -1197,7 +1198,7 @@ void Assembler::swpb(Register dst, ...@@ -1197,7 +1198,7 @@ void Assembler::swpb(Register dst,
} }
// Exception-generating instructions and debugging support // Exception-generating instructions and debugging support.
void Assembler::stop(const char* msg) { void Assembler::stop(const char* msg) {
#if !defined(__arm__) #if !defined(__arm__)
// The simulator handles these special instructions and stops execution. // The simulator handles these special instructions and stops execution.
...@@ -1222,7 +1223,7 @@ void Assembler::swi(uint32_t imm24, Condition cond) { ...@@ -1222,7 +1223,7 @@ void Assembler::swi(uint32_t imm24, Condition cond) {
} }
// Coprocessor instructions // Coprocessor instructions.
void Assembler::cdp(Coprocessor coproc, void Assembler::cdp(Coprocessor coproc,
int opcode_1, int opcode_1,
CRegister crd, CRegister crd,
...@@ -1307,7 +1308,7 @@ void Assembler::ldc(Coprocessor coproc, ...@@ -1307,7 +1308,7 @@ void Assembler::ldc(Coprocessor coproc,
int option, int option,
LFlag l, LFlag l,
Condition cond) { Condition cond) {
// unindexed addressing // Unindexed addressing.
ASSERT(is_uint8(option)); ASSERT(is_uint8(option));
emit(cond | B27 | B26 | U | l | L | rn.code()*B16 | crd.code()*B12 | emit(cond | B27 | B26 | U | l | L | rn.code()*B16 | crd.code()*B12 |
coproc*B8 | (option & 255)); coproc*B8 | (option & 255));
...@@ -1346,7 +1347,7 @@ void Assembler::stc(Coprocessor coproc, ...@@ -1346,7 +1347,7 @@ void Assembler::stc(Coprocessor coproc,
int option, int option,
LFlag l, LFlag l,
Condition cond) { Condition cond) {
// unindexed addressing // Unindexed addressing.
ASSERT(is_uint8(option)); ASSERT(is_uint8(option));
emit(cond | B27 | B26 | U | l | rn.code()*B16 | crd.code()*B12 | emit(cond | B27 | B26 | U | l | rn.code()*B16 | crd.code()*B12 |
coproc*B8 | (option & 255)); coproc*B8 | (option & 255));
...@@ -1464,7 +1465,7 @@ void Assembler::vcvt(const DwVfpRegister dst, ...@@ -1464,7 +1465,7 @@ void Assembler::vcvt(const DwVfpRegister dst,
const Condition cond) { const Condition cond) {
// Dd = Sm (integer in Sm converted to IEEE 64-bit doubles in Dd). // Dd = Sm (integer in Sm converted to IEEE 64-bit doubles in Dd).
// Instruction details available in ARM DDI 0406A, A8-576. // Instruction details available in ARM DDI 0406A, A8-576.
// cond(31-28) | 11101(27-23)| D=?(22) | 11(21-20) | 1(19) |opc2=000(18-16) | // cond(31-28) | 11101(27-23)| D=?(22) | 11(21-20) | 1(19) | opc2=000(18-16) |
// Vd(15-12) | 101(11-9) | sz(8)=1 | op(7)=1 | 1(6) | M=?(5) | 0(4) | Vm(3-0) // Vd(15-12) | 101(11-9) | sz(8)=1 | op(7)=1 | 1(6) | M=?(5) | 0(4) | Vm(3-0)
ASSERT(CpuFeatures::IsEnabled(VFP3)); ASSERT(CpuFeatures::IsEnabled(VFP3));
emit(cond | 0xE*B24 | B23 | 0x3*B20 | B19 | emit(cond | 0xE*B24 | B23 | 0x3*B20 | B19 |
...@@ -1571,14 +1572,14 @@ void Assembler::vmrs(Register dst, Condition cond) { ...@@ -1571,14 +1572,14 @@ void Assembler::vmrs(Register dst, Condition cond) {
} }
// Pseudo instructions // Pseudo instructions.
void Assembler::lea(Register dst, void Assembler::lea(Register dst,
const MemOperand& x, const MemOperand& x,
SBit s, SBit s,
Condition cond) { Condition cond) {
int am = x.am_; int am = x.am_;
if (!x.rm_.is_valid()) { if (!x.rm_.is_valid()) {
// immediate offset // Immediate offset.
if ((am & P) == 0) // post indexing if ((am & P) == 0) // post indexing
mov(dst, Operand(x.rn_), s, cond); mov(dst, Operand(x.rn_), s, cond);
else if ((am & U) == 0) // negative indexing else if ((am & U) == 0) // negative indexing
...@@ -1612,7 +1613,7 @@ void Assembler::BlockConstPoolFor(int instructions) { ...@@ -1612,7 +1613,7 @@ void Assembler::BlockConstPoolFor(int instructions) {
} }
// Debugging // Debugging.
void Assembler::RecordJSReturn() { void Assembler::RecordJSReturn() {
WriteRecordedPositions(); WriteRecordedPositions();
CheckBuffer(); CheckBuffer();
...@@ -1665,7 +1666,7 @@ void Assembler::WriteRecordedPositions() { ...@@ -1665,7 +1666,7 @@ void Assembler::WriteRecordedPositions() {
void Assembler::GrowBuffer() { void Assembler::GrowBuffer() {
if (!own_buffer_) FATAL("external code buffer is too small"); if (!own_buffer_) FATAL("external code buffer is too small");
// compute new buffer size // Compute new buffer size.
CodeDesc desc; // the new buffer CodeDesc desc; // the new buffer
if (buffer_size_ < 4*KB) { if (buffer_size_ < 4*KB) {
desc.buffer_size = 4*KB; desc.buffer_size = 4*KB;
...@@ -1676,20 +1677,20 @@ void Assembler::GrowBuffer() { ...@@ -1676,20 +1677,20 @@ void Assembler::GrowBuffer() {
} }
CHECK_GT(desc.buffer_size, 0); // no overflow CHECK_GT(desc.buffer_size, 0); // no overflow
// setup new buffer // Setup new buffer.
desc.buffer = NewArray<byte>(desc.buffer_size); desc.buffer = NewArray<byte>(desc.buffer_size);
desc.instr_size = pc_offset(); desc.instr_size = pc_offset();
desc.reloc_size = (buffer_ + buffer_size_) - reloc_info_writer.pos(); desc.reloc_size = (buffer_ + buffer_size_) - reloc_info_writer.pos();
// copy the data // Copy the data.
int pc_delta = desc.buffer - buffer_; int pc_delta = desc.buffer - buffer_;
int rc_delta = (desc.buffer + desc.buffer_size) - (buffer_ + buffer_size_); int rc_delta = (desc.buffer + desc.buffer_size) - (buffer_ + buffer_size_);
memmove(desc.buffer, buffer_, desc.instr_size); memmove(desc.buffer, buffer_, desc.instr_size);
memmove(reloc_info_writer.pos() + rc_delta, memmove(reloc_info_writer.pos() + rc_delta,
reloc_info_writer.pos(), desc.reloc_size); reloc_info_writer.pos(), desc.reloc_size);
// switch buffers // Switch buffers.
DeleteArray(buffer_); DeleteArray(buffer_);
buffer_ = desc.buffer; buffer_ = desc.buffer;
buffer_size_ = desc.buffer_size; buffer_size_ = desc.buffer_size;
...@@ -1697,11 +1698,11 @@ void Assembler::GrowBuffer() { ...@@ -1697,11 +1698,11 @@ void Assembler::GrowBuffer() {
reloc_info_writer.Reposition(reloc_info_writer.pos() + rc_delta, reloc_info_writer.Reposition(reloc_info_writer.pos() + rc_delta,
reloc_info_writer.last_pc() + pc_delta); reloc_info_writer.last_pc() + pc_delta);
// none of our relocation types are pc relative pointing outside the code // None of our relocation types are pc relative pointing outside the code
// buffer nor pc absolute pointing inside the code buffer, so there is no need // buffer nor pc absolute pointing inside the code buffer, so there is no need
// to relocate any emitted relocation entries // to relocate any emitted relocation entries.
// relocate pending relocation entries // Relocate pending relocation entries.
for (int i = 0; i < num_prinfo_; i++) { for (int i = 0; i < num_prinfo_; i++) {
RelocInfo& rinfo = prinfo_[i]; RelocInfo& rinfo = prinfo_[i];
ASSERT(rinfo.rmode() != RelocInfo::COMMENT && ASSERT(rinfo.rmode() != RelocInfo::COMMENT &&
...@@ -1716,16 +1717,16 @@ void Assembler::GrowBuffer() { ...@@ -1716,16 +1717,16 @@ void Assembler::GrowBuffer() {
void Assembler::RecordRelocInfo(RelocInfo::Mode rmode, intptr_t data) { void Assembler::RecordRelocInfo(RelocInfo::Mode rmode, intptr_t data) {
RelocInfo rinfo(pc_, rmode, data); // we do not try to reuse pool constants RelocInfo rinfo(pc_, rmode, data); // we do not try to reuse pool constants
if (rmode >= RelocInfo::JS_RETURN && rmode <= RelocInfo::STATEMENT_POSITION) { if (rmode >= RelocInfo::JS_RETURN && rmode <= RelocInfo::STATEMENT_POSITION) {
// Adjust code for new modes // Adjust code for new modes.
ASSERT(RelocInfo::IsJSReturn(rmode) ASSERT(RelocInfo::IsJSReturn(rmode)
|| RelocInfo::IsComment(rmode) || RelocInfo::IsComment(rmode)
|| RelocInfo::IsPosition(rmode)); || RelocInfo::IsPosition(rmode));
// these modes do not need an entry in the constant pool // These modes do not need an entry in the constant pool.
} else { } else {
ASSERT(num_prinfo_ < kMaxNumPRInfo); ASSERT(num_prinfo_ < kMaxNumPRInfo);
prinfo_[num_prinfo_++] = rinfo; prinfo_[num_prinfo_++] = rinfo;
// Make sure the constant pool is not emitted in place of the next // Make sure the constant pool is not emitted in place of the next
// instruction for which we just recorded relocation info // instruction for which we just recorded relocation info.
BlockConstPoolBefore(pc_offset() + kInstrSize); BlockConstPoolBefore(pc_offset() + kInstrSize);
} }
if (rinfo.rmode() != RelocInfo::NONE) { if (rinfo.rmode() != RelocInfo::NONE) {
...@@ -1752,7 +1753,7 @@ void Assembler::CheckConstPool(bool force_emit, bool require_jump) { ...@@ -1752,7 +1753,7 @@ void Assembler::CheckConstPool(bool force_emit, bool require_jump) {
// blocked for a specific range. // blocked for a specific range.
next_buffer_check_ = pc_offset() + kCheckConstInterval; next_buffer_check_ = pc_offset() + kCheckConstInterval;
// There is nothing to do if there are no pending relocation info entries // There is nothing to do if there are no pending relocation info entries.
if (num_prinfo_ == 0) return; if (num_prinfo_ == 0) return;
// We emit a constant pool at regular intervals of about kDistBetweenPools // We emit a constant pool at regular intervals of about kDistBetweenPools
...@@ -1778,10 +1779,11 @@ void Assembler::CheckConstPool(bool force_emit, bool require_jump) { ...@@ -1778,10 +1779,11 @@ void Assembler::CheckConstPool(bool force_emit, bool require_jump) {
// no_const_pool_before_, which is checked here. Also, recursive calls to // no_const_pool_before_, which is checked here. Also, recursive calls to
// CheckConstPool are blocked by no_const_pool_before_. // CheckConstPool are blocked by no_const_pool_before_.
if (pc_offset() < no_const_pool_before_) { if (pc_offset() < no_const_pool_before_) {
// Emission is currently blocked; make sure we try again as soon as possible // Emission is currently blocked; make sure we try again as soon as
// possible.
next_buffer_check_ = no_const_pool_before_; next_buffer_check_ = no_const_pool_before_;
// Something is wrong if emission is forced and blocked at the same time // Something is wrong if emission is forced and blocked at the same time.
ASSERT(!force_emit); ASSERT(!force_emit);
return; return;
} }
...@@ -1795,23 +1797,23 @@ void Assembler::CheckConstPool(bool force_emit, bool require_jump) { ...@@ -1795,23 +1797,23 @@ void Assembler::CheckConstPool(bool force_emit, bool require_jump) {
jump_instr + kInstrSize + num_prinfo_*(kInstrSize + kMaxRelocSize); jump_instr + kInstrSize + num_prinfo_*(kInstrSize + kMaxRelocSize);
while (buffer_space() <= (max_needed_space + kGap)) GrowBuffer(); while (buffer_space() <= (max_needed_space + kGap)) GrowBuffer();
// Block recursive calls to CheckConstPool // Block recursive calls to CheckConstPool.
BlockConstPoolBefore(pc_offset() + jump_instr + kInstrSize + BlockConstPoolBefore(pc_offset() + jump_instr + kInstrSize +
num_prinfo_*kInstrSize); num_prinfo_*kInstrSize);
// Don't bother to check for the emit calls below. // Don't bother to check for the emit calls below.
next_buffer_check_ = no_const_pool_before_; next_buffer_check_ = no_const_pool_before_;
// Emit jump over constant pool if necessary // Emit jump over constant pool if necessary.
Label after_pool; Label after_pool;
if (require_jump) b(&after_pool); if (require_jump) b(&after_pool);
RecordComment("[ Constant Pool"); RecordComment("[ Constant Pool");
// Put down constant pool marker // Put down constant pool marker "Undefined instruction" as specified by
// "Undefined instruction" as specified by A3.1 Instruction set encoding // A3.1 Instruction set encoding.
emit(0x03000000 | num_prinfo_); emit(0x03000000 | num_prinfo_);
// Emit constant pool entries // Emit constant pool entries.
for (int i = 0; i < num_prinfo_; i++) { for (int i = 0; i < num_prinfo_; i++) {
RelocInfo& rinfo = prinfo_[i]; RelocInfo& rinfo = prinfo_[i];
ASSERT(rinfo.rmode() != RelocInfo::COMMENT && ASSERT(rinfo.rmode() != RelocInfo::COMMENT &&
...@@ -1819,8 +1821,8 @@ void Assembler::CheckConstPool(bool force_emit, bool require_jump) { ...@@ -1819,8 +1821,8 @@ void Assembler::CheckConstPool(bool force_emit, bool require_jump) {
rinfo.rmode() != RelocInfo::STATEMENT_POSITION); rinfo.rmode() != RelocInfo::STATEMENT_POSITION);
Instr instr = instr_at(rinfo.pc()); Instr instr = instr_at(rinfo.pc());
// Instruction to patch must be a ldr/str [pc, #offset] // Instruction to patch must be a ldr/str [pc, #offset].
// P and U set, B and W clear, Rn == pc, offset12 still 0 // P and U set, B and W clear, Rn == pc, offset12 still 0.
ASSERT((instr & (7*B25 | P | U | B | W | 15*B16 | Off12Mask)) == ASSERT((instr & (7*B25 | P | U | B | W | 15*B16 | Off12Mask)) ==
(2*B25 | P | U | pc.code()*B16)); (2*B25 | P | U | pc.code()*B16));
int delta = pc_ - rinfo.pc() - 8; int delta = pc_ - rinfo.pc() - 8;
......
...@@ -80,7 +80,7 @@ struct Register { ...@@ -80,7 +80,7 @@ struct Register {
return 1 << code_; return 1 << code_;
} }
// (unfortunately we can't make this private in a struct) // Unfortunately we can't make this private in a struct.
int code_; int code_;
}; };
...@@ -205,7 +205,7 @@ struct CRegister { ...@@ -205,7 +205,7 @@ struct CRegister {
return 1 << code_; return 1 << code_;
} }
// (unfortunately we can't make this private in a struct) // Unfortunately we can't make this private in a struct.
int code_; int code_;
}; };
......
...@@ -80,7 +80,7 @@ struct Register { ...@@ -80,7 +80,7 @@ struct Register {
return 1 << code_; return 1 << code_;
} }
// (unfortunately we can't make this private in a struct) // Unfortunately we can't make this private in a struct.
int code_; int code_;
}; };
...@@ -205,7 +205,7 @@ struct CRegister { ...@@ -205,7 +205,7 @@ struct CRegister {
return 1 << code_; return 1 << code_;
} }
// (unfortunately we can't make this private in a struct) // Unfortunately we can't make this private in a struct.
int code_; int code_;
}; };
......
...@@ -57,14 +57,7 @@ class MacroAssembler: public Assembler { ...@@ -57,14 +57,7 @@ class MacroAssembler: public Assembler {
public: public:
MacroAssembler(void* buffer, int size); MacroAssembler(void* buffer, int size);
// --------------------------------------------------------------------------- // Jump, Call, and Ret pseudo instructions implementing inter-working.
// Low-level helpers for compiler
// Jump, Call, and Ret pseudo instructions implementing inter-working
private:
void Jump(intptr_t target, RelocInfo::Mode rmode, Condition cond = al);
void Call(intptr_t target, RelocInfo::Mode rmode, Condition cond = al);
public:
void Jump(Register target, Condition cond = al); void Jump(Register target, Condition cond = al);
void Jump(byte* target, RelocInfo::Mode rmode, Condition cond = al); void Jump(byte* target, RelocInfo::Mode rmode, Condition cond = al);
void Jump(Handle<Code> code, RelocInfo::Mode rmode, Condition cond = al); void Jump(Handle<Code> code, RelocInfo::Mode rmode, Condition cond = al);
...@@ -394,11 +387,8 @@ class MacroAssembler: public Assembler { ...@@ -394,11 +387,8 @@ class MacroAssembler: public Assembler {
Label* not_flat_ascii_strings); Label* not_flat_ascii_strings);
private: private:
List<Unresolved> unresolved_; void Jump(intptr_t target, RelocInfo::Mode rmode, Condition cond = al);
bool generating_stub_; void Call(intptr_t target, RelocInfo::Mode rmode, Condition cond = al);
bool allow_stub_calls_;
Handle<Object> code_object_; // This handle will be patched with the code
// object on installation.
// Helper functions for generating invokes. // Helper functions for generating invokes.
void InvokePrologue(const ParameterCount& expected, void InvokePrologue(const ParameterCount& expected,
...@@ -423,6 +413,12 @@ class MacroAssembler: public Assembler { ...@@ -423,6 +413,12 @@ class MacroAssembler: public Assembler {
// Activation support. // Activation support.
void EnterFrame(StackFrame::Type type); void EnterFrame(StackFrame::Type type);
void LeaveFrame(StackFrame::Type type); void LeaveFrame(StackFrame::Type type);
List<Unresolved> unresolved_;
bool generating_stub_;
bool allow_stub_calls_;
// This handle will be patched with the code object on installation.
Handle<Object> code_object_;
}; };
......
...@@ -267,7 +267,7 @@ bool Operand::is_reg(Register reg) const { ...@@ -267,7 +267,7 @@ bool Operand::is_reg(Register reg) const {
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// Implementation of Assembler // Implementation of Assembler.
// Emit a single byte. Must always be inlined. // Emit a single byte. Must always be inlined.
#define EMIT(x) \ #define EMIT(x) \
...@@ -278,12 +278,12 @@ bool Operand::is_reg(Register reg) const { ...@@ -278,12 +278,12 @@ bool Operand::is_reg(Register reg) const {
static void InitCoverageLog(); static void InitCoverageLog();
#endif #endif
// spare_buffer_ // Spare buffer.
byte* Assembler::spare_buffer_ = NULL; byte* Assembler::spare_buffer_ = NULL;
Assembler::Assembler(void* buffer, int buffer_size) { Assembler::Assembler(void* buffer, int buffer_size) {
if (buffer == NULL) { if (buffer == NULL) {
// do our own buffer management // Do our own buffer management.
if (buffer_size <= kMinimalBufferSize) { if (buffer_size <= kMinimalBufferSize) {
buffer_size = kMinimalBufferSize; buffer_size = kMinimalBufferSize;
...@@ -300,7 +300,7 @@ Assembler::Assembler(void* buffer, int buffer_size) { ...@@ -300,7 +300,7 @@ Assembler::Assembler(void* buffer, int buffer_size) {
buffer_size_ = buffer_size; buffer_size_ = buffer_size;
own_buffer_ = true; own_buffer_ = true;
} else { } else {
// use externally provided buffer instead // Use externally provided buffer instead.
ASSERT(buffer_size > 0); ASSERT(buffer_size > 0);
buffer_ = static_cast<byte*>(buffer); buffer_ = static_cast<byte*>(buffer);
buffer_size_ = buffer_size; buffer_size_ = buffer_size;
...@@ -316,7 +316,7 @@ Assembler::Assembler(void* buffer, int buffer_size) { ...@@ -316,7 +316,7 @@ Assembler::Assembler(void* buffer, int buffer_size) {
} }
#endif #endif
// setup buffer pointers // Setup buffer pointers.
ASSERT(buffer_ != NULL); ASSERT(buffer_ != NULL);
pc_ = buffer_; pc_ = buffer_;
reloc_info_writer.Reposition(buffer_ + buffer_size, pc_); reloc_info_writer.Reposition(buffer_ + buffer_size, pc_);
...@@ -344,11 +344,10 @@ Assembler::~Assembler() { ...@@ -344,11 +344,10 @@ Assembler::~Assembler() {
void Assembler::GetCode(CodeDesc* desc) { void Assembler::GetCode(CodeDesc* desc) {
// finalize code // Finalize code (at this point overflow() may be true, but the gap ensures
// (at this point overflow() may be true, but the gap ensures that // that we are still not overlapping instructions and relocation info).
// we are still not overlapping instructions and relocation info) ASSERT(pc_ <= reloc_info_writer.pos()); // No overlap.
ASSERT(pc_ <= reloc_info_writer.pos()); // no overlap // Setup code descriptor.
// setup desc
desc->buffer = buffer_; desc->buffer = buffer_;
desc->buffer_size = buffer_size_; desc->buffer_size = buffer_size_;
desc->instr_size = pc_offset(); desc->instr_size = pc_offset();
...@@ -435,7 +434,7 @@ void Assembler::push(const Operand& src) { ...@@ -435,7 +434,7 @@ void Assembler::push(const Operand& src) {
void Assembler::pop(Register dst) { void Assembler::pop(Register dst) {
ASSERT(reloc_info_writer.last_pc() != NULL); ASSERT(reloc_info_writer.last_pc() != NULL);
if (FLAG_push_pop_elimination && (reloc_info_writer.last_pc() <= last_pc_)) { if (FLAG_push_pop_elimination && (reloc_info_writer.last_pc() <= last_pc_)) {
// (last_pc_ != NULL) is rolled into the above check // (last_pc_ != NULL) is rolled into the above check.
// If a last_pc_ is set, we need to make sure that there has not been any // If a last_pc_ is set, we need to make sure that there has not been any
// relocation information generated between the last instruction and this // relocation information generated between the last instruction and this
// pop instruction. // pop instruction.
...@@ -461,7 +460,7 @@ void Assembler::pop(Register dst) { ...@@ -461,7 +460,7 @@ void Assembler::pop(Register dst) {
return; return;
} else if (instr == 0xff) { // push of an operand, convert to a move } else if (instr == 0xff) { // push of an operand, convert to a move
byte op1 = last_pc_[1]; byte op1 = last_pc_[1];
// Check if the operation is really a push // Check if the operation is really a push.
if ((op1 & 0x38) == (6 << 3)) { if ((op1 & 0x38) == (6 << 3)) {
op1 = (op1 & ~0x38) | static_cast<byte>(dst.code() << 3); op1 = (op1 & ~0x38) | static_cast<byte>(dst.code() << 3);
last_pc_[0] = 0x8b; last_pc_[0] = 0x8b;
...@@ -747,7 +746,7 @@ void Assembler::cmov(Condition cc, Register dst, const Operand& src) { ...@@ -747,7 +746,7 @@ void Assembler::cmov(Condition cc, Register dst, const Operand& src) {
ASSERT(CpuFeatures::IsEnabled(CMOV)); ASSERT(CpuFeatures::IsEnabled(CMOV));
EnsureSpace ensure_space(this); EnsureSpace ensure_space(this);
last_pc_ = pc_; last_pc_ = pc_;
// Opcode: 0f 40 + cc /r // Opcode: 0f 40 + cc /r.
EMIT(0x0F); EMIT(0x0F);
EMIT(0x40 + cc); EMIT(0x40 + cc);
emit_operand(dst, src); emit_operand(dst, src);
...@@ -765,7 +764,7 @@ void Assembler::rep_movs() { ...@@ -765,7 +764,7 @@ void Assembler::rep_movs() {
void Assembler::xchg(Register dst, Register src) { void Assembler::xchg(Register dst, Register src) {
EnsureSpace ensure_space(this); EnsureSpace ensure_space(this);
last_pc_ = pc_; last_pc_ = pc_;
if (src.is(eax) || dst.is(eax)) { // Single-byte encoding if (src.is(eax) || dst.is(eax)) { // Single-byte encoding.
EMIT(0x90 | (src.is(eax) ? dst.code() : src.code())); EMIT(0x90 | (src.is(eax) ? dst.code() : src.code()));
} else { } else {
EMIT(0x87); EMIT(0x87);
...@@ -1434,7 +1433,7 @@ void Assembler::bind_to(Label* L, int pos) { ...@@ -1434,7 +1433,7 @@ void Assembler::bind_to(Label* L, int pos) {
if (disp.type() == Displacement::UNCONDITIONAL_JUMP) { if (disp.type() == Displacement::UNCONDITIONAL_JUMP) {
ASSERT(byte_at(fixup_pos - 1) == 0xE9); // jmp expected ASSERT(byte_at(fixup_pos - 1) == 0xE9); // jmp expected
} }
// relative address, relative to point after address // Relative address, relative to point after address.
int imm32 = pos - (fixup_pos + sizeof(int32_t)); int imm32 = pos - (fixup_pos + sizeof(int32_t));
long_at_put(fixup_pos, imm32); long_at_put(fixup_pos, imm32);
} }
...@@ -1449,7 +1448,7 @@ void Assembler::link_to(Label* L, Label* appendix) { ...@@ -1449,7 +1448,7 @@ void Assembler::link_to(Label* L, Label* appendix) {
last_pc_ = NULL; last_pc_ = NULL;
if (appendix->is_linked()) { if (appendix->is_linked()) {
if (L->is_linked()) { if (L->is_linked()) {
// append appendix to L's list // Append appendix to L's list.
Label p; Label p;
Label q = *L; Label q = *L;
do { do {
...@@ -1462,7 +1461,7 @@ void Assembler::link_to(Label* L, Label* appendix) { ...@@ -1462,7 +1461,7 @@ void Assembler::link_to(Label* L, Label* appendix) {
disp_at_put(&p, disp); disp_at_put(&p, disp);
p.Unuse(); // to avoid assertion failure in ~Label p.Unuse(); // to avoid assertion failure in ~Label
} else { } else {
// L is empty, simply use appendix // L is empty, simply use appendix.
*L = *appendix; *L = *appendix;
} }
} }
...@@ -1485,11 +1484,11 @@ void Assembler::call(Label* L) { ...@@ -1485,11 +1484,11 @@ void Assembler::call(Label* L) {
const int long_size = 5; const int long_size = 5;
int offs = L->pos() - pc_offset(); int offs = L->pos() - pc_offset();
ASSERT(offs <= 0); ASSERT(offs <= 0);
// 1110 1000 #32-bit disp // 1110 1000 #32-bit disp.
EMIT(0xE8); EMIT(0xE8);
emit(offs - long_size); emit(offs - long_size);
} else { } else {
// 1110 1000 #32-bit disp // 1110 1000 #32-bit disp.
EMIT(0xE8); EMIT(0xE8);
emit_disp(L, Displacement::OTHER); emit_disp(L, Displacement::OTHER);
} }
...@@ -1532,16 +1531,16 @@ void Assembler::jmp(Label* L) { ...@@ -1532,16 +1531,16 @@ void Assembler::jmp(Label* L) {
int offs = L->pos() - pc_offset(); int offs = L->pos() - pc_offset();
ASSERT(offs <= 0); ASSERT(offs <= 0);
if (is_int8(offs - short_size)) { if (is_int8(offs - short_size)) {
// 1110 1011 #8-bit disp // 1110 1011 #8-bit disp.
EMIT(0xEB); EMIT(0xEB);
EMIT((offs - short_size) & 0xFF); EMIT((offs - short_size) & 0xFF);
} else { } else {
// 1110 1001 #32-bit disp // 1110 1001 #32-bit disp.
EMIT(0xE9); EMIT(0xE9);
emit(offs - long_size); emit(offs - long_size);
} }
} else { } else {
// 1110 1001 #32-bit disp // 1110 1001 #32-bit disp.
EMIT(0xE9); EMIT(0xE9);
emit_disp(L, Displacement::UNCONDITIONAL_JUMP); emit_disp(L, Displacement::UNCONDITIONAL_JUMP);
} }
...@@ -1611,7 +1610,7 @@ void Assembler::j(Condition cc, byte* entry, RelocInfo::Mode rmode, Hint hint) { ...@@ -1611,7 +1610,7 @@ void Assembler::j(Condition cc, byte* entry, RelocInfo::Mode rmode, Hint hint) {
last_pc_ = pc_; last_pc_ = pc_;
ASSERT((0 <= cc) && (cc < 16)); ASSERT((0 <= cc) && (cc < 16));
if (FLAG_emit_branch_hints && hint != no_hint) EMIT(hint); if (FLAG_emit_branch_hints && hint != no_hint) EMIT(hint);
// 0000 1111 1000 tttn #32-bit disp // 0000 1111 1000 tttn #32-bit disp.
EMIT(0x0F); EMIT(0x0F);
EMIT(0x80 | cc); EMIT(0x80 | cc);
emit(entry - (pc_ + sizeof(int32_t)), rmode); emit(entry - (pc_ + sizeof(int32_t)), rmode);
...@@ -1629,7 +1628,7 @@ void Assembler::j(Condition cc, Handle<Code> code, Hint hint) { ...@@ -1629,7 +1628,7 @@ void Assembler::j(Condition cc, Handle<Code> code, Hint hint) {
} }
// FPU instructions // FPU instructions.
void Assembler::fld(int i) { void Assembler::fld(int i) {
EnsureSpace ensure_space(this); EnsureSpace ensure_space(this);
...@@ -2225,10 +2224,10 @@ void Assembler::WriteRecordedPositions() { ...@@ -2225,10 +2224,10 @@ void Assembler::WriteRecordedPositions() {
void Assembler::GrowBuffer() { void Assembler::GrowBuffer() {
ASSERT(overflow()); // should not call this otherwise ASSERT(overflow());
if (!own_buffer_) FATAL("external code buffer is too small"); if (!own_buffer_) FATAL("external code buffer is too small");
// compute new buffer size // Compute new buffer size.
CodeDesc desc; // the new buffer CodeDesc desc; // the new buffer
if (buffer_size_ < 4*KB) { if (buffer_size_ < 4*KB) {
desc.buffer_size = 4*KB; desc.buffer_size = 4*KB;
...@@ -2242,7 +2241,7 @@ void Assembler::GrowBuffer() { ...@@ -2242,7 +2241,7 @@ void Assembler::GrowBuffer() {
V8::FatalProcessOutOfMemory("Assembler::GrowBuffer"); V8::FatalProcessOutOfMemory("Assembler::GrowBuffer");
} }
// setup new buffer // Setup new buffer.
desc.buffer = NewArray<byte>(desc.buffer_size); desc.buffer = NewArray<byte>(desc.buffer_size);
desc.instr_size = pc_offset(); desc.instr_size = pc_offset();
desc.reloc_size = (buffer_ + buffer_size_) - (reloc_info_writer.pos()); desc.reloc_size = (buffer_ + buffer_size_) - (reloc_info_writer.pos());
...@@ -2253,14 +2252,14 @@ void Assembler::GrowBuffer() { ...@@ -2253,14 +2252,14 @@ void Assembler::GrowBuffer() {
memset(desc.buffer, 0xCC, desc.buffer_size); memset(desc.buffer, 0xCC, desc.buffer_size);
#endif #endif
// copy the data // Copy the data.
int pc_delta = desc.buffer - buffer_; int pc_delta = desc.buffer - buffer_;
int rc_delta = (desc.buffer + desc.buffer_size) - (buffer_ + buffer_size_); int rc_delta = (desc.buffer + desc.buffer_size) - (buffer_ + buffer_size_);
memmove(desc.buffer, buffer_, desc.instr_size); memmove(desc.buffer, buffer_, desc.instr_size);
memmove(rc_delta + reloc_info_writer.pos(), memmove(rc_delta + reloc_info_writer.pos(),
reloc_info_writer.pos(), desc.reloc_size); reloc_info_writer.pos(), desc.reloc_size);
// switch buffers // Switch buffers.
if (spare_buffer_ == NULL && buffer_size_ == kMinimalBufferSize) { if (spare_buffer_ == NULL && buffer_size_ == kMinimalBufferSize) {
spare_buffer_ = buffer_; spare_buffer_ = buffer_;
} else { } else {
...@@ -2275,7 +2274,7 @@ void Assembler::GrowBuffer() { ...@@ -2275,7 +2274,7 @@ void Assembler::GrowBuffer() {
reloc_info_writer.Reposition(reloc_info_writer.pos() + rc_delta, reloc_info_writer.Reposition(reloc_info_writer.pos() + rc_delta,
reloc_info_writer.last_pc() + pc_delta); reloc_info_writer.last_pc() + pc_delta);
// relocate runtime entries // Relocate runtime entries.
for (RelocIterator it(desc); !it.done(); it.next()) { for (RelocIterator it(desc); !it.done(); it.next()) {
RelocInfo::Mode rmode = it.rinfo()->rmode(); RelocInfo::Mode rmode = it.rinfo()->rmode();
if (rmode == RelocInfo::RUNTIME_ENTRY) { if (rmode == RelocInfo::RUNTIME_ENTRY) {
......
...@@ -77,7 +77,7 @@ struct Register { ...@@ -77,7 +77,7 @@ struct Register {
return 1 << code_; return 1 << code_;
} }
// (unfortunately we can't make this private in a struct) // Unfortunately we can't make this private in a struct.
int code_; int code_;
}; };
......
...@@ -430,8 +430,8 @@ class MacroAssembler: public Assembler { ...@@ -430,8 +430,8 @@ class MacroAssembler: public Assembler {
List<Unresolved> unresolved_; List<Unresolved> unresolved_;
bool generating_stub_; bool generating_stub_;
bool allow_stub_calls_; bool allow_stub_calls_;
Handle<Object> code_object_; // This handle will be patched with the // This handle will be patched with the code object on installation.
// code object on installation. Handle<Object> code_object_;
// Helper functions for generating invokes. // Helper functions for generating invokes.
void InvokePrologue(const ParameterCount& expected, void InvokePrologue(const ParameterCount& expected,
......
...@@ -265,7 +265,7 @@ Operand::Operand(Register base, ...@@ -265,7 +265,7 @@ Operand::Operand(Register base,
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// Implementation of Assembler // Implementation of Assembler.
#ifdef GENERATED_CODE_COVERAGE #ifdef GENERATED_CODE_COVERAGE
static void InitCoverageLog(); static void InitCoverageLog();
...@@ -276,7 +276,7 @@ byte* Assembler::spare_buffer_ = NULL; ...@@ -276,7 +276,7 @@ byte* Assembler::spare_buffer_ = NULL;
Assembler::Assembler(void* buffer, int buffer_size) Assembler::Assembler(void* buffer, int buffer_size)
: code_targets_(100) { : code_targets_(100) {
if (buffer == NULL) { if (buffer == NULL) {
// do our own buffer management // Do our own buffer management.
if (buffer_size <= kMinimalBufferSize) { if (buffer_size <= kMinimalBufferSize) {
buffer_size = kMinimalBufferSize; buffer_size = kMinimalBufferSize;
...@@ -293,7 +293,7 @@ Assembler::Assembler(void* buffer, int buffer_size) ...@@ -293,7 +293,7 @@ Assembler::Assembler(void* buffer, int buffer_size)
buffer_size_ = buffer_size; buffer_size_ = buffer_size;
own_buffer_ = true; own_buffer_ = true;
} else { } else {
// use externally provided buffer instead // Use externally provided buffer instead.
ASSERT(buffer_size > 0); ASSERT(buffer_size > 0);
buffer_ = static_cast<byte*>(buffer); buffer_ = static_cast<byte*>(buffer);
buffer_size_ = buffer_size; buffer_size_ = buffer_size;
...@@ -309,7 +309,7 @@ Assembler::Assembler(void* buffer, int buffer_size) ...@@ -309,7 +309,7 @@ Assembler::Assembler(void* buffer, int buffer_size)
} }
#endif #endif
// setup buffer pointers // Setup buffer pointers.
ASSERT(buffer_ != NULL); ASSERT(buffer_ != NULL);
pc_ = buffer_; pc_ = buffer_;
reloc_info_writer.Reposition(buffer_ + buffer_size, pc_); reloc_info_writer.Reposition(buffer_ + buffer_size, pc_);
...@@ -337,11 +337,10 @@ Assembler::~Assembler() { ...@@ -337,11 +337,10 @@ Assembler::~Assembler() {
void Assembler::GetCode(CodeDesc* desc) { void Assembler::GetCode(CodeDesc* desc) {
// finalize code // Finalize code (at this point overflow() may be true, but the gap ensures
// (at this point overflow() may be true, but the gap ensures that // that we are still not overlapping instructions and relocation info).
// we are still not overlapping instructions and relocation info) ASSERT(pc_ <= reloc_info_writer.pos()); // No overlap.
ASSERT(pc_ <= reloc_info_writer.pos()); // no overlap // Setup code descriptor.
// setup desc
desc->buffer = buffer_; desc->buffer = buffer_;
desc->buffer_size = buffer_size_; desc->buffer_size = buffer_size_;
desc->instr_size = pc_offset(); desc->instr_size = pc_offset();
...@@ -370,7 +369,7 @@ void Assembler::bind_to(Label* L, int pos) { ...@@ -370,7 +369,7 @@ void Assembler::bind_to(Label* L, int pos) {
int current = L->pos(); int current = L->pos();
int next = long_at(current); int next = long_at(current);
while (next != current) { while (next != current) {
// relative address, relative to point after address // Relative address, relative to point after address.
int imm32 = pos - (current + sizeof(int32_t)); int imm32 = pos - (current + sizeof(int32_t));
long_at_put(current, imm32); long_at_put(current, imm32);
current = next; current = next;
...@@ -390,10 +389,10 @@ void Assembler::bind(Label* L) { ...@@ -390,10 +389,10 @@ void Assembler::bind(Label* L) {
void Assembler::GrowBuffer() { void Assembler::GrowBuffer() {
ASSERT(buffer_overflow()); // should not call this otherwise ASSERT(buffer_overflow());
if (!own_buffer_) FATAL("external code buffer is too small"); if (!own_buffer_) FATAL("external code buffer is too small");
// compute new buffer size // Compute new buffer size.
CodeDesc desc; // the new buffer CodeDesc desc; // the new buffer
if (buffer_size_ < 4*KB) { if (buffer_size_ < 4*KB) {
desc.buffer_size = 4*KB; desc.buffer_size = 4*KB;
...@@ -407,7 +406,7 @@ void Assembler::GrowBuffer() { ...@@ -407,7 +406,7 @@ void Assembler::GrowBuffer() {
V8::FatalProcessOutOfMemory("Assembler::GrowBuffer"); V8::FatalProcessOutOfMemory("Assembler::GrowBuffer");
} }
// setup new buffer // Setup new buffer.
desc.buffer = NewArray<byte>(desc.buffer_size); desc.buffer = NewArray<byte>(desc.buffer_size);
desc.instr_size = pc_offset(); desc.instr_size = pc_offset();
desc.reloc_size = desc.reloc_size =
...@@ -419,7 +418,7 @@ void Assembler::GrowBuffer() { ...@@ -419,7 +418,7 @@ void Assembler::GrowBuffer() {
memset(desc.buffer, 0xCC, desc.buffer_size); memset(desc.buffer, 0xCC, desc.buffer_size);
#endif #endif
// copy the data // Copy the data.
intptr_t pc_delta = desc.buffer - buffer_; intptr_t pc_delta = desc.buffer - buffer_;
intptr_t rc_delta = (desc.buffer + desc.buffer_size) - intptr_t rc_delta = (desc.buffer + desc.buffer_size) -
(buffer_ + buffer_size_); (buffer_ + buffer_size_);
...@@ -427,7 +426,7 @@ void Assembler::GrowBuffer() { ...@@ -427,7 +426,7 @@ void Assembler::GrowBuffer() {
memmove(rc_delta + reloc_info_writer.pos(), memmove(rc_delta + reloc_info_writer.pos(),
reloc_info_writer.pos(), desc.reloc_size); reloc_info_writer.pos(), desc.reloc_size);
// switch buffers // Switch buffers.
if (spare_buffer_ == NULL && buffer_size_ == kMinimalBufferSize) { if (spare_buffer_ == NULL && buffer_size_ == kMinimalBufferSize) {
spare_buffer_ = buffer_; spare_buffer_ = buffer_;
} else { } else {
...@@ -442,7 +441,7 @@ void Assembler::GrowBuffer() { ...@@ -442,7 +441,7 @@ void Assembler::GrowBuffer() {
reloc_info_writer.Reposition(reloc_info_writer.pos() + rc_delta, reloc_info_writer.Reposition(reloc_info_writer.pos() + rc_delta,
reloc_info_writer.last_pc() + pc_delta); reloc_info_writer.last_pc() + pc_delta);
// relocate runtime entries // Relocate runtime entries.
for (RelocIterator it(desc); !it.done(); it.next()) { for (RelocIterator it(desc); !it.done(); it.next()) {
RelocInfo::Mode rmode = it.rinfo()->rmode(); RelocInfo::Mode rmode = it.rinfo()->rmode();
if (rmode == RelocInfo::INTERNAL_REFERENCE) { if (rmode == RelocInfo::INTERNAL_REFERENCE) {
...@@ -472,7 +471,7 @@ void Assembler::emit_operand(int code, const Operand& adr) { ...@@ -472,7 +471,7 @@ void Assembler::emit_operand(int code, const Operand& adr) {
} }
// Assembler Instruction implementations // Assembler Instruction implementations.
void Assembler::arithmetic_op(byte opcode, Register reg, const Operand& op) { void Assembler::arithmetic_op(byte opcode, Register reg, const Operand& op) {
EnsureSpace ensure_space(this); EnsureSpace ensure_space(this);
...@@ -756,7 +755,7 @@ void Assembler::bts(const Operand& dst, Register src) { ...@@ -756,7 +755,7 @@ void Assembler::bts(const Operand& dst, Register src) {
void Assembler::call(Label* L) { void Assembler::call(Label* L) {
EnsureSpace ensure_space(this); EnsureSpace ensure_space(this);
last_pc_ = pc_; last_pc_ = pc_;
// 1110 1000 #32-bit disp // 1110 1000 #32-bit disp.
emit(0xE8); emit(0xE8);
if (L->is_bound()) { if (L->is_bound()) {
int offset = L->pos() - pc_offset() - sizeof(int32_t); int offset = L->pos() - pc_offset() - sizeof(int32_t);
...@@ -777,7 +776,7 @@ void Assembler::call(Label* L) { ...@@ -777,7 +776,7 @@ void Assembler::call(Label* L) {
void Assembler::call(Handle<Code> target, RelocInfo::Mode rmode) { void Assembler::call(Handle<Code> target, RelocInfo::Mode rmode) {
EnsureSpace ensure_space(this); EnsureSpace ensure_space(this);
last_pc_ = pc_; last_pc_ = pc_;
// 1110 1000 #32-bit disp // 1110 1000 #32-bit disp.
emit(0xE8); emit(0xE8);
emit_code_target(target, rmode); emit_code_target(target, rmode);
} }
...@@ -786,7 +785,7 @@ void Assembler::call(Handle<Code> target, RelocInfo::Mode rmode) { ...@@ -786,7 +785,7 @@ void Assembler::call(Handle<Code> target, RelocInfo::Mode rmode) {
void Assembler::call(Register adr) { void Assembler::call(Register adr) {
EnsureSpace ensure_space(this); EnsureSpace ensure_space(this);
last_pc_ = pc_; last_pc_ = pc_;
// Opcode: FF /2 r64 // Opcode: FF /2 r64.
if (adr.high_bit()) { if (adr.high_bit()) {
emit_rex_64(adr); emit_rex_64(adr);
} }
...@@ -798,7 +797,7 @@ void Assembler::call(Register adr) { ...@@ -798,7 +797,7 @@ void Assembler::call(Register adr) {
void Assembler::call(const Operand& op) { void Assembler::call(const Operand& op) {
EnsureSpace ensure_space(this); EnsureSpace ensure_space(this);
last_pc_ = pc_; last_pc_ = pc_;
// Opcode: FF /2 m64 // Opcode: FF /2 m64.
emit_rex_64(op); emit_rex_64(op);
emit(0xFF); emit(0xFF);
emit_operand(2, op); emit_operand(2, op);
...@@ -829,7 +828,7 @@ void Assembler::cmovq(Condition cc, Register dst, Register src) { ...@@ -829,7 +828,7 @@ void Assembler::cmovq(Condition cc, Register dst, Register src) {
ASSERT(cc >= 0); // Use mov for unconditional moves. ASSERT(cc >= 0); // Use mov for unconditional moves.
EnsureSpace ensure_space(this); EnsureSpace ensure_space(this);
last_pc_ = pc_; last_pc_ = pc_;
// Opcode: REX.W 0f 40 + cc /r // Opcode: REX.W 0f 40 + cc /r.
emit_rex_64(dst, src); emit_rex_64(dst, src);
emit(0x0f); emit(0x0f);
emit(0x40 + cc); emit(0x40 + cc);
...@@ -846,7 +845,7 @@ void Assembler::cmovq(Condition cc, Register dst, const Operand& src) { ...@@ -846,7 +845,7 @@ void Assembler::cmovq(Condition cc, Register dst, const Operand& src) {
ASSERT(cc >= 0); ASSERT(cc >= 0);
EnsureSpace ensure_space(this); EnsureSpace ensure_space(this);
last_pc_ = pc_; last_pc_ = pc_;
// Opcode: REX.W 0f 40 + cc /r // Opcode: REX.W 0f 40 + cc /r.
emit_rex_64(dst, src); emit_rex_64(dst, src);
emit(0x0f); emit(0x0f);
emit(0x40 + cc); emit(0x40 + cc);
...@@ -863,7 +862,7 @@ void Assembler::cmovl(Condition cc, Register dst, Register src) { ...@@ -863,7 +862,7 @@ void Assembler::cmovl(Condition cc, Register dst, Register src) {
ASSERT(cc >= 0); ASSERT(cc >= 0);
EnsureSpace ensure_space(this); EnsureSpace ensure_space(this);
last_pc_ = pc_; last_pc_ = pc_;
// Opcode: 0f 40 + cc /r // Opcode: 0f 40 + cc /r.
emit_optional_rex_32(dst, src); emit_optional_rex_32(dst, src);
emit(0x0f); emit(0x0f);
emit(0x40 + cc); emit(0x40 + cc);
...@@ -880,7 +879,7 @@ void Assembler::cmovl(Condition cc, Register dst, const Operand& src) { ...@@ -880,7 +879,7 @@ void Assembler::cmovl(Condition cc, Register dst, const Operand& src) {
ASSERT(cc >= 0); ASSERT(cc >= 0);
EnsureSpace ensure_space(this); EnsureSpace ensure_space(this);
last_pc_ = pc_; last_pc_ = pc_;
// Opcode: 0f 40 + cc /r // Opcode: 0f 40 + cc /r.
emit_optional_rex_32(dst, src); emit_optional_rex_32(dst, src);
emit(0x0f); emit(0x0f);
emit(0x40 + cc); emit(0x40 + cc);
...@@ -1110,17 +1109,17 @@ void Assembler::j(Condition cc, Label* L) { ...@@ -1110,17 +1109,17 @@ void Assembler::j(Condition cc, Label* L) {
int offs = L->pos() - pc_offset(); int offs = L->pos() - pc_offset();
ASSERT(offs <= 0); ASSERT(offs <= 0);
if (is_int8(offs - short_size)) { if (is_int8(offs - short_size)) {
// 0111 tttn #8-bit disp // 0111 tttn #8-bit disp.
emit(0x70 | cc); emit(0x70 | cc);
emit((offs - short_size) & 0xFF); emit((offs - short_size) & 0xFF);
} else { } else {
// 0000 1111 1000 tttn #32-bit disp // 0000 1111 1000 tttn #32-bit disp.
emit(0x0F); emit(0x0F);
emit(0x80 | cc); emit(0x80 | cc);
emitl(offs - long_size); emitl(offs - long_size);
} }
} else if (L->is_linked()) { } else if (L->is_linked()) {
// 0000 1111 1000 tttn #32-bit disp // 0000 1111 1000 tttn #32-bit disp.
emit(0x0F); emit(0x0F);
emit(0x80 | cc); emit(0x80 | cc);
emitl(L->pos()); emitl(L->pos());
...@@ -1142,7 +1141,7 @@ void Assembler::j(Condition cc, ...@@ -1142,7 +1141,7 @@ void Assembler::j(Condition cc,
EnsureSpace ensure_space(this); EnsureSpace ensure_space(this);
last_pc_ = pc_; last_pc_ = pc_;
ASSERT(is_uint4(cc)); ASSERT(is_uint4(cc));
// 0000 1111 1000 tttn #32-bit disp // 0000 1111 1000 tttn #32-bit disp.
emit(0x0F); emit(0x0F);
emit(0x80 | cc); emit(0x80 | cc);
emit_code_target(target, rmode); emit_code_target(target, rmode);
...@@ -1156,21 +1155,21 @@ void Assembler::jmp(Label* L) { ...@@ -1156,21 +1155,21 @@ void Assembler::jmp(Label* L) {
int offs = L->pos() - pc_offset() - 1; int offs = L->pos() - pc_offset() - 1;
ASSERT(offs <= 0); ASSERT(offs <= 0);
if (is_int8(offs - sizeof(int8_t))) { if (is_int8(offs - sizeof(int8_t))) {
// 1110 1011 #8-bit disp // 1110 1011 #8-bit disp.
emit(0xEB); emit(0xEB);
emit((offs - sizeof(int8_t)) & 0xFF); emit((offs - sizeof(int8_t)) & 0xFF);
} else { } else {
// 1110 1001 #32-bit disp // 1110 1001 #32-bit disp.
emit(0xE9); emit(0xE9);
emitl(offs - sizeof(int32_t)); emitl(offs - sizeof(int32_t));
} }
} else if (L->is_linked()) { } else if (L->is_linked()) {
// 1110 1001 #32-bit disp // 1110 1001 #32-bit disp.
emit(0xE9); emit(0xE9);
emitl(L->pos()); emitl(L->pos());
L->link_to(pc_offset() - sizeof(int32_t)); L->link_to(pc_offset() - sizeof(int32_t));
} else { } else {
// 1110 1001 #32-bit disp // 1110 1001 #32-bit disp.
ASSERT(L->is_unused()); ASSERT(L->is_unused());
emit(0xE9); emit(0xE9);
int32_t current = pc_offset(); int32_t current = pc_offset();
...@@ -1183,7 +1182,7 @@ void Assembler::jmp(Label* L) { ...@@ -1183,7 +1182,7 @@ void Assembler::jmp(Label* L) {
void Assembler::jmp(Handle<Code> target, RelocInfo::Mode rmode) { void Assembler::jmp(Handle<Code> target, RelocInfo::Mode rmode) {
EnsureSpace ensure_space(this); EnsureSpace ensure_space(this);
last_pc_ = pc_; last_pc_ = pc_;
// 1110 1001 #32-bit disp // 1110 1001 #32-bit disp.
emit(0xE9); emit(0xE9);
emit_code_target(target, rmode); emit_code_target(target, rmode);
} }
...@@ -1192,7 +1191,7 @@ void Assembler::jmp(Handle<Code> target, RelocInfo::Mode rmode) { ...@@ -1192,7 +1191,7 @@ void Assembler::jmp(Handle<Code> target, RelocInfo::Mode rmode) {
void Assembler::jmp(Register target) { void Assembler::jmp(Register target) {
EnsureSpace ensure_space(this); EnsureSpace ensure_space(this);
last_pc_ = pc_; last_pc_ = pc_;
// Opcode FF/4 r64 // Opcode FF/4 r64.
if (target.high_bit()) { if (target.high_bit()) {
emit_rex_64(target); emit_rex_64(target);
} }
...@@ -1204,7 +1203,7 @@ void Assembler::jmp(Register target) { ...@@ -1204,7 +1203,7 @@ void Assembler::jmp(Register target) {
void Assembler::jmp(const Operand& src) { void Assembler::jmp(const Operand& src) {
EnsureSpace ensure_space(this); EnsureSpace ensure_space(this);
last_pc_ = pc_; last_pc_ = pc_;
// Opcode FF/4 m64 // Opcode FF/4 m64.
emit_optional_rex_32(src); emit_optional_rex_32(src);
emit(0xFF); emit(0xFF);
emit_operand(0x4, src); emit_operand(0x4, src);
...@@ -1413,10 +1412,8 @@ void Assembler::movq(const Operand& dst, Immediate value) { ...@@ -1413,10 +1412,8 @@ void Assembler::movq(const Operand& dst, Immediate value) {
} }
/* // Loads the ip-relative location of the src label into the target location
* Loads the ip-relative location of the src label into the target // (as a 32-bit offset sign extended to 64-bit).
* location (as a 32-bit offset sign extended to 64-bit).
*/
void Assembler::movl(const Operand& dst, Label* src) { void Assembler::movl(const Operand& dst, Label* src) {
EnsureSpace ensure_space(this); EnsureSpace ensure_space(this);
last_pc_ = pc_; last_pc_ = pc_;
...@@ -2006,7 +2003,7 @@ void Assembler::testq(Register dst, Immediate mask) { ...@@ -2006,7 +2003,7 @@ void Assembler::testq(Register dst, Immediate mask) {
} }
// FPU instructions // FPU instructions.
void Assembler::fld(int i) { void Assembler::fld(int i) {
...@@ -2377,7 +2374,7 @@ void Assembler::emit_farith(int b1, int b2, int i) { ...@@ -2377,7 +2374,7 @@ void Assembler::emit_farith(int b1, int b2, int i) {
emit(b2 + i); emit(b2 + i);
} }
// SSE 2 operations // SSE 2 operations.
void Assembler::movsd(const Operand& dst, XMMRegister src) { void Assembler::movsd(const Operand& dst, XMMRegister src) {
EnsureSpace ensure_space(this); EnsureSpace ensure_space(this);
...@@ -2527,7 +2524,7 @@ void Assembler::emit_sse_operand(XMMRegister dst, Register src) { ...@@ -2527,7 +2524,7 @@ void Assembler::emit_sse_operand(XMMRegister dst, Register src) {
} }
// Relocation information implementations // Relocation information implementations.
void Assembler::RecordRelocInfo(RelocInfo::Mode rmode, intptr_t data) { void Assembler::RecordRelocInfo(RelocInfo::Mode rmode, intptr_t data) {
ASSERT(rmode != RelocInfo::NONE); ASSERT(rmode != RelocInfo::NONE);
......
...@@ -113,8 +113,8 @@ struct Register { ...@@ -113,8 +113,8 @@ struct Register {
return code_ & 0x7; return code_ & 0x7;
} }
// (unfortunately we can't make this private in a struct when initializing // Unfortunately we can't make this private in a struct when initializing
// by assignment.) // by assignment.
int code_; int code_;
}; };
......
...@@ -712,8 +712,8 @@ class MacroAssembler: public Assembler { ...@@ -712,8 +712,8 @@ class MacroAssembler: public Assembler {
List<Unresolved> unresolved_; List<Unresolved> unresolved_;
bool generating_stub_; bool generating_stub_;
bool allow_stub_calls_; bool allow_stub_calls_;
Handle<Object> code_object_; // This handle will be patched with the code // This handle will be patched with the code object on installation.
// object on installation. Handle<Object> code_object_;
// Helper functions for generating invokes. // Helper functions for generating invokes.
void InvokePrologue(const ParameterCount& expected, void InvokePrologue(const ParameterCount& expected,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment