src/share/vm/classfile/bytecodeAssembler.cpp

Print this page




  33 u2 BytecodeConstantPool::find_or_add(BytecodeCPEntry const& bcpe) {
  34   u2 index;
  35   u2* probe = _indices.get(bcpe);
  36   if (probe == NULL) {
  37     index = _entries.length();
  38     _entries.append(bcpe);
  39     _indices.put(bcpe, index);
  40   } else {
  41     index = *probe;
  42   }
  43   return index + _orig->length();
  44 }
  45 
  46 ConstantPool* BytecodeConstantPool::create_constant_pool(TRAPS) const {
  47   if (_entries.length() == 0) {
  48     return _orig;
  49   }
  50 
  51   ConstantPool* cp = ConstantPool::allocate(
  52       _orig->pool_holder()->class_loader_data(),
  53       _orig->length() + _entries.length(), CHECK_NULL);
  54 
  55   cp->set_pool_holder(_orig->pool_holder());
  56   _orig->copy_cp_to(1, _orig->length() - 1, cp, 1, CHECK_NULL);
  57 
  58   for (int i = 0; i < _entries.length(); ++i) {
  59     BytecodeCPEntry entry = _entries.at(i);
  60     int idx = i + _orig->length();
  61     switch (entry._tag) {
  62       case BytecodeCPEntry::UTF8:
  63         entry._u.utf8->increment_refcount();
  64         cp->symbol_at_put(idx, entry._u.utf8);
  65         break;
  66       case BytecodeCPEntry::KLASS:
  67         cp->unresolved_klass_at_put(
  68             idx, cp->symbol_at(entry._u.klass));
  69         break;
  70       case BytecodeCPEntry::STRING:
  71         cp->unresolved_string_at_put(
  72             idx, cp->symbol_at(entry._u.string));
  73         break;




  33 u2 BytecodeConstantPool::find_or_add(BytecodeCPEntry const& bcpe) {
  34   u2 index;
  35   u2* probe = _indices.get(bcpe);
  36   if (probe == NULL) {
  37     index = _entries.length();
  38     _entries.append(bcpe);
  39     _indices.put(bcpe, index);
  40   } else {
  41     index = *probe;
  42   }
  43   return index + _orig->length();
  44 }
  45 
  46 ConstantPool* BytecodeConstantPool::create_constant_pool(TRAPS) const {
  47   if (_entries.length() == 0) {
  48     return _orig;
  49   }
  50 
  51   ConstantPool* cp = ConstantPool::allocate(
  52       _orig->pool_holder()->class_loader_data(),
  53       _orig->length() + _entries.length(), _orig->patched(), CHECK_NULL);
  54 
  55   cp->set_pool_holder(_orig->pool_holder());
  56   _orig->copy_cp_to(1, _orig->length() - 1, cp, 1, CHECK_NULL);
  57 
  58   for (int i = 0; i < _entries.length(); ++i) {
  59     BytecodeCPEntry entry = _entries.at(i);
  60     int idx = i + _orig->length();
  61     switch (entry._tag) {
  62       case BytecodeCPEntry::UTF8:
  63         entry._u.utf8->increment_refcount();
  64         cp->symbol_at_put(idx, entry._u.utf8);
  65         break;
  66       case BytecodeCPEntry::KLASS:
  67         cp->unresolved_klass_at_put(
  68             idx, cp->symbol_at(entry._u.klass));
  69         break;
  70       case BytecodeCPEntry::STRING:
  71         cp->unresolved_string_at_put(
  72             idx, cp->symbol_at(entry._u.string));
  73         break;