void RelocInfo::apply(int delta) {
- if (is_internal_reference(rmode_)) {
+ if (RelocInfo::IsInternalReference(rmode_)) {
// absolute code pointer inside code object moves with the code object.
int32_t* p = reinterpret_cast<int32_t*>(pc_);
*p += delta; // relocate entry
Address RelocInfo::target_address() {
- ASSERT(is_code_target(rmode_));
+ ASSERT(IsCodeTarget(rmode_));
return Assembler::target_address_at(pc_);
}
void RelocInfo::set_target_address(Address target) {
- ASSERT(is_code_target(rmode_));
+ ASSERT(IsCodeTarget(rmode_));
Assembler::set_target_address_at(pc_, target);
}
Object* RelocInfo::target_object() {
- ASSERT(is_code_target(rmode_) || rmode_ == embedded_object);
+ ASSERT(IsCodeTarget(rmode_) || rmode_ == EMBEDDED_OBJECT);
return reinterpret_cast<Object*>(Assembler::target_address_at(pc_));
}
Object** RelocInfo::target_object_address() {
- ASSERT(is_code_target(rmode_) || rmode_ == embedded_object);
+ ASSERT(IsCodeTarget(rmode_) || rmode_ == EMBEDDED_OBJECT);
return reinterpret_cast<Object**>(Assembler::target_address_address_at(pc_));
}
void RelocInfo::set_target_object(Object* target) {
- ASSERT(is_code_target(rmode_) || rmode_ == embedded_object);
+ ASSERT(IsCodeTarget(rmode_) || rmode_ == EMBEDDED_OBJECT);
Assembler::set_target_address_at(pc_, reinterpret_cast<Address>(target));
}
Address* RelocInfo::target_reference_address() {
- ASSERT(rmode_ == external_reference);
+ ASSERT(rmode_ == EXTERNAL_REFERENCE);
return reinterpret_cast<Address*>(pc_);
}
}
-Operand::Operand(int32_t immediate, RelocMode rmode) {
+Operand::Operand(int32_t immediate, RelocInfo::Mode rmode) {
rm_ = no_reg;
imm32_ = immediate;
rmode_ = rmode;
Operand::Operand(const char* s) {
rm_ = no_reg;
imm32_ = reinterpret_cast<int32_t>(s);
- rmode_ = embedded_string;
+ rmode_ = RelocInfo::EMBEDDED_STRING;
}
Operand::Operand(const ExternalReference& f) {
rm_ = no_reg;
imm32_ = reinterpret_cast<int32_t>(f.address());
- rmode_ = external_reference;
+ rmode_ = RelocInfo::EXTERNAL_REFERENCE;
}
Operand::Operand(Object** opp) {
rm_ = no_reg;
imm32_ = reinterpret_cast<int32_t>(opp);
- rmode_ = no_reloc;
+ rmode_ = RelocInfo::NONE;
}
Operand::Operand(Context** cpp) {
rm_ = no_reg;
imm32_ = reinterpret_cast<int32_t>(cpp);
- rmode_ = no_reloc;
+ rmode_ = RelocInfo::NONE;
}
Operand::Operand(Smi* value) {
rm_ = no_reg;
imm32_ = reinterpret_cast<intptr_t>(value);
- rmode_ = no_reloc;
+ rmode_ = RelocInfo::NONE;
}
ASSERT(!Heap::InNewSpace(obj));
if (obj->IsHeapObject()) {
imm32_ = reinterpret_cast<intptr_t>(handle.location());
- rmode_ = embedded_object;
+ rmode_ = RelocInfo::EMBEDDED_OBJECT;
} else {
// no relocation needed
imm32_ = reinterpret_cast<intptr_t>(obj);
- rmode_ = no_reloc;
+ rmode_ = RelocInfo::NONE;
}
}
no_const_pool_before_ = 0;
last_const_pool_end_ = 0;
last_bound_pos_ = 0;
- last_position_ = kNoPosition;
+ last_position_ = RelocInfo::kNoPosition;
last_position_is_statement_ = false;
}
// immediate
uint32_t rotate_imm;
uint32_t immed_8;
- if ((x.rmode_ != no_reloc && x.rmode_ != external_reference) ||
+ if ((x.rmode_ != RelocInfo::NONE &&
+ x.rmode_ != RelocInfo::EXTERNAL_REFERENCE) ||
!fits_shifter(x.imm32_, &rotate_imm, &immed_8, &instr)) {
// 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.
// immediate
uint32_t rotate_imm;
uint32_t immed_8;
- if ((src.rmode_ != no_reloc && src.rmode_ != external_reference)||
+ if ((src.rmode_ != RelocInfo::NONE &&
+ src.rmode_ != RelocInfo::EXTERNAL_REFERENCE)||
!fits_shifter(src.imm32_, &rotate_imm, &immed_8, NULL)) {
// immediate operand cannot be encoded, load it first to register ip
RecordRelocInfo(src.rmode_, src.imm32_);
void Assembler::RecordComment(const char* msg) {
if (FLAG_debug_code) {
CheckBuffer();
- RecordRelocInfo(comment, reinterpret_cast<intptr_t>(msg));
+ RecordRelocInfo(RelocInfo::COMMENT, reinterpret_cast<intptr_t>(msg));
}
}
void Assembler::RecordPosition(int pos) {
- if (pos == kNoPosition) return;
- ASSERT(position >= 0);
+ if (pos == RelocInfo::kNoPosition) return;
+ ASSERT(pos >= 0);
if (pos == last_position_) return;
CheckBuffer();
- RecordRelocInfo(position, pos);
+ RecordRelocInfo(RelocInfo::POSITION, pos);
last_position_ = pos;
last_position_is_statement_ = false;
}
void Assembler::RecordStatementPosition(int pos) {
if (pos == last_position_) return;
CheckBuffer();
- RecordRelocInfo(statement_position, pos);
+ RecordRelocInfo(RelocInfo::STATEMENT_POSITION, pos);
last_position_ = pos;
last_position_is_statement_ = true;
}
// relocate pending relocation entries
for (int i = 0; i < num_prinfo_; i++) {
RelocInfo& rinfo = prinfo_[i];
- ASSERT(rinfo.rmode() != comment && rinfo.rmode() != position);
+ ASSERT(rinfo.rmode() != RelocInfo::COMMENT &&
+ rinfo.rmode() != RelocInfo::POSITION);
rinfo.set_pc(rinfo.pc() + pc_delta);
}
}
-void Assembler::RecordRelocInfo(RelocMode 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
- if (rmode >= comment && rmode <= statement_position) {
+ if (rmode >= RelocInfo::COMMENT && rmode <= RelocInfo::STATEMENT_POSITION) {
// adjust code for new modes
- ASSERT(is_comment(rmode) || is_position(rmode));
+ ASSERT(RelocInfo::IsComment(rmode) || RelocInfo::IsPosition(rmode));
// these modes do not need an entry in the constant pool
} else {
ASSERT(num_prinfo_ < kMaxNumPRInfo);
// instruction for which we just recorded relocation info
BlockConstPoolBefore(pc_offset() + kInstrSize);
}
- if (rinfo.rmode() != no_reloc) {
+ if (rinfo.rmode() != RelocInfo::NONE) {
// Don't record external references unless the heap will be serialized.
- if (rmode == external_reference &&
+ if (rmode == RelocInfo::EXTERNAL_REFERENCE &&
!Serializer::enabled() &&
!FLAG_debug_code) {
return;
// Emit constant pool entries
for (int i = 0; i < num_prinfo_; i++) {
RelocInfo& rinfo = prinfo_[i];
- ASSERT(rinfo.rmode() != comment && rinfo.rmode() != position &&
- rinfo.rmode() != statement_position);
+ ASSERT(rinfo.rmode() != RelocInfo::COMMENT &&
+ rinfo.rmode() != RelocInfo::POSITION &&
+ rinfo.rmode() != RelocInfo::STATEMENT_POSITION);
Instr instr = instr_at(rinfo.pc());
// Instruction to patch must be a ldr/str [pc, #offset]
// P and U set, B and W clear, Rn == pc, offset12 still 0
class Operand BASE_EMBEDDED {
public:
// immediate
- INLINE(explicit Operand(int32_t immediate, RelocMode rmode = no_reloc));
+ INLINE(explicit Operand(int32_t immediate,
+ RelocInfo::Mode rmode = RelocInfo::NONE));
INLINE(explicit Operand(const ExternalReference& f));
INLINE(explicit Operand(const char* s));
INLINE(explicit Operand(Object** opp));
ShiftOp shift_op_;
int shift_imm_; // valid if rm_ != no_reg && rs_ == no_reg
int32_t imm32_; // valid if rm_ == no_reg
- RelocMode rmode_;
+ RelocInfo::Mode rmode_;
friend class Assembler;
};
void next(Label* L);
// Record reloc info for current pc_
- void RecordRelocInfo(RelocMode rmode, intptr_t data = 0);
+ void RecordRelocInfo(RelocInfo::Mode rmode, intptr_t data = 0);
// Check if is time to emit a constant pool for pending reloc info entries
void CheckConstPool(bool force_emit, bool require_jump);
// The modes possibly affected by apply must be in kApplyMask.
void RelocInfo::apply(int delta) {
- if (rmode_ == runtime_entry || is_code_target(rmode_)) {
+ if (rmode_ == RUNTIME_ENTRY || IsCodeTarget(rmode_)) {
int32_t* p = reinterpret_cast<int32_t*>(pc_);
*p -= delta; // relocate entry
- } else if (rmode_ == js_return && is_call_instruction()) {
+ } else if (rmode_ == JS_RETURN && is_call_instruction()) {
// Special handling of js_return when a break point is set (call
// instruction has been inserted).
int32_t* p = reinterpret_cast<int32_t*>(pc_ + 1);
*p -= delta; // relocate entry
- } else if (is_internal_reference(rmode_)) {
+ } else if (IsInternalReference(rmode_)) {
// absolute code pointer inside code object moves with the code object.
int32_t* p = reinterpret_cast<int32_t*>(pc_);
*p += delta; // relocate entry
Address RelocInfo::target_address() {
- ASSERT(is_code_target(rmode_) || rmode_ == runtime_entry);
+ ASSERT(IsCodeTarget(rmode_) || rmode_ == RUNTIME_ENTRY);
return Assembler::target_address_at(pc_);
}
void RelocInfo::set_target_address(Address target) {
- ASSERT(is_code_target(rmode_) || rmode_ == runtime_entry);
+ ASSERT(IsCodeTarget(rmode_) || rmode_ == RUNTIME_ENTRY);
Assembler::set_target_address_at(pc_, target);
}
Object* RelocInfo::target_object() {
- ASSERT(is_code_target(rmode_) || rmode_ == embedded_object);
+ ASSERT(IsCodeTarget(rmode_) || rmode_ == EMBEDDED_OBJECT);
return *reinterpret_cast<Object**>(pc_);
}
Object** RelocInfo::target_object_address() {
- ASSERT(is_code_target(rmode_) || rmode_ == embedded_object);
+ ASSERT(IsCodeTarget(rmode_) || rmode_ == EMBEDDED_OBJECT);
return reinterpret_cast<Object**>(pc_);
}
void RelocInfo::set_target_object(Object* target) {
- ASSERT(is_code_target(rmode_) || rmode_ == embedded_object);
+ ASSERT(IsCodeTarget(rmode_) || rmode_ == EMBEDDED_OBJECT);
*reinterpret_cast<Object**>(pc_) = target;
}
Address* RelocInfo::target_reference_address() {
- ASSERT(rmode_ == external_reference);
+ ASSERT(rmode_ == RelocInfo::EXTERNAL_REFERENCE);
return reinterpret_cast<Address*>(pc_);
}
Immediate::Immediate(int x) {
x_ = x;
- rmode_ = no_reloc;
+ rmode_ = RelocInfo::NONE;
}
Immediate::Immediate(const ExternalReference& ext) {
x_ = reinterpret_cast<int32_t>(ext.address());
- rmode_ = external_reference;
+ rmode_ = RelocInfo::EXTERNAL_REFERENCE;
}
Immediate::Immediate(const char* s) {
x_ = reinterpret_cast<int32_t>(s);
- rmode_ = embedded_string;
+ rmode_ = RelocInfo::EMBEDDED_STRING;
}
ASSERT(!Heap::InNewSpace(obj));
if (obj->IsHeapObject()) {
x_ = reinterpret_cast<intptr_t>(handle.location());
- rmode_ = embedded_object;
+ rmode_ = RelocInfo::EMBEDDED_OBJECT;
} else {
// no relocation needed
x_ = reinterpret_cast<intptr_t>(obj);
- rmode_ = no_reloc;
+ rmode_ = RelocInfo::NONE;
}
}
Immediate::Immediate(Smi* value) {
x_ = reinterpret_cast<intptr_t>(value);
- rmode_ = no_reloc;
+ rmode_ = RelocInfo::NONE;
}
Object* obj = *handle;
ASSERT(!Heap::InNewSpace(obj));
if (obj->IsHeapObject()) {
- emit(reinterpret_cast<intptr_t>(handle.location()), embedded_object);
+ emit(reinterpret_cast<intptr_t>(handle.location()),
+ RelocInfo::EMBEDDED_OBJECT);
} else {
// no relocation needed
emit(reinterpret_cast<intptr_t>(obj));
}
-void Assembler::emit(uint32_t x, RelocMode rmode) {
- if (rmode != no_reloc) RecordRelocInfo(rmode);
+void Assembler::emit(uint32_t x, RelocInfo::Mode rmode) {
+ if (rmode != RelocInfo::NONE) RecordRelocInfo(rmode);
emit(x);
}
void Assembler::emit(const Immediate& x) {
- if (x.rmode_ != no_reloc) RecordRelocInfo(x.rmode_);
+ if (x.rmode_ != RelocInfo::NONE) RecordRelocInfo(x.rmode_);
emit(x.x_);
}
}
-void Operand::set_dispr(int32_t disp, RelocMode rmode) {
+void Operand::set_dispr(int32_t disp, RelocInfo::Mode rmode) {
ASSERT(len_ == 1 || len_ == 2);
*reinterpret_cast<int32_t*>(&buf_[len_]) = disp;
len_ += sizeof(int32_t);
}
-Operand::Operand(int32_t disp, RelocMode rmode) {
+Operand::Operand(int32_t disp, RelocInfo::Mode rmode) {
// [disp/r]
set_modrm(0, ebp);
set_dispr(disp, rmode);
const int RelocInfo::kApplyMask =
- RelocInfo::kCodeTargetMask | 1 << runtime_entry |
- 1 << js_return | 1 << internal_reference;
+ RelocInfo::kCodeTargetMask | 1 << RelocInfo::RUNTIME_ENTRY |
+ 1 << RelocInfo::JS_RETURN | 1 << RelocInfo::INTERNAL_REFERENCE;
void RelocInfo::patch_code(byte* instructions, int instruction_count) {
// Patch the code.
CodePatcher patcher(pc_, code_size);
- patcher.masm()->call(target, no_reloc);
+ patcher.masm()->call(target, RelocInfo::NONE);
// Add the requested number of int3 instructions after the call.
for (int i = 0; i < guard_bytes; i++) {
// -----------------------------------------------------------------------------
// Implementation of Operand
-Operand::Operand(Register base, int32_t disp, RelocMode rmode) {
+Operand::Operand(Register base, int32_t disp, RelocInfo::Mode rmode) {
// [base + disp/r]
- if (disp == 0 && rmode == no_reloc && !base.is(ebp)) {
+ if (disp == 0 && rmode == RelocInfo::NONE && !base.is(ebp)) {
// [base]
set_modrm(0, base);
if (base.is(esp)) set_sib(times_1, esp, base);
- } else if (is_int8(disp) && rmode == no_reloc) {
+ } else if (is_int8(disp) && rmode == RelocInfo::NONE) {
// [base + disp8]
set_modrm(1, base);
if (base.is(esp)) set_sib(times_1, esp, base);
Register index,
ScaleFactor scale,
int32_t disp,
- RelocMode rmode) {
+ RelocInfo::Mode rmode) {
ASSERT(!index.is(esp)); // illegal addressing mode
// [base + index*scale + disp/r]
- if (disp == 0 && rmode == no_reloc && !base.is(ebp)) {
+ if (disp == 0 && rmode == RelocInfo::NONE && !base.is(ebp)) {
// [base + index*scale]
set_modrm(0, esp);
set_sib(scale, index, base);
- } else if (is_int8(disp) && rmode == no_reloc) {
+ } else if (is_int8(disp) && rmode == RelocInfo::NONE) {
// [base + index*scale + disp8]
set_modrm(1, esp);
set_sib(scale, index, base);
Operand::Operand(Register index,
ScaleFactor scale,
int32_t disp,
- RelocMode rmode) {
+ RelocInfo::Mode rmode) {
ASSERT(!index.is(esp)); // illegal addressing mode
// [index*scale + disp/r]
set_modrm(0, esp);
last_pc_ = NULL;
last_bound_pos_ = 0;
- last_position_ = kNoPosition;
- last_statement_position_ = kNoPosition;
+ last_position_ = RelocInfo::kNoPosition;
+ last_statement_position_ = RelocInfo::kNoPosition;
}
last_pc_ = pc_;
// Only use test against byte for registers that have a byte
// variant: eax, ebx, ecx, and edx.
- if (imm.rmode_ == no_reloc && is_uint8(imm.x_) && reg.code() < 4) {
+ if (imm.rmode_ == RelocInfo::NONE && is_uint8(imm.x_) && reg.code() < 4) {
uint8_t imm8 = imm.x_;
if (reg.is(eax)) {
EMIT(0xA8);
}
-void Assembler::call(byte* entry, RelocMode rmode) {
+void Assembler::call(byte* entry, RelocInfo::Mode rmode) {
EnsureSpace ensure_space(this);
last_pc_ = pc_;
- ASSERT(!is_code_target(rmode));
+ ASSERT(!RelocInfo::IsCodeTarget(rmode));
EMIT(0xE8);
emit(entry - (pc_ + sizeof(int32_t)), rmode);
}
}
-void Assembler::call(Handle<Code> code, RelocMode rmode) {
+void Assembler::call(Handle<Code> code, RelocInfo::Mode rmode) {
WriteRecordedPositions();
EnsureSpace ensure_space(this);
last_pc_ = pc_;
- ASSERT(is_code_target(rmode));
+ ASSERT(RelocInfo::IsCodeTarget(rmode));
EMIT(0xE8);
emit(reinterpret_cast<intptr_t>(code.location()), rmode);
}
}
-void Assembler::jmp(byte* entry, RelocMode rmode) {
+void Assembler::jmp(byte* entry, RelocInfo::Mode rmode) {
EnsureSpace ensure_space(this);
last_pc_ = pc_;
- ASSERT(!is_code_target(rmode));
+ ASSERT(!RelocInfo::IsCodeTarget(rmode));
EMIT(0xE9);
emit(entry - (pc_ + sizeof(int32_t)), rmode);
}
}
-void Assembler::jmp(Handle<Code> code, RelocMode rmode) {
+void Assembler::jmp(Handle<Code> code, RelocInfo::Mode rmode) {
EnsureSpace ensure_space(this);
last_pc_ = pc_;
- ASSERT(is_code_target(rmode));
+ ASSERT(RelocInfo::IsCodeTarget(rmode));
EMIT(0xE9);
emit(reinterpret_cast<intptr_t>(code.location()), rmode);
}
}
-void Assembler::j(Condition cc, byte* entry, RelocMode rmode, Hint hint) {
+void Assembler::j(Condition cc, byte* entry, RelocInfo::Mode rmode, Hint hint) {
EnsureSpace ensure_space(this);
last_pc_ = pc_;
ASSERT((0 <= cc) && (cc < 16));
// 0000 1111 1000 tttn #32-bit disp
EMIT(0x0F);
EMIT(0x80 | cc);
- emit(reinterpret_cast<intptr_t>(code.location()), code_target);
+ emit(reinterpret_cast<intptr_t>(code.location()), RelocInfo::CODE_TARGET);
}
void Assembler::RecordJSReturn() {
WriteRecordedPositions();
EnsureSpace ensure_space(this);
- RecordRelocInfo(js_return);
+ RecordRelocInfo(RelocInfo::JS_RETURN);
}
void Assembler::RecordComment(const char* msg) {
if (FLAG_debug_code) {
EnsureSpace ensure_space(this);
- RecordRelocInfo(comment, reinterpret_cast<intptr_t>(msg));
+ RecordRelocInfo(RelocInfo::COMMENT, reinterpret_cast<intptr_t>(msg));
}
}
void Assembler::RecordPosition(int pos) {
- if (pos == kNoPosition) return;
+ if (pos == RelocInfo::kNoPosition) return;
ASSERT(pos >= 0);
last_position_ = pos;
}
void Assembler::RecordStatementPosition(int pos) {
- if (pos == kNoPosition) return;
+ if (pos == RelocInfo::kNoPosition) return;
ASSERT(pos >= 0);
last_statement_position_ = pos;
}
void Assembler::WriteRecordedPositions() {
- if (last_statement_position_ != kNoPosition) {
+ if (last_statement_position_ != RelocInfo::kNoPosition) {
EnsureSpace ensure_space(this);
- RecordRelocInfo(statement_position, last_statement_position_);
+ RecordRelocInfo(RelocInfo::STATEMENT_POSITION, last_statement_position_);
}
- if ((last_position_ != kNoPosition) &&
+ if ((last_position_ != RelocInfo::kNoPosition) &&
(last_position_ != last_statement_position_)) {
EnsureSpace ensure_space(this);
- RecordRelocInfo(position, last_position_);
+ RecordRelocInfo(RelocInfo::POSITION, last_position_);
}
- last_statement_position_ = kNoPosition;
- last_position_ = kNoPosition;
+ last_statement_position_ = RelocInfo::kNoPosition;
+ last_position_ = RelocInfo::kNoPosition;
}
// relocate runtime entries
for (RelocIterator it(desc); !it.done(); it.next()) {
- RelocMode rmode = it.rinfo()->rmode();
- if (rmode == runtime_entry) {
+ RelocInfo::Mode rmode = it.rinfo()->rmode();
+ if (rmode == RelocInfo::RUNTIME_ENTRY) {
int32_t* p = reinterpret_cast<int32_t*>(it.rinfo()->pc());
*p -= pc_delta; // relocate entry
- } else if (rmode == internal_reference) {
+ } else if (rmode == RelocInfo::INTERNAL_REFERENCE) {
int32_t* p = reinterpret_cast<int32_t*>(it.rinfo()->pc());
if (*p != 0) { // 0 means uninitialized.
*p += pc_delta;
adr.set_reg(reg);
memmove(pc_, adr.buf_, adr.len_);
pc_ += adr.len_;
- if (adr.len_ >= sizeof(int32_t) && adr.rmode_ != no_reloc) {
+ if (adr.len_ >= sizeof(int32_t) && adr.rmode_ != RelocInfo::NONE) {
pc_ -= sizeof(int32_t); // pc_ must be *at* disp32
RecordRelocInfo(adr.rmode_);
pc_ += sizeof(int32_t);
adr.set_reg(reg);
memmove(pc_, adr.buf_, adr.len_);
pc_ += adr.len_;
- if (adr.len_ >= sizeof(int32_t) && adr.rmode_ != no_reloc) {
+ if (adr.len_ >= sizeof(int32_t) && adr.rmode_ != RelocInfo::NONE) {
pc_ -= sizeof(int32_t); // pc_ must be *at* disp32
RecordRelocInfo(adr.rmode_);
pc_ += sizeof(int32_t);
}
-void Assembler::dd(uint32_t data, RelocMode reloc_info) {
+void Assembler::dd(uint32_t data, RelocInfo::Mode reloc_info) {
EnsureSpace ensure_space(this);
emit(data, reloc_info);
}
-void Assembler::RecordRelocInfo(RelocMode rmode, intptr_t data) {
- ASSERT(rmode != no_reloc);
+void Assembler::RecordRelocInfo(RelocInfo::Mode rmode, intptr_t data) {
+ ASSERT(rmode != RelocInfo::NONE);
// Don't record external references unless the heap will be serialized.
- if (rmode == external_reference &&
+ if (rmode == RelocInfo::EXTERNAL_REFERENCE &&
!Serializer::enabled() &&
!FLAG_debug_code) {
return;
inline explicit Immediate(Handle<Object> handle);
inline explicit Immediate(Smi* value);
- bool is_zero() const { return x_ == 0 && rmode_ == no_reloc; }
- bool is_int8() const { return -128 <= x_ && x_ < 128 && rmode_ == no_reloc; }
+ bool is_zero() const { return x_ == 0 && rmode_ == RelocInfo::NONE; }
+ bool is_int8() const {
+ return -128 <= x_ && x_ < 128 && rmode_ == RelocInfo::NONE;
+ }
private:
int x_;
- RelocMode rmode_;
+ RelocInfo::Mode rmode_;
friend class Assembler;
};
INLINE(explicit Operand(Register reg));
// [disp/r]
- INLINE(explicit Operand(int32_t disp, RelocMode rmode));
+ INLINE(explicit Operand(int32_t disp, RelocInfo::Mode rmode));
// disp only must always be relocated
// [base + disp/r]
- explicit Operand(Register base, int32_t disp, RelocMode rmode = no_reloc);
+ explicit Operand(Register base, int32_t disp,
+ RelocInfo::Mode rmode = RelocInfo::NONE);
// [base + index*scale + disp/r]
explicit Operand(Register base,
Register index,
ScaleFactor scale,
int32_t disp,
- RelocMode rmode = no_reloc);
+ RelocInfo::Mode rmode = RelocInfo::NONE);
// [index*scale + disp/r]
explicit Operand(Register index,
ScaleFactor scale,
int32_t disp,
- RelocMode rmode = no_reloc);
+ RelocInfo::Mode rmode = RelocInfo::NONE);
static Operand StaticVariable(const ExternalReference& ext) {
return Operand(reinterpret_cast<int32_t>(ext.address()),
- external_reference);
+ RelocInfo::EXTERNAL_REFERENCE);
}
static Operand StaticArray(Register index,
ScaleFactor scale,
const ExternalReference& arr) {
return Operand(index, scale, reinterpret_cast<int32_t>(arr.address()),
- external_reference);
+ RelocInfo::EXTERNAL_REFERENCE);
}
// Returns true if this Operand is a wrapper for the specified register.
// The number of bytes in buf_.
unsigned int len_;
// Only valid if len_ > 4.
- RelocMode rmode_;
+ RelocInfo::Mode rmode_;
inline void set_modrm(int mod, // reg == 0
Register rm);
inline void set_sib(ScaleFactor scale, Register index, Register base);
inline void set_disp8(int8_t disp);
- inline void set_dispr(int32_t disp, RelocMode rmode);
+ inline void set_dispr(int32_t disp, RelocInfo::Mode rmode);
inline void set_reg(Register reg) const;
friend class Assembler;
// Calls
void call(Label* L);
- void call(byte* entry, RelocMode rmode);
+ void call(byte* entry, RelocInfo::Mode rmode);
void call(const Operand& adr);
- void call(Handle<Code> code, RelocMode rmode);
+ void call(Handle<Code> code, RelocInfo::Mode rmode);
// Jumps
void jmp(Label* L); // unconditional jump to L
- void jmp(byte* entry, RelocMode rmode);
+ void jmp(byte* entry, RelocInfo::Mode rmode);
void jmp(const Operand& adr);
- void jmp(Handle<Code> code, RelocMode rmode);
+ void jmp(Handle<Code> code, RelocInfo::Mode rmode);
// Conditional jumps
void j(Condition cc, Label* L, Hint hint = no_hint);
- void j(Condition cc, byte* entry, RelocMode rmode, Hint hint = no_hint);
+ void j(Condition cc, byte* entry, RelocInfo::Mode rmode, Hint hint = no_hint);
void j(Condition cc, Handle<Code> code, Hint hint = no_hint);
// Floating-point operations
// Writes a single word of data in the code stream.
// Used for inline tables, e.g., jump-tables.
- void dd(uint32_t data, RelocMode reloc_info);
+ void dd(uint32_t data, RelocInfo::Mode reloc_info);
// Writes the absolute address of a bound label at the given position in
// the generated code. That positions should have the relocation mode
void GrowBuffer();
inline void emit(uint32_t x);
inline void emit(Handle<Object> handle);
- inline void emit(uint32_t x, RelocMode rmode);
+ inline void emit(uint32_t x, RelocInfo::Mode rmode);
inline void emit(const Immediate& x);
// instruction generation
inline void emit_disp(Label* L, Displacement::Type type);
// record reloc info for current pc_
- void RecordRelocInfo(RelocMode rmode, intptr_t data = 0);
+ void RecordRelocInfo(RelocInfo::Mode rmode, intptr_t data = 0);
friend class CodePatcher;
friend class EnsureSpace;
#endif
Counters::reloc_info_count.Increment();
ASSERT(rinfo->pc() - last_pc_ >= 0);
- ASSERT(reloc_mode_count < kMaxRelocModes);
+ ASSERT(RelocInfo::NUMBER_OF_MODES < kMaxRelocModes);
// Use unsigned delta-encoding for pc.
uint32_t pc_delta = rinfo->pc() - last_pc_;
- RelocMode rmode = rinfo->rmode();
+ RelocInfo::Mode rmode = rinfo->rmode();
// The two most common modes are given small tags, and usually fit in a byte.
- if (rmode == embedded_object) {
+ if (rmode == RelocInfo::EMBEDDED_OBJECT) {
WriteTaggedPC(pc_delta, kEmbeddedObjectTag);
- } else if (rmode == code_target) {
+ } else if (rmode == RelocInfo::CODE_TARGET) {
WriteTaggedPC(pc_delta, kCodeTargetTag);
- } else if (rmode == position || rmode == statement_position) {
+ } else if (RelocInfo::IsPosition(rmode)) {
// Use signed delta-encoding for data.
int32_t data_delta = rinfo->data() - last_data_;
- int pos_type_tag = rmode == position ? kNonstatementPositionTag
- : kStatementPositionTag;
+ int pos_type_tag = rmode == RelocInfo::POSITION ? kNonstatementPositionTag
+ : kStatementPositionTag;
// Check if data is small enough to fit in a tagged byte.
if (is_intn(data_delta, kSmallDataBits)) {
WriteTaggedPC(pc_delta, kPositionTag);
WriteExtraTaggedData(data_delta, pos_type_tag);
last_data_ = rinfo->data();
}
- } else if (rmode == comment) {
+ } else if (RelocInfo::IsComment(rmode)) {
// Comments are normally not generated, so we use the costly encoding.
WriteExtraTaggedPC(pc_delta, kPCJumpTag);
WriteExtraTaggedData(rinfo->data() - last_data_, kCommentTag);
}
-inline RelocMode RelocIterator::DebugInfoModeFromTag(int tag) {
+inline RelocInfo::Mode RelocIterator::DebugInfoModeFromTag(int tag) {
if (tag == kStatementPositionTag) {
- return statement_position;
+ return RelocInfo::STATEMENT_POSITION;
} else if (tag == kNonstatementPositionTag) {
- return position;
+ return RelocInfo::POSITION;
} else {
ASSERT(tag == kCommentTag);
- return comment;
+ return RelocInfo::COMMENT;
}
}
int tag = AdvanceGetTag();
if (tag == kEmbeddedObjectTag) {
ReadTaggedPC();
- if (SetMode(embedded_object)) return;
+ if (SetMode(RelocInfo::EMBEDDED_OBJECT)) return;
} else if (tag == kCodeTargetTag) {
ReadTaggedPC();
if (*(reinterpret_cast<int**>(rinfo_.pc())) ==
reinterpret_cast<int*>(0x61)) {
tag = 0;
}
- if (SetMode(code_target)) return;
+ if (SetMode(RelocInfo::CODE_TARGET)) return;
} else if (tag == kPositionTag) {
ReadTaggedPC();
Advance();
}
} else {
AdvanceReadPC();
- if (SetMode(static_cast<RelocMode>(extra_tag))) return;
+ if (SetMode(static_cast<RelocInfo::Mode>(extra_tag))) return;
}
}
}
#ifdef ENABLE_DISASSEMBLER
-const char* RelocInfo::RelocModeName(RelocMode rmode) {
+const char* RelocInfo::RelocModeName(RelocInfo::Mode rmode) {
switch (rmode) {
- case no_reloc:
+ case RelocInfo::NONE:
return "no reloc";
- case embedded_object:
+ case RelocInfo::EMBEDDED_OBJECT:
return "embedded object";
- case embedded_string:
+ case RelocInfo::EMBEDDED_STRING:
return "embedded string";
- case js_construct_call:
+ case RelocInfo::CONSTRUCT_CALL:
return "code target (js construct call)";
- case exit_js_frame:
- return "code target (exit js frame)";
- case code_target_context:
+ case RelocInfo::CODE_TARGET_CONTEXT:
return "code target (context)";
- case code_target:
+ case RelocInfo::CODE_TARGET:
return "code target";
- case runtime_entry:
+ case RelocInfo::RUNTIME_ENTRY:
return "runtime entry";
- case js_return:
+ case RelocInfo::JS_RETURN:
return "js return";
- case comment:
+ case RelocInfo::COMMENT:
return "comment";
- case position:
+ case RelocInfo::POSITION:
return "position";
- case statement_position:
+ case RelocInfo::STATEMENT_POSITION:
return "statement position";
- case external_reference:
+ case RelocInfo::EXTERNAL_REFERENCE:
return "external reference";
- case internal_reference:
+ case RelocInfo::INTERNAL_REFERENCE:
return "internal reference";
- case reloc_mode_count:
+ case RelocInfo::NUMBER_OF_MODES:
UNREACHABLE();
- return "reloc_mode_count";
+ return "number_of_modes";
}
return "unknown relocation type";
}
void RelocInfo::Print() {
PrintF("%p %s", pc_, RelocModeName(rmode_));
- if (rmode_ == comment) {
+ if (IsComment(rmode_)) {
PrintF(" (%s)", data_);
- } else if (rmode_ == embedded_object) {
+ } else if (rmode_ == EMBEDDED_OBJECT) {
PrintF(" (");
target_object()->ShortPrint();
PrintF(")");
- } else if (rmode_ == external_reference) {
+ } else if (rmode_ == EXTERNAL_REFERENCE) {
ExternalReferenceEncoder ref_encoder;
PrintF(" (%s) (%p)",
ref_encoder.NameOfAddress(*target_reference_address()),
*target_reference_address());
- } else if (is_code_target(rmode_)) {
+ } else if (IsCodeTarget(rmode_)) {
Code* code = Debug::GetCodeTarget(target_address());
PrintF(" (%s) (%p)", Code::Kind2String(code->kind()), target_address());
- } else if (is_position(rmode_)) {
+ } else if (IsPosition(rmode_)) {
PrintF(" (%d)", data());
}
#ifdef DEBUG
void RelocInfo::Verify() {
switch (rmode_) {
- case embedded_object:
+ case EMBEDDED_OBJECT:
Object::VerifyPointer(target_object());
break;
- case js_construct_call:
- case exit_js_frame:
- case code_target_context:
- case code_target: {
+ case CONSTRUCT_CALL:
+ case CODE_TARGET_CONTEXT:
+ case CODE_TARGET: {
// convert inline target address to code object
Address addr = target_address();
ASSERT(addr != NULL);
ASSERT(code->address() == HeapObject::cast(found)->address());
break;
}
- case embedded_string:
- case runtime_entry:
- case js_return:
- case comment:
- case position:
- case statement_position:
- case external_reference:
- case internal_reference:
- case no_reloc:
+ case RelocInfo::EMBEDDED_STRING:
+ case RUNTIME_ENTRY:
+ case JS_RETURN:
+ case COMMENT:
+ case POSITION:
+ case STATEMENT_POSITION:
+ case EXTERNAL_REFERENCE:
+ case INTERNAL_REFERENCE:
+ case NONE:
break;
- case reloc_mode_count:
+ case NUMBER_OF_MODES:
UNREACHABLE();
break;
}
// -----------------------------------------------------------------------------
// Relocation information
-// The constant kNoPosition is used with the collecting of source positions
-// in the relocation information. Two types of source positions are collected
-// "position" (RelocMode position) and "statement position" (RelocMode
-// statement_position). The "position" is collected at places in the source
-// code which are of interest when making stack traces to pin-point the source
-// location of a stack frame as close as possible. The "statement position" is
-// collected at the beginning at each statement, and is used to indicate
-// possible break locations. kNoPosition is used to indicate an
-// invalid/uninitialized position value.
-static const int kNoPosition = -1;
-
-
-enum RelocMode {
- // Please note the order is important (see is_code_target, is_gc_reloc_mode).
- js_construct_call, // code target that is an exit JavaScript frame stub.
- exit_js_frame, // code target that is an exit JavaScript frame stub.
- code_target_context, // code target used for contextual loads.
- code_target, // code target which is not any of the above.
- embedded_object,
- embedded_string,
-
- // Everything after runtime_entry (inclusive) is not GC'ed.
- runtime_entry,
- js_return, // Marks start of the ExitJSFrame code.
- comment,
- position, // See comment for kNoPosition above.
- statement_position, // See comment for kNoPosition above.
- external_reference, // The address of an external C++ function.
- internal_reference, // An address inside the same function.
-
- // add more as needed
- // Pseudo-types
- reloc_mode_count, // must be no greater than 14 - see RelocInfoWriter
- no_reloc, // never recorded
- last_code_enum = code_target,
- last_gced_enum = embedded_string
-};
-
-
-inline int RelocMask(RelocMode mode) {
- return 1 << mode;
-}
-
-
-inline bool is_js_construct_call(RelocMode mode) {
- return mode == js_construct_call;
-}
-
-
-inline bool is_exit_js_frame(RelocMode mode) {
- return mode == exit_js_frame;
-}
-
-
-inline bool is_code_target(RelocMode mode) {
- return mode <= last_code_enum;
-}
-
-
-// Is the relocation mode affected by GC?
-inline bool is_gc_reloc_mode(RelocMode mode) {
- return mode <= last_gced_enum;
-}
-
-
-inline bool is_js_return(RelocMode mode) {
- return mode == js_return;
-}
-
-
-inline bool is_comment(RelocMode mode) {
- return mode == comment;
-}
-
-
-inline bool is_position(RelocMode mode) {
- return mode == position || mode == statement_position;
-}
-
-
-inline bool is_statement_position(RelocMode mode) {
- return mode == statement_position;
-}
-
-
-inline bool is_external_reference(RelocMode mode) {
- return mode == external_reference;
-}
-
-
-inline bool is_internal_reference(RelocMode mode) {
- return mode == internal_reference;
-}
-
// Relocation information consists of the address (pc) of the datum
// to which the relocation information applies, the relocation mode
class RelocInfo BASE_EMBEDDED {
public:
+ // The constant kNoPosition is used with the collecting of source positions
+ // in the relocation information. Two types of source positions are collected
+ // "position" (RelocMode position) and "statement position" (RelocMode
+ // statement_position). The "position" is collected at places in the source
+ // code which are of interest when making stack traces to pin-point the source
+ // location of a stack frame as close as possible. The "statement position" is
+ // collected at the beginning at each statement, and is used to indicate
+ // possible break locations. kNoPosition is used to indicate an
+ // invalid/uninitialized position value.
+ static const int kNoPosition = -1;
+
+ enum Mode {
+ // Please note the order is important (see IsCodeTarget, IsGCRelocMode).
+ CONSTRUCT_CALL, // code target that is a call to a JavaScript constructor.
+ CODE_TARGET_CONTEXT, // code target used for contextual loads.
+ CODE_TARGET, // code target which is not any of the above.
+ EMBEDDED_OBJECT,
+ EMBEDDED_STRING,
+
+ // Everything after runtime_entry (inclusive) is not GC'ed.
+ RUNTIME_ENTRY,
+ JS_RETURN, // Marks start of the ExitJSFrame code.
+ COMMENT,
+ POSITION, // See comment for kNoPosition above.
+ STATEMENT_POSITION, // See comment for kNoPosition above.
+ EXTERNAL_REFERENCE, // The address of an external C++ function.
+ INTERNAL_REFERENCE, // An address inside the same function.
+
+ // add more as needed
+ // Pseudo-types
+ NUMBER_OF_MODES, // must be no greater than 14 - see RelocInfoWriter
+ NONE, // never recorded
+ LAST_CODE_ENUM = CODE_TARGET,
+ LAST_GCED_ENUM = EMBEDDED_STRING
+ };
+
+
RelocInfo() {}
- RelocInfo(byte* pc, RelocMode rmode, intptr_t data)
+ RelocInfo(byte* pc, Mode rmode, intptr_t data)
: pc_(pc), rmode_(rmode), data_(data) {
}
+ static inline bool IsConstructCall(Mode mode) {
+ return mode == CONSTRUCT_CALL;
+ }
+ static inline bool IsCodeTarget(Mode mode) {
+ return mode <= LAST_CODE_ENUM;
+ }
+ // Is the relocation mode affected by GC?
+ static inline bool IsGCRelocMode(Mode mode) {
+ return mode <= LAST_GCED_ENUM;
+ }
+ static inline bool IsJSReturn(Mode mode) {
+ return mode == JS_RETURN;
+ }
+ static inline bool IsComment(Mode mode) {
+ return mode == COMMENT;
+ }
+ static inline bool IsPosition(Mode mode) {
+ return mode == POSITION || mode == STATEMENT_POSITION;
+ }
+ static inline bool IsStatementPosition(Mode mode) {
+ return mode == STATEMENT_POSITION;
+ }
+ static inline bool IsExternalReference(Mode mode) {
+ return mode == EXTERNAL_REFERENCE;
+ }
+ static inline bool IsInternalReference(Mode mode) {
+ return mode == INTERNAL_REFERENCE;
+ }
+ static inline int ModeMask(Mode mode) { return 1 << mode; }
+
// Accessors
byte* pc() const { return pc_; }
void set_pc(byte* pc) { pc_ = pc; }
- RelocMode rmode() const { return rmode_; }
+ Mode rmode() const { return rmode_; }
intptr_t data() const { return data_; }
// Apply a relocation by delta bytes
INLINE(void apply(int delta));
// Read/modify the code target in the branch/call instruction this relocation
- // applies to; can only be called if this->is_code_target(rmode_)
+ // applies to; can only be called if IsCodeTarget(rmode_)
INLINE(Address target_address());
INLINE(void set_target_address(Address target));
INLINE(Object* target_object());
#ifdef ENABLE_DISASSEMBLER
// Printing
- static const char* RelocModeName(RelocMode rmode);
+ static const char* RelocModeName(Mode rmode);
void Print();
#endif // ENABLE_DISASSEMBLER
#ifdef DEBUG
void Verify();
#endif
- static const int kCodeTargetMask = (1 << (last_code_enum + 1)) - 1;
- static const int kPositionMask = 1 << position | 1 << statement_position;
- static const int kDebugMask = kPositionMask | 1 << comment;
+ static const int kCodeTargetMask = (1 << (LAST_CODE_ENUM + 1)) - 1;
+ static const int kPositionMask = 1 << POSITION | 1 << STATEMENT_POSITION;
+ static const int kDebugMask = kPositionMask | 1 << COMMENT;
static const int kApplyMask; // Modes affected by apply. Depends on arch.
private:
// referencing the constant pool entry (except when rmode_ ==
// comment).
byte* pc_;
- RelocMode rmode_;
+ Mode rmode_;
intptr_t data_;
friend class RelocIterator;
};
int GetPositionTypeTag();
void ReadTaggedData();
- static RelocMode DebugInfoModeFromTag(int tag);
+ static RelocInfo::Mode DebugInfoModeFromTag(int tag);
// If the given mode is wanted, set it in rinfo_ and return true.
// Else return false. Used for efficiently skipping unwanted modes.
- bool SetMode(RelocMode mode) {
+ bool SetMode(RelocInfo::Mode mode) {
return (mode_mask_ & 1 << mode) ? (rinfo_.rmode_ = mode, true) : false;
}
class Node: public ZoneObject {
public:
- Node(): statement_pos_(kNoPosition) { }
+ Node(): statement_pos_(RelocInfo::kNoPosition) { }
virtual ~Node() { }
virtual void Accept(Visitor* v) = 0;
start_position_(start_position),
end_position_(end_position),
is_expression_(is_expression),
- function_token_position_(kNoPosition) {
+ function_token_position_(RelocInfo::kNoPosition) {
}
virtual void Accept(Visitor* v);
// r0: number of arguments
// r1: constructor function
Label return_site;
- __ RecordPosition(position);
ParameterCount actual(r0);
__ InvokeFunction(r1, actual, CALL_FUNCTION);
__ bind(&return_site);
__ mov(r0, Operand(r3));
if (is_construct) {
__ Call(Handle<Code>(Builtins::builtin(Builtins::JSConstructCall)),
- code_target);
+ RelocInfo::CODE_TARGET);
} else {
ParameterCount actual(r0);
__ InvokeFunction(r1, actual, CALL_FUNCTION);
__ b(ne, &invoke);
__ mov(r2, Operand(0)); // expected arguments is 0 for CALL_NON_FUNCTION
__ GetBuiltinEntry(r3, Builtins::CALL_NON_FUNCTION);
- __ Jump(Handle<Code>(builtin(ArgumentsAdaptorTrampoline)), code_target);
+ __ Jump(Handle<Code>(builtin(ArgumentsAdaptorTrampoline)),
+ RelocInfo::CODE_TARGET);
__ bind(&invoke);
__ ldr(r3, FieldMemOperand(r1, JSFunction::kSharedFunctionInfoOffset));
MemOperand(r3, SharedFunctionInfo::kCodeOffset - kHeapObjectTag));
__ add(r3, r3, Operand(Code::kHeaderSize - kHeapObjectTag));
__ cmp(r2, r0); // Check formal and actual parameter counts.
- __ Jump(Handle<Code>(builtin(ArgumentsAdaptorTrampoline)), code_target, ne);
+ __ Jump(Handle<Code>(builtin(ArgumentsAdaptorTrampoline)),
+ RelocInfo::CODE_TARGET, ne);
// 7. Jump to the code in r3 without checking arguments.
ParameterCount expected(0);
// Call the function.
Label return_site;
- __ RecordPosition(position);
ParameterCount actual(eax);
__ InvokeFunction(edi, actual, CALL_FUNCTION);
__ bind(&return_site);
// Invoke the code.
if (is_construct) {
__ call(Handle<Code>(Builtins::builtin(Builtins::JSConstructCall)),
- code_target);
+ RelocInfo::CODE_TARGET);
} else {
ParameterCount actual(eax);
__ InvokeFunction(edi, actual, CALL_FUNCTION);
__ j(not_zero, &invoke, taken);
__ xor_(ebx, Operand(ebx));
__ GetBuiltinEntry(edx, Builtins::CALL_NON_FUNCTION);
- __ jmp(Handle<Code>(builtin(ArgumentsAdaptorTrampoline)), code_target);
+ __ jmp(Handle<Code>(builtin(ArgumentsAdaptorTrampoline)),
+ RelocInfo::CODE_TARGET);
__ bind(&invoke);
__ mov(edx, FieldOperand(edi, JSFunction::kSharedFunctionInfoOffset));
// Use inline caching to speed up access to arguments.
Handle<Code> ic(Builtins::builtin(Builtins::KeyedLoadIC_Initialize));
- __ call(ic, code_target);
+ __ call(ic, RelocInfo::CODE_TARGET);
// Remove IC arguments from the stack and push the nth argument.
__ add(Operand(esp), Immediate(2 * kPointerSize));
Literal key(variable->name());
// TODO(1241834): Fetch the position from the variable instead of using
// no position.
- Property property(&global, &key, kNoPosition);
+ Property property(&global, &key, RelocInfo::kNoPosition);
Load(&property);
} else {
Load(x, CodeGenState::LOAD_TYPEOF_EXPR);
// r5: pointer to builtin function (C callee-saved)
if (do_gc) {
- __ Call(FUNCTION_ADDR(Runtime::PerformGC), runtime_entry); // passing r0
+ // Passing r0.
+ __ Call(FUNCTION_ADDR(Runtime::PerformGC), RelocInfo::RUNTIME_ENTRY);
}
// Call C built-in.
Variable* var = ref()->expression()->AsVariableProxy()->AsVariable();
if (var != NULL) {
ASSERT(var->is_global());
- __ Call(ic, code_target_context);
+ __ Call(ic, RelocInfo::CODE_TARGET_CONTEXT);
} else {
- __ Call(ic, code_target);
+ __ Call(ic, RelocInfo::CODE_TARGET);
}
} else {
// Setup the name register.
masm->mov(r2, Operand(name));
Handle<Code> ic(Builtins::builtin(Builtins::StoreIC_Initialize));
- masm->Call(ic, code_target);
+ masm->Call(ic, RelocInfo::CODE_TARGET);
} else {
// Access keyed property.
// Setup the receiver register and call the IC initialization code.
Handle<Code> stub = ComputeCallInitialize(args->length());
__ RecordPosition(node->position());
- __ Call(stub, code_target_context);
+ __ Call(stub, RelocInfo::CODE_TARGET_CONTEXT);
__ ldr(cp, MemOperand(fp, StandardFrameConstants::kContextOffset));
// Remove the function from the stack.
__ pop();
// Set the receiver register and call the IC initialization code.
Handle<Code> stub = ComputeCallInitialize(args->length());
__ RecordPosition(node->position());
- __ Call(stub, code_target);
+ __ Call(stub, RelocInfo::CODE_TARGET);
__ ldr(cp, MemOperand(fp, StandardFrameConstants::kContextOffset));
// Remove the function from the stack.
// Call the construct call builtin that handles allocation and
// constructor invocation.
- __ RecordPosition(position);
+ __ RecordPosition(RelocInfo::POSITION);
__ Call(Handle<Code>(Builtins::builtin(Builtins::JSConstructCall)),
- js_construct_call);
+ RelocInfo::CONSTRUCT_CALL);
// Discard old TOS value and push r0 on the stack (same as Pop(), push(r0)).
__ str(r0, MemOperand(sp, 0 * kPointerSize));
// Call the JS runtime function.
Handle<Code> stub = ComputeCallInitialize(args->length());
- __ Call(stub, code_target);
+ __ Call(stub, RelocInfo::CODE_TARGET);
__ ldr(cp, MemOperand(fp, StandardFrameConstants::kContextOffset));
__ pop();
__ push(r0);
void ArmCodeGenerator::RecordStatementPosition(Node* node) {
if (FLAG_debug_info) {
int statement_pos = node->statement_pos();
- if (statement_pos == kNoPosition) return;
+ if (statement_pos == RelocInfo::kNoPosition) return;
__ RecordStatementPosition(statement_pos);
}
}
Literal key(variable->name());
// TODO(1241834): Fetch the position from the variable instead of using
// no position.
- Property property(&global, &key, kNoPosition);
+ Property property(&global, &key, RelocInfo::kNoPosition);
Load(&property);
} else {
Load(x, CodeGenState::LOAD_TYPEOF_EXPR);
__ Set(ecx, Immediate(name));
if (var != NULL) {
ASSERT(var->is_global());
- __ call(ic, code_target_context);
+ __ call(ic, RelocInfo::CODE_TARGET_CONTEXT);
} else {
- __ call(ic, code_target);
+ __ call(ic, RelocInfo::CODE_TARGET);
}
} else {
// Access keyed property.
Variable* var = ref()->expression()->AsVariableProxy()->AsVariable();
if (var != NULL) {
ASSERT(var->is_global());
- __ call(ic, code_target_context);
+ __ call(ic, RelocInfo::CODE_TARGET_CONTEXT);
} else {
- __ call(ic, code_target);
+ __ call(ic, RelocInfo::CODE_TARGET);
}
}
__ push(eax); // IC call leaves result in eax, push it out
masm->pop(eax);
// Setup the name register.
masm->Set(ecx, Immediate(name));
- masm->call(ic, code_target);
+ masm->call(ic, RelocInfo::CODE_TARGET);
} else {
// Access keyed property.
ASSERT(type == Reference::KEYED);
Handle<Code> ic(Builtins::builtin(Builtins::KeyedStoreIC_Initialize));
// TODO(1222589): Make the IC grab the values from the stack.
masm->pop(eax);
- masm->call(ic, code_target);
+ masm->call(ic, RelocInfo::CODE_TARGET);
}
masm->push(eax); // IC call leaves result in eax, push it out
}
masm->Set(ebx, Immediate(0));
masm->GetBuiltinEntry(edx, Builtins::CALL_NON_FUNCTION);
Handle<Code> adaptor(Builtins::builtin(Builtins::ArgumentsAdaptorTrampoline));
- masm->jmp(adaptor, code_target);
+ masm->jmp(adaptor, RelocInfo::CODE_TARGET);
}
__ cmp(eax, range * 2);
__ j(greater_equal, fail_label, not_taken);
- __ jmp(Operand(eax, times_2, 0x0, internal_reference)); // 0 is placeholder
+ // 0 is placeholder.
+ __ jmp(Operand(eax, times_2, 0x0, RelocInfo::INTERNAL_REFERENCE));
// calculate address to overwrite later with actual address of table.
int32_t jump_table_ref = __ pc_offset() - sizeof(int32_t);
__ WriteInternalReference(jump_table_ref, table_start);
for (int i = 0; i < range; i++) {
- __ dd(0x0, internal_reference); // table entry, 0 is placeholder
+ __ dd(0x0, RelocInfo::INTERNAL_REFERENCE); // table entry, 0 is placeholder
}
}
Load(property->value());
__ pop(eax);
__ Set(ecx, Immediate(key));
- __ call(ic, code_target);
+ __ call(ic, RelocInfo::CODE_TARGET);
__ add(Operand(esp), Immediate(kPointerSize));
// Ignore result.
break;
// Setup the receiver register and call the IC initialization code.
Handle<Code> stub = ComputeCallInitialize(args->length());
__ RecordPosition(node->position());
- __ call(stub, code_target_context);
+ __ call(stub, RelocInfo::CODE_TARGET_CONTEXT);
__ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset));
// Overwrite the function on the stack with the result.
// Call the IC initialization code.
Handle<Code> stub = ComputeCallInitialize(args->length());
__ RecordPosition(node->position());
- __ call(stub, code_target);
+ __ call(stub, RelocInfo::CODE_TARGET);
__ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset));
// Overwrite the function on the stack with the result.
// constructor invocation.
__ RecordPosition(node->position());
__ call(Handle<Code>(Builtins::builtin(Builtins::JSConstructCall)),
- js_construct_call);
+ RelocInfo::CONSTRUCT_CALL);
__ mov(TOS, eax); // discard the function and "push" the newly created object
}
// Call the JS runtime function.
Handle<Code> stub = ComputeCallInitialize(args->length());
__ Set(eax, Immediate(args->length()));
- __ call(stub, code_target);
+ __ call(stub, RelocInfo::CODE_TARGET);
__ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset));
__ mov(TOS, eax);
}
void Ia32CodeGenerator::RecordStatementPosition(Node* node) {
if (FLAG_debug_info) {
int pos = node->statement_pos();
- if (pos != kNoPosition) {
+ if (pos != RelocInfo::kNoPosition) {
__ RecordStatementPosition(pos);
}
}
if (do_gc) {
__ mov(Operand(esp, 0 * kPointerSize), eax); // Result.
- __ call(FUNCTION_ADDR(Runtime::PerformGC), runtime_entry);
+ __ call(FUNCTION_ADDR(Runtime::PerformGC), RelocInfo::RUNTIME_ENTRY);
}
// Call C function.
DeferredCode* code = deferred_.RemoveLast();
MacroAssembler* masm = code->masm();
// Record position of deferred code stub.
- if (code->statement_position() != kNoPosition) {
+ if (code->statement_position() != RelocInfo::kNoPosition) {
masm->RecordStatementPosition(code->statement_position());
}
- if (code->position() != kNoPosition) {
+ if (code->position() != RelocInfo::kNoPosition) {
masm->RecordPosition(code->position());
}
// Bind labels and generate the code.
code);
CodeGenerator::SetFunctionInfo(fun, lit->scope()->num_parameters(),
- kNoPosition,
+ RelocInfo::kNoPosition,
lit->start_position(), lit->end_position(),
lit->is_expression(), true, script);
// Whenever a statement position or (plain) position is passed update the
// current value of these.
- if (is_position(rmode())) {
- if (is_statement_position(rmode())) {
+ if (RelocInfo::IsPosition(rmode())) {
+ if (RelocInfo::IsStatementPosition(rmode())) {
statement_position_ =
rinfo()->data() - debug_info_->shared()->start_position();
}
// Check for breakable code target. Look in the original code as setting
// break points can cause the code targets in the running (debugged) code to
// be of a different kind than in the original code.
- if (is_code_target(rmode())) {
+ if (RelocInfo::IsCodeTarget(rmode())) {
Address target = original_rinfo()->target_address();
Code* code = Debug::GetCodeTarget(target);
- if (code->is_inline_cache_stub() || is_js_construct_call(rmode())) {
+ if (code->is_inline_cache_stub() || RelocInfo::IsConstructCall(rmode())) {
break_point_++;
return;
}
}
// Check for break at return.
- // Currently is_exit_js_frame is used on ARM.
- if (is_js_return(rmode()) || is_exit_js_frame(rmode())) {
+ if (RelocInfo::IsJSReturn(rmode())) {
// Set the positions to the end of the function.
if (debug_info_->shared()->HasSourceCode()) {
position_ = debug_info_->shared()->end_position() -
return;
}
- if (is_js_return(rmode())) {
+ if (RelocInfo::IsJSReturn(rmode())) {
// This path is currently only used on IA32 as JSExitFrame on ARM uses a
// stub.
// Patch the JS frame exit code with a debug break call. See
void BreakLocationIterator::ClearDebugBreak() {
- if (is_js_return(rmode())) {
+ if (RelocInfo::IsJSReturn(rmode())) {
// Restore the JS frame exit code.
rinfo()->patch_code(original_rinfo()->pc(),
Debug::kIa32JSReturnSequenceLength);
}
} else {
// Step in through constructs call requires no changes to the running code.
- ASSERT(is_js_construct_call(rmode()));
+ ASSERT(RelocInfo::IsConstructCall(rmode()));
}
}
// Check whether the break point is at a position which will exit the function.
bool BreakLocationIterator::IsExit() const {
- // Currently is_exit_js_frame is used on ARM.
- return (is_js_return(rmode()) || is_exit_js_frame(rmode()));
+ return (RelocInfo::IsJSReturn(rmode()));
}
// Check whether there is a debug break at the current position.
bool BreakLocationIterator::IsDebugBreak() {
- if (is_js_return(rmode())) {
+ if (RelocInfo::IsJSReturn(rmode())) {
// This is IA32 specific but works as long as the ARM version
// still uses a stub for JSExitFrame.
//
// Threading support.
void Debug::ThreadInit() {
thread_local_.last_step_action_ = StepNone;
- thread_local_.last_statement_position_ = kNoPosition;
+ thread_local_.last_statement_position_ = RelocInfo::kNoPosition;
thread_local_.step_count_ = 0;
thread_local_.last_fp_ = 0;
thread_local_.step_into_fp_ = 0;
// Compute whether or not the target is a call target.
bool is_call_target = false;
- if (is_code_target(it.rinfo()->rmode())) {
+ if (RelocInfo::IsCodeTarget(it.rinfo()->rmode())) {
Address target = it.rinfo()->target_address();
Code* code = Debug::GetCodeTarget(target);
if (code->is_call_stub()) is_call_target = true;
JSFunction* function = JSFunction::cast(frames_it.frame()->function());
FloodWithOneShot(Handle<SharedFunctionInfo>(function->shared()));
}
- } else if (!(is_call_target || is_js_construct_call(it.rmode())) ||
+ } else if (!(is_call_target || RelocInfo::IsConstructCall(it.rmode())) ||
step_action == StepNext || step_action == StepMin) {
// Step next or step min.
Handle<Code> Debug::FindDebugBreak(RelocInfo* rinfo) {
// Find the builtin debug break function matching the calling convention
// used by the call site.
- RelocMode mode = rinfo->rmode();
+ RelocInfo::Mode mode = rinfo->rmode();
- if (is_code_target(mode)) {
+ if (RelocInfo::IsCodeTarget(mode)) {
Address target = rinfo->target_address();
Code* code = Debug::GetCodeTarget(target);
if (code->is_inline_cache_stub()) {
return result;
}
}
- if (is_js_construct_call(mode)) {
+ if (RelocInfo::IsConstructCall(mode)) {
Handle<Code> result =
Handle<Code>(Builtins::builtin(Builtins::ConstructCall_DebugBreak));
return result;
}
- // Currently is_exit_js_frame is used on ARM.
- if (is_exit_js_frame(mode)) {
- return Handle<Code>(Builtins::builtin(Builtins::Return_DebugBreak));
- }
if (code->kind() == Code::STUB) {
ASSERT(code->major_key() == CodeStub::CallFunction ||
code->major_key() == CodeStub::StackCheck);
void Debug::ClearStepNext() {
thread_local_.last_step_action_ = StepNone;
- thread_local_.last_statement_position_ = kNoPosition;
+ thread_local_.last_statement_position_ = RelocInfo::kNoPosition;
thread_local_.last_fp_ = 0;
}
bool at_js_exit = false;
RelocIterator it(debug_info->code());
while (!it.done()) {
- if (is_js_return(it.rinfo()->rmode())) {
+ if (RelocInfo::IsJSReturn(it.rinfo()->rmode())) {
at_js_exit = it.rinfo()->pc() == addr - 1;
}
it.next();
inline Address pc() { return reloc_iterator_->rinfo()->pc(); }
inline Code* code() { return debug_info_->code(); }
inline RelocInfo* rinfo() { return reloc_iterator_->rinfo(); }
- inline RelocMode rmode() const { return reloc_iterator_->rinfo()->rmode(); }
+ inline RelocInfo::Mode rmode() const {
+ return reloc_iterator_->rinfo()->rmode();
+ }
inline RelocInfo* original_rinfo() {
return reloc_iterator_original_->rinfo();
}
- inline RelocMode original_rmode() const {
+ inline RelocInfo::Mode original_rmode() const {
return reloc_iterator_original_->rinfo()->rmode();
}
constants = num_const;
pc += 4;
} else if (it != NULL && !it->done() && it->rinfo()->pc() == pc &&
- it->rinfo()->rmode() == internal_reference) {
+ it->rinfo()->rmode() == RelocInfo::INTERNAL_REFERENCE) {
// raw pointer embedded in code stream, e.g., jump table
byte* ptr = *reinterpret_cast<byte**>(pc);
OS::SNPrintF(decode_buffer,
// Collect RelocInfo for this instruction (prev_pc .. pc-1)
List<const char*> comments(4);
List<byte*> pcs(1);
- List<RelocMode> rmodes(1);
+ List<RelocInfo::Mode> rmodes(1);
List<intptr_t> datas(1);
if (it != NULL) {
while (!it->done() && it->rinfo()->pc() < pc) {
- if (is_comment(it->rinfo()->rmode())) {
+ if (RelocInfo::IsComment(it->rinfo()->rmode())) {
// For comments just collect the text.
comments.Add(reinterpret_cast<const char*>(it->rinfo()->data()));
} else {
out.AddPadding(' ', kRelocInfoPosition);
}
- RelocMode rmode = relocinfo.rmode();
- if (is_position(rmode)) {
- if (is_statement_position(rmode)) {
+ RelocInfo::Mode rmode = relocinfo.rmode();
+ if (RelocInfo::IsPosition(rmode)) {
+ if (RelocInfo::IsStatementPosition(rmode)) {
out.AddFormatted(" ;; debug: statement %d", relocinfo.data());
} else {
out.AddFormatted(" ;; debug: position %d", relocinfo.data());
}
- } else if (rmode == embedded_object) {
+ } else if (rmode == RelocInfo::EMBEDDED_OBJECT) {
HeapStringAllocator allocator;
StringStream accumulator(&allocator);
relocinfo.target_object()->ShortPrint(&accumulator);
SmartPointer<char> obj_name = accumulator.ToCString();
out.AddFormatted(" ;; object: %s", *obj_name);
- } else if (rmode == external_reference) {
+ } else if (rmode == RelocInfo::EXTERNAL_REFERENCE) {
const char* reference_name =
ref_encoder.NameOfAddress(*relocinfo.target_reference_address());
out.AddFormatted(" ;; external reference (%s)", reference_name);
- } else if (is_code_target(rmode)) {
+ } else if (RelocInfo::IsCodeTarget(rmode)) {
out.AddFormatted(" ;; code:");
- if (rmode == js_construct_call) {
+ if (rmode == RelocInfo::CONSTRUCT_CALL) {
out.AddFormatted(" constructor,");
}
Code* code = Debug::GetCodeTarget(relocinfo.target_address());
Code::Kind kind = code->kind();
if (code->is_inline_cache_stub()) {
- if (rmode == code_target_context) {
+ if (rmode == RelocInfo::CODE_TARGET_CONTEXT) {
out.AddFormatted(" contextual,");
}
InlineCacheState ic_state = code->ic_state();
// Cache miss: Jump to runtime.
__ bind(&miss);
Handle<Code> ic(Builtins::builtin(Builtins::LoadIC_Miss));
- __ Jump(ic, code_target);
+ __ Jump(ic, RelocInfo::CODE_TARGET);
}
// Cache miss: Jump to runtime.
__ bind(&miss);
Handle<Code> ic(Builtins::builtin(Builtins::LoadIC_Miss));
- __ Jump(ic, code_target);
+ __ Jump(ic, RelocInfo::CODE_TARGET);
}
// Cache miss: Jump to runtime.
__ bind(&miss);
Handle<Code> ic(Builtins::builtin(Builtins::LoadIC_Miss));
- __ Jump(ic, code_target);
+ __ Jump(ic, RelocInfo::CODE_TARGET);
}
// Cache miss: Jump to runtime.
__ bind(&miss);
Handle<Code> ic(Builtins::builtin(Builtins::LoadIC_Miss));
- __ Jump(ic, code_target);
+ __ Jump(ic, RelocInfo::CODE_TARGET);
}
// sub-optimal. We should port the fast case code from IA-32.
Handle<Code> ic(Builtins::builtin(Builtins::LoadIC_Miss));
- __ Jump(ic, code_target);
+ __ Jump(ic, RelocInfo::CODE_TARGET);
}
}
-RelocMode IC::ComputeMode() {
+RelocInfo::Mode IC::ComputeMode() {
Address addr = address();
Code* code = Code::cast(Heap::FindCodeObject(addr));
for (RelocIterator it(code, RelocInfo::kCodeTargetMask);
if (info->pc() == addr) return info->rmode();
}
UNREACHABLE();
- return no_reloc;
+ return RelocInfo::NONE;
}
// Computes the reloc info for this IC. This is a fairly expensive
// operation as it has to search through the heap to find the code
// object that contains this IC site.
- RelocMode ComputeMode();
+ RelocInfo::Mode ComputeMode();
// Returns if this IC is for contextual (no explicit receiver)
// access to properties.
- bool is_contextual() { return ComputeMode() == code_target_context; }
+ bool is_contextual() {
+ return ComputeMode() == RelocInfo::CODE_TARGET_CONTEXT;
+ }
// Returns the map to use for caching stubs for a given object.
// This method should not be called with undefined or null.
}
-void MacroAssembler::Jump(intptr_t target, RelocMode rmode, Condition cond) {
+void MacroAssembler::Jump(intptr_t target, RelocInfo::Mode rmode,
+ Condition cond) {
#if USE_BX
mov(ip, Operand(target, rmode), LeaveCC, cond);
bx(ip, cond);
}
-void MacroAssembler::Jump(byte* target, RelocMode rmode, Condition cond) {
- ASSERT(!is_code_target(rmode));
+void MacroAssembler::Jump(byte* target, RelocInfo::Mode rmode,
+ Condition cond) {
+ ASSERT(!RelocInfo::IsCodeTarget(rmode));
Jump(reinterpret_cast<intptr_t>(target), rmode, cond);
}
-void MacroAssembler::Jump(Handle<Code> code, RelocMode rmode, Condition cond) {
- ASSERT(is_code_target(rmode));
+void MacroAssembler::Jump(Handle<Code> code, RelocInfo::Mode rmode,
+ Condition cond) {
+ ASSERT(RelocInfo::IsCodeTarget(rmode));
// 'code' is always generated ARM code, never THUMB code
Jump(reinterpret_cast<intptr_t>(code.location()), rmode, cond);
}
}
-void MacroAssembler::Call(intptr_t target, RelocMode rmode, Condition cond) {
+void MacroAssembler::Call(intptr_t target, RelocInfo::Mode rmode,
+ Condition cond) {
#if !defined(__arm__)
- if (rmode == runtime_entry) {
+ if (rmode == RelocInfo::RUNTIME_ENTRY) {
mov(r2, Operand(target, rmode), LeaveCC, cond);
// Set lr for return at current pc + 8.
mov(lr, Operand(pc), LeaveCC, cond);
}
-void MacroAssembler::Call(byte* target, RelocMode rmode, Condition cond) {
- ASSERT(!is_code_target(rmode));
+void MacroAssembler::Call(byte* target, RelocInfo::Mode rmode,
+ Condition cond) {
+ ASSERT(!RelocInfo::IsCodeTarget(rmode));
Call(reinterpret_cast<intptr_t>(target), rmode, cond);
}
-void MacroAssembler::Call(Handle<Code> code, RelocMode rmode, Condition cond) {
- ASSERT(is_code_target(rmode));
+void MacroAssembler::Call(Handle<Code> code, RelocInfo::Mode rmode,
+ Condition cond) {
+ ASSERT(RelocInfo::IsCodeTarget(rmode));
// 'code' is always generated ARM code, never THUMB code
Call(reinterpret_cast<intptr_t>(code.location()), rmode, cond);
}
Handle<Code> adaptor =
Handle<Code>(Builtins::builtin(Builtins::ArgumentsAdaptorTrampoline));
if (flag == CALL_FUNCTION) {
- Call(adaptor, code_target);
+ Call(adaptor, RelocInfo::CODE_TARGET);
b(done);
} else {
- Jump(adaptor, code_target);
+ Jump(adaptor, RelocInfo::CODE_TARGET);
}
bind(®ular_invoke);
}
void MacroAssembler::InvokeCode(Handle<Code> code,
const ParameterCount& expected,
const ParameterCount& actual,
- RelocMode rmode,
+ RelocInfo::Mode rmode,
InvokeFlag flag) {
Label done;
void MacroAssembler::CallStub(CodeStub* stub) {
ASSERT(allow_stub_calls()); // stub calls are not allowed in some stubs
- Call(stub->GetCode(), code_target);
-}
-
-
-void MacroAssembler::CallJSExitStub(CodeStub* stub) {
- ASSERT(allow_stub_calls()); // stub calls are not allowed in some stubs
- Call(stub->GetCode(), exit_js_frame);
+ Call(stub->GetCode(), RelocInfo::CODE_TARGET);
}
#endif
mov(r1, Operand(builtin));
CEntryStub stub;
- Jump(stub.GetCode(), code_target);
+ Jump(stub.GetCode(), RelocInfo::CODE_TARGET);
}
Handle<Code> code = ResolveBuiltin(id, &resolved);
if (flags == CALL_JS) {
- Call(code, code_target);
+ Call(code, RelocInfo::CODE_TARGET);
} else {
ASSERT(flags == JUMP_JS);
- Jump(code, code_target);
+ Jump(code, RelocInfo::CODE_TARGET);
}
if (!resolved) {
// Jump, Call, and Ret pseudo instructions implementing inter-working
private:
- void Jump(intptr_t target, RelocMode rmode, Condition cond = al);
- void Call(intptr_t target, RelocMode rmode, Condition cond = al);
+ 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(byte* target, RelocMode rmode, Condition cond = al);
- void Jump(Handle<Code> code, RelocMode 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 Call(Register target, Condition cond = al);
- void Call(byte* target, RelocMode rmode, Condition cond = al);
- void Call(Handle<Code> code, RelocMode rmode, Condition cond = al);
+ void Call(byte* target, RelocInfo::Mode rmode, Condition cond = al);
+ void Call(Handle<Code> code, RelocInfo::Mode rmode, Condition cond = al);
void Ret();
// Sets the remembered set bit for [address+offset], where address is the
void InvokeCode(Handle<Code> code,
const ParameterCount& expected,
const ParameterCount& actual,
- RelocMode rmode,
+ RelocInfo::Mode rmode,
InvokeFlag flag);
// Invoke the JavaScript function in the given register. Changes the
void MacroAssembler::CallStub(CodeStub* stub) {
ASSERT(allow_stub_calls()); // calls are not allowed in some stubs
- call(stub->GetCode(), code_target);
+ call(stub->GetCode(), RelocInfo::CODE_TARGET);
}
// Set the entry point and jump to the C entry runtime stub.
mov(Operand(ebx), Immediate(ext));
CEntryStub ces;
- jmp(ces.GetCode(), code_target);
+ jmp(ces.GetCode(), RelocInfo::CODE_TARGET);
}
}
if (flag == CALL_FUNCTION) {
- call(adaptor, code_target);
+ call(adaptor, RelocInfo::CODE_TARGET);
jmp(done);
} else {
- jmp(adaptor, code_target);
+ jmp(adaptor, RelocInfo::CODE_TARGET);
}
bind(&invoke);
}
void MacroAssembler::InvokeCode(Handle<Code> code,
const ParameterCount& expected,
const ParameterCount& actual,
- RelocMode rmode,
+ RelocInfo::Mode rmode,
InvokeFlag flag) {
Label done;
Operand dummy(eax);
// arguments match the expected number of arguments. Fake a
// parameter count to avoid emitting code to do the check.
ParameterCount expected(0);
- InvokeCode(Handle<Code>(code), expected, expected, code_target, flag);
+ InvokeCode(Handle<Code>(code), expected, expected,
+ RelocInfo::CODE_TARGET, flag);
const char* name = Builtins::GetName(id);
int argc = Builtins::GetArgumentsCount(id);
void InvokeCode(Handle<Code> code,
const ParameterCount& expected,
const ParameterCount& actual,
- RelocMode rmode,
+ RelocInfo::Mode rmode,
InvokeFlag flag);
// Invoke the JavaScript function in the given register. Changes the
}
void VisitCodeTarget(RelocInfo* rinfo) {
- ASSERT(is_code_target(rinfo->rmode()));
+ ASSERT(RelocInfo::IsCodeTarget(rinfo->rmode()));
Code* code = CodeFromDerivedPointer(rinfo->target_address());
if (FLAG_cleanup_ics_at_gc && code->is_inline_cache_stub()) {
IC::Clear(rinfo->pc());
}
void VisitDebugTarget(RelocInfo* rinfo) {
- ASSERT(is_js_return(rinfo->rmode()) && rinfo->is_call_instruction());
+ ASSERT(RelocInfo::IsJSReturn(rinfo->rmode()) &&
+ rinfo->is_call_instruction());
HeapObject* code = CodeFromDerivedPointer(rinfo->call_address());
MarkCompactCollector::MarkObject(code);
// When compacting we convert the call to a real object pointer.
for (RelocIterator it(this); !it.done(); it.next()) {
it.rinfo()->Verify();
// Ensure that GC will not iterate twice over the same pointer.
- if (is_gc_reloc_mode(it.rinfo()->rmode())) {
+ if (RelocInfo::IsGCRelocMode(it.rinfo()->rmode())) {
CHECK(it.rinfo()->pc() != last_gc_pc);
last_gc_pc = it.rinfo()->pc();
}
void ObjectVisitor::VisitCodeTarget(RelocInfo* rinfo) {
- ASSERT(is_code_target(rinfo->rmode()));
+ ASSERT(RelocInfo::IsCodeTarget(rinfo->rmode()));
VisitPointer(rinfo->target_object_address());
}
void ObjectVisitor::VisitDebugTarget(RelocInfo* rinfo) {
- ASSERT(is_js_return(rinfo->rmode()) && rinfo->is_call_instruction());
+ ASSERT(RelocInfo::IsJSReturn(rinfo->rmode()) && rinfo->is_call_instruction());
VisitPointer(rinfo->call_object_address());
}
}
if (Debug::has_break_points()) {
- for (RelocIterator it(this, RelocMask(js_return)); !it.done(); it.next()) {
+ for (RelocIterator it(this, RelocInfo::ModeMask(RelocInfo::JS_RETURN));
+ !it.done();
+ it.next()) {
if (it.rinfo()->is_call_instruction()) {
Address addr = it.rinfo()->call_address();
ASSERT(addr != NULL);
v->BeginCodeIteration(this);
int mode_mask = RelocInfo::kCodeTargetMask |
- RelocMask(embedded_object) |
- RelocMask(external_reference) |
- RelocMask(js_return) |
- RelocMask(runtime_entry);
+ RelocInfo::ModeMask(RelocInfo::EMBEDDED_OBJECT) |
+ RelocInfo::ModeMask(RelocInfo::EXTERNAL_REFERENCE) |
+ RelocInfo::ModeMask(RelocInfo::JS_RETURN) |
+ RelocInfo::ModeMask(RelocInfo::RUNTIME_ENTRY);
for (RelocIterator it(this, mode_mask); !it.done(); it.next()) {
- RelocMode rmode = it.rinfo()->rmode();
- if (rmode == embedded_object) {
+ RelocInfo::Mode rmode = it.rinfo()->rmode();
+ if (rmode == RelocInfo::EMBEDDED_OBJECT) {
v->VisitPointer(it.rinfo()->target_object_address());
- } else if (is_code_target(rmode)) {
+ } else if (RelocInfo::IsCodeTarget(rmode)) {
v->VisitCodeTarget(it.rinfo());
- } else if (rmode == external_reference) {
+ } else if (rmode == RelocInfo::EXTERNAL_REFERENCE) {
v->VisitExternalReference(it.rinfo()->target_reference_address());
} else if (Debug::has_break_points() &&
- is_js_return(rmode) && it.rinfo()->is_call_instruction()) {
+ RelocInfo::IsJSReturn(rmode) &&
+ it.rinfo()->is_call_instruction()) {
v->VisitDebugTarget(it.rinfo());
- } else if (rmode == runtime_entry) {
+ } else if (rmode == RelocInfo::RUNTIME_ENTRY) {
v->VisitRuntimeEntry(it.rinfo());
}
}
}
if (Debug::has_break_points()) {
- for (RelocIterator it(this, RelocMask(js_return)); !it.done(); it.next()) {
+ for (RelocIterator it(this, RelocInfo::ModeMask(RelocInfo::JS_RETURN));
+ !it.done();
+ it.next()) {
if (it.rinfo()->is_call_instruction()) {
Code* code = reinterpret_cast<Code*>(it.rinfo()->call_object());
ASSERT((code != NULL) && code->IsHeapObject());
// unbox handles and relocate
int delta = instruction_start() - desc.buffer;
int mode_mask = RelocInfo::kCodeTargetMask |
- RelocMask(embedded_object) |
+ RelocInfo::ModeMask(RelocInfo::EMBEDDED_OBJECT) |
RelocInfo::kApplyMask;
for (RelocIterator it(this, mode_mask); !it.done(); it.next()) {
- RelocMode mode = it.rinfo()->rmode();
- if (mode == embedded_object) {
+ RelocInfo::Mode mode = it.rinfo()->rmode();
+ if (mode == RelocInfo::EMBEDDED_OBJECT) {
Object** p = reinterpret_cast<Object**>(it.rinfo()->target_object());
it.rinfo()->set_target_object(*p);
- } else if (is_code_target(mode)) {
+ } else if (RelocInfo::IsCodeTarget(mode)) {
// rewrite code handles in inline cache targets to direct
// pointers to the first instruction in the code object
Object** p = reinterpret_cast<Object**>(it.rinfo()->target_object());
// source for this function is found.
int Code::SourcePosition(Address pc) {
int distance = kMaxInt;
- int position = kNoPosition; // Initially no position found.
+ int position = RelocInfo::kNoPosition; // Initially no position found.
// Run through all the relocation info to find the best matching source
// position. All the code needs to be considered as the sequence of the
// instructions in the code does not necessarily follow the same order as the
int statement_position = 0;
RelocIterator it(this, RelocInfo::kPositionMask);
while (!it.done()) {
- if (is_statement_position(it.rinfo()->rmode())) {
+ if (RelocInfo::IsStatementPosition(it.rinfo()->rmode())) {
int p = it.rinfo()->data();
if (statement_position < p && p <= position) {
statement_position = p;
FunctionLiteralType type = is_expression ? EXPRESSION : DECLARATION;
bool ok = true;
- result = ParseFunctionLiteral(name, kNoPosition, type, &ok);
+ result = ParseFunctionLiteral(name, RelocInfo::kNoPosition, type, &ok);
// Make sure the results agree.
ASSERT(ok == (result != NULL));
// The only errors should be stack overflows.
NEW(FunctionBoilerplateLiteral(boilerplate));
VariableProxy* var = Declare(name, Variable::VAR, NULL, true, CHECK_OK);
return NEW(ExpressionStatement(
- new Assignment(Token::INIT_VAR, var, lit, kNoPosition)));
+ new Assignment(Token::INIT_VAR, var, lit, RelocInfo::kNoPosition)));
}
if (peek() == Token::IDENTIFIER) {
Handle<String> name = ParseIdentifier(CHECK_OK);
FunctionLiteral* value =
- ParseFunctionLiteral(name, kNoPosition, DECLARATION, CHECK_OK);
+ ParseFunctionLiteral(name, RelocInfo::kNoPosition,
+ DECLARATION, CHECK_OK);
ObjectLiteral::Property* property =
NEW(ObjectLiteral::Property(is_getter, value));
if (IsBoilerplateProperty(property))
fproxy->BindTo(fvar);
body.Add(new ExpressionStatement(
new Assignment(Token::INIT_VAR, fproxy,
- NEW(ThisFunction()), kNoPosition)));
+ NEW(ThisFunction()),
+ RelocInfo::kNoPosition)));
}
// Determine if the function will be lazily compiled. The mode can
Expression* SetResult(Expression* value) {
result_assigned_ = true;
- return new Assignment(Token::ASSIGN, result_, value, kNoPosition);
+ return new Assignment(Token::ASSIGN, result_, value,
+ RelocInfo::kNoPosition);
}
// Node visitors.
Smi::FromInt(info.NumberOfLocals()));
// Add the source position.
- if (position != kNoPosition) {
+ if (position != RelocInfo::kNoPosition) {
details->set(kFrameDetailsSourcePositionIndex, Smi::FromInt(position));
} else {
details->set(kFrameDetailsSourcePositionIndex, Heap::undefined_value());
// these functions.
bool done = false;
// The current candidate for the source position:
- int target_start_position = kNoPosition;
+ int target_start_position = RelocInfo::kNoPosition;
Handle<SharedFunctionInfo> target;
// The current candidate for the last function in script:
Handle<SharedFunctionInfo> last;
// If the SharedFunctionInfo found has the requested script data and
// contains the source position it is a candidate.
int start_position = shared->function_token_position();
- if (start_position == kNoPosition) {
+ if (start_position == RelocInfo::kNoPosition) {
start_position = shared->start_position();
}
if (start_position <= position &&
var->rewrite_ =
new Property(arguments_shadow_,
new Literal(Handle<Object>(Smi::FromInt(i))),
- kNoPosition);
+ RelocInfo::kNoPosition);
arguments_shadow->var_uses()->RecordUses(var->var_uses());
}
}
// with ']'. RelocIterator 'it' must point to a comment reloc info.
static void CollectCommentStatistics(RelocIterator* it) {
ASSERT(!it->done());
- ASSERT(it->rinfo()->rmode() == comment);
+ ASSERT(it->rinfo()->rmode() == RelocInfo::COMMENT);
const char* tmp = reinterpret_cast<const char*>(it->rinfo()->data());
if (tmp[0] != '[') {
// Not a nested comment; skip
// All nested comments must be terminated properly, and therefore exit
// from loop.
ASSERT(!it->done());
- if (it->rinfo()->rmode() == comment) {
+ if (it->rinfo()->rmode() == RelocInfo::COMMENT) {
const char* const txt =
reinterpret_cast<const char*>(it->rinfo()->data());
flat_delta += it->rinfo()->pc() - prev_pc;
int delta = 0;
const byte* prev_pc = code->instruction_start();
while (!it.done()) {
- if (it.rinfo()->rmode() == comment) {
+ if (it.rinfo()->rmode() == RelocInfo::COMMENT) {
delta += it.rinfo()->pc() - prev_pc;
CollectCommentStatistics(&it);
prev_pc = it.rinfo()->pc();
// Handle call cache miss.
__ bind(&miss);
Handle<Code> ic = ComputeCallMiss(arguments().immediate());
- __ Jump(ic, code_target);
+ __ Jump(ic, RelocInfo::CODE_TARGET);
// Return the generated code.
return GetCode(FIELD);
// Jump to the cached code (tail call).
Handle<Code> code(function->code());
ParameterCount expected(function->shared()->formal_parameter_count());
- __ InvokeCode(code, expected, arguments(), code_target, JUMP_FUNCTION);
+ __ InvokeCode(code, expected, arguments(),
+ RelocInfo::CODE_TARGET, JUMP_FUNCTION);
// Handle call cache miss.
__ bind(&miss);
Handle<Code> ic = ComputeCallMiss(arguments().immediate());
- __ Jump(ic, code_target);
+ __ Jump(ic, RelocInfo::CODE_TARGET);
// Return the generated code.
return GetCode(CONSTANT_FUNCTION);
// Handle call cache miss.
__ bind(&miss);
Handle<Code> ic = ComputeCallMiss(arguments().immediate());
- __ Jump(ic, code_target);
+ __ Jump(ic, RelocInfo::CODE_TARGET);
// Return the generated code.
return GetCode(INTERCEPTOR);
__ bind(&miss);
__ mov(r2, Operand(Handle<String>(name))); // restore name
Handle<Code> ic(Builtins::builtin(Builtins::StoreIC_Miss));
- __ Jump(ic, code_target);
+ __ Jump(ic, RelocInfo::CODE_TARGET);
// Return the generated code.
return GetCode(transition == NULL ? FIELD : MAP_TRANSITION);
__ bind(&miss);
__ mov(r2, Operand(Handle<String>(name))); // restore name
Handle<Code> ic(Builtins::builtin(Builtins::StoreIC_Miss));
- __ Jump(ic, code_target);
+ __ Jump(ic, RelocInfo::CODE_TARGET);
// Return the generated code.
return GetCode(CALLBACKS);
__ bind(&miss);
__ mov(r2, Operand(Handle<String>(name))); // restore name
Handle<Code> ic(Builtins::builtin(Builtins::StoreIC_Miss));
- __ Jump(ic, code_target);
+ __ Jump(ic, RelocInfo::CODE_TARGET);
// Return the generated code.
return GetCode(INTERCEPTOR);
__ bind(&miss);
__ ldr(r0, MemOperand(sp)); // restore receiver
Handle<Code> ic(Builtins::builtin(Builtins::LoadIC_Miss));
- __ Jump(ic, code_target);
+ __ Jump(ic, RelocInfo::CODE_TARGET);
// Return the generated code.
return GetCode(FIELD);
// Handle load cache miss.
__ bind(&miss);
Handle<Code> ic(Builtins::builtin(Builtins::LoadIC_Miss));
- __ Jump(ic, code_target);
+ __ Jump(ic, RelocInfo::CODE_TARGET);
// Return the generated code.
return GetCode(CALLBACKS);
// Handle load cache miss.
__ bind(&miss);
Handle<Code> ic(Builtins::builtin(Builtins::LoadIC_Miss));
- __ Jump(ic, code_target);
+ __ Jump(ic, RelocInfo::CODE_TARGET);
// Return the generated code.
return GetCode(CONSTANT_FUNCTION);
// Handle load cache miss.
__ bind(&miss);
Handle<Code> ic(Builtins::builtin(Builtins::LoadIC_Miss));
- __ Jump(ic, code_target);
+ __ Jump(ic, RelocInfo::CODE_TARGET);
// Return the generated code.
return GetCode(INTERCEPTOR);
}
Handle<Code> ic(code);
- __ jmp(ic, code_target);
+ __ jmp(ic, RelocInfo::CODE_TARGET);
}
// Handle call cache miss.
__ bind(&miss);
Handle<Code> ic = ComputeCallMiss(arguments().immediate());
- __ jmp(ic, code_target);
+ __ jmp(ic, RelocInfo::CODE_TARGET);
// Return the generated code.
return GetCode(FIELD);
// Jump to the cached code (tail call).
Handle<Code> code(function->code());
ParameterCount expected(function->shared()->formal_parameter_count());
- __ InvokeCode(code, expected, arguments(), code_target, JUMP_FUNCTION);
+ __ InvokeCode(code, expected, arguments(),
+ RelocInfo::CODE_TARGET, JUMP_FUNCTION);
// Handle call cache miss.
__ bind(&miss);
Handle<Code> ic = ComputeCallMiss(arguments().immediate());
- __ jmp(ic, code_target);
+ __ jmp(ic, RelocInfo::CODE_TARGET);
// Return the generated code.
return GetCode(CONSTANT_FUNCTION);
// Handle load cache miss.
__ bind(&miss);
Handle<Code> ic = ComputeCallMiss(argc);
- __ jmp(ic, code_target);
+ __ jmp(ic, RelocInfo::CODE_TARGET);
// Return the generated code.
return GetCode(INTERCEPTOR);
__ bind(&miss);
__ mov(Operand(ecx), Immediate(Handle<String>(name))); // restore name
Handle<Code> ic(Builtins::builtin(Builtins::StoreIC_Miss));
- __ jmp(ic, code_target);
+ __ jmp(ic, RelocInfo::CODE_TARGET);
// Return the generated code.
return GetCode(transition == NULL ? FIELD : MAP_TRANSITION);
__ bind(&miss);
__ mov(Operand(ecx), Immediate(Handle<String>(name))); // restore name
Handle<Code> ic(Builtins::builtin(Builtins::StoreIC_Miss));
- __ jmp(ic, code_target);
+ __ jmp(ic, RelocInfo::CODE_TARGET);
// Return the generated code.
return GetCode(CALLBACKS);
__ bind(&miss);
__ mov(Operand(ecx), Immediate(Handle<String>(name))); // restore name
Handle<Code> ic(Builtins::builtin(Builtins::StoreIC_Miss));
- __ jmp(ic, code_target);
+ __ jmp(ic, RelocInfo::CODE_TARGET);
// Return the generated code.
return GetCode(INTERCEPTOR);
__ bind(&miss);
__ DecrementCounter(&Counters::keyed_store_field, 1);
Handle<Code> ic(Builtins::builtin(Builtins::KeyedStoreIC_Miss));
- __ jmp(ic, code_target);
+ __ jmp(ic, RelocInfo::CODE_TARGET);
// Return the generated code.
return GetCode(transition == NULL ? FIELD : MAP_TRANSITION);
// some relocated stuff here, not executed
__ mov(eax, Factory::true_value());
- __ jmp(NULL, runtime_entry);
+ __ jmp(NULL, RelocInfo::RUNTIME_ENTRY);
CodeDesc desc;
assm.GetCode(&desc);
v8::internal::byte buffer[256];
Assembler assm(buffer, sizeof buffer);
- __ mov(eax, Operand(reinterpret_cast<intptr_t>(&baz), no_reloc));
+ __ mov(eax, Operand(reinterpret_cast<intptr_t>(&baz), RelocInfo::NONE));
__ ret(0);
CodeDesc desc;
// location in the code is the expected debug_break function.
void CheckDebugBreakFunction(DebugLocalContext* env,
const char* source, const char* name,
- int position, v8::internal::RelocMode mode,
+ int position, v8::internal::RelocInfo::Mode mode,
Code* debug_break) {
// Create function and set the break point.
Handle<v8::internal::JSFunction> fun = v8::Utils::OpenHandle(
TestBreakLocationIterator it1(Debug::GetDebugInfo(shared));
it1.FindBreakLocationFromPosition(position);
CHECK_EQ(mode, it1.it()->rinfo()->rmode());
- if (mode != v8::internal::js_return) {
+ if (mode != v8::internal::RelocInfo::JS_RETURN) {
CHECK_EQ(debug_break,
Debug::GetCodeTarget(it1.it()->rinfo()->target_address()));
} else {
TestBreakLocationIterator it2(Debug::GetDebugInfo(shared));
it2.FindBreakLocationFromPosition(position);
CHECK_EQ(mode, it2.it()->rinfo()->rmode());
- if (mode == v8::internal::js_return) {
+ if (mode == v8::internal::RelocInfo::JS_RETURN) {
// TODO(1240753): Make the test architecture independent or split
// parts of the debugger into architecture dependent files.
CHECK_NE(0xE8, *(it2.rinfo()->pc()));
v8::HandleScope scope;
DebugLocalContext env;
- // TODO(1240753): Make the test architecture independent or split
- // parts of the debugger into architecture dependent files. This
- // part currently disabled as it is not portable between IA32/ARM.
- // Ia32 uses js_return ARM uses exit_js_frame.
-#if !defined (__arm__) && !defined(__thumb__)
CheckDebugBreakFunction(&env,
"function f1(){}", "f1",
0,
- v8::internal::js_return,
+ v8::internal::RelocInfo::JS_RETURN,
NULL);
-#endif
CheckDebugBreakFunction(&env,
"function f2(){x=1;}", "f2",
0,
- v8::internal::code_target,
+ v8::internal::RelocInfo::CODE_TARGET,
Builtins::builtin(Builtins::StoreIC_DebugBreak));
CheckDebugBreakFunction(&env,
"function f3(){var a=x;}", "f3",
0,
- v8::internal::code_target_context,
+ v8::internal::RelocInfo::CODE_TARGET_CONTEXT,
Builtins::builtin(Builtins::LoadIC_DebugBreak));
+// TODO(1240753): Make the test architecture independent or split
+// parts of the debugger into architecture dependent files. This
+// part currently disabled as it is not portable between IA32/ARM.
// Currently on ICs for keyed store/load on ARM.
#if !defined (__arm__) && !defined(__thumb__)
CheckDebugBreakFunction(
"function f4(){var index='propertyName'; var a={}; a[index] = 'x';}",
"f4",
0,
- v8::internal::code_target,
+ v8::internal::RelocInfo::CODE_TARGET,
Builtins::builtin(Builtins::KeyedStoreIC_DebugBreak));
CheckDebugBreakFunction(
&env,
"function f5(){var index='propertyName'; var a={}; return a[index];}",
"f5",
0,
- v8::internal::code_target,
+ v8::internal::RelocInfo::CODE_TARGET,
Builtins::builtin(Builtins::KeyedLoadIC_DebugBreak));
#endif
CheckDebugBreakFunction(&env,
"function f4_0(){x();}", "f4_0",
0,
- v8::internal::code_target_context,
+ v8::internal::RelocInfo::CODE_TARGET_CONTEXT,
*debug_break_0);
CheckDebugBreakFunction(&env,
"function f4_1(){x(1);}", "f4_1",
0,
- v8::internal::code_target_context,
+ v8::internal::RelocInfo::CODE_TARGET_CONTEXT,
*debug_break_1);
CheckDebugBreakFunction(&env,
"function f4_4(){x(1,2,3,4);}", "f4_4",
0,
- v8::internal::code_target_context,
+ v8::internal::RelocInfo::CODE_TARGET_CONTEXT,
*debug_break_4);
}
// ---- All instructions that I can think of
__ add(edx, Operand(ebx));
- __ add(edx, Operand(12, no_reloc));
+ __ add(edx, Operand(12, RelocInfo::NONE));
__ add(edx, Operand(ebx, 0));
__ add(edx, Operand(ebx, 16));
__ add(edx, Operand(ebx, 1999));
__ call(Operand(ebx, ecx, times_4, 10000));
__ nop();
Handle<Code> ic(Builtins::builtin(Builtins::LoadIC_Initialize));
- __ call(ic, code_target);
+ __ call(ic, RelocInfo::CODE_TARGET);
__ nop();
- __ call(FUNCTION_ADDR(DummyStaticFunction), runtime_entry);
+ __ call(FUNCTION_ADDR(DummyStaticFunction), RelocInfo::RUNTIME_ENTRY);
__ nop();
__ jmp(&L1);
ExternalReference after_break_target =
ExternalReference(Debug_Address::AfterBreakTarget());
__ jmp(Operand::StaticVariable(after_break_target));
- __ jmp(ic, code_target);
+ __ jmp(ic, RelocInfo::CODE_TARGET);
__ nop();