Perf tweaks to compiling and oat writing.
Make hot quick compiler routines inlinable.
Remove computation/use of SSA strings.
Use vector insert when writing to the end of a vector in the output stream, to
avoid a memset followed by a memcpy.
Generating boot.oat/art these changes improve performance by around 2.5%.
Change-Id: I3d0bdb01333efe8f0eda4bdf97225e0b307f934d
diff --git a/src/vector_output_stream.h b/src/vector_output_stream.h
index a99128e..3546c8d 100644
--- a/src/vector_output_stream.h
+++ b/src/vector_output_stream.h
@@ -20,6 +20,7 @@
#include "output_stream.h"
#include <string>
+#include <string.h>
#include <vector>
namespace art {
@@ -30,12 +31,28 @@
virtual ~VectorOutputStream() {}
- virtual bool WriteFully(const void* buffer, int64_t byte_count);
+ bool WriteFully(const void* buffer, int64_t byte_count) {
+ if (static_cast<size_t>(offset_) == vector_.size()) {
+ const uint8_t* start = reinterpret_cast<const uint8_t*>(buffer);
+ vector_.insert(vector_.end(), &start[0], &start[byte_count]);
+ offset_ += byte_count;
+ } else {
+ off_t new_offset = offset_ + byte_count;
+ EnsureCapacity(new_offset);
+ memcpy(&vector_[offset_], buffer, byte_count);
+ offset_ = new_offset;
+ }
+ return true;
+ }
- virtual off_t Seek(off_t offset, Whence whence);
+ off_t Seek(off_t offset, Whence whence);
private:
- void EnsureCapacity(off_t new_offset);
+ void EnsureCapacity(off_t new_offset) {
+ if (new_offset > static_cast<off_t>(vector_.size())) {
+ vector_.resize(new_offset);
+ }
+ }
off_t offset_;
std::vector<uint8_t>& vector_;