src/hotspot/share/classfile/bytecodeAssembler.cpp
author lfoltan
Mon, 21 Oct 2019 13:13:16 -0400
changeset 58722 cba8afa5cfed
parent 58273 08a5148e7c4e
child 59056 15936b142f86
permissions -rw-r--r--
8231844: Enhance type signature characters in classfile_constants.h and improve the JVM to use type signature characters more consistently Summary: Increase the use of type signature constants instead of hard coded characters within the JVM. Reviewed-by: coleenp, dholmes, fparain Contributed-by: lois.foltan@oracle.com, john.r.rose@oracle.com
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
14385
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
     1
/*
58273
08a5148e7c4e 8230505: Replace JVM type comparisons to T_OBJECT and T_ARRAY with call to is_reference_type
lfoltan
parents: 49380
diff changeset
     2
 * Copyright (c) 2012, 2019, Oracle and/or its affiliates. All rights reserved.
14385
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
     4
 *
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
     7
 * published by the Free Software Foundation.
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
     8
 *
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    13
 * accompanied this code).
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    14
 *
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    18
 *
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    21
 * questions.
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    22
 *
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    23
 */
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    24
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    25
#include "precompiled.hpp"
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    26
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    27
#include "classfile/bytecodeAssembler.hpp"
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    28
#include "interpreter/bytecodes.hpp"
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    29
#include "memory/oopFactory.hpp"
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    30
#include "oops/constantPool.hpp"
49361
1956d0ec092a 8199319: Remove handles.inline.hpp include from reflectionUtils.hpp
stefank
parents: 47216
diff changeset
    31
#include "runtime/handles.inline.hpp"
25715
d5a8dbdc5150 8049325: Introduce and clean up umbrella headers for the files in the cpu subdirectories.
goetz
parents: 22234
diff changeset
    32
#include "utilities/bytes.hpp"
14385
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    33
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    34
u2 BytecodeConstantPool::find_or_add(BytecodeCPEntry const& bcpe) {
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    35
  u2 index;
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    36
  u2* probe = _indices.get(bcpe);
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    37
  if (probe == NULL) {
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    38
    index = _entries.length();
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    39
    _entries.append(bcpe);
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    40
    _indices.put(bcpe, index);
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    41
  } else {
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    42
    index = *probe;
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    43
  }
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    44
  return index + _orig->length();
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    45
}
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    46
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    47
ConstantPool* BytecodeConstantPool::create_constant_pool(TRAPS) const {
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    48
  if (_entries.length() == 0) {
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    49
    return _orig;
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    50
  }
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    51
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    52
  ConstantPool* cp = ConstantPool::allocate(
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    53
      _orig->pool_holder()->class_loader_data(),
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    54
      _orig->length() + _entries.length(), CHECK_NULL);
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    55
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    56
  cp->set_pool_holder(_orig->pool_holder());
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    57
  _orig->copy_cp_to(1, _orig->length() - 1, cp, 1, CHECK_NULL);
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    58
49380
74518f9ca4b4 8199342: The constant pool forgets it has a Dynamic entry if there are overpass methods
psandoz
parents: 49361
diff changeset
    59
  // Preserve dynamic constant information from the original pool
74518f9ca4b4 8199342: The constant pool forgets it has a Dynamic entry if there are overpass methods
psandoz
parents: 49361
diff changeset
    60
  if (_orig->has_dynamic_constant()) {
74518f9ca4b4 8199342: The constant pool forgets it has a Dynamic entry if there are overpass methods
psandoz
parents: 49361
diff changeset
    61
    cp->set_has_dynamic_constant();
74518f9ca4b4 8199342: The constant pool forgets it has a Dynamic entry if there are overpass methods
psandoz
parents: 49361
diff changeset
    62
  }
74518f9ca4b4 8199342: The constant pool forgets it has a Dynamic entry if there are overpass methods
psandoz
parents: 49361
diff changeset
    63
14385
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    64
  for (int i = 0; i < _entries.length(); ++i) {
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    65
    BytecodeCPEntry entry = _entries.at(i);
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    66
    int idx = i + _orig->length();
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    67
    switch (entry._tag) {
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    68
      case BytecodeCPEntry::UTF8:
17304
436c6e158ce5 8010783: assert(s->refcount() != 0) failed: for create_overpasses
acorn
parents: 14385
diff changeset
    69
        entry._u.utf8->increment_refcount();
14385
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    70
        cp->symbol_at_put(idx, entry._u.utf8);
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    71
        break;
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    72
      case BytecodeCPEntry::KLASS:
46427
54713555867e 8171392: Move Klass pointers outside of ConstantPool entries so ConstantPool can be read-only
iklam
parents: 25715
diff changeset
    73
        cp->klass_index_at_put(
54713555867e 8171392: Move Klass pointers outside of ConstantPool entries so ConstantPool can be read-only
iklam
parents: 25715
diff changeset
    74
            idx, entry._u.klass);
14385
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    75
        break;
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    76
      case BytecodeCPEntry::STRING:
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    77
        cp->unresolved_string_at_put(
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    78
            idx, cp->symbol_at(entry._u.string));
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    79
        break;
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    80
      case BytecodeCPEntry::NAME_AND_TYPE:
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    81
        cp->name_and_type_at_put(idx,
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    82
            entry._u.name_and_type.name_index,
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    83
            entry._u.name_and_type.type_index);
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    84
        break;
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    85
      case BytecodeCPEntry::METHODREF:
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    86
        cp->method_at_put(idx,
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    87
            entry._u.methodref.class_index,
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    88
            entry._u.methodref.name_and_type_index);
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    89
        break;
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    90
      default:
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    91
        ShouldNotReachHere();
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    92
    }
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    93
  }
46427
54713555867e 8171392: Move Klass pointers outside of ConstantPool entries so ConstantPool can be read-only
iklam
parents: 25715
diff changeset
    94
54713555867e 8171392: Move Klass pointers outside of ConstantPool entries so ConstantPool can be read-only
iklam
parents: 25715
diff changeset
    95
  cp->initialize_unresolved_klasses(_orig->pool_holder()->class_loader_data(),
54713555867e 8171392: Move Klass pointers outside of ConstantPool entries so ConstantPool can be read-only
iklam
parents: 25715
diff changeset
    96
                                    CHECK_NULL);
14385
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    97
  return cp;
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    98
}
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    99
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   100
void BytecodeAssembler::append(u1 imm_u1) {
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   101
  _code->append(imm_u1);
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   102
}
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   103
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   104
void BytecodeAssembler::append(u2 imm_u2) {
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   105
  _code->append(0);
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   106
  _code->append(0);
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   107
  Bytes::put_Java_u2(_code->adr_at(_code->length() - 2), imm_u2);
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   108
}
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   109
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   110
void BytecodeAssembler::append(u4 imm_u4) {
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   111
  _code->append(0);
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   112
  _code->append(0);
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   113
  _code->append(0);
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   114
  _code->append(0);
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   115
  Bytes::put_Java_u4(_code->adr_at(_code->length() - 4), imm_u4);
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   116
}
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   117
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   118
void BytecodeAssembler::xload(u4 index, u1 onebyteop, u1 twobyteop) {
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   119
  if (index < 4) {
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   120
    _code->append(onebyteop + index);
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   121
  } else {
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   122
    _code->append(twobyteop);
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   123
    _code->append((u2)index);
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   124
  }
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   125
}
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   126
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   127
void BytecodeAssembler::dup() {
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   128
  _code->append(Bytecodes::_dup);
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   129
}
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   130
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   131
void BytecodeAssembler::_new(Symbol* sym) {
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   132
  u2 cpool_index = _cp->klass(sym);
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   133
  _code->append(Bytecodes::_new);
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   134
  append(cpool_index);
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   135
}
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   136
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   137
void BytecodeAssembler::load_string(Symbol* sym) {
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   138
  u2 cpool_index = _cp->string(sym);
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   139
  if (cpool_index < 0x100) {
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   140
    ldc(cpool_index);
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   141
  } else {
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   142
    ldc_w(cpool_index);
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   143
  }
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   144
}
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   145
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   146
void BytecodeAssembler::ldc(u1 index) {
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   147
  _code->append(Bytecodes::_ldc);
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   148
  append(index);
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   149
}
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   150
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   151
void BytecodeAssembler::ldc_w(u2 index) {
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   152
  _code->append(Bytecodes::_ldc_w);
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   153
  append(index);
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   154
}
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   155
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   156
void BytecodeAssembler::athrow() {
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   157
  _code->append(Bytecodes::_athrow);
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   158
}
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   159
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   160
void BytecodeAssembler::iload(u4 index) {
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   161
  xload(index, Bytecodes::_iload_0, Bytecodes::_iload);
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   162
}
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   163
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   164
void BytecodeAssembler::lload(u4 index) {
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   165
  xload(index, Bytecodes::_lload_0, Bytecodes::_lload);
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   166
}
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   167
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   168
void BytecodeAssembler::fload(u4 index) {
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   169
  xload(index, Bytecodes::_fload_0, Bytecodes::_fload);
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   170
}
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   171
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   172
void BytecodeAssembler::dload(u4 index) {
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   173
  xload(index, Bytecodes::_dload_0, Bytecodes::_dload);
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   174
}
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   175
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   176
void BytecodeAssembler::aload(u4 index) {
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   177
  xload(index, Bytecodes::_aload_0, Bytecodes::_aload);
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   178
}
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   179
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   180
void BytecodeAssembler::load(BasicType bt, u4 index) {
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   181
  switch (bt) {
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   182
    case T_BOOLEAN:
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   183
    case T_CHAR:
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   184
    case T_BYTE:
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   185
    case T_SHORT:
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   186
    case T_INT:     iload(index); break;
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   187
    case T_FLOAT:   fload(index); break;
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   188
    case T_DOUBLE:  dload(index); break;
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   189
    case T_LONG:    lload(index); break;
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   190
    default:
58273
08a5148e7c4e 8230505: Replace JVM type comparisons to T_OBJECT and T_ARRAY with call to is_reference_type
lfoltan
parents: 49380
diff changeset
   191
      if (is_reference_type(bt)) {
08a5148e7c4e 8230505: Replace JVM type comparisons to T_OBJECT and T_ARRAY with call to is_reference_type
lfoltan
parents: 49380
diff changeset
   192
                    aload(index);
08a5148e7c4e 8230505: Replace JVM type comparisons to T_OBJECT and T_ARRAY with call to is_reference_type
lfoltan
parents: 49380
diff changeset
   193
                    break;
08a5148e7c4e 8230505: Replace JVM type comparisons to T_OBJECT and T_ARRAY with call to is_reference_type
lfoltan
parents: 49380
diff changeset
   194
      }
14385
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   195
      ShouldNotReachHere();
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   196
  }
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   197
}
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   198
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   199
void BytecodeAssembler::checkcast(Symbol* sym) {
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   200
  u2 cpool_index = _cp->klass(sym);
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   201
  _code->append(Bytecodes::_checkcast);
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   202
  append(cpool_index);
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   203
}
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   204
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   205
void BytecodeAssembler::invokespecial(Method* method) {
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   206
  invokespecial(method->klass_name(), method->name(), method->signature());
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   207
}
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   208
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   209
void BytecodeAssembler::invokespecial(Symbol* klss, Symbol* name, Symbol* sig) {
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   210
  u2 methodref_index = _cp->methodref(klss, name, sig);
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   211
  _code->append(Bytecodes::_invokespecial);
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   212
  append(methodref_index);
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   213
}
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   214
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   215
void BytecodeAssembler::invokevirtual(Method* method) {
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   216
  invokevirtual(method->klass_name(), method->name(), method->signature());
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   217
}
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   218
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   219
void BytecodeAssembler::invokevirtual(Symbol* klss, Symbol* name, Symbol* sig) {
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   220
  u2 methodref_index = _cp->methodref(klss, name, sig);
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   221
  _code->append(Bytecodes::_invokevirtual);
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   222
  append(methodref_index);
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   223
}
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   224
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   225
void BytecodeAssembler::ireturn() {
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   226
  _code->append(Bytecodes::_ireturn);
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   227
}
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   228
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   229
void BytecodeAssembler::lreturn() {
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   230
  _code->append(Bytecodes::_lreturn);
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   231
}
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   232
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   233
void BytecodeAssembler::freturn() {
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   234
  _code->append(Bytecodes::_freturn);
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   235
}
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   236
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   237
void BytecodeAssembler::dreturn() {
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   238
  _code->append(Bytecodes::_dreturn);
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   239
}
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   240
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   241
void BytecodeAssembler::areturn() {
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   242
  _code->append(Bytecodes::_areturn);
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   243
}
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   244
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   245
void BytecodeAssembler::_return() {
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   246
  _code->append(Bytecodes::_return);
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   247
}
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   248
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   249
void BytecodeAssembler::_return(BasicType bt) {
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   250
  switch (bt) {
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   251
    case T_BOOLEAN:
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   252
    case T_CHAR:
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   253
    case T_BYTE:
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   254
    case T_SHORT:
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   255
    case T_INT:     ireturn(); break;
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   256
    case T_FLOAT:   freturn(); break;
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   257
    case T_DOUBLE:  dreturn(); break;
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   258
    case T_LONG:    lreturn(); break;
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   259
    case T_VOID:    _return(); break;
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   260
    default:
58273
08a5148e7c4e 8230505: Replace JVM type comparisons to T_OBJECT and T_ARRAY with call to is_reference_type
lfoltan
parents: 49380
diff changeset
   261
      if (is_reference_type(bt)) {
08a5148e7c4e 8230505: Replace JVM type comparisons to T_OBJECT and T_ARRAY with call to is_reference_type
lfoltan
parents: 49380
diff changeset
   262
                    areturn();
08a5148e7c4e 8230505: Replace JVM type comparisons to T_OBJECT and T_ARRAY with call to is_reference_type
lfoltan
parents: 49380
diff changeset
   263
                    break;
08a5148e7c4e 8230505: Replace JVM type comparisons to T_OBJECT and T_ARRAY with call to is_reference_type
lfoltan
parents: 49380
diff changeset
   264
      }
14385
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   265
      ShouldNotReachHere();
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   266
  }
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   267
}