changeset in /hg/icedtea: 2007-11-20 Gary Benson <gbenson at redh...
Gary Benson
gbenson at redhat.com
Wed Jan 16 07:09:29 PST 2008
changeset f3622a4f4ebc in /hg/icedtea
details: http://icedtea.classpath.org/hg/icedtea?cmd=changeset;node=f3622a4f4ebc
description:
2007-11-20 Gary Benson <gbenson at redhat.com>
* ports/hotspot/src/cpu/ppc/vm/register_ppc.hpp
(noreg): Declare.
* ports/hotspot/src/cpu/ppc/vm/register_definitions_ppc.cpp
(noreg): Define.
* ports/hotspot/src/cpu/ppc/vm/interp_masm_ppc.hpp
* ports/hotspot/src/cpu/ppc/vm/interp_masm_ppc.cpp
(set_last_Java_frame): Optionally preserve the link register.
* ports/hotspot/src/cpu/ppc/vm/assembler_ppc.hpp
* ports/hotspot/src/cpu/ppc/vm/assembler_ppc.cpp
(call_VM, call_VM_leaf, call_VM_base, call_VM_leaf_base,
call_VM_pass_args): New methods.
* ports/hotspot/src/cpu/ppc/vm/interp_masm_ppc.hpp
* ports/hotspot/src/cpu/ppc/vm/interp_masm_ppc.cpp
(call_VM_base, call_VM_leaf_base): Likewise.
* ports/hotspot/src/cpu/ppc/vm/cppInterpreter_ppc.cpp
(generate_native_entry): Use call_VM and call_VM_leaf
when making VM calls.
* ports/hotspot/src/cpu/ppc/vm/interpreter_ppc.cpp
(generate_slow_signature_handler): Likewise.
diffstat:
9 files changed, 257 insertions(+), 21 deletions(-)
ChangeLog | 25 ++
ports/hotspot/src/cpu/ppc/vm/assembler_ppc.cpp | 113 +++++++++++++
ports/hotspot/src/cpu/ppc/vm/assembler_ppc.hpp | 57 ++++++
ports/hotspot/src/cpu/ppc/vm/cppInterpreter_ppc.cpp | 18 +-
ports/hotspot/src/cpu/ppc/vm/interp_masm_ppc.cpp | 36 ++++
ports/hotspot/src/cpu/ppc/vm/interp_masm_ppc.hpp | 9 -
ports/hotspot/src/cpu/ppc/vm/interpreter_ppc.cpp | 16 -
ports/hotspot/src/cpu/ppc/vm/register_definitions_ppc.cpp | 2
ports/hotspot/src/cpu/ppc/vm/register_ppc.hpp | 2
diffs (404 lines):
diff -r d9c52d01ccae -r f3622a4f4ebc ChangeLog
--- a/ChangeLog Mon Nov 19 11:03:52 2007 -0500
+++ b/ChangeLog Tue Nov 20 07:05:00 2007 -0500
@@ -1,3 +1,28 @@ 2007-11-19 Gary Benson <gbenson at redhat
+2007-11-20 Gary Benson <gbenson at redhat.com>
+
+ * ports/hotspot/src/cpu/ppc/vm/register_ppc.hpp
+ (noreg): Declare.
+ * ports/hotspot/src/cpu/ppc/vm/register_definitions_ppc.cpp
+ (noreg): Define.
+
+ * ports/hotspot/src/cpu/ppc/vm/interp_masm_ppc.hpp
+ * ports/hotspot/src/cpu/ppc/vm/interp_masm_ppc.cpp
+ (set_last_Java_frame): Optionally preserve the link register.
+
+ * ports/hotspot/src/cpu/ppc/vm/assembler_ppc.hpp
+ * ports/hotspot/src/cpu/ppc/vm/assembler_ppc.cpp
+ (call_VM, call_VM_leaf, call_VM_base, call_VM_leaf_base,
+ call_VM_pass_args): New methods.
+ * ports/hotspot/src/cpu/ppc/vm/interp_masm_ppc.hpp
+ * ports/hotspot/src/cpu/ppc/vm/interp_masm_ppc.cpp
+ (call_VM_base, call_VM_leaf_base): Likewise.
+
+ * ports/hotspot/src/cpu/ppc/vm/cppInterpreter_ppc.cpp
+ (generate_native_entry): Use call_VM and call_VM_leaf
+ when making VM calls.
+ * ports/hotspot/src/cpu/ppc/vm/interpreter_ppc.cpp
+ (generate_slow_signature_handler): Likewise.
+
2007-11-19 Gary Benson <gbenson at redhat.com>
* ports/hotspot/src/cpu/ppc/vm/cppInterpreter_ppc.cpp
diff -r d9c52d01ccae -r f3622a4f4ebc ports/hotspot/src/cpu/ppc/vm/assembler_ppc.cpp
--- a/ports/hotspot/src/cpu/ppc/vm/assembler_ppc.cpp Mon Nov 19 11:03:52 2007 -0500
+++ b/ports/hotspot/src/cpu/ppc/vm/assembler_ppc.cpp Tue Nov 20 07:05:00 2007 -0500
@@ -1200,6 +1200,119 @@ void MacroAssembler::cmpxchg_(Register e
bind(done);
}
+void MacroAssembler::call_VM_pass_args(Register arg_1,
+ Register arg_2,
+ Register arg_3)
+{
+ if (arg_1 != r4) {
+ assert(arg_2 != r4, "smashed argument");
+ assert(arg_3 != r4, "smashed argument");
+ mr(r4, arg_1);
+ }
+
+ if (arg_2 == noreg) {
+ assert (arg_3 == noreg, "what?");
+ return;
+ }
+
+ if (arg_2 != r5) {
+ assert(arg_3 != r5, "smashed argument");
+ mr(r5, arg_2);
+ }
+
+ if (arg_3 != noreg && arg_3 != r6) {
+ mr(r6, arg_3);
+ }
+}
+
+void MacroAssembler::call_VM_base(Register oop_result,
+ address entry_point,
+ CallVMFlags flags)
+{
+ StackFrame frame;
+
+ if (flags & CALL_VM_PRESERVE_LR)
+ prolog(frame);
+
+ mr(r3, Rthread);
+ call(entry_point);
+
+ if (flags & CALL_VM_PRESERVE_LR)
+ epilog(frame);
+
+ if (!(flags & CALL_VM_NO_EXCEPTION_CHECKS)) {
+ Label ok;
+ load(r0, Address(Rthread, Thread::pending_exception_offset()));
+ compare (r0, 0);
+ beq(ok);
+ unimplemented(__FILE__, __LINE__);
+ bind(ok);
+ }
+
+ if (oop_result->is_valid()) {
+ unimplemented(__FILE__, __LINE__);
+ }
+}
+
+void MacroAssembler::call_VM(Register oop_result,
+ address entry_point,
+ CallVMFlags flags)
+{
+ call_VM_base(oop_result, entry_point, flags);
+}
+void MacroAssembler::call_VM(Register oop_result,
+ address entry_point,
+ Register arg_1,
+ CallVMFlags flags)
+{
+ call_VM_pass_args(arg_1);
+ call_VM_base(oop_result, entry_point, flags);
+}
+void MacroAssembler::call_VM(Register oop_result,
+ address entry_point,
+ Register arg_1, Register arg_2,
+ CallVMFlags flags)
+{
+ call_VM_pass_args(arg_1, arg_2);
+ call_VM_base(oop_result, entry_point, flags);
+}
+void MacroAssembler::call_VM(Register oop_result,
+ address entry_point,
+ Register arg_1, Register arg_2, Register arg_3,
+ CallVMFlags flags)
+{
+ call_VM_pass_args(arg_1, arg_2, arg_3);
+ call_VM_base(oop_result, entry_point, flags);
+}
+
+void MacroAssembler::call_VM_leaf_base(address entry_point)
+{
+ mr(r3, Rthread);
+ call(entry_point);
+}
+
+void MacroAssembler::call_VM_leaf(address entry_point)
+{
+ call_VM_leaf_base(entry_point);
+}
+void MacroAssembler::call_VM_leaf(address entry_point, Register arg_1)
+{
+ call_VM_pass_args(arg_1);
+ call_VM_leaf_base(entry_point);
+}
+void MacroAssembler::call_VM_leaf(address entry_point, Register arg_1,
+ Register arg_2)
+{
+ call_VM_pass_args(arg_1, arg_2);
+ call_VM_leaf_base(entry_point);
+}
+void MacroAssembler::call_VM_leaf(address entry_point, Register arg_1,
+ Register arg_2, Register arg_3)
+{
+ call_VM_pass_args(arg_1, arg_2, arg_3);
+ call_VM_leaf_base(entry_point);
+}
+
// Write serialization page so VM thread can do a pseudo remote membar.
void MacroAssembler::serialize_memory(Register tmp1, Register tmp2)
{
diff -r d9c52d01ccae -r f3622a4f4ebc ports/hotspot/src/cpu/ppc/vm/assembler_ppc.hpp
--- a/ports/hotspot/src/cpu/ppc/vm/assembler_ppc.hpp Mon Nov 19 11:03:52 2007 -0500
+++ b/ports/hotspot/src/cpu/ppc/vm/assembler_ppc.hpp Tue Nov 20 07:05:00 2007 -0500
@@ -311,12 +311,43 @@ class StackFrame {
};
+// Flags for MacroAssembler::call_VM
+
+enum CallVMFlags {
+ CALL_VM_DEFAULTS = 0,
+ CALL_VM_NO_EXCEPTION_CHECKS = 1,
+ CALL_VM_PRESERVE_LR = 2
+};
+
+
// MacroAssembler extends Assembler by frequently used macros.
//
// Instructions for which a 'better' code sequence exists depending
// on arguments should also go in here.
class MacroAssembler : public Assembler {
+ protected:
+ // Support for VM calls
+ //
+ // This is the base routine called by the different versions of
+ // call_VM_leaf. The interpreter may customize this version by
+ // overriding it for its purposes (e.g., to save/restore additional
+ // registers when doing a VM call).
+ virtual void call_VM_leaf_base(address entry_point);
+
+ // This is the base routine called by the different versions of
+ // call_VM. The interpreter may customize this version by overriding
+ // it for its purposes (e.g., to save/restore additional registers
+ // when doing a VM call).
+ virtual void call_VM_base(Register oop_result,
+ address entry_point,
+ CallVMFlags flags);
+
+ private:
+ void call_VM_pass_args(Register arg_1,
+ Register arg_2 = noreg,
+ Register arg_3 = noreg);
+
public:
MacroAssembler(CodeBuffer* code) : Assembler(code) {}
@@ -353,6 +384,32 @@ class MacroAssembler : public Assembler
void cmpxchg_(Register exchange, Register dst, Register compare);
+ // Support for VM calls
+ void call_VM(Register oop_result,
+ address entry_point,
+ CallVMFlags flags = CALL_VM_DEFAULTS);
+ void call_VM(Register oop_result,
+ address entry_point,
+ Register arg_1,
+ CallVMFlags flags = CALL_VM_DEFAULTS);
+ void call_VM(Register oop_result,
+ address entry_point,
+ Register arg_1, Register arg_2,
+ CallVMFlags flags = CALL_VM_DEFAULTS);
+ void call_VM(Register oop_result,
+ address entry_point,
+ Register arg_1, Register arg_2, Register arg_3,
+ CallVMFlags flags = CALL_VM_DEFAULTS);
+
+ void call_VM_leaf(address entry_point);
+ void call_VM_leaf(address entry_point,
+ Register arg_1);
+ void call_VM_leaf(address entry_point,
+ Register arg_1, Register arg_2);
+ void call_VM_leaf(address entry_point,
+ Register arg_1, Register arg_2, Register arg_3);
+
+ // Support for serializing memory accesses between threads
void serialize_memory(Register tmp1, Register tmp2);
void calc_padding_for_alignment(Register dst, Register src, int align);
diff -r d9c52d01ccae -r f3622a4f4ebc ports/hotspot/src/cpu/ppc/vm/cppInterpreter_ppc.cpp
--- a/ports/hotspot/src/cpu/ppc/vm/cppInterpreter_ppc.cpp Mon Nov 19 11:03:52 2007 -0500
+++ b/ports/hotspot/src/cpu/ppc/vm/cppInterpreter_ppc.cpp Tue Nov 20 07:05:00 2007 -0500
@@ -521,10 +521,11 @@ address InterpreterGenerator::generate_n
__ load (handler, signature_handler_addr);
__ compare (handler, 0);
__ bne (got_signature_handler);
- __ mr (r3, Rthread);
- __ mr (r4, Rmethod);
- __ call (CAST_FROM_FN_PTR(address, InterpreterRuntime::prepare_native_call));
- __ fixup_after_potential_safepoint ();
+ __ call_VM (noreg,
+ CAST_FROM_FN_PTR(address,
+ InterpreterRuntime::prepare_native_call),
+ Rmethod,
+ CALL_VM_NO_EXCEPTION_CHECKS);
__ load (r0, Address(Rthread, Thread::pending_exception_offset()));
__ compare (r0, 0);
__ bne (return_to_caller);
@@ -619,7 +620,8 @@ address InterpreterGenerator::generate_n
}
// Check for safepoint operation in progress and/or pending
- // suspend requests
+ // suspend requests. We use a leaf call in order to leave
+ // the last_Java_frame setup undisturbed.
Label block, no_block;
__ load (r3, (intptr_t) SafepointSynchronize::address_of_state());
@@ -630,9 +632,9 @@ address InterpreterGenerator::generate_n
__ compare (r0, 0);
__ beq (no_block);
__ bind (block);
- __ mr (r3, Rthread);
- __ call (CAST_FROM_FN_PTR(address,
- JavaThread::check_special_condition_for_native_trans));
+ __ call_VM_leaf (
+ CAST_FROM_FN_PTR(address,
+ JavaThread::check_special_condition_for_native_trans));
__ fixup_after_potential_safepoint ();
__ bind (no_block);
diff -r d9c52d01ccae -r f3622a4f4ebc ports/hotspot/src/cpu/ppc/vm/interp_masm_ppc.cpp
--- a/ports/hotspot/src/cpu/ppc/vm/interp_masm_ppc.cpp Mon Nov 19 11:03:52 2007 -0500
+++ b/ports/hotspot/src/cpu/ppc/vm/interp_masm_ppc.cpp Tue Nov 20 07:05:00 2007 -0500
@@ -30,14 +30,48 @@ REGISTER_DEFINITION(Register, Rstate);
REGISTER_DEFINITION(Register, Rstate);
#endif
+// Interpreter-specific support for VM calls
+
+void InterpreterMacroAssembler::call_VM_base(Register oop_result,
+ address entry_point,
+ CallVMFlags flags)
+{
+ // Set the Java frame anchor
+ set_last_Java_frame(flags & CALL_VM_PRESERVE_LR ? r3 : noreg);
+
+ // Make the call
+ MacroAssembler::call_VM_base(oop_result, entry_point, flags);
+
+ // Clear the Java frame anchor
+ reset_last_Java_frame();
+
+ // Reload anything that may have changed if there was a safepoint
+ fixup_after_potential_safepoint();
+}
+
+void InterpreterMacroAssembler::call_VM_leaf_base(address entry_point)
+{
+ // Make the call
+ MacroAssembler::call_VM_leaf_base(entry_point);
+}
+
// Set the last Java frame pointer
+// NB trashes LR unless you pass it a register to store it in
-void InterpreterMacroAssembler::set_last_Java_frame()
+void InterpreterMacroAssembler::set_last_Java_frame(Register lr_save)
{
+ assert_different_registers(lr_save, r0);
+
+ if (lr_save->is_valid())
+ mflr(lr_save);
+
bcl(20, 31, pc() + 4); // magic branch that preserves the link stack
mflr(r0);
store(r0, Address(Rthread, JavaThread::last_Java_pc_offset()));
store(r1, Address(Rthread, JavaThread::last_Java_sp_offset()));
+
+ if (lr_save->is_valid())
+ mtlr(lr_save);
}
// Clear the last Java frame pointer
diff -r d9c52d01ccae -r f3622a4f4ebc ports/hotspot/src/cpu/ppc/vm/interp_masm_ppc.hpp
--- a/ports/hotspot/src/cpu/ppc/vm/interp_masm_ppc.hpp Mon Nov 19 11:03:52 2007 -0500
+++ b/ports/hotspot/src/cpu/ppc/vm/interp_masm_ppc.hpp Tue Nov 20 07:05:00 2007 -0500
@@ -33,11 +33,18 @@ REGISTER_DECLARATION(Register, Rstate, r
#endif // CC_INTERP
class InterpreterMacroAssembler : public MacroAssembler {
+ protected:
+ // Support for VM calls
+ virtual void call_VM_leaf_base(address entry_point);
+ virtual void call_VM_base(Register oop_result,
+ address entry_point,
+ CallVMFlags flags);
+
public:
InterpreterMacroAssembler(CodeBuffer* code) : MacroAssembler(code) {}
// Frame anchor tracking
- void set_last_Java_frame();
+ void set_last_Java_frame(Register lr_save = noreg);
void reset_last_Java_frame();
// Object locking
diff -r d9c52d01ccae -r f3622a4f4ebc ports/hotspot/src/cpu/ppc/vm/interpreter_ppc.cpp
--- a/ports/hotspot/src/cpu/ppc/vm/interpreter_ppc.cpp Mon Nov 19 11:03:52 2007 -0500
+++ b/ports/hotspot/src/cpu/ppc/vm/interpreter_ppc.cpp Tue Nov 20 07:05:00 2007 -0500
@@ -83,18 +83,12 @@ address AbstractInterpreterGenerator::ge
__ maybe_extend_frame (required_bytes, available_bytes);
// Fill in the parameter list space and register images
- StackFrame frame;
-
- __ mr (r3, Rthread);
- __ mr (r4, Rmethod);
- __ mr (r5, Rlocals);
__ la (r6, Address(r1, StackFrame::link_area_words * wordSize));
-
- __ prolog (frame);
- __ call (CAST_FROM_FN_PTR(address,
- InterpreterRuntime::slow_signature_handler));
- __ fixup_after_potential_safepoint ();
- __ epilog (frame);
+ __ call_VM (noreg,
+ CAST_FROM_FN_PTR(address,
+ InterpreterRuntime::slow_signature_handler),
+ Rmethod, Rlocals, r6,
+ CALL_VM_PRESERVE_LR);
// Load the register images into the registers
const Register src = r11;
diff -r d9c52d01ccae -r f3622a4f4ebc ports/hotspot/src/cpu/ppc/vm/register_definitions_ppc.cpp
--- a/ports/hotspot/src/cpu/ppc/vm/register_definitions_ppc.cpp Mon Nov 19 11:03:52 2007 -0500
+++ b/ports/hotspot/src/cpu/ppc/vm/register_definitions_ppc.cpp Tue Nov 20 07:05:00 2007 -0500
@@ -25,6 +25,8 @@
#include "incls/_precompiled.incl"
#include "incls/_register_definitions_ppc.cpp.incl"
+
+REGISTER_DEFINITION(Register, noreg);
REGISTER_DEFINITION(Register, r0);
REGISTER_DEFINITION(Register, r1);
diff -r d9c52d01ccae -r f3622a4f4ebc ports/hotspot/src/cpu/ppc/vm/register_ppc.hpp
--- a/ports/hotspot/src/cpu/ppc/vm/register_ppc.hpp Mon Nov 19 11:03:52 2007 -0500
+++ b/ports/hotspot/src/cpu/ppc/vm/register_ppc.hpp Tue Nov 20 07:05:00 2007 -0500
@@ -63,6 +63,8 @@ class RegisterImpl : public AbstractRegi
}
const char* name() const;
};
+
+CONSTANT_REGISTER_DECLARATION(Register, noreg, (-1));
// The integer registers of the ppc architecture
CONSTANT_REGISTER_DECLARATION(Register, r0, (0));
More information about the distro-pkg-dev
mailing list