Small optimisation for Assembler::Emit (#71)
Inside Emit(), the compiler can't be sure that the pc_ field of the Assembler
object doesn't point to itself, so it must be reloaded from the object after the
call to memcpy, in order to advance pc_.
Emit() is used by all Assembler methods, so optimise it a little by making a
local copy of the field.
diff --git a/src/code-buffer-vixl.h b/src/code-buffer-vixl.h
index 9a1efd4..cb9031f 100644
--- a/src/code-buffer-vixl.h
+++ b/src/code-buffer-vixl.h
@@ -124,8 +124,9 @@
void Emit(T value) {
VIXL_ASSERT(HasSpaceFor(sizeof(value)));
dirty_ = true;
- memcpy(cursor_, &value, sizeof(value));
- cursor_ += sizeof(value);
+ byte* c = cursor_;
+ memcpy(c, &value, sizeof(value));
+ cursor_ = c + sizeof(value);
}
void UpdateData(size_t offset, const void* data, size_t size);
diff --git a/tools/code_coverage.log b/tools/code_coverage.log
index cf1305c..dec72e8 100644
--- a/tools/code_coverage.log
+++ b/tools/code_coverage.log
@@ -17,3 +17,4 @@
1669202345 82.79% 97.51% 95.51%
1673432155 82.79% 97.51% 95.51%
1677171445 82.78% 97.56% 94.81%
+1681814646 82.90% 97.57% 94.87%