37 #ifndef V8_IA32_ASSEMBLER_IA32_H_
38 #define V8_IA32_ASSEMBLER_IA32_H_
127 const char*
const kNames[] = {
"eax",
"ecx",
"edx",
"ebx",
"esi",
"edi" };
128 return kNames[index];
134 return (reg.code() >= 6) ? reg.code() - 2 : reg.code();
153 return reg.
code() - 1;
209 const char*
const names[] = {
223 #define xmm0 (static_cast<const XMMRegister&>(double_register_0))
224 #define xmm1 (static_cast<const XMMRegister&>(double_register_1))
225 #define xmm2 (static_cast<const XMMRegister&>(double_register_2))
226 #define xmm3 (static_cast<const XMMRegister&>(double_register_3))
227 #define xmm4 (static_cast<const XMMRegister&>(double_register_4))
228 #define xmm5 (static_cast<const XMMRegister&>(double_register_5))
229 #define xmm6 (static_cast<const XMMRegister&>(double_register_6))
230 #define xmm7 (static_cast<const XMMRegister&>(double_register_7))
231 #define no_xmm_reg (static_cast<const XMMRegister&>(no_double_reg))
244 const char*
const names[] = {
245 "stX_0",
"stX_1",
"stX_2",
"stX_3",
"stX_4"
254 result.
code_ = index;
263 #define stX_0 static_cast<const X87Register&>(double_register_0)
264 #define stX_1 static_cast<const X87Register&>(double_register_1)
265 #define stX_2 static_cast<const X87Register&>(double_register_2)
266 #define stX_3 static_cast<const X87Register&>(double_register_3)
267 #define stX_4 static_cast<const X87Register&>(double_register_4)
343 inline explicit Immediate(
int x);
344 inline explicit Immediate(
const ExternalReference& ext);
345 inline explicit Immediate(Handle<Object>
handle);
346 inline explicit Immediate(Smi* value);
347 inline explicit Immediate(
Address addr);
350 return Immediate(label);
353 bool is_zero()
const {
return x_ == 0 && RelocInfo::IsNone(rmode_); }
355 return -128 <= x_ && x_ < 128 && RelocInfo::IsNone(rmode_);
358 return -32768 <= x_ && x_ < 32768 && RelocInfo::IsNone(rmode_);
362 inline explicit Immediate(Label* value);
365 RelocInfo::Mode rmode_;
398 RelocInfo::Mode rmode = RelocInfo::NONE32);
401 explicit Operand(Register base,
405 RelocInfo::Mode rmode = RelocInfo::NONE32);
408 explicit Operand(Register index,
411 RelocInfo::Mode rmode = RelocInfo::NONE32);
414 return Operand(reinterpret_cast<int32_t>(ext.address()),
415 RelocInfo::EXTERNAL_REFERENCE);
420 const ExternalReference& arr) {
421 return Operand(index, scale, reinterpret_cast<int32_t>(arr.address()),
422 RelocInfo::EXTERNAL_REFERENCE);
427 return Operand(reinterpret_cast<int32_t>(cell.location()),
435 bool is_reg_only()
const;
447 inline void set_modrm(
int mod,
Register rm);
450 inline void set_disp8(int8_t disp);
451 inline void set_dispr(
int32_t disp, RelocInfo::Mode rmode);
457 RelocInfo::Mode rmode_;
492 int data()
const {
return data_; }
493 Type type()
const {
return TypeField::decode(data_); }
495 int n = NextField::decode(data_);
496 n > 0 ? L->link_to(n) : L->Unuse();
505 PrintF(
"%s (%x) ", (type() == UNCONDITIONAL_JUMP ?
"jmp" :
"[other]"),
506 NextField::decode(data_));
512 class TypeField:
public BitField<Type, 0, 2> {};
513 class NextField:
public BitField<int, 2, 32-2> {};
515 void init(Label*
L,
Type type);
529 class CpuFeatures :
public AllStatic {
538 if (Check(f, cross_compile_))
return true;
539 if (f ==
SSE2 && !FLAG_enable_sse2)
return false;
540 if (f ==
SSE3 && !FLAG_enable_sse3)
return false;
541 if (f ==
SSE4_1 && !FLAG_enable_sse4_1)
return false;
542 if (f ==
CMOV && !FLAG_enable_cmov)
return false;
543 return Check(f, supported_);
548 return Check(f, found_by_runtime_probing_only_);
552 return Check(f, cross_compile_) ||
558 return cross_compile_ == 0;
562 uint64_t mask = flag2set(f);
563 return cross_compile_ == 0 ||
564 (cross_compile_ & mask) == mask;
568 static bool Check(
CpuFeature f, uint64_t set) {
569 return (set & flag2set(f)) != 0;
573 return static_cast<uint64_t
>(1) << f;
577 static bool initialized_;
579 static uint64_t supported_;
580 static uint64_t found_by_runtime_probing_only_;
582 static uint64_t cross_compile_;
590 class Assembler :
public AssemblerBase {
601 static const int kGap = 32;
713 void Nop(
int bytes = 1);
724 void push(
const Immediate& x);
751 void mov(
const Operand& dst,
const Immediate& x);
792 void add(
const Operand& dst,
const Immediate& x);
813 void cmp(
const Operand& op,
const Immediate& imm);
849 void or_(
const Operand& dst,
const Immediate& x);
874 void sub(
const Operand& dst,
const Immediate& x);
883 void test(
const Operand& op,
const Immediate& imm);
926 void call(
byte* entry, RelocInfo::Mode rmode);
932 RelocInfo::Mode rmode,
937 void jmp(Label*
L, Label::Distance distance = Label::kFar);
938 void jmp(
byte* entry, RelocInfo::Mode rmode);
946 Label::Distance distance = Label::kFar);
1000 void faddp(
int i = 1);
1001 void fsubp(
int i = 1);
1003 void fmulp(
int i = 1);
1004 void fdivp(
int i = 1);
1008 void fxch(
int i = 1);
1010 void ffree(
int i = 0);
1167 void db(uint8_t data);
1168 void dd(uint32_t data);
1174 return pc_ >= reloc_info_writer.pos() - kGap;
1210 uint32_t long_at(
int pos) {
1211 return *
reinterpret_cast<uint32_t*
>(
addr_at(pos));
1213 void long_at_put(
int pos, uint32_t x) {
1214 *
reinterpret_cast<uint32_t*
>(
addr_at(pos)) = x;
1219 inline void emit(uint32_t x);
1220 inline void emit(Handle<Object>
handle);
1221 inline void emit(uint32_t x,
1222 RelocInfo::Mode rmode,
1224 inline void emit(Handle<Code> code,
1225 RelocInfo::Mode rmode,
1227 inline void emit(
const Immediate& x);
1228 inline void emit_w(
const Immediate& x);
1231 inline void emit_code_relative_offset(Label* label);
1234 void emit_arith_b(
int op1,
int op2, Register dst,
int imm8);
1240 void emit_arith(
int sel, Operand dst,
const Immediate& x);
1242 void emit_operand(Register reg,
const Operand&
adr);
1244 void emit_farith(
int b1,
int b2,
int i);
1247 void print(Label*
L);
1248 void bind_to(Label*
L,
int pos);
1251 inline Displacement disp_at(Label*
L);
1252 inline void disp_at_put(Label*
L, Displacement disp);
1254 inline void emit_near_disp(Label*
L);
1257 void RecordRelocInfo(RelocInfo::Mode rmode, intptr_t data = 0);
1263 RelocInfoWriter reloc_info_writer;
1277 if (assembler_->buffer_overflow()) assembler_->GrowBuffer();
1279 space_before_ = assembler_->available_space();
1285 int bytes_generated = space_before_ - assembler_->available_space();
1286 ASSERT(bytes_generated < assembler_->kGap);
1291 Assembler* assembler_;
1299 #endif // V8_IA32_ASSEMBLER_IA32_H_
void cmp(Register src1, const Operand &src2, Condition cond=al)
void psllq(XMMRegister reg, int8_t shift)
enable upcoming ES6 features enable harmony block scoping enable harmony enable harmony proxies enable harmony generators enable harmony numeric enable harmony string enable harmony math functions harmony_scoping harmony_symbols harmony_collections harmony_iteration harmony_strings harmony_scoping harmony_maths tracks arrays with only smi values Optimize object Array DOM strings and string pretenure call new trace pretenuring decisions of HAllocate instructions track fields with only smi values track fields with heap values track_fields track_fields Enables optimizations which favor memory size over execution speed use string slices optimization filter maximum number of GVN fix point iterations use function inlining use allocation folding eliminate write barriers targeting allocations in optimized code maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining crankshaft harvests type feedback from stub cache trace check elimination phase hydrogen tracing filter NULL
static const int kMaximalBufferSize
static const int kNumAllocatableRegisters
Isolate * isolate() const
const int kRegister_ebp_Code
void fsub(const FPRegister &fd, const FPRegister &fn, const FPRegister &fm)
void test(Register reg0, Register reg1)
void fst_d(const Operand &adr)
static const byte kJccShortPrefix
void ucomisd(XMMRegister dst, XMMRegister src)
static Immediate CodeRelativeOffset(Label *label)
void pcmpeqd(XMMRegister dst, XMMRegister src)
static void set_target_address_at(Address pc, Code *code, Address target)
void cmpb(Register reg, int8_t imm8)
void cvttss2si(Register dst, const Operand &src)
void PopulateConstantPool(ConstantPoolArray *constant_pool)
void PrintF(const char *format,...)
void or_(Register dst, Register src)
static Address target_address_at(Address pc, Code *code)
void roundsd(XMMRegister dst, XMMRegister src, RoundingMode mode)
static const char * AllocationIndexToString(int index)
void por(XMMRegister dst, XMMRegister src)
static const int kMaxNumAllocatableRegisters
bool buffer_overflow() const
void add(Register dst, const Immediate &imm)
void mulsd(XMMRegister dst, XMMRegister src)
void addps(XMMRegister dst, const Operand &src)
bool is_byte_register() const
void cvtsd2si(Register dst, XMMRegister src)
static TypeFeedbackId None()
void or_(Register dst, const Immediate &imm)
void movdq(bool aligned, XMMRegister dst, const Operand &src)
const IntelDoubleRegister no_double_reg
void imul(Register dst, Register src)
void subps(XMMRegister dst, XMMRegister src)
void orpd(XMMRegister dst, XMMRegister src)
static int NumAllocatableRegisters()
static const int kPatchDebugBreakSlotReturnOffset
static Operand StaticVariable(const ExternalReference &ext)
int SizeOfCodeGeneratedSince(Label *label)
void or_(Register dst, int32_t imm32)
void push(Register src, Condition cond=al)
void movntdq(const Operand &dst, XMMRegister src)
void cvtsi2sd(XMMRegister dst, Register src)
void cvtss2sd(XMMRegister dst, XMMRegister src)
TypeImpl< ZoneTypeConfig > Type
void sqrtsd(XMMRegister dst, XMMRegister src)
static XMMRegister FromAllocationIndex(int index)
void fst_s(const Operand &adr)
static bool IsSupported(CpuFeature f)
const int kRegister_ebx_Code
const IntelDoubleRegister double_register_1
static Operand StaticArray(Register index, ScaleFactor scale, const ExternalReference &arr)
void sbb(Register dst, const Operand &src)
static Address target_address_at(Address pc, ConstantPoolArray *constant_pool)
void mulps(XMMRegister dst, const Operand &src)
static X87Register FromAllocationIndex(int index)
void andpd(XMMRegister dst, XMMRegister src)
void j(Condition cc, Label *L, Label::Distance distance=Label::kFar)
void sub(Register dst, Register src)
#define ASSERT(condition)
void ptest(XMMRegister dst, XMMRegister src)
static const int kPatchReturnSequenceAddressOffset
static const byte kJmpShortOpcode
static const int kNumRegisters
static bool IsSafeForSnapshot(CpuFeature f)
static const char * AllocationIndexToString(int index)
void xorpd(XMMRegister dst, XMMRegister src)
void fdiv(const FPRegister &fd, const FPRegister &fn, const FPRegister &fm)
void bt(const Operand &dst, Register src)
void sar(Register dst, uint8_t imm8)
static const byte kTestAlByte
const int kRegister_esp_Code
void fistp_s(const Operand &adr)
void movsx_b(Register dst, Register src)
ConstantPoolArray * constant_pool()
void pxor(XMMRegister dst, XMMRegister src)
void addsd(XMMRegister dst, XMMRegister src)
void movzx_b(Register dst, Register src)
static int NumRegisters()
void shr_cl(Register dst)
void fld_d(const Operand &adr)
static const int kNumRegisters
void cmpb_al(const Operand &op)
void xchg(Register dst, Register src)
void fild_s(const Operand &adr)
EnsureSpace(Assembler *assembler)
void movntdqa(XMMRegister dst, const Operand &src)
void rcl(Register dst, uint8_t imm8)
void enter(const Immediate &size)
void ret(const Register &xn=lr)
Condition ReverseCondition(Condition cond)
static const byte kJcShortOpcode
void movd(Register dst, XMMRegister src)
static const int kMaxNumAllocatableRegisters
void shld(Register dst, Register src)
void neg(const Register &rd, const Operand &operand)
enable upcoming ES6 features enable harmony block scoping enable harmony enable harmony proxies enable harmony generators enable harmony numeric enable harmony string enable harmony math functions harmony_scoping harmony_symbols harmony_collections harmony_iteration harmony_strings harmony_scoping harmony_maths tracks arrays with only smi values Optimize object Array DOM strings and string pretenure call new trace pretenuring decisions of HAllocate instructions track fields with only smi values track fields with heap values track_fields track_fields Enables optimizations which favor memory size over execution speed use string slices optimization filter maximum number of GVN fix point iterations use function inlining use allocation folding eliminate write barriers targeting allocations in optimized code maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining crankshaft harvests type feedback from stub cache trace check elimination phase hydrogen tracing filter trace hydrogen to given file name trace inlining decisions trace store elimination trace all use positions trace global value numbering trace hydrogen escape analysis trace the tracking of allocation sites trace map generalization environment for every instruction deoptimize every n garbage collections put a break point before deoptimizing deoptimize uncommon cases use on stack replacement trace array bounds check elimination perform array index dehoisting use load elimination use store elimination use constant folding eliminate unreachable code number of stress runs when picking a function to watch for shared function not JSFunction itself flushes the cache of optimized code for closures on every GC functions with arguments object maximum number of escape analysis fix point iterations allow uint32 values on optimize frames if they are used only in safe operations track concurrent recompilation artificial compilation delay in ms concurrent on stack replacement do not emit check maps for constant values that have a leaf deoptimize the optimized code if the layout of the maps changes number of stack frames inspected by the profiler percentage of ICs that must have type info to allow optimization extra verbose compilation tracing generate extra emit comments in code disassembly enable use of SSE3 instructions if available enable use of CMOV instruction if available enable use of VFP3 instructions if available enable use of NEON instructions if enable use of SDIV and UDIV instructions if enable loading bit constant by means of movw movt instruction enable unaligned accesses for enable use of d16 d31 registers on ARM this requires VFP3 force all emitted branches to be in long mode(MIPS only)") DEFINE_string(expose_natives_as
DwVfpRegister DoubleRegister
enable upcoming ES6 features enable harmony block scoping enable harmony enable harmony proxies enable harmony generators enable harmony numeric enable harmony string enable harmony math functions harmony_scoping harmony_symbols harmony_collections harmony_iteration harmony_strings harmony_scoping harmony_maths tracks arrays with only smi values Optimize object size
static const int kNumAllocatableRegisters
void andps(XMMRegister dst, const Operand &src)
void fisttp_d(const Operand &adr)
bool is(X87Register reg) const
void bsr(Register dst, Register src)
static int ToAllocationIndex(X87Register reg)
void movss(XMMRegister dst, const Operand &src)
STATIC_ASSERT(sizeof(CPURegister)==sizeof(Register))
void set_byte_at(int pos, byte value)
void cvtsd2ss(XMMRegister dst, XMMRegister src)
void pinsrd(XMMRegister dst, Register src, int8_t offset)
void mov_b(Register dst, int8_t imm8)
static const int kSpecialTargetSize
const IntelDoubleRegister double_register_5
friend class ExternalReference
void movsd(XMMRegister dst, XMMRegister src)
void GetCode(CodeDesc *desc)
void movdqa(XMMRegister dst, const Operand &src)
static const int kJSReturnSequenceLength
static Operand ForCell(Handle< Cell > cell)
void movdqu(XMMRegister dst, const Operand &src)
static const byte kNopByte
int available_space() const
static IntelDoubleRegister FromAllocationIndex(int index)
static const byte kJzShortOpcode
void movmskpd(Register dst, XMMRegister src)
void fisttp_s(const Operand &adr)
const int kRegister_edx_Code
enable upcoming ES6 features enable harmony block scoping enable harmony enable harmony proxies enable harmony generators enable harmony numeric enable harmony string enable harmony math functions harmony_scoping harmony_symbols harmony_collections harmony_iteration harmony_strings harmony_scoping harmony_maths tracks arrays with only smi values Optimize object Array DOM strings and string pretenure call new trace pretenuring decisions of HAllocate instructions track fields with only smi values track fields with heap values track_fields track_fields Enables optimizations which favor memory size over execution speed use string slices optimization filter maximum number of GVN fix point iterations use function inlining use allocation folding eliminate write barriers targeting allocations in optimized code maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining crankshaft harvests type feedback from stub cache trace check elimination phase hydrogen tracing filter trace hydrogen to given file name trace inlining decisions trace store elimination trace all use positions trace global value numbering trace hydrogen escape analysis trace the tracking of allocation sites trace map generalization environment for every instruction deoptimize every n garbage collections put a break point before deoptimizing deoptimize uncommon cases use on stack replacement trace array bounds check elimination perform array index dehoisting use load elimination use store elimination use constant folding eliminate unreachable code number of stress runs when picking a function to watch for shared function not JSFunction itself flushes the cache of optimized code for closures on every GC functions with arguments object maximum number of escape analysis fix point iterations allow uint32 values on optimize frames if they are used only in safe operations track concurrent recompilation artificial compilation delay in ms concurrent on stack replacement do not emit check maps for constant values that have a leaf deoptimize the optimized code if the layout of the maps changes number of stack frames inspected by the profiler percentage of ICs that must have type info to allow optimization extra verbose compilation tracing generate extra code(assertions) for debugging") DEFINE_bool(code_comments
static IntelDoubleRegister from_code(int code)
static Register FromAllocationIndex(int index)
void xor_(Register dst, const Immediate &imm)
void orps(XMMRegister dst, const Operand &src)
#define DISALLOW_COPY_AND_ASSIGN(TypeName)
int relocation_writer_size()
void shl(Register dst, uint8_t imm8)
void cmpw_ax(const Operand &op)
void ror(const Register &rd, const Register &rs, unsigned shift)
static Register from_code(int code)
static int ToAllocationIndex(Register reg)
MaybeObject * AllocateConstantPool(Heap *heap)
static bool IsFoundByRuntimeProbingOnly(CpuFeature f)
void emit_sse_operand(XMMRegister reg, const Operand &adr)
void rcr(Register dst, uint8_t imm8)
void cvttss2si(Register dst, XMMRegister src)
void xorps(XMMRegister dst, XMMRegister src)
static const int kCallTargetAddressOffset
void mulps(XMMRegister dst, XMMRegister src)
void fmul(const FPRegister &fd, const FPRegister &fn, const FPRegister &fm)
void add(Register dst, Register src1, const Operand &src2, SBit s=LeaveCC, Condition cond=al)
static const int kDebugBreakSlotLength
void setcc(Condition cc, Register reg)
void fld_s(const Operand &adr)
void fadd(const FPRegister &fd, const FPRegister &fn, const FPRegister &fm)
const IntelDoubleRegister double_register_2
const IntelDoubleRegister double_register_3
static bool IsNop(Instr instr, int type=NON_MARKING_NOP)
void RecordDebugBreakSlot()
void pand(XMMRegister dst, XMMRegister src)
void mov_w(Register dst, const Operand &src)
void fstp_d(const Operand &adr)
void orps(XMMRegister dst, XMMRegister src)
const int kRegister_eax_Code
static int NumAllocatableRegisters()
void push_imm32(int32_t imm32)
void fistp_d(const Operand &adr)
bool is(Register reg) const
void pextrd(Register dst, XMMRegister src, int8_t offset)
static const int kCallInstructionLength
static const int kNumRegisters
friend class PlatformFeatureScope
void ror_cl(Register dst)
static const byte kJncShortOpcode
void shrd(Register dst, Register src)
void movaps(XMMRegister dst, XMMRegister src)
void movmskps(Register dst, XMMRegister src)
Operand(Register reg, Shift shift=LSL, unsigned shift_amount=0)
Handle< T > handle(T *t, Isolate *isolate)
void psrlq(XMMRegister reg, int8_t shift)
void RecordComment(const char *msg)
int CallSize(const Operand &adr)
void sub(Register dst, const Immediate &imm)
INLINE(static HeapObject *EnsureDoubleAligned(Heap *heap, HeapObject *object, int size))
void mov_b(Register dst, Register src)
void fstp_s(const Operand &adr)
void divsd(XMMRegister dst, XMMRegister src)
const IntelDoubleRegister double_register_0
void lea(Register dst, const Operand &src)
static Address target_address_from_return_address(Address pc)
void fild_d(const Operand &adr)
void xor_(Register dst, int32_t imm32)
friend class PositionsRecorder
void mov(Register dst, const Operand &src, SBit s=LeaveCC, Condition cond=al)
static bool VerifyCrossCompiling()
void andps(XMMRegister dst, XMMRegister src)
Displacement(Label *L, Type type)
Assembler(Isolate *isolate, void *buffer, int buffer_size)
static int NumAllocatableRegisters()
void cmpltsd(XMMRegister dst, XMMRegister src)
Condition NegateCondition(Condition cond)
void test(Register reg, const Immediate &imm)
void shr(Register dst, uint8_t imm8)
const int kRegister_ecx_Code
static XMMRegister from_code(int code)
void divps(XMMRegister dst, const Operand &src)
void add(Register dst, Register src)
const IntelDoubleRegister double_register_7
void sar_cl(Register dst)
void movd(XMMRegister dst, Register src)
void xorps(XMMRegister dst, const Operand &src)
void cmov(Condition cc, Register dst, Register src)
static int ToAllocationIndex(IntelDoubleRegister reg)
PositionsRecorder * positions_recorder()
void movss(XMMRegister dst, XMMRegister src)
void movsx_w(Register dst, Register src)
void subps(XMMRegister dst, const Operand &src)
static const char * AllocationIndexToString(int index)
void cmp(Register reg, const Immediate &imm)
void fisub_s(const Operand &adr)
void pshufd(XMMRegister dst, XMMRegister src, uint8_t shuffle)
void cmp(Register reg0, Register reg1)
static void set_target_address_at(Address pc, ConstantPoolArray *constant_pool, Address target)
void extractps(Register dst, XMMRegister src, byte imm8)
void shufps(XMMRegister dst, XMMRegister src, byte imm8)
static const byte kJnzShortOpcode
void divps(XMMRegister dst, XMMRegister src)
void and_(Register dst, Register src1, const Operand &src2, SBit s=LeaveCC, Condition cond=al)
void fist_s(const Operand &adr)
bool is(XMMRegister reg) const
const int kRegister_esi_Code
const IntelDoubleRegister double_register_6
void adr(const Register &rd, Label *label)
void bts(Register dst, Register src)
const int kRegister_edi_Code
static const int kMaxNumRegisters
void prefetch(const Operand &src, int level)
static bool VerifyCrossCompiling(CpuFeature f)
static const int kPatchDebugBreakSlotAddressOffset
void movzx_w(Register dst, Register src)
void sub(Register dst, Register src1, const Operand &src2, SBit s=LeaveCC, Condition cond=al)
static const char * AllocationIndexToString(int index)
void subsd(XMMRegister dst, XMMRegister src)
void addps(XMMRegister dst, XMMRegister src)
void cmpw(const Operand &op, Immediate imm16)
RelocInfo::Mode rmode() const
const int kRegister_no_reg_Code
void xor_(Register dst, Register src)
void next(Label *L) const
const IntelDoubleRegister double_register_4
void test_b(Register reg, const Operand &op)
void mul(Register dst, Register src1, Register src2, SBit s=LeaveCC, Condition cond=al)
void cvttsd2si(Register dst, const Operand &src)
void and_(Register dst, Register src)
static void deserialization_set_special_target_at(Address instruction_payload, Code *code, Address target)
void shl_cl(Register dst)
void adc(Register dst, Register src1, const Operand &src2, SBit s=LeaveCC, Condition cond=al)