changeset 13181:389d40d7d99f

fixed bug in MethodData and added assertion that precomputed size == initialized size reduced diff to upstream HotSpot
author Doug Simon <doug.simon@oracle.com>
date Wed, 27 Nov 2013 02:31:03 +0100
parents feff37de4465
children 599eaf3bc4b2
files src/share/vm/graal/graalCompilerToVM.cpp src/share/vm/oops/methodData.cpp src/share/vm/oops/methodData.hpp
diffstat 3 files changed, 12 insertions(+), 24 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/vm/graal/graalCompilerToVM.cpp	Tue Nov 26 23:14:18 2013 +0100
+++ b/src/share/vm/graal/graalCompilerToVM.cpp	Wed Nov 27 02:31:03 2013 +0100
@@ -1025,7 +1025,7 @@
     method_data = MethodData::allocate(loader_data, method, CHECK);
     method->set_method_data(method_data);
   } else {
-    method_data->initialize();
+    method_data->initialize(true);
   }
 C2V_END
 
--- a/src/share/vm/oops/methodData.cpp	Tue Nov 26 23:14:18 2013 +0100
+++ b/src/share/vm/oops/methodData.cpp	Wed Nov 27 02:31:03 2013 +0100
@@ -821,8 +821,7 @@
   while ((c = stream.next()) >= 0) {
     int size_in_bytes = compute_data_size(&stream);
     data_size += size_in_bytes;
-
-    if (is_empty_data(size_in_bytes, c)) empty_bc_count += 1;
+    if (size_in_bytes == 0 GRAAL_ONLY(&& Bytecodes::can_trap(c)))  empty_bc_count += 1;
   }
   int object_size = in_bytes(data_offset()) + data_size;
 
@@ -830,7 +829,6 @@
   int extra_data_count = compute_extra_data_count(data_size, empty_bc_count);
   object_size += extra_data_count * DataLayout::compute_size_in_bytes(0);
 
-#ifndef GRAALVM
   // Add a cell to record information about modified arguments.
   int arg_size = method->size_of_parameters();
   object_size += DataLayout::compute_size_in_bytes(arg_size+1);
@@ -841,7 +839,6 @@
   if (args_cell > 0) {
     object_size += DataLayout::compute_size_in_bytes(args_cell);
   }
-#endif
   return object_size;
 }
 
@@ -1051,7 +1048,7 @@
   initialize();
 }
 
-void MethodData::initialize() {
+void MethodData::initialize(bool for_reprofile) {
   No_Safepoint_Verifier no_safepoint;  // init function atomic wrt GC
   ResourceMark rm;
 
@@ -1068,8 +1065,7 @@
   while ((c = stream.next()) >= 0) {
     int size_in_bytes = initialize_data(&stream, data_size);
     data_size += size_in_bytes;
-
-    if (is_empty_data(size_in_bytes, c)) empty_bc_count += 1;
+    if (size_in_bytes == 0 GRAAL_ONLY(&& Bytecodes::can_trap(c)))  empty_bc_count += 1;
   }
   _data_size = data_size;
   int object_size = in_bytes(data_offset()) + data_size;
@@ -1077,11 +1073,14 @@
   // Add some extra DataLayout cells (at least one) to track stray traps.
   int extra_data_count = compute_extra_data_count(data_size, empty_bc_count);
   int extra_size = extra_data_count * DataLayout::compute_size_in_bytes(0);
-  object_size += extra_size;
 
-  Copy::zero_to_bytes((HeapWord*) extra_data_base(), extra_size);
+#ifdef GRAAL
+  if (for_reprofile) {
+    // Clear out extra data
+    Copy::zero_to_bytes((HeapWord*) extra_data_base(), extra_size);
+  }
+#endif
 
-#ifndef GRAALVM
   // Add a cell to record information about modified arguments.
   // Set up _args_modified array after traps cells so that
   // the code for traps cells works.
@@ -1107,9 +1106,6 @@
   } else {
     _parameters_type_data_di = -1;
   }
-#else
-  _parameters_type_data_di = -1;
-#endif
 
   // Set an initial hint. Don't use set_hint_di() because
   // first_di() may be out of bounds if data_size is 0.
@@ -1119,6 +1115,7 @@
 
   post_initialize(&stream);
 
+  assert(object_size == compute_allocation_size_in_bytes(methodHandle(_method)), "MethodData: computed size != initialized size");
   set_size(object_size);
 }
 
@@ -1143,14 +1140,6 @@
                       sizeof(_trap_hist) / sizeof(HeapWord));
 }
 
-bool MethodData::is_empty_data(int size_in_bytes, Bytecodes::Code code) {
-#ifdef GRAAL
-  return size_in_bytes == 0 && Bytecodes::can_trap(code);
-#else
-  return size_in_bytes == 0;
-#endif
-}
-
 // Get a measure of how much mileage the method has on it.
 int MethodData::mileage_of(Method* method) {
   int mileage = 0;
--- a/src/share/vm/oops/methodData.hpp	Tue Nov 26 23:14:18 2013 +0100
+++ b/src/share/vm/oops/methodData.hpp	Wed Nov 27 02:31:03 2013 +0100
@@ -1896,7 +1896,7 @@
   MethodData() {}; // For ciMethodData
 
   bool is_methodData() const volatile { return true; }
-  void initialize();
+  void initialize(bool for_reprofile = false);
 
   // Whole-method sticky bits and flags
   enum {
@@ -2103,7 +2103,6 @@
 
   bool is_mature() const;  // consult mileage and ProfileMaturityPercentage
   static int mileage_of(Method* m);
-  static bool is_empty_data(int size, Bytecodes::Code code);
 
   // Support for interprocedural escape analysis, from Thomas Kotzmann.
   enum EscapeFlag {