6932091: JSR 292 x86 code cleanup
Summary: Some code cleanups found during the JSR 292 SPARC port.
Reviewed-by: kvn, never
--- a/hotspot/src/cpu/x86/vm/methodHandles_x86.cpp Wed Mar 17 16:40:25 2010 -0700
+++ b/hotspot/src/cpu/x86/vm/methodHandles_x86.cpp Thu Mar 18 09:56:51 2010 +0100
@@ -60,13 +60,13 @@
}
#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 @@
// 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 @@
(!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 @@
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 @@
__ 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 @@
// 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 @@
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 @@
}
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 @@
__ 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 @@
}
break;
default:
- assert(false, "");
+ ShouldNotReachHere();
}
__ movptr(rcx_recv, rcx_mh_vmtarget);
@@ -778,20 +732,9 @@
if (ek == _adapter_opt_f2d) {
__ fld_s(vmarg); // load float to ST0
__ fstp_s(vmarg); // store single
- } else if (!TaggedStackInterpreter) {
+ } else {
__ 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 @@
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 @@
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 @@
__ 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 @@
__ 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();
}
}
--- a/hotspot/src/cpu/x86/vm/templateTable_x86_32.cpp Wed Mar 17 16:40:25 2010 -0700
+++ b/hotspot/src/cpu/x86/vm/templateTable_x86_32.cpp Thu Mar 18 09:56:51 2010 +0100
@@ -1,5 +1,5 @@
/*
- * 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 @@
__ 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
--- a/hotspot/src/cpu/x86/vm/templateTable_x86_64.cpp Wed Mar 17 16:40:25 2010 -0700
+++ b/hotspot/src/cpu/x86/vm/templateTable_x86_64.cpp Thu Mar 18 09:56:51 2010 +0100
@@ -1,5 +1,5 @@
/*
- * 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 @@
__ 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
--- a/hotspot/src/share/vm/c1/c1_LIRGenerator.cpp Wed Mar 17 16:40:25 2010 -0700
+++ b/hotspot/src/share/vm/c1/c1_LIRGenerator.cpp Thu Mar 18 09:56:51 2010 +0100
@@ -2376,8 +2376,7 @@
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);
--- a/hotspot/src/share/vm/prims/methodHandles.hpp Wed Mar 17 16:40:25 2010 -0700
+++ b/hotspot/src/share/vm/prims/methodHandles.hpp Thu Mar 18 09:56:51 2010 +0100
@@ -1,5 +1,5 @@
/*
- * 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 @@
_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 @@
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);
};
--- a/hotspot/src/share/vm/runtime/arguments.cpp Wed Mar 17 16:40:25 2010 -0700
+++ b/hotspot/src/share/vm/runtime/arguments.cpp Thu Mar 18 09:56:51 2010 +0100
@@ -2859,6 +2859,12 @@
}
#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;