changeset 13581:c6b48833776d mvt

8187625: [MVT] Interpreter cleanup Reviewed-by: dsimms
author fparain
date Mon, 18 Sep 2017 10:34:11 -0400
parents 010b6b654b23
children e2676828062c
files src/cpu/x86/vm/templateTable_x86.cpp src/share/vm/interpreter/interpreterRuntime.cpp src/share/vm/interpreter/interpreterRuntime.hpp src/share/vm/runtime/globals.hpp
diffstat 4 files changed, 43 insertions(+), 55 deletions(-) [+]
line wrap: on
line diff
--- a/src/cpu/x86/vm/templateTable_x86.cpp	Fri Sep 15 13:49:06 2017 -0700
+++ b/src/cpu/x86/vm/templateTable_x86.cpp	Mon Sep 18 10:34:11 2017 -0400
@@ -2874,6 +2874,7 @@
   const Register off   = rbx;
   const Register flags = rax;
   const Register bc    = LP64_ONLY(c_rarg3) NOT_LP64(rcx); // uses same reg as obj, so don't mix them
+  const Register flags2 = rdx;
 
   resolve_cache_and_index(byte_no, cache, index, sizeof(u2));
   jvmti_post_field_access(cache, index, is_static, false);
@@ -2884,6 +2885,8 @@
 
   Label Done, notByte, notBool, notInt, notShort, notChar, notLong, notFloat, notObj, notValueType, notDouble;
 
+  __ movl(flags2, flags);
+
   __ shrl(flags, ConstantPoolCacheEntry::tos_state_shift);
   // Make sure we don't need to mask edx after the above shift
   assert(btos == 0, "change code, btos != 0");
@@ -2912,15 +2915,17 @@
     __ load_heap_oop(rax, field);
     __ testptr(rax, rax);
     __ jcc(Assembler::notZero, initialized);
+    __ andl(flags2, ConstantPoolCacheEntry::field_index_mask);
     __ call_VM(rax, CAST_FROM_FN_PTR(address, InterpreterRuntime::initialize_static_value_field),
-         obj, off);
+         obj, flags2);
     __ verify_oop(rax);
     __ bind(initialized);
     __ push(qtos);
   } else {
     pop_and_check_object(obj);
+    __ andl(flags2, ConstantPoolCacheEntry::field_index_mask);
     call_VM(rax, CAST_FROM_FN_PTR(address, InterpreterRuntime::qgetfield),
-        obj, off);
+        obj, flags2);
     __ verify_oop(rax);
     __ push(qtos);
     // Bytecode rewrite?
@@ -3175,6 +3180,7 @@
   const Register off   = rbx;
   const Register flags = rax;
   const Register bc    = LP64_ONLY(c_rarg3) NOT_LP64(rcx);
+  const Register flags2 = rdx;
 
   resolve_cache_and_index(byte_no, cache, index, sizeof(u2));
   jvmti_post_field_mod(cache, index, is_static);
@@ -3185,9 +3191,8 @@
   //                                              Assembler::StoreStore));
 
   Label notVolatile, Done;
-  __ movl(rdx, flags);
-  __ shrl(rdx, ConstantPoolCacheEntry::is_volatile_shift);
-  __ andl(rdx, 0x1);
+
+  __ movl(flags2, flags);
 
   // field addresses
   const Address field(obj, off, Address::times_1, 0*wordSize);
@@ -3254,17 +3259,16 @@
     __ pop(qtos); // => rax == value
     if (!is_static) {
       // value types in non-static fields are embedded
-      __ movl(rcx, off);
       pop_and_check_object(rbx);
       call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::qputfield),
-          rbx, rax, rcx);
+          rbx, rax, flags2);
       __ jmp(notVolatile); // value types are never volatile
     } else {
       // Store into the static field
       // Value types in static fields are currently handled with indirection
       // but a copy to the Java heap might be required if the value is currently
       // stored in a thread local buffer
-      call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::qputstatic), rax);
+      call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::qputstatic), rax, off, obj);
     }
     __ jmp(Done);
   }
@@ -3401,8 +3405,11 @@
 
   __ bind(Done);
 
+  __ shrl(flags2, ConstantPoolCacheEntry::is_volatile_shift);
+  __ andl(flags2, 0x1);
+
   // Check for volatile store
-  __ testl(rdx, rdx);
+  __ testl(flags2, flags2);
   __ jcc(Assembler::zero, notVolatile);
   volatile_barrier(Assembler::Membar_mask_bits(Assembler::StoreLoad |
                                                Assembler::StoreStore));
--- a/src/share/vm/interpreter/interpreterRuntime.cpp	Fri Sep 15 13:49:06 2017 -0700
+++ b/src/share/vm/interpreter/interpreterRuntime.cpp	Mon Sep 18 10:34:11 2017 -0400
@@ -236,9 +236,9 @@
 
   // Getting Field information
   int offset = cp_entry->f2_as_index();
-  fieldDescriptor fd;
-  vklass->find_field_from_offset(offset, false, &fd);
-  Symbol* field_signature = fd.signature();
+  int field_index = cp_entry->field_index();
+  int field_offset = cp_entry->f2_as_offset();
+  Symbol* field_signature = vklass->field_signature(field_index);
   ResourceMark rm(THREAD);
   const char* signature = (const char *) field_signature->as_utf8();
   BasicType field_type = char2type(signature[0]);
@@ -264,18 +264,18 @@
   if (field_type == T_OBJECT || field_type == T_ARRAY) {
     oop aoop = *(oop*)f.interpreter_frame_expression_stack_at(tos_idx);
     assert(aoop == NULL || (oopDesc::is_oop(aoop) && (!aoop->is_value())),"argument must be a reference type");
-    new_value_h()->obj_field_put(fd.offset(), aoop);
+    new_value_h()->obj_field_put(field_offset, aoop);
   } else if (field_type == T_VALUETYPE) {
-    Klass* field_k = vklass->get_value_field_klass(fd.index());
+    Klass* field_k = vklass->get_value_field_klass(field_index);
     ValueKlass* field_vk = ValueKlass::cast(field_k);
     oop vt_oop = *(oop*)f.interpreter_frame_expression_stack_at(tos_idx);
     assert(vt_oop != NULL && oopDesc::is_oop(vt_oop) && vt_oop->is_value(),"argument must be a value type");
     assert(field_vk == vt_oop->klass(), "Must match");
     field_vk->value_store(field_vk->data_for_oop(vt_oop),
-        ((char*)(oopDesc*)new_value_h()) + fd.offset(), true, false);
+        ((char*)(oopDesc*)new_value_h()) + field_offset, true, false);
   } else {
     intptr_t* addr = f.interpreter_frame_expression_stack_at(tos_idx);
-    copy_primitive_argument(addr, new_value_h, fd.offset(), field_type);
+    copy_primitive_argument(addr, new_value_h, field_offset, field_type);
   }
 
   // returning result
@@ -330,13 +330,11 @@
   thread->set_vm_result(value);
 IRT_END
 
-IRT_ENTRY(void, InterpreterRuntime::qgetfield(JavaThread* thread, oopDesc* value, int offset))
+IRT_ENTRY(void, InterpreterRuntime::qgetfield(JavaThread* thread, oopDesc* value, int index))
   Handle value_h(THREAD, value);
   InstanceKlass* klass = InstanceKlass::cast(value->klass());
 
-  fieldDescriptor fd;
-  klass->find_field_from_offset(offset, false, &fd);
-  Klass* field_k = klass->get_value_field_klass(fd.index());
+  Klass* field_k = klass->get_value_field_klass(index);
   ValueKlass* field_vklass = ValueKlass::cast(field_k);
   field_vklass->initialize(THREAD);
 
@@ -345,19 +343,18 @@
   instanceOop res = field_vklass->allocate_buffered_or_heap_instance(&in_heap, CHECK);
   instanceHandle res_h(THREAD, res);
   // copy value
-  field_vklass->value_store(((char*)(oopDesc*)value_h()) + offset,
+  field_vklass->value_store(((char*)(oopDesc*)value_h()) + klass->field_offset(index),
                             field_vklass->data_for_oop(res), in_heap, false);
   thread->set_vm_result(res_h());
 IRT_END
 
-IRT_ENTRY(void, InterpreterRuntime::initialize_static_value_field(JavaThread* thread, oopDesc* mirror, int offset))
+IRT_ENTRY(void, InterpreterRuntime::initialize_static_value_field(JavaThread* thread, oopDesc* mirror, int index))
   instanceHandle mirror_h(THREAD, (instanceOop)mirror);
   InstanceKlass* klass = InstanceKlass::cast(java_lang_Class::as_Klass(mirror));
+  int offset = klass->field_offset(index);
   assert(mirror->obj_field(offset) == NULL,"Field must not be initialized twice");
 
-  fieldDescriptor fd;
-  klass->find_field_from_offset(offset, true, &fd);
-  Klass* field_k = klass->get_value_field_klass(fd.index());
+  Klass* field_k = klass->get_value_field_klass(index);
   ValueKlass* field_vklass = ValueKlass::cast(field_k);
   // allocate instance, because it is going to be assigned to a static field
   // it must not be a buffered value
@@ -367,48 +364,32 @@
   thread->set_vm_result(res_h());
 IRT_END
 
-IRT_ENTRY(void, InterpreterRuntime::qputfield(JavaThread* thread, oopDesc* obj, oopDesc* value, int offset))
+IRT_ENTRY(void, InterpreterRuntime::qputfield(JavaThread* thread, oopDesc* obj, oopDesc* value, int flags))
   Handle value_h(THREAD, value);
   Handle obj_h(THREAD, obj);
   assert(!obj_h()->klass()->is_value(), "obj must be an object");
   assert(value_h()->klass()->is_value(), "value must be an value type");
+  int index = flags & ConstantPoolCacheEntry::field_index_mask;
 
   InstanceKlass* klass = InstanceKlass::cast(obj->klass());
-  fieldDescriptor fd;
-  klass->find_field_from_offset(offset, false, &fd);
-  Klass* field_k = klass->get_value_field_klass(fd.index());
+  Klass* field_k = klass->get_value_field_klass(index);
   ValueKlass* field_vklass = ValueKlass::cast(value->klass());
   assert(field_k == field_vklass, "Field descriptor and argument must match");
   // copy value
   field_vklass->value_store(field_vklass->data_for_oop(value_h()),
-                            ((char*)(oopDesc*)obj_h()) + offset, true, false);
+                            ((char*)(oopDesc*)obj_h()) + klass->field_offset(index), true, false);
 IRT_END
 
-IRT_ENTRY(void, InterpreterRuntime::qputstatic(JavaThread* thread, oopDesc* value))
+IRT_ENTRY(void, InterpreterRuntime::qputstatic(JavaThread* thread, oopDesc* value, int offset, oopDesc* mirror))
   instanceHandle value_h(THREAD, (instanceOop)value);
   assert(value_h()->is_value(), "qputstatic only deals with value arguments");
-  Method* m = last_frame(thread).interpreter_frame_method();
-  jint bci = last_frame(thread).interpreter_frame_bci();
-  assert(m->code_at(bci) == Bytecodes::_putstatic, "qputstatic is a particular case of putstatic");
-  ConstantPoolCache* cp_cache = last_frame(thread).interpreter_frame_method()->constants()->cache();
-  int index = ConstantPool::decode_cpcache_index(get_index_u2_cpcache(thread, Bytecodes::_putstatic));
-  ConstantPoolCacheEntry* cp_entry = cp_cache->entry_at(index);
-  assert(cp_entry->is_field_entry(), "Sanity check");
-
-  InstanceKlass* klass = InstanceKlass::cast(cp_entry->f1_as_klass());
-  int offset = cp_entry->f2_as_index();
-  oop mirror = klass->java_mirror();
-
   if (Universe::heap()->is_in_reserved(value_h())) {
-    mirror->obj_field_put(offset, value_h());
+      mirror->obj_field_put(offset, value_h());
   } else {
     // The argument is a buffered value, a copy must be created in the Java heap
     // because a static field cannot point to a thread-local buffered value
-    fieldDescriptor fd;
-    klass->find_field_from_offset(offset, false, &fd);
-    Klass* field_k = klass->get_value_field_klass(fd.index());
-    ValueKlass* field_vklass = ValueKlass::cast(field_k);
-    assert(field_vklass == value->klass(), "Field descriptor and argument must match");
+    ValueKlass* field_vklass = ValueKlass::cast(value_h()->klass());
+    Handle mirror_h(THREAD, mirror);
     // allocate heap instance
     instanceOop res = field_vklass->allocate_instance(CHECK);
     assert(Universe::heap()->is_in_reserved(res), "Must be in the Java heap");
@@ -417,8 +398,8 @@
     field_vklass->value_store(field_vklass->data_for_oop(value_h()),
                               field_vklass->data_for_oop(res), true, false);
     // writing static field
-    mirror->obj_field_put(offset, res_h());
-    assert(mirror->obj_field(offset) != NULL,"Sanity check");
+    mirror_h->obj_field_put(offset, res_h());
+    assert(mirror_h->obj_field(offset) != NULL,"Sanity check");
   }
 IRT_END
 
--- a/src/share/vm/interpreter/interpreterRuntime.hpp	Fri Sep 15 13:49:06 2017 -0700
+++ b/src/share/vm/interpreter/interpreterRuntime.hpp	Mon Sep 18 10:34:11 2017 -0400
@@ -89,9 +89,9 @@
   static void    register_finalizer(JavaThread* thread, oopDesc* obj);
   static void    vdefault      (JavaThread* thread, ConstantPool* pool, int index);
   static int     vwithfield    (JavaThread* thread, ConstantPoolCache* cp_cache);
-  static void    qgetfield     (JavaThread* thread, oopDesc* value, int offset);
-  static void    qputfield     (JavaThread* thread, oopDesc* obj, oopDesc* value, int offset);
-  static void    qputstatic    (JavaThread* thread, oopDesc* value);
+  static void    qgetfield     (JavaThread* thread, oopDesc* value, int index);
+  static void    qputfield     (JavaThread* thread, oopDesc* obj, oopDesc* value, int flags);
+  static void    qputstatic    (JavaThread* thread, oopDesc* value, int offset, oopDesc* mirror);
   static void    initialize_static_value_field(JavaThread*, oopDesc* mirror, int offset);
 
   // Value Buffers support
--- a/src/share/vm/runtime/globals.hpp	Fri Sep 15 13:49:06 2017 -0700
+++ b/src/share/vm/runtime/globals.hpp	Mon Sep 18 10:34:11 2017 -0400
@@ -4099,7 +4099,7 @@
   product(size_t, BigValueTypeThreshold, 4 * BytesPerLong,                  \
           "Max value type size for buffering")                              \
                                                                             \
-  product(intx, ValueTypesBufferMaxMemory, 128,                             \
+  product(intx, ValueTypesBufferMaxMemory, 0,                               \
           "Max memory used for value types buffers (in pages)")             \
                                                                             \
   product(bool, ValueTypesThreadLocalRecycling, true,                       \