提交 6adf09af 编写于 作者: T twisti

6932091: JSR 292 x86 code cleanup

Summary: Some code cleanups found during the JSR 292 SPARC port.
Reviewed-by: kvn, never
上级 cb1cb002
......@@ -60,13 +60,13 @@ MethodHandleEntry* MethodHandleEntry::finish_compiled_entry(MacroAssembler* _mas
}
#ifdef ASSERT
static void verify_argslot(MacroAssembler* _masm, Register rax_argslot,
static void verify_argslot(MacroAssembler* _masm, Register argslot_reg,
const char* error_message) {
// Verify that argslot lies within (rsp, rbp].
Label L_ok, L_bad;
__ cmpptr(rax_argslot, rbp);
__ cmpptr(argslot_reg, rbp);
__ jccb(Assembler::above, L_bad);
__ cmpptr(rsp, rax_argslot);
__ cmpptr(rsp, argslot_reg);
__ jccb(Assembler::below, L_ok);
__ bind(L_bad);
__ stop(error_message);
......@@ -178,22 +178,6 @@ void MethodHandles::insert_arg_slots(MacroAssembler* _masm,
// Now move the argslot down, to point to the opened-up space.
__ lea(rax_argslot, Address(rax_argslot, arg_slots, Address::times_ptr));
if (TaggedStackInterpreter && arg_mask != _INSERT_NO_MASK) {
// The caller has specified a bitmask of tags to put into the opened space.
// This only works when the arg_slots value is an assembly-time constant.
int constant_arg_slots = arg_slots.as_constant() / stack_move_unit();
int tag_offset = Interpreter::tag_offset_in_bytes() - Interpreter::value_offset_in_bytes();
for (int slot = 0; slot < constant_arg_slots; slot++) {
BasicType slot_type = ((arg_mask & (1 << slot)) == 0 ? T_OBJECT : T_INT);
int slot_offset = Interpreter::stackElementSize() * slot;
Address tag_addr(rax_argslot, slot_offset + tag_offset);
__ movptr(tag_addr, frame::tag_for_basic_type(slot_type));
}
// Note that the new argument slots are tagged properly but contain
// garbage at this point. The value portions must be initialized
// by the caller. (Especially references!)
}
}
// Helper to remove argument slots from the stack.
......@@ -206,18 +190,9 @@ void MethodHandles::remove_arg_slots(MacroAssembler* _masm,
(!arg_slots.is_register() ? rsp : arg_slots.as_register()));
#ifdef ASSERT
{
// Verify that [argslot..argslot+size) lies within (rsp, rbp).
Label L_ok, L_bad;
__ lea(rbx_temp, Address(rax_argslot, arg_slots, Address::times_ptr));
__ cmpptr(rbx_temp, rbp);
__ jccb(Assembler::above, L_bad);
__ cmpptr(rsp, rax_argslot);
__ jccb(Assembler::below, L_ok);
__ bind(L_bad);
__ stop("deleted argument(s) must fall within current frame");
__ bind(L_ok);
}
// Verify that [argslot..argslot+size) lies within (rsp, rbp).
__ lea(rbx_temp, Address(rax_argslot, arg_slots, Address::times_ptr));
verify_argslot(_masm, rbx_temp, "deleted argument(s) must fall within current frame");
if (arg_slots.is_register()) {
Label L_ok, L_bad;
__ cmpptr(arg_slots.as_register(), (int32_t) NULL_WORD);
......@@ -321,12 +296,6 @@ void MethodHandles::generate_method_handle_stub(MacroAssembler* _masm, MethodHan
Address rcx_amh_conversion( rcx_recv, sun_dyn_AdapterMethodHandle::conversion_offset_in_bytes() );
Address vmarg; // __ argument_address(vmargslot)
int tag_offset = -1;
if (TaggedStackInterpreter) {
tag_offset = Interpreter::tag_offset_in_bytes() - Interpreter::value_offset_in_bytes();
assert(tag_offset = wordSize, "stack grows as expected");
}
const int java_mirror_offset = klassOopDesc::klass_part_offset_in_bytes() + Klass::java_mirror_offset_in_bytes();
if (have_entry(ek)) {
......@@ -372,11 +341,8 @@ void MethodHandles::generate_method_handle_stub(MacroAssembler* _masm, MethodHan
__ mov(rsp, rsi); // cut the stack back to where the caller started
// Repush the arguments as if coming from the interpreter.
if (TaggedStackInterpreter) __ push(frame::tag_for_basic_type(T_INT));
__ push(rdx_code);
if (TaggedStackInterpreter) __ push(frame::tag_for_basic_type(T_OBJECT));
__ push(rcx_fail);
if (TaggedStackInterpreter) __ push(frame::tag_for_basic_type(T_OBJECT));
__ push(rax_want);
Register rbx_method = rbx_temp;
......@@ -397,7 +363,6 @@ void MethodHandles::generate_method_handle_stub(MacroAssembler* _masm, MethodHan
// Do something that is at least causes a valid throw from the interpreter.
__ bind(no_method);
__ pop(rax_want);
if (TaggedStackInterpreter) __ pop(rcx_fail);
__ pop(rcx_fail);
__ push(rax_want);
__ push(rcx_fail);
......@@ -510,18 +475,10 @@ void MethodHandles::generate_method_handle_stub(MacroAssembler* _masm, MethodHan
case _bound_long_direct_mh:
{
bool direct_to_method = (ek >= _bound_ref_direct_mh);
BasicType arg_type = T_ILLEGAL;
if (ek == _bound_long_mh || ek == _bound_long_direct_mh) {
arg_type = T_LONG;
} else if (ek == _bound_int_mh || ek == _bound_int_direct_mh) {
arg_type = T_INT;
} else {
assert(ek == _bound_ref_mh || ek == _bound_ref_direct_mh, "must be ref");
arg_type = T_OBJECT;
}
int arg_slots = type2size[arg_type];
int arg_mask = (arg_type == T_OBJECT ? _INSERT_REF_MASK :
arg_slots == 1 ? _INSERT_INT_MASK : _INSERT_LONG_MASK);
BasicType arg_type = T_ILLEGAL;
int arg_mask = _INSERT_NO_MASK;
int arg_slots = -1;
get_ek_bound_mh_info(ek, arg_type, arg_mask, arg_slots);
// make room for the new argument:
__ movl(rax_argslot, rcx_bmh_vmargslot);
......@@ -660,13 +617,10 @@ void MethodHandles::generate_method_handle_stub(MacroAssembler* _masm, MethodHan
}
break;
default:
assert(false, "");
ShouldNotReachHere();
}
goto finish_int_conversion;
}
finish_int_conversion:
{
// Do the requested conversion and store the value.
Register rbx_vminfo = rbx_temp;
__ movl(rbx_vminfo, rcx_amh_conversion);
assert(CONV_VMINFO_SHIFT == 0, "preshifted");
......@@ -692,7 +646,7 @@ void MethodHandles::generate_method_handle_stub(MacroAssembler* _masm, MethodHan
__ shrl(rdx_temp /*, rcx*/);
__ bind(done);
__ movl(vmarg, rdx_temp);
__ movl(vmarg, rdx_temp); // Store the value.
__ xchgptr(rcx, rbx_vminfo); // restore rcx_recv
__ jump_to_method_handle_entry(rcx_recv, rdx_temp);
......@@ -744,7 +698,7 @@ void MethodHandles::generate_method_handle_stub(MacroAssembler* _masm, MethodHan
}
break;
default:
assert(false, "");
ShouldNotReachHere();
}
__ movptr(rcx_recv, rcx_mh_vmtarget);
......@@ -778,19 +732,8 @@ void MethodHandles::generate_method_handle_stub(MacroAssembler* _masm, MethodHan
if (ek == _adapter_opt_f2d) {
__ fld_s(vmarg); // load float to ST0
__ fstp_s(vmarg); // store single
} else if (!TaggedStackInterpreter) {
__ fld_d(vmarg); // load double to ST0
__ fstp_s(vmarg); // store single
} else {
Address vmarg_tag = vmarg.plus_disp(tag_offset);
Address vmarg2 = vmarg.plus_disp(Interpreter::stackElementSize());
// vmarg2_tag does not participate in this code
Register rbx_tag = rbx_temp;
__ movl(rbx_tag, vmarg_tag); // preserve tag
__ movl(rdx_temp, vmarg2); // get second word of double
__ movl(vmarg_tag, rdx_temp); // align with first word
__ fld_d(vmarg); // load double to ST0
__ movl(vmarg_tag, rbx_tag); // restore tag
__ fstp_s(vmarg); // store single
}
#endif //_LP64
......@@ -822,19 +765,8 @@ void MethodHandles::generate_method_handle_stub(MacroAssembler* _masm, MethodHan
case _adapter_opt_rot_2_up:
case _adapter_opt_rot_2_down:
{
int rotate = 0, swap_slots = 0;
switch ((int)ek) {
case _adapter_opt_swap_1: swap_slots = 1; break;
case _adapter_opt_swap_2: swap_slots = 2; break;
case _adapter_opt_rot_1_up: swap_slots = 1; rotate++; break;
case _adapter_opt_rot_1_down: swap_slots = 1; rotate--; break;
case _adapter_opt_rot_2_up: swap_slots = 2; rotate++; break;
case _adapter_opt_rot_2_down: swap_slots = 2; rotate--; break;
default: assert(false, "");
}
// the real size of the move must be doubled if TaggedStackInterpreter:
int swap_bytes = (int)( swap_slots * Interpreter::stackElementWords() * wordSize );
int swap_bytes = 0, rotate = 0;
get_ek_adapter_opt_swap_rot_info(ek, swap_bytes, rotate);
// 'argslot' is the position of the first argument to swap
__ movl(rax_argslot, rcx_amh_vmargslot);
......@@ -1024,11 +956,7 @@ void MethodHandles::generate_method_handle_stub(MacroAssembler* _masm, MethodHan
case _adapter_opt_spread_more:
{
// spread an array out into a group of arguments
int length_constant = -1;
switch (ek) {
case _adapter_opt_spread_0: length_constant = 0; break;
case _adapter_opt_spread_1: length_constant = 1; break;
}
int length_constant = get_ek_adapter_opt_spread_info(ek);
// find the address of the array argument
__ movl(rax_argslot, rcx_amh_vmargslot);
......@@ -1124,10 +1052,6 @@ void MethodHandles::generate_method_handle_stub(MacroAssembler* _masm, MethodHan
__ movptr(rbx_temp, Address(rsi_source, 0));
__ movptr(Address(rax_argslot, 0), rbx_temp);
__ addptr(rsi_source, type2aelembytes(elem_type));
if (TaggedStackInterpreter) {
__ movptr(Address(rax_argslot, tag_offset),
frame::tag_for_basic_type(elem_type));
}
__ addptr(rax_argslot, Interpreter::stackElementSize());
__ cmpptr(rax_argslot, rdx_argslot_limit);
__ jccb(Assembler::less, loop);
......@@ -1141,10 +1065,6 @@ void MethodHandles::generate_method_handle_stub(MacroAssembler* _masm, MethodHan
__ movptr(rbx_temp, Address(rsi_array, elem_offset));
__ movptr(Address(rax_argslot, slot_offset), rbx_temp);
elem_offset += type2aelembytes(elem_type);
if (TaggedStackInterpreter) {
__ movptr(Address(rax_argslot, slot_offset + tag_offset),
frame::tag_for_basic_type(elem_type));
}
slot_offset += Interpreter::stackElementSize();
}
}
......
/*
* Copyright 1997-2009 Sun Microsystems, Inc. All Rights Reserved.
* Copyright 1997-2010 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
......@@ -2915,12 +2915,8 @@ void TemplateTable::prepare_invoke(Register method, Register index, int byte_no)
__ andl(recv, 0xFF);
// recv count is 0 based?
Address recv_addr(rsp, recv, Interpreter::stackElementScale(), -Interpreter::expr_offset_in_bytes(1));
if (is_invokedynamic) {
__ lea(recv, recv_addr);
} else {
__ movptr(recv, recv_addr);
__ verify_oop(recv);
}
__ movptr(recv, recv_addr);
__ verify_oop(recv);
}
// do null check if needed
......
/*
* Copyright 2003-2009 Sun Microsystems, Inc. All Rights Reserved.
* Copyright 2003-2010 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
......@@ -2860,12 +2860,8 @@ void TemplateTable::prepare_invoke(Register method, Register index, int byte_no)
__ andl(recv, 0xFF);
if (TaggedStackInterpreter) __ shll(recv, 1); // index*2
Address recv_addr(rsp, recv, Address::times_8, -Interpreter::expr_offset_in_bytes(1));
if (is_invokedynamic) {
__ lea(recv, recv_addr);
} else {
__ movptr(recv, recv_addr);
__ verify_oop(recv);
}
__ movptr(recv, recv_addr);
__ verify_oop(recv);
}
// do null check if needed
......
......@@ -2376,8 +2376,7 @@ void LIRGenerator::do_Invoke(Invoke* x) {
CodeEmitInfo* info = state_for(x, x->state());
// invokedynamics can deoptimize.
bool is_invokedynamic = x->code() == Bytecodes::_invokedynamic;
CodeEmitInfo* deopt_info = is_invokedynamic ? state_for(x, x->state_before()) : NULL;
CodeEmitInfo* deopt_info = x->is_invokedynamic() ? state_for(x, x->state_before()) : NULL;
invoke_load_arguments(x, args, arg_list);
......
/*
* Copyright 2008-2009 Sun Microsystems, Inc. All Rights Reserved.
* Copyright 2008-2010 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
......@@ -137,6 +137,43 @@ class MethodHandles: AllStatic {
_entries[ek] = me;
}
// Some adapter helper functions.
static void get_ek_bound_mh_info(EntryKind ek, BasicType& arg_type, int& arg_mask, int& arg_slots) {
switch (ek) {
case _bound_int_mh : // fall-thru
case _bound_int_direct_mh : arg_type = T_INT; arg_mask = _INSERT_INT_MASK; break;
case _bound_long_mh : // fall-thru
case _bound_long_direct_mh: arg_type = T_LONG; arg_mask = _INSERT_LONG_MASK; break;
case _bound_ref_mh : // fall-thru
case _bound_ref_direct_mh : arg_type = T_OBJECT; arg_mask = _INSERT_REF_MASK; break;
default: ShouldNotReachHere();
}
arg_slots = type2size[arg_type];
}
static void get_ek_adapter_opt_swap_rot_info(EntryKind ek, int& swap_bytes, int& rotate) {
int swap_slots = 0;
switch (ek) {
case _adapter_opt_swap_1: swap_slots = 1; rotate = 0; break;
case _adapter_opt_swap_2: swap_slots = 2; rotate = 0; break;
case _adapter_opt_rot_1_up: swap_slots = 1; rotate = 1; break;
case _adapter_opt_rot_1_down: swap_slots = 1; rotate = -1; break;
case _adapter_opt_rot_2_up: swap_slots = 2; rotate = 1; break;
case _adapter_opt_rot_2_down: swap_slots = 2; rotate = -1; break;
default: ShouldNotReachHere();
}
// Return the size of the stack slots to move in bytes.
swap_bytes = swap_slots * Interpreter::stackElementSize();
}
static int get_ek_adapter_opt_spread_info(EntryKind ek) {
switch (ek) {
case _adapter_opt_spread_0: return 0;
case _adapter_opt_spread_1: return 1;
default : return -1;
}
}
static methodOop raise_exception_method() {
oop rem = JNIHandles::resolve(_raise_exception_method);
assert(rem == NULL || rem->is_method(), "");
......@@ -392,13 +429,13 @@ class MethodHandles: AllStatic {
static void insert_arg_slots(MacroAssembler* _masm,
RegisterOrConstant arg_slots,
int arg_mask,
Register rax_argslot,
Register rbx_temp, Register rdx_temp);
Register argslot_reg,
Register temp_reg, Register temp2_reg);
static void remove_arg_slots(MacroAssembler* _masm,
RegisterOrConstant arg_slots,
Register rax_argslot,
Register rbx_temp, Register rdx_temp);
Register argslot_reg,
Register temp_reg, Register temp2_reg);
};
......
......@@ -2859,6 +2859,12 @@ jint Arguments::parse(const JavaVMInitArgs* args) {
}
#endif // _LP64
// MethodHandles code does not support TaggedStackInterpreter.
if (EnableMethodHandles && TaggedStackInterpreter) {
warning("TaggedStackInterpreter is not supported by MethodHandles code. Disabling TaggedStackInterpreter.");
TaggedStackInterpreter = false;
}
// Check the GC selections again.
if (!check_gc_consistency()) {
return JNI_EINVAL;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册