changeset 13018:b03e14ea3e9b mvt

Fix and cleanup in vwithfield
author fparain
date Wed, 07 Jun 2017 15:38:35 -0400
parents 0767f26001f2
children e31f5c06438d
files src/share/vm/interpreter/interpreterRuntime.cpp
diffstat 1 files changed, 12 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/vm/interpreter/interpreterRuntime.cpp	Tue Jun 06 12:40:13 2017 +0100
+++ b/src/share/vm/interpreter/interpreterRuntime.cpp	Wed Jun 07 15:38:35 2017 -0400
@@ -244,11 +244,11 @@
   BasicType field_type = char2type(signature[0]);
 
   // Getting old value
-  intptr_t* arg = last_frame(thread).sp();
-  int offset2 = type2size[field_type];
-  oop old_value = *(oop*)(&arg[type2size[field_type]]);
-  int arg_size = (type2size[field_type]) * AbstractInterpreter::stackElementSize;
-  assert(old_value->is_oop(),"Verify pointer arithmetic above is correct");
+  frame f = last_frame(thread);
+  jint tos_idx = f.interpreter_frame_expression_stack_size() - 1;
+  int vt_offset = type2size[field_type];
+  oop old_value = *(oop*)f.interpreter_frame_expression_stack_at(tos_idx - vt_offset);
+  assert(old_value != NULL && old_value->is_oop() && old_value->is_value(),"Verifying receiver");
   Handle old_value_h(THREAD, old_value);
 
   // Creating new value by copying the one passed in argument
@@ -260,24 +260,25 @@
 
   // Updating the field specified in arguments
   if (field_type == T_OBJECT || field_type == T_ARRAY) {
-    oop aoop = *((oop*)arg);
-    assert(aoop == NULL || (aoop->is_oop() && (!aoop->is_value())),"value type argument should be oop");
+    oop aoop = *(oop*)f.interpreter_frame_expression_stack_at(tos_idx);
+    assert(aoop == NULL || (aoop->is_oop() && (!aoop->is_value())),"argument must be a reference type");
     new_value_h()->obj_field_put(fd.offset(), aoop);
   } else if (field_type == T_VALUETYPE) {
     Klass* field_k = vklass->get_value_field_klass(fd.index());
     ValueKlass* field_vk = ValueKlass::cast(field_k);
-    oop vt_oop = *(oop*)arg;
-    assert(vt_oop->is_oop(),"value type argument should be oop");
+    oop vt_oop = *(oop*)f.interpreter_frame_expression_stack_at(tos_idx);
+    assert(vt_oop != NULL && vt_oop->is_oop() && vt_oop->is_value(),"argument must be a value type");
     assert(field_vk == vt_oop->klass(), "Must match");
     field_vk->value_store(((char*)(oopDesc*)vt_oop + field_vk->first_field_offset()),
             ((char*)(oopDesc*)new_value_h()) + fd.offset(), true, false);
   } else {
-    copy_primitive_argument(arg, new_value_h, fd.offset(), field_type);
+    intptr_t* addr = f.interpreter_frame_expression_stack_at(tos_idx);
+    copy_primitive_argument(addr, new_value_h, fd.offset(), field_type);
   }
 
   // returning result
   thread->set_vm_result(new_value_h());
-  return arg_size;
+  return (type2size[field_type] + type2size[T_VALUETYPE]) * AbstractInterpreter::stackElementSize;
 IRT_END
 
 IRT_ENTRY(void, InterpreterRuntime::vbox(JavaThread* thread, ConstantPool* pool, int index, oopDesc* value))