Get PORTABLE + SMALL on x86.
Implemented the portable resolution trampoline and
the portable to interpreter bridge.
Also work on integrating SEA_IR in the PORTABLE+SMALL framework.
Refactor some naming and correct indenting.
Change-Id: Ibd97da5e5b6f5148274c9bff368e3654b661ef51
diff --git a/runtime/arch/arm/portable_entrypoints_arm.S b/runtime/arch/arm/portable_entrypoints_arm.S
index f21ae28..073efdc 100644
--- a/runtime/arch/arm/portable_entrypoints_arm.S
+++ b/runtime/arch/arm/portable_entrypoints_arm.S
@@ -114,7 +114,7 @@
.cfi_rel_offset r10, 28
.cfi_rel_offset r11, 32
.cfi_rel_offset lr, 36
- sub sp, #8 @ 2 words of space, bottom word will hold Method*
+ sub sp, #8 @ 2 words of space, bottom word will hold Method*
.pad #8
.cfi_adjust_cfa_offset 8
mov r2, r9 @ pass Thread::Current
@@ -156,7 +156,7 @@
.cfi_rel_offset r10, 28
.cfi_rel_offset r11, 32
.cfi_rel_offset lr, 36
- sub sp, #8 @ 2 words of space, bottom word will hold Method*
+ sub sp, #8 @ 2 words of space, bottom word will hold Method*
.pad #8
.cfi_adjust_cfa_offset 8
mov r1, r9 @ pass Thread::Current
diff --git a/runtime/arch/x86/portable_entrypoints_x86.S b/runtime/arch/x86/portable_entrypoints_x86.S
index 0313d4b..24fa98b 100644
--- a/runtime/arch/x86/portable_entrypoints_x86.S
+++ b/runtime/arch/x86/portable_entrypoints_x86.S
@@ -68,13 +68,13 @@
DEFINE_FUNCTION art_portable_proxy_invoke_handler
// Fake callee save ref and args frame set up, note portable doesn't use callee save frames.
// TODO: just save the registers that are needed in artPortableProxyInvokeHandler.
- PUSH edi // Save callee saves
+ PUSH edi // Save callee saves
PUSH esi
PUSH ebp
- PUSH ebx // Save args
+ PUSH ebx // Save args
PUSH edx
PUSH ecx
- PUSH eax // Align stack, eax will be clobbered by Method*
+ PUSH eax // Align stack, eax will be clobbered by Method*
// Begin argument set up.
PUSH esp // pass SP
pushl %fs:THREAD_SELF_OFFSET // pass Thread::Current()
@@ -90,5 +90,35 @@
ret
END_FUNCTION art_portable_proxy_invoke_handler
-UNIMPLEMENTED art_portable_resolution_trampoline
-UNIMPLEMENTED art_portable_to_interpreter_bridge
+DEFINE_FUNCTION art_portable_resolution_trampoline
+ pushl %ebp
+ movl %esp, %ebp // save ESP
+ subl LITERAL(8), %esp // Align stack
+ movl 8(%ebp), %eax // Method* called
+ leal 8(%ebp), %edx // Method** called_addr
+ pushl %edx // pass called_addr
+ pushl %fs:THREAD_SELF_OFFSET // pass thread
+ pushl %ecx // pass receiver
+ pushl %eax // pass called
+ call SYMBOL(artPortableResolutionTrampoline)
+ leave
+ cmpl LITERAL(0), %eax
+ je resolve_fail
+ jmp * %eax
+resolve_fail:
+ ret
+END_FUNCTION art_portable_resolution_trampoline
+
+DEFINE_FUNCTION art_portable_to_interpreter_bridge
+ pushl %ebp
+ movl %esp, %ebp // save ESP
+ subl LITERAL(12), %esp // Align stack
+ movl 8(%ebp), %eax // Method* called
+ leal 8(%ebp), %edx // Method** called_addr
+ pushl %edx // pass called_addr
+ pushl %fs:THREAD_SELF_OFFSET // pass thread
+ pushl %eax // pass called
+ call SYMBOL(artPortableToInterpreterBridge)
+ leave
+ ret
+END_FUNCTION art_quick_to_interpreter_bridge
diff --git a/runtime/entrypoints/entrypoint_utils.cc b/runtime/entrypoints/entrypoint_utils.cc
index bf0fffa..52f8c81 100644
--- a/runtime/entrypoints/entrypoint_utils.cc
+++ b/runtime/entrypoints/entrypoint_utils.cc
@@ -23,6 +23,7 @@
#include "mirror/art_method-inl.h"
#include "mirror/class-inl.h"
#include "mirror/object-inl.h"
+#include "object_utils.h"
#include "mirror/object_array-inl.h"
#include "mirror/proxy.h"
#include "reflection.h"
diff --git a/runtime/entrypoints/entrypoint_utils.h b/runtime/entrypoints/entrypoint_utils.h
index 2b73af4..8b58cb3 100644
--- a/runtime/entrypoints/entrypoint_utils.h
+++ b/runtime/entrypoints/entrypoint_utils.h
@@ -16,7 +16,7 @@
#ifndef ART_RUNTIME_ENTRYPOINTS_ENTRYPOINT_UTILS_H_
#define ART_RUNTIME_ENTRYPOINTS_ENTRYPOINT_UTILS_H_
-
+#include "object_utils.h"
#include "class_linker.h"
#include "common_throws.h"
#include "dex_file.h"
@@ -27,7 +27,7 @@
#include "mirror/array.h"
#include "mirror/class-inl.h"
#include "mirror/throwable.h"
-#include "object_utils.h"
+
#include "thread.h"
namespace art {
diff --git a/runtime/entrypoints/portable/portable_trampoline_entrypoints.cc b/runtime/entrypoints/portable/portable_trampoline_entrypoints.cc
index e1ce11a..61f7440 100644
--- a/runtime/entrypoints/portable/portable_trampoline_entrypoints.cc
+++ b/runtime/entrypoints/portable/portable_trampoline_entrypoints.cc
@@ -42,8 +42,10 @@
#define PORTABLE_CALLEE_SAVE_FRAME__REF_AND_ARGS__FRAME_SIZE 64
#define PORTABLE_STACK_ARG_SKIP 16
#elif defined(__i386__)
-#define PORTABLE_CALLEE_SAVE_FRAME__REF_AND_ARGS__R1_OFFSET 4
-#define PORTABLE_CALLEE_SAVE_FRAME__REF_AND_ARGS__FRAME_SIZE 32
+// For x86 there are no register arguments and the stack pointer will point directly to the called
+// method argument passed by the caller.
+#define PORTABLE_CALLEE_SAVE_FRAME__REF_AND_ARGS__R1_OFFSET 0
+#define PORTABLE_CALLEE_SAVE_FRAME__REF_AND_ARGS__FRAME_SIZE 0
#define PORTABLE_STACK_ARG_SKIP 4
#else
#error "Unsupported architecture"
diff --git a/runtime/entrypoints/quick/quick_trampoline_entrypoints.cc b/runtime/entrypoints/quick/quick_trampoline_entrypoints.cc
index 392bcc5..535d540 100644
--- a/runtime/entrypoints/quick/quick_trampoline_entrypoints.cc
+++ b/runtime/entrypoints/quick/quick_trampoline_entrypoints.cc
@@ -15,8 +15,10 @@
*/
#include "callee_save_frame.h"
+#include "common_throws.h"
#include "dex_file-inl.h"
#include "dex_instruction-inl.h"
+#include "entrypoints/entrypoint_utils.h"
#include "interpreter/interpreter.h"
#include "invoke_arg_array_builder.h"
#include "mirror/art_method-inl.h"
@@ -26,6 +28,8 @@
#include "object_utils.h"
#include "runtime.h"
+
+
namespace art {
// Visits the arguments as saved to the stack by a Runtime::kRefAndArgs callee save frame.
@@ -218,10 +222,11 @@
};
// Visits arguments on the stack placing them into the shadow frame.
-class BuildShadowFrameVisitor : public QuickArgumentVisitor {
+class BuildQuickShadowFrameVisitor : public QuickArgumentVisitor {
public:
- BuildShadowFrameVisitor(mirror::ArtMethod** sp, bool is_static, const char* shorty,
- uint32_t shorty_len, ShadowFrame& sf, size_t first_arg_reg) :
+ BuildQuickShadowFrameVisitor(mirror::ArtMethod** sp,
+ bool is_static, const char* shorty,
+ uint32_t shorty_len, ShadowFrame& sf, size_t first_arg_reg) :
QuickArgumentVisitor(sp, is_static, shorty, shorty_len), sf_(sf), cur_reg_(first_arg_reg) {}
virtual void Visit() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
@@ -258,7 +263,7 @@
ShadowFrame& sf_;
size_t cur_reg_;
- DISALLOW_COPY_AND_ASSIGN(BuildShadowFrameVisitor);
+ DISALLOW_COPY_AND_ASSIGN(BuildQuickShadowFrameVisitor);
};
extern "C" uint64_t artQuickToInterpreterBridge(mirror::ArtMethod* method, Thread* self,
@@ -280,7 +285,7 @@
ShadowFrame* shadow_frame(ShadowFrame::Create(num_regs, NULL, // No last shadow coming from quick.
method, 0, memory));
size_t first_arg_reg = code_item->registers_size_ - code_item->ins_size_;
- BuildShadowFrameVisitor shadow_frame_builder(sp, mh.IsStatic(), mh.GetShorty(),
+ BuildQuickShadowFrameVisitor shadow_frame_builder(sp, mh.IsStatic(), mh.GetShorty(),
mh.GetShortyLength(),
*shadow_frame, first_arg_reg);
shadow_frame_builder.VisitArguments();