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

Unified Diff: src/assembler-ia32.cc

Issue 18656: Avoid memmove when emitting operands in the assembler ... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 11 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/assembler-ia32.h ('k') | src/assembler-ia32-inl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/assembler-ia32.cc
===================================================================
--- src/assembler-ia32.cc (revision 1122)
+++ src/assembler-ia32.cc (working copy)
@@ -255,12 +255,6 @@
}
-void Operand::set_reg(Register reg) const {
- ASSERT(len_ > 0);
- buf_[0] = (buf_[0] & ~0x38) | static_cast<byte>(reg.code() << 3);
-}
-
-
bool Operand::is_reg(Register reg) const {
return ((buf_[0] & 0xF8) == 0xC0) // addressing mode is register only.
&& ((buf_[0] & 0x07) == reg.code()); // register codes match.
@@ -2098,10 +2092,18 @@
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) {
+ const unsigned length = adr.len_;
+ ASSERT(length > 0);
+
+ // Emit updated ModRM byte containing the given register.
+ pc_[0] = (adr.buf_[0] & ~0x38) | (reg.code() << 3);
+
+ // Emit the rest of the encoded operand.
+ for (unsigned i = 1; i < length; i++) pc_[i] = adr.buf_[i];
+ pc_ += length;
+
+ // Emit relocation information if necessary.
+ if (length >= sizeof(int32_t) && adr.rmode_ != RelocInfo::NONE) {
pc_ -= sizeof(int32_t); // pc_ must be *at* disp32
RecordRelocInfo(adr.rmode_);
pc_ += sizeof(int32_t);
« no previous file with comments | « src/assembler-ia32.h ('k') | src/assembler-ia32-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698