📄 assembler-ia32.cc.svn-base
字号:
EMIT(0xDF); emit_operand(edi, adr);}void Assembler::fabs() { EnsureSpace ensure_space(this); last_pc_ = pc_; EMIT(0xD9); EMIT(0xE1);}void Assembler::fchs() { EnsureSpace ensure_space(this); last_pc_ = pc_; EMIT(0xD9); EMIT(0xE0);}void Assembler::fadd(int i) { EnsureSpace ensure_space(this); last_pc_ = pc_; emit_farith(0xDC, 0xC0, i);}void Assembler::fsub(int i) { EnsureSpace ensure_space(this); last_pc_ = pc_; emit_farith(0xDC, 0xE8, i);}void Assembler::fisub_s(const Operand& adr) { EnsureSpace ensure_space(this); last_pc_ = pc_; EMIT(0xDA); emit_operand(esp, adr);}void Assembler::fmul(int i) { EnsureSpace ensure_space(this); last_pc_ = pc_; emit_farith(0xDC, 0xC8, i);}void Assembler::fdiv(int i) { EnsureSpace ensure_space(this); last_pc_ = pc_; emit_farith(0xDC, 0xF8, i);}void Assembler::faddp(int i) { EnsureSpace ensure_space(this); last_pc_ = pc_; emit_farith(0xDE, 0xC0, i);}void Assembler::fsubp(int i) { EnsureSpace ensure_space(this); last_pc_ = pc_; emit_farith(0xDE, 0xE8, i);}void Assembler::fsubrp(int i) { EnsureSpace ensure_space(this); last_pc_ = pc_; emit_farith(0xDE, 0xE0, i);}void Assembler::fmulp(int i) { EnsureSpace ensure_space(this); last_pc_ = pc_; emit_farith(0xDE, 0xC8, i);}void Assembler::fdivp(int i) { EnsureSpace ensure_space(this); last_pc_ = pc_; emit_farith(0xDE, 0xF8, i);}void Assembler::fprem() { EnsureSpace ensure_space(this); last_pc_ = pc_; EMIT(0xD9); EMIT(0xF8);}void Assembler::fprem1() { EnsureSpace ensure_space(this); last_pc_ = pc_; EMIT(0xD9); EMIT(0xF5);}void Assembler::fxch(int i) { EnsureSpace ensure_space(this); last_pc_ = pc_; emit_farith(0xD9, 0xC8, i);}void Assembler::fincstp() { EnsureSpace ensure_space(this); last_pc_ = pc_; EMIT(0xD9); EMIT(0xF7);}void Assembler::ffree(int i) { EnsureSpace ensure_space(this); last_pc_ = pc_; emit_farith(0xDD, 0xC0, i);}void Assembler::ftst() { EnsureSpace ensure_space(this); last_pc_ = pc_; EMIT(0xD9); EMIT(0xE4);}void Assembler::fucomp(int i) { EnsureSpace ensure_space(this); last_pc_ = pc_; emit_farith(0xDD, 0xE8, i);}void Assembler::fucompp() { EnsureSpace ensure_space(this); last_pc_ = pc_; EMIT(0xDA); EMIT(0xE9);}void Assembler::fcompp() { EnsureSpace ensure_space(this); last_pc_ = pc_; EMIT(0xDE); EMIT(0xD9);}void Assembler::fnstsw_ax() { EnsureSpace ensure_space(this); last_pc_ = pc_; EMIT(0xdF); EMIT(0xE0);}void Assembler::fwait() { EnsureSpace ensure_space(this); last_pc_ = pc_; EMIT(0x9B);}void Assembler::frndint() { EnsureSpace ensure_space(this); last_pc_ = pc_; EMIT(0xD9); EMIT(0xFC);}void Assembler::sahf() { EnsureSpace ensure_space(this); last_pc_ = pc_; EMIT(0x9E);}void Assembler::cvttss2si(Register dst, const Operand& src) { ASSERT(CpuFeatures::IsEnabled(CpuFeatures::SSE2)); EnsureSpace ensure_space(this); last_pc_ = pc_; EMIT(0xF3); EMIT(0x0F); EMIT(0x2C); emit_operand(dst, src);}void Assembler::cvttsd2si(Register dst, const Operand& src) { ASSERT(CpuFeatures::IsEnabled(CpuFeatures::SSE2)); EnsureSpace ensure_space(this); last_pc_ = pc_; EMIT(0xF2); EMIT(0x0F); EMIT(0x2C); emit_operand(dst, src);}void Assembler::cvtsi2sd(XMMRegister dst, const Operand& src) { ASSERT(CpuFeatures::IsEnabled(CpuFeatures::SSE2)); EnsureSpace ensure_space(this); last_pc_ = pc_; EMIT(0xF2); EMIT(0x0F); EMIT(0x2A); emit_sse_operand(dst, src);}void Assembler::addsd(XMMRegister dst, XMMRegister src) { ASSERT(CpuFeatures::IsEnabled(CpuFeatures::SSE2)); EnsureSpace ensure_space(this); last_pc_ = pc_; EMIT(0xF2); EMIT(0x0F); EMIT(0x58); emit_sse_operand(dst, src);}void Assembler::mulsd(XMMRegister dst, XMMRegister src) { ASSERT(CpuFeatures::IsEnabled(CpuFeatures::SSE2)); EnsureSpace ensure_space(this); last_pc_ = pc_; EMIT(0xF2); EMIT(0x0F); EMIT(0x59); emit_sse_operand(dst, src);}void Assembler::subsd(XMMRegister dst, XMMRegister src) { ASSERT(CpuFeatures::IsEnabled(CpuFeatures::SSE2)); EnsureSpace ensure_space(this); last_pc_ = pc_; EMIT(0xF2); EMIT(0x0F); EMIT(0x5C); emit_sse_operand(dst, src);}void Assembler::divsd(XMMRegister dst, XMMRegister src) { ASSERT(CpuFeatures::IsEnabled(CpuFeatures::SSE2)); EnsureSpace ensure_space(this); last_pc_ = pc_; EMIT(0xF2); EMIT(0x0F); EMIT(0x5E); emit_sse_operand(dst, src);}void Assembler::movdbl(XMMRegister dst, const Operand& src) { EnsureSpace ensure_space(this); last_pc_ = pc_; movsd(dst, src);}void Assembler::movdbl(const Operand& dst, XMMRegister src) { EnsureSpace ensure_space(this); last_pc_ = pc_; movsd(dst, src);}void Assembler::movsd(const Operand& dst, XMMRegister src ) { ASSERT(CpuFeatures::IsEnabled(CpuFeatures::SSE2)); EnsureSpace ensure_space(this); last_pc_ = pc_; EMIT(0xF2); // double EMIT(0x0F); EMIT(0x11); // store emit_sse_operand(src, dst);}void Assembler::movsd(XMMRegister dst, const Operand& src) { ASSERT(CpuFeatures::IsEnabled(CpuFeatures::SSE2)); EnsureSpace ensure_space(this); last_pc_ = pc_; EMIT(0xF2); // double EMIT(0x0F); EMIT(0x10); // load emit_sse_operand(dst, src);}void Assembler::emit_sse_operand(XMMRegister reg, const Operand& adr) { Register ireg = { reg.code() }; emit_operand(ireg, adr);}void Assembler::emit_sse_operand(XMMRegister dst, XMMRegister src) { EMIT(0xC0 | dst.code() << 3 | src.code());}void Assembler::Print() { Disassembler::Decode(stdout, buffer_, pc_);}void Assembler::RecordJSReturn() { WriteRecordedPositions(); EnsureSpace ensure_space(this); RecordRelocInfo(RelocInfo::JS_RETURN);}void Assembler::RecordComment(const char* msg) { if (FLAG_debug_code) { EnsureSpace ensure_space(this); RecordRelocInfo(RelocInfo::COMMENT, reinterpret_cast<intptr_t>(msg)); }}void Assembler::RecordPosition(int pos) { if (pos == RelocInfo::kNoPosition) return; ASSERT(pos >= 0); last_position_ = pos;}void Assembler::RecordStatementPosition(int pos) { if (pos == RelocInfo::kNoPosition) return; ASSERT(pos >= 0); last_statement_position_ = pos;}void Assembler::WriteRecordedPositions() { if (last_statement_position_ != RelocInfo::kNoPosition) { EnsureSpace ensure_space(this); RecordRelocInfo(RelocInfo::STATEMENT_POSITION, last_statement_position_); } if ((last_position_ != RelocInfo::kNoPosition) && (last_position_ != last_statement_position_)) { EnsureSpace ensure_space(this); RecordRelocInfo(RelocInfo::POSITION, last_position_); } last_statement_position_ = RelocInfo::kNoPosition; last_position_ = RelocInfo::kNoPosition;}void Assembler::GrowBuffer() { ASSERT(overflow()); // should not call this otherwise if (!own_buffer_) FATAL("external code buffer is too small"); // compute new buffer size CodeDesc desc; // the new buffer if (buffer_size_ < 4*KB) { desc.buffer_size = 4*KB; } else { desc.buffer_size = 2*buffer_size_; } // Some internal data structures overflow for very large buffers, // they must ensure that kMaximalBufferSize is not too large. if ((desc.buffer_size > kMaximalBufferSize) || (desc.buffer_size > Heap::OldGenerationSize())) { V8::FatalProcessOutOfMemory("Assembler::GrowBuffer"); } // setup new buffer desc.buffer = NewArray<byte>(desc.buffer_size); desc.instr_size = pc_offset(); desc.reloc_size = (buffer_ + buffer_size_) - (reloc_info_writer.pos()); // Clear the buffer in debug mode. Use 'int3' instructions to make // sure to get into problems if we ever run uninitialized code. if (kDebug) { memset(desc.buffer, 0xCC, desc.buffer_size); } // copy the data int pc_delta = desc.buffer - buffer_; int rc_delta = (desc.buffer + desc.buffer_size) - (buffer_ + buffer_size_); memmove(desc.buffer, buffer_, desc.instr_size); memmove(rc_delta + reloc_info_writer.pos(), reloc_info_writer.pos(), desc.reloc_size); // switch buffers if (spare_buffer_ == NULL && buffer_size_ == kMinimalBufferSize) { spare_buffer_ = buffer_; } else { DeleteArray(buffer_); } buffer_ = desc.buffer; buffer_size_ = desc.buffer_size; pc_ += pc_delta; if (last_pc_ != NULL) { last_pc_ += pc_delta; } reloc_info_writer.Reposition(reloc_info_writer.pos() + rc_delta, reloc_info_writer.last_pc() + pc_delta); // relocate runtime entries for (RelocIterator it(desc); !it.done(); it.next()) { 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 == RelocInfo::INTERNAL_REFERENCE) { int32_t* p = reinterpret_cast<int32_t*>(it.rinfo()->pc()); if (*p != 0) { // 0 means uninitialized. *p += pc_delta; } } } ASSERT(!overflow());}void Assembler::emit_arith_b(int op1, int op2, Register dst, int imm8) { ASSERT(is_uint8(op1) && is_uint8(op2)); // wrong opcode ASSERT(is_uint8(imm8)); ASSERT((op1 & 0x01) == 0); // should be 8bit operation EMIT(op1); EMIT(op2 | dst.code()); EMIT(imm8);}void Assembler::emit_arith(int sel, Operand dst, const Immediate& x) { ASSERT((0 <= sel) && (sel <= 7)); Register ireg = { sel }; if (x.is_int8()) { EMIT(0x83); // using a sign-extended 8-bit immediate. emit_operand(ireg, dst); EMIT(x.x_ & 0xFF); } else if (dst.is_reg(eax)) { EMIT((sel << 3) | 0x05); // short form if the destination is eax. emit(x); } else { EMIT(0x81); // using a literal 32-bit immediate. emit_operand(ireg, dst); emit(x); }}void Assembler::emit_operand(Register reg, const Operand& adr) { adr.set_reg(reg); memmove(pc_, adr.buf_, adr.len_); pc_ += adr.len_; 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::emit_operand(const Operand& adr, Register reg) { adr.set_reg(reg); memmove(pc_, adr.buf_, adr.len_); pc_ += adr.len_; 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::emit_farith(int b1, int b2, int i) { ASSERT(is_uint8(b1) && is_uint8(b2)); // wrong opcode ASSERT(0 <= i && i < 8); // illegal stack offset EMIT(b1); EMIT(b2 + i);}void Assembler::dd(uint32_t data, RelocInfo::Mode reloc_info) { EnsureSpace ensure_space(this); emit(data, reloc_info);}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 == RelocInfo::EXTERNAL_REFERENCE && !Serializer::enabled() && !FLAG_debug_code) { return; } RelocInfo rinfo(pc_, rmode, data); reloc_info_writer.Write(&rinfo);}void Assembler::WriteInternalReference(int position, const Label& bound_label) { ASSERT(bound_label.is_bound()); ASSERT(0 <= position); ASSERT(position + static_cast<int>(sizeof(uint32_t)) <= pc_offset()); ASSERT(long_at(position) == 0); // only initialize once! uint32_t label_loc = reinterpret_cast<uint32_t>(addr_at(bound_label.pos())); long_at_put(position, label_loc);}} } // namespace v8::internal
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -