# HG changeset patch # User Christian Haeubl # Date 1328925575 28800 # Node ID 8e1d9c27989a97f965cf1d8a0667d609bf585f3d # Parent 716fa6564c5511734f46b954753beee5d829343b better allocation of methodData's extraData so that exceptions and deoptimizations can be recorded more accurately diff -r 716fa6564c55 -r 8e1d9c27989a src/share/vm/oops/methodDataOop.cpp --- a/src/share/vm/oops/methodDataOop.cpp Fri Feb 10 17:03:51 2012 -0800 +++ b/src/share/vm/oops/methodDataOop.cpp Fri Feb 10 17:59:35 2012 -0800 @@ -555,6 +555,14 @@ return DataLayout::compute_size_in_bytes(cell_count); } +#ifdef GRAAL +int methodDataOopDesc::compute_extra_data_count(int data_size, int empty_bc_count) { + if (!ProfileTraps) return 0; + + // Assume that up to 30% of the possibly trapping BCIs with no MDP will need to allocate one. + return MIN2(empty_bc_count, MAX2(4, (empty_bc_count * 30) / 100)); +} +#else int methodDataOopDesc::compute_extra_data_count(int data_size, int empty_bc_count) { if (ProfileTraps) { // Assume that up to 3% of BCIs with no MDP will need to allocate one. @@ -571,6 +579,7 @@ return 0; } } +#endif // Compute the size of the methodDataOop necessary to store // profiling information about a given method. Size is in bytes. @@ -582,7 +591,8 @@ while ((c = stream.next()) >= 0) { int size_in_bytes = compute_data_size(&stream); data_size += size_in_bytes; - if (size_in_bytes == 0) empty_bc_count += 1; + + if (is_empty_data(size_in_bytes, c)) empty_bc_count++; } int object_size = in_bytes(data_offset()) + data_size; @@ -590,9 +600,11 @@ 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 GRAAL // 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); +#endif return object_size; } @@ -781,7 +793,8 @@ while ((c = stream.next()) >= 0) { int size_in_bytes = initialize_data(&stream, data_size); data_size += size_in_bytes; - if (size_in_bytes == 0) empty_bc_count += 1; + + if (is_empty_data(size_in_bytes, c)) empty_bc_count++; } _data_size = data_size; int object_size = in_bytes(data_offset()) + data_size; @@ -789,7 +802,9 @@ // 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; +#ifndef GRAAL // 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. @@ -798,7 +813,8 @@ int arg_size = method->size_of_parameters(); dp->initialize(DataLayout::arg_info_data_tag, 0, arg_size+1); - object_size += extra_size + DataLayout::compute_size_in_bytes(arg_size+1); + object_size += DataLayout::compute_size_in_bytes(arg_size+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. @@ -811,6 +827,14 @@ set_object_is_parsable(object_size); } +bool methodDataOopDesc::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 methodDataOopDesc::mileage_of(methodOop method) { int mileage = 0; diff -r 716fa6564c55 -r 8e1d9c27989a src/share/vm/oops/methodDataOop.hpp --- a/src/share/vm/oops/methodDataOop.hpp Fri Feb 10 17:03:51 2012 -0800 +++ b/src/share/vm/oops/methodDataOop.hpp Fri Feb 10 17:59:35 2012 -0800 @@ -1386,6 +1386,7 @@ bool is_mature() const; // consult mileage and ProfileMaturityPercentage static int mileage_of(methodOop m); + static bool is_empty_data(int size, Bytecodes::Code code); // Support for interprocedural escape analysis, from Thomas Kotzmann. enum EscapeFlag {