diff options
author | Mark Mendell <mark.p.mendell@intel.com> | 2015-04-09 20:42:42 -0400 |
---|---|---|
committer | Mark Mendell <mark.p.mendell@intel.com> | 2015-04-10 08:50:40 -0400 |
commit | 39dcf55a56da746e04f477f89e7b00ba1de03880 (patch) | |
tree | 97bbd68fa538cf76ac26cfeb7a101b5ceb330028 /compiler/utils | |
parent | fcfea6324b2913621d5cb642d4315f22c4901368 (diff) | |
download | art-39dcf55a56da746e04f477f89e7b00ba1de03880.zip art-39dcf55a56da746e04f477f89e7b00ba1de03880.tar.gz art-39dcf55a56da746e04f477f89e7b00ba1de03880.tar.bz2 |
[optimizing] Address x86_64 RIP patch comments
Nicolas had some comments after the patch
https://android-review.googlesource.com/#/c/144100 had merged. Fix the
problems that he found.
Change-Id: I40e8a4273997860db7511dc8f1986281b72bead2
Signed-off-by: Mark Mendell <mark.p.mendell@intel.com>
Diffstat (limited to 'compiler/utils')
-rw-r--r-- | compiler/utils/x86_64/assembler_x86_64.cc | 8 | ||||
-rw-r--r-- | compiler/utils/x86_64/assembler_x86_64.h | 69 |
2 files changed, 26 insertions, 51 deletions
diff --git a/compiler/utils/x86_64/assembler_x86_64.cc b/compiler/utils/x86_64/assembler_x86_64.cc index cb6d400..638659d 100644 --- a/compiler/utils/x86_64/assembler_x86_64.cc +++ b/compiler/utils/x86_64/assembler_x86_64.cc @@ -2742,14 +2742,14 @@ void X86_64ExceptionSlowPath::Emit(Assembler *sasm) { void X86_64Assembler::AddConstantArea() { const std::vector<int32_t>& area = constant_area_.GetBuffer(); - for (size_t i = 0, u = area.size(); i < u; i++) { + for (size_t i = 0, e = area.size(); i < e; i++) { AssemblerBuffer::EnsureCapacity ensured(&buffer_); EmitInt32(area[i]); } } int ConstantArea::AddInt32(int32_t v) { - for (size_t i = 0, u = buffer_.size(); i < u; i++) { + for (size_t i = 0, e = buffer_.size(); i < e; i++) { if (v == buffer_[i]) { return i * elem_size_; } @@ -2766,8 +2766,8 @@ int ConstantArea::AddInt64(int64_t v) { int32_t v_high = v >> 32; if (buffer_.size() > 1) { // Ensure we don't pass the end of the buffer. - for (size_t i = 0, u = buffer_.size() - 1; i < u; i++) { - if (v_low == buffer_[i] && v_high == buffer_[i+1]) { + for (size_t i = 0, e = buffer_.size() - 1; i < e; i++) { + if (v_low == buffer_[i] && v_high == buffer_[i + 1]) { return i * elem_size_; } } diff --git a/compiler/utils/x86_64/assembler_x86_64.h b/compiler/utils/x86_64/assembler_x86_64.h index ef6205c..15b8b15 100644 --- a/compiler/utils/x86_64/assembler_x86_64.h +++ b/compiler/utils/x86_64/assembler_x86_64.h @@ -235,6 +235,8 @@ class Address : public Operand { result.SetSIB(TIMES_1, CpuRegister(RSP), CpuRegister(RBP)); result.SetDisp32(addr); } else { + // RIP addressing is done using RBP as the base register. + // The value in RBP isn't used. Instead the offset is added to RIP. result.SetModRM(0, CpuRegister(RBP)); result.SetDisp32(addr); } @@ -244,6 +246,8 @@ class Address : public Operand { // An RIP relative address that will be fixed up later. static Address RIP(AssemblerFixup* fixup) { Address result; + // RIP addressing is done using RBP as the base register. + // The value in RBP isn't used. Instead the offset is added to RIP. result.SetModRM(0, CpuRegister(RBP)); result.SetDisp32(0); result.SetFixup(fixup); @@ -267,32 +271,20 @@ class ConstantArea { public: ConstantArea() {} - /** - * Add a double to the constant area. - * @param v literal to be added to the constant area. - * @returns the offset in the constant area where the literal resides. - */ + // Add a double to the constant area, returning the offset into + // the constant area where the literal resides. int AddDouble(double v); - /** - * Add a float to the constant area. - * @param v literal to be added to the constant area. - * @returns the offset in the constant area where the literal resides. - */ + // Add a float to the constant area, returning the offset into + // the constant area where the literal resides. int AddFloat(float v); - /** - * Add an int32_t to the constant area. - * @param v literal to be added to the constant area. - * @returns the offset in the constant area where the literal resides. - */ + // Add an int32_t to the constant area, returning the offset into + // the constant area where the literal resides. int AddInt32(int32_t v); - /** - * Add an int64_t to the constant area. - * @param v literal to be added to the constant area. - * @returns the offset in the constant area where the literal resides. - */ + // Add an int64_t to the constant area, returning the offset into + // the constant area where the literal resides. int AddInt64(int64_t v); int GetSize() const { @@ -736,43 +728,26 @@ class X86_64Assembler FINAL : public Assembler { // and branch to a ExceptionSlowPath if it is. void ExceptionPoll(ManagedRegister scratch, size_t stack_adjust) OVERRIDE; - /** - * Add a double to the constant area. - * @param v literal to be added to the constant area. - * @returns the offset in the constant area where the literal resides. - */ + // Add a double to the constant area, returning the offset into + // the constant area where the literal resides. int AddDouble(double v) { return constant_area_.AddDouble(v); } - /** - * Add a float to the constant area. - * @param v literal to be added to the constant area. - * @returns the offset in the constant area where the literal resides. - */ + // Add a float to the constant area, returning the offset into + // the constant area where the literal resides. int AddFloat(float v) { return constant_area_.AddFloat(v); } - /** - * Add an int32_t to the constant area. - * @param v literal to be added to the constant area. - * @returns the offset in the constant area where the literal resides. - */ + // Add an int32_t to the constant area, returning the offset into + // the constant area where the literal resides. int AddInt32(int32_t v) { return constant_area_.AddInt32(v); } - /** - * Add an int64_t to the constant area. - * @param v literal to be added to the constant area. - * @returns the offset in the constant area where the literal resides. - */ + // Add an int64_t to the constant area, returning the offset into + // the constant area where the literal resides. int AddInt64(int64_t v) { return constant_area_.AddInt64(v); } - /** - * Add the contents of the constant area to the assembler buffer. - */ + // Add the contents of the constant area to the assembler buffer. void AddConstantArea(); - /** - * Is the constant area empty? - * @returns 'true' if there are no literals in the constant area. - */ + // Is the constant area empty? Return true if there are no literals in the constant area. bool IsConstantAreaEmpty() const { return constant_area_.GetSize() == 0; } private: |