nterp: Address old x86-64 comments.
Follow-up to
https://android-review.googlesource.com/1185416 ,
https://android-review.googlesource.com/1180627 .
Test: testrunner.py --host --interpreter
Change-Id: I4ee8825593cf11d673fcaf8e1172d00405cc7abc
diff --git a/runtime/interpreter/mterp/x86_64ng/main.S b/runtime/interpreter/mterp/x86_64ng/main.S
index 4eaf95e..aeacec4 100644
--- a/runtime/interpreter/mterp/x86_64ng/main.S
+++ b/runtime/interpreter/mterp/x86_64ng/main.S
@@ -606,19 +606,19 @@
je 2f
cmpb MACRO_LITERAL(70), %al // if (al == 'F') goto FOUND_FLOAT
je 3f
- addq MACRO_LITERAL(4), REG_VAR(arg_index)
+ addq MACRO_LITERAL(1), REG_VAR(arg_index)
// Handle extra argument in arg array taken by a long.
cmpb MACRO_LITERAL(74), %al // if (al != 'J') goto LOOP
jne 1b
- addq MACRO_LITERAL(4), REG_VAR(arg_index)
+ addq MACRO_LITERAL(1), REG_VAR(arg_index)
jmp 1b // goto LOOP
2: // FOUND_DOUBLE
- movsd REG_VAR(xmm_reg),(REG_VAR(fp), REG_VAR(arg_index), 1)
- addq MACRO_LITERAL(8), REG_VAR(arg_index)
+ movsd REG_VAR(xmm_reg),(REG_VAR(fp), REG_VAR(arg_index), 4)
+ addq MACRO_LITERAL(2), REG_VAR(arg_index)
jmp 4f
3: // FOUND_FLOAT
- movss REG_VAR(xmm_reg), (REG_VAR(fp), REG_VAR(arg_index), 1)
- addq MACRO_LITERAL(4), REG_VAR(arg_index)
+ movss REG_VAR(xmm_reg), (REG_VAR(fp), REG_VAR(arg_index), 4)
+ addq MACRO_LITERAL(1), REG_VAR(arg_index)
4:
.endm
@@ -638,22 +638,22 @@
je 3f
cmpb MACRO_LITERAL(68), %al // if (al == 'D') goto SKIP_DOUBLE
je 4f
- movl REG_VAR(gpr_reg32), (REG_VAR(regs), REG_VAR(arg_index), 1)
+ movl REG_VAR(gpr_reg32), (REG_VAR(regs), REG_VAR(arg_index), 4)
cmpb MACRO_LITERAL(76), %al // if (al != 'L') goto NOT_REFERENCE
jne 6f
- movl REG_VAR(gpr_reg32), (REG_VAR(refs), REG_VAR(arg_index), 1)
+ movl REG_VAR(gpr_reg32), (REG_VAR(refs), REG_VAR(arg_index), 4)
6: // NOT_REFERENCE
- addq MACRO_LITERAL(4), REG_VAR(arg_index)
+ addq MACRO_LITERAL(1), REG_VAR(arg_index)
jmp 5f
2: // FOUND_LONG
- movq REG_VAR(gpr_reg64), (REG_VAR(regs), REG_VAR(arg_index), 1)
- addq MACRO_LITERAL(8), REG_VAR(arg_index)
+ movq REG_VAR(gpr_reg64), (REG_VAR(regs), REG_VAR(arg_index), 4)
+ addq MACRO_LITERAL(2), REG_VAR(arg_index)
jmp 5f
3: // SKIP_FLOAT
- addq MACRO_LITERAL(4), REG_VAR(arg_index)
+ addq MACRO_LITERAL(1), REG_VAR(arg_index)
jmp 1b
4: // SKIP_DOUBLE
- addq MACRO_LITERAL(8), REG_VAR(arg_index)
+ addq MACRO_LITERAL(2), REG_VAR(arg_index)
jmp 1b
5:
.endm
@@ -676,21 +676,21 @@
je 2f
cmpb MACRO_LITERAL(70), %al // if (al == 'F') goto FOUND_FLOAT
je 3f
- addq MACRO_LITERAL(4), REG_VAR(arg_index)
+ addq MACRO_LITERAL(1), REG_VAR(arg_index)
// Handle extra argument in arg array taken by a long.
cmpb MACRO_LITERAL(74), %al // if (al != 'J') goto LOOP
jne 1b
- addq MACRO_LITERAL(4), REG_VAR(arg_index)
+ addq MACRO_LITERAL(1), REG_VAR(arg_index)
jmp 1b // goto LOOP
2: // FOUND_DOUBLE
- movq OFFSET_TO_FIRST_ARGUMENT_IN_STACK(REG_VAR(stack_ptr), REG_VAR(arg_index), 1), %rax
- movq %rax, (REG_VAR(regs), REG_VAR(arg_index), 1)
- addq MACRO_LITERAL(8), REG_VAR(arg_index)
+ movq OFFSET_TO_FIRST_ARGUMENT_IN_STACK(REG_VAR(stack_ptr), REG_VAR(arg_index), 4), %rax
+ movq %rax, (REG_VAR(regs), REG_VAR(arg_index), 4)
+ addq MACRO_LITERAL(2), REG_VAR(arg_index)
jmp 1b
3: // FOUND_FLOAT
- movl OFFSET_TO_FIRST_ARGUMENT_IN_STACK(REG_VAR(stack_ptr), REG_VAR(arg_index), 1), %eax
- movl %eax, (REG_VAR(regs), REG_VAR(arg_index), 1)
- addq MACRO_LITERAL(4), REG_VAR(arg_index)
+ movl OFFSET_TO_FIRST_ARGUMENT_IN_STACK(REG_VAR(stack_ptr), REG_VAR(arg_index), 4), %eax
+ movl %eax, (REG_VAR(regs), REG_VAR(arg_index), 4)
+ addq MACRO_LITERAL(1), REG_VAR(arg_index)
jmp 1b
.endm
@@ -712,26 +712,26 @@
je 3f
cmpb MACRO_LITERAL(68), %al // if (al == 'D') goto SKIP_DOUBLE
je 4f
- movl OFFSET_TO_FIRST_ARGUMENT_IN_STACK(REG_VAR(stack_ptr), REG_VAR(arg_index), 1), %eax
- movl %eax, (REG_VAR(regs), REG_VAR(arg_index), 1)
- addq MACRO_LITERAL(4), REG_VAR(arg_index)
+ movl OFFSET_TO_FIRST_ARGUMENT_IN_STACK(REG_VAR(stack_ptr), REG_VAR(arg_index), 4), %eax
+ movl %eax, (REG_VAR(regs), REG_VAR(arg_index), 4)
+ addq MACRO_LITERAL(1), REG_VAR(arg_index)
jmp 1b
6: // FOUND_REFERENCE
- movl OFFSET_TO_FIRST_ARGUMENT_IN_STACK(REG_VAR(stack_ptr), REG_VAR(arg_index), 1), %eax
- movl %eax, (REG_VAR(regs), REG_VAR(arg_index), 1)
- movl %eax, (REG_VAR(refs), REG_VAR(arg_index), 1)
- addq MACRO_LITERAL(4), REG_VAR(arg_index)
+ movl OFFSET_TO_FIRST_ARGUMENT_IN_STACK(REG_VAR(stack_ptr), REG_VAR(arg_index), 4), %eax
+ movl %eax, (REG_VAR(regs), REG_VAR(arg_index), 4)
+ movl %eax, (REG_VAR(refs), REG_VAR(arg_index), 4)
+ addq MACRO_LITERAL(1), REG_VAR(arg_index)
jmp 1b
2: // FOUND_LONG
- movq OFFSET_TO_FIRST_ARGUMENT_IN_STACK(REG_VAR(stack_ptr), REG_VAR(arg_index), 1), %rax
- movq %rax, (REG_VAR(regs), REG_VAR(arg_index), 1)
- addq MACRO_LITERAL(8), REG_VAR(arg_index)
+ movq OFFSET_TO_FIRST_ARGUMENT_IN_STACK(REG_VAR(stack_ptr), REG_VAR(arg_index), 4), %rax
+ movq %rax, (REG_VAR(regs), REG_VAR(arg_index), 4)
+ addq MACRO_LITERAL(2), REG_VAR(arg_index)
jmp 1b
3: // SKIP_FLOAT
- addq MACRO_LITERAL(4), REG_VAR(arg_index)
+ addq MACRO_LITERAL(1), REG_VAR(arg_index)
jmp 1b
4: // SKIP_DOUBLE
- addq MACRO_LITERAL(8), REG_VAR(arg_index)
+ addq MACRO_LITERAL(2), REG_VAR(arg_index)
jmp 1b
.endm
diff --git a/runtime/oat_quick_method_header.cc b/runtime/oat_quick_method_header.cc
index ebb868b..bbc3bfa 100644
--- a/runtime/oat_quick_method_header.cc
+++ b/runtime/oat_quick_method_header.cc
@@ -16,6 +16,7 @@
#include "oat_quick_method_header.h"
+#include "arch/instruction_set.h"
#include "art_method.h"
#include "dex/dex_file_types.h"
#include "interpreter/interpreter_mterp_impl.h"
@@ -88,12 +89,19 @@
return UINTPTR_MAX;
}
-OatQuickMethodHeader* OatQuickMethodHeader::NterpMethodHeader =
- (interpreter::IsNterpSupported()
- ? reinterpret_cast<OatQuickMethodHeader*>(
- reinterpret_cast<uintptr_t>(interpreter::GetNterpEntryPoint()) -
- sizeof(OatQuickMethodHeader))
- : nullptr);
+static inline OatQuickMethodHeader* GetNterpMethodHeader() {
+ if (!interpreter::IsNterpSupported()) {
+ return nullptr;
+ }
+ uintptr_t nterp_entrypoint = reinterpret_cast<uintptr_t>(interpreter::GetNterpEntryPoint());
+ uintptr_t nterp_code_pointer = (kRuntimeISA == InstructionSet::kArm)
+ // Remove the Thumb mode bit if present on ARM.
+ ? nterp_entrypoint & ~static_cast<uintptr_t>(1)
+ : nterp_entrypoint;
+ return reinterpret_cast<OatQuickMethodHeader*>(nterp_code_pointer - sizeof(OatQuickMethodHeader));
+}
+
+OatQuickMethodHeader* OatQuickMethodHeader::NterpMethodHeader = GetNterpMethodHeader();
bool OatQuickMethodHeader::IsNterpMethodHeader() const {
return interpreter::IsNterpSupported() ? (this == NterpMethodHeader) : false;