< prev index next >

src/share/vm/ci/ciValueKlass.cpp

Print this page




  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "ci/ciField.hpp"
  27 #include "ci/ciValueKlass.hpp"
  28 #include "oops/fieldStreams.hpp"
  29 #include "oops/valueKlass.hpp"
  30 
  31 int ciValueKlass::compute_field_index_map() {
  32   assert(is_loaded(), "value class must be loaded to compute mapping of field indeces");
  33 
  34   if (_field_index_map != NULL) {
  35     return _field_index_map->length();
  36   }
  37 
  38   Arena* arena = CURRENT_ENV->arena();
  39   guarantee(has_nonstatic_fields(), "value types without fields currently not supported");



  40 
  41   // FIXME: Once it is possible to construct class hierarchies with value types.
  42   assert(!super()->has_nonstatic_fields(), "a value type must not inherit fields from its superclass");
  43 
  44   _field_index_map = new (arena) GrowableArray<int>(arena, nof_declared_nonstatic_fields(), 0, 0);
  45   ValueKlass* vklass = ValueKlass::cast(get_Klass());
  46   for (JavaFieldStream fs(vklass); !fs.done(); fs.next()) {
  47     if (fs.access_flags().is_static()) {
  48       continue;
  49     }
  50     _field_index_map->append(fs.field_descriptor().index());
  51   }
  52   return _field_index_map->length();
  53 }
  54 
  55 // Number of value type fields
  56 int ciValueKlass::field_count() {
  57   if (this == ciEnv::current()->___Value_klass()) {
  58     return 0;
  59   }
  60   if (_field_index_map == NULL) {
  61     return compute_field_index_map();
  62   } else {
  63     return _field_index_map->length();
  64   }
  65 }
  66 
  67 // Size of value type fields in words
  68 int ciValueKlass::field_size() {
  69   int size = 0;
  70   for (int i = 0; i < field_count(); ++i) {
  71     size += field_type_by_index(i)->size();
  72   }
  73   return size;
  74 }
  75 
  76 // Returns the index of the field with the given offset. If the field at 'offset'
  77 // belongs to a flattened value type field, return the index of the field
  78 // in the flattened value type.
  79 int ciValueKlass::field_index_by_offset(int offset) {




  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "ci/ciField.hpp"
  27 #include "ci/ciValueKlass.hpp"
  28 #include "oops/fieldStreams.hpp"
  29 #include "oops/valueKlass.hpp"
  30 
  31 int ciValueKlass::compute_field_index_map() {
  32   assert(is_loaded(), "value class must be loaded to compute mapping of field indeces");
  33 
  34   if (_field_index_map != NULL) {
  35     return _field_index_map->length();
  36   }
  37 
  38   Arena* arena = CURRENT_ENV->arena();
  39   _field_index_map = new (arena) GrowableArray<int>(arena, nof_declared_nonstatic_fields(), 0, 0);
  40   if (!has_nonstatic_fields()) {
  41     return 0;
  42   }
  43 
  44   // FIXME: Once it is possible to construct class hierarchies with value types.
  45   assert(!super()->has_nonstatic_fields(), "a value type must not inherit fields from its superclass");
  46 

  47   ValueKlass* vklass = ValueKlass::cast(get_Klass());
  48   for (JavaFieldStream fs(vklass); !fs.done(); fs.next()) {
  49     if (fs.access_flags().is_static()) {
  50       continue;
  51     }
  52     _field_index_map->append(fs.field_descriptor().index());
  53   }
  54   return _field_index_map->length();
  55 }
  56 
  57 // Number of value type fields
  58 int ciValueKlass::field_count() {



  59   if (_field_index_map == NULL) {
  60     return compute_field_index_map();
  61   } else {
  62     return _field_index_map->length();
  63   }
  64 }
  65 
  66 // Size of value type fields in words
  67 int ciValueKlass::field_size() {
  68   int size = 0;
  69   for (int i = 0; i < field_count(); ++i) {
  70     size += field_type_by_index(i)->size();
  71   }
  72   return size;
  73 }
  74 
  75 // Returns the index of the field with the given offset. If the field at 'offset'
  76 // belongs to a flattened value type field, return the index of the field
  77 // in the flattened value type.
  78 int ciValueKlass::field_index_by_offset(int offset) {


< prev index next >