8202016: Use obj+offset in interpreter array access
authorrkennke
Mon, 14 May 2018 21:56:07 +0200
changeset 50106 24151f48582b
parent 50105 6f6e8c1b4208
child 50107 300e4a88c400
8202016: Use obj+offset in interpreter array access Reviewed-by: adinn
src/hotspot/cpu/x86/interp_masm_x86.cpp
src/hotspot/cpu/x86/templateTable_x86.cpp
--- a/src/hotspot/cpu/x86/interp_masm_x86.cpp	Mon May 14 11:17:18 2018 -0700
+++ b/src/hotspot/cpu/x86/interp_masm_x86.cpp	Mon May 14 21:56:07 2018 +0200
@@ -504,18 +504,15 @@
 void InterpreterMacroAssembler::load_resolved_reference_at_index(
                                            Register result, Register index, Register tmp) {
   assert_different_registers(result, index);
-  // convert from field index to resolved_references() index and from
-  // word index to byte offset. Since this is a java object, it can be compressed
-  shll(index, LogBytesPerHeapOop);
 
   get_constant_pool(result);
   // load pointer for resolved_references[] objArray
   movptr(result, Address(result, ConstantPool::cache_offset_in_bytes()));
   movptr(result, Address(result, ConstantPoolCache::resolved_references_offset_in_bytes()));
   resolve_oop_handle(result, tmp);
-  // Add in the index
-  addptr(result, index);
-  load_heap_oop(result, Address(result, arrayOopDesc::base_offset_in_bytes(T_OBJECT)), tmp);
+  load_heap_oop(result, Address(result, index,
+                                UseCompressedOops ? Address::times_4 : Address::times_ptr,
+                                arrayOopDesc::base_offset_in_bytes(T_OBJECT)), tmp);
 }
 
 // load cpool->resolved_klass_at(index)
--- a/src/hotspot/cpu/x86/templateTable_x86.cpp	Mon May 14 11:17:18 2018 -0700
+++ b/src/hotspot/cpu/x86/templateTable_x86.cpp	Mon May 14 21:56:07 2018 +0200
@@ -1112,8 +1112,6 @@
   __ load_klass(rax, rdx);
   __ movptr(rax, Address(rax,
                          ObjArrayKlass::element_klass_offset()));
-  // Compress array + index*oopSize + 12 into a single register.  Frees rcx.
-  __ lea(rdx, element_address);
 
   // Generate subtype check.  Blows rcx, rdi
   // Superklass in rax.  Subklass in rbx.
@@ -1128,8 +1126,9 @@
 
   // Get the value we will store
   __ movptr(rax, at_tos());
+  __ movl(rcx, at_tos_p1()); // index
   // Now store using the appropriate barrier
-  do_oop_store(_masm, Address(rdx, 0), rax, IN_HEAP_ARRAY);
+  do_oop_store(_masm, element_address, rax, IN_HEAP_ARRAY);
   __ jmp(done);
 
   // Have a NULL in rax, rdx=array, ecx=index.  Store NULL at ary[idx]