hotspot/src/share/vm/classfile/bytecodeAssembler.cpp
author mchung
Tue, 24 Nov 2015 14:59:17 -0800
changeset 34280 72bfaaffee36
parent 25715 d5a8dbdc5150
child 46427 54713555867e
permissions -rw-r--r--
8143911: Reintegrate JEP 259: Stack-Walking API Reviewed-by: coleenp, dfuchs, bchristi, psandoz, sspitsyn Contributed-by: Mandy Chung <mandy.chung@oracle.com>, Brent Christian <brent.christian@oracle.com>, Daniel Fuchs <daniel.fuchs@oracle.com>, Hamlin Li <huaming.li@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
/*
25715
d5a8dbdc5150 8049325: Introduce and clean up umbrella headers for the files in the cpu subdirectories.
goetz
parents: 22234
diff changeset
     2
 * Copyright (c) 2012, 2014, 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"
25715
d5a8dbdc5150 8049325: Introduce and clean up umbrella headers for the files in the cpu subdirectories.
goetz
parents: 22234
diff changeset
    31
#include "utilities/bytes.hpp"
14385
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    32
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    33
u2 BytecodeConstantPool::find_or_add(BytecodeCPEntry const& bcpe) {
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    34
  u2 index;
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    35
  u2* probe = _indices.get(bcpe);
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    36
  if (probe == NULL) {
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    37
    index = _entries.length();
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    38
    _entries.append(bcpe);
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    39
    _indices.put(bcpe, index);
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    40
  } else {
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    41
    index = *probe;
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    42
  }
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    43
  return index + _orig->length();
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    44
}
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    45
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    46
ConstantPool* BytecodeConstantPool::create_constant_pool(TRAPS) const {
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    47
  if (_entries.length() == 0) {
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    48
    return _orig;
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    49
  }
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    50
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    51
  ConstantPool* cp = ConstantPool::allocate(
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    52
      _orig->pool_holder()->class_loader_data(),
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    53
      _orig->length() + _entries.length(), CHECK_NULL);
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    54
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    55
  cp->set_pool_holder(_orig->pool_holder());
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    56
  _orig->copy_cp_to(1, _orig->length() - 1, cp, 1, CHECK_NULL);
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    57
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    58
  for (int i = 0; i < _entries.length(); ++i) {
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    59
    BytecodeCPEntry entry = _entries.at(i);
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    60
    int idx = i + _orig->length();
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    61
    switch (entry._tag) {
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    62
      case BytecodeCPEntry::UTF8:
17304
436c6e158ce5 8010783: assert(s->refcount() != 0) failed: for create_overpasses
acorn
parents: 14385
diff changeset
    63
        entry._u.utf8->increment_refcount();
14385
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    64
        cp->symbol_at_put(idx, entry._u.utf8);
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    65
        break;
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    66
      case BytecodeCPEntry::KLASS:
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    67
        cp->unresolved_klass_at_put(
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    68
            idx, cp->symbol_at(entry._u.klass));
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    69
        break;
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    70
      case BytecodeCPEntry::STRING:
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    71
        cp->unresolved_string_at_put(
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    72
            idx, cp->symbol_at(entry._u.string));
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    73
        break;
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    74
      case BytecodeCPEntry::NAME_AND_TYPE:
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    75
        cp->name_and_type_at_put(idx,
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    76
            entry._u.name_and_type.name_index,
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    77
            entry._u.name_and_type.type_index);
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    78
        break;
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    79
      case BytecodeCPEntry::METHODREF:
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    80
        cp->method_at_put(idx,
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    81
            entry._u.methodref.class_index,
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    82
            entry._u.methodref.name_and_type_index);
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    83
        break;
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    84
      default:
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    85
        ShouldNotReachHere();
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    86
    }
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    87
  }
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    88
  return cp;
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    89
}
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    90
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    91
void BytecodeAssembler::append(u1 imm_u1) {
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    92
  _code->append(imm_u1);
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    93
}
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    94
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    95
void BytecodeAssembler::append(u2 imm_u2) {
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    96
  _code->append(0);
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    97
  _code->append(0);
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    98
  Bytes::put_Java_u2(_code->adr_at(_code->length() - 2), imm_u2);
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    99
}
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   100
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   101
void BytecodeAssembler::append(u4 imm_u4) {
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   102
  _code->append(0);
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   103
  _code->append(0);
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   104
  _code->append(0);
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
  Bytes::put_Java_u4(_code->adr_at(_code->length() - 4), imm_u4);
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   107
}
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   108
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   109
void BytecodeAssembler::xload(u4 index, u1 onebyteop, u1 twobyteop) {
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   110
  if (index < 4) {
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   111
    _code->append(onebyteop + index);
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   112
  } else {
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   113
    _code->append(twobyteop);
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   114
    _code->append((u2)index);
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   115
  }
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::dup() {
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   119
  _code->append(Bytecodes::_dup);
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   120
}
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   121
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   122
void BytecodeAssembler::_new(Symbol* sym) {
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   123
  u2 cpool_index = _cp->klass(sym);
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   124
  _code->append(Bytecodes::_new);
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   125
  append(cpool_index);
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   126
}
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   127
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   128
void BytecodeAssembler::load_string(Symbol* sym) {
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   129
  u2 cpool_index = _cp->string(sym);
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   130
  if (cpool_index < 0x100) {
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   131
    ldc(cpool_index);
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   132
  } else {
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   133
    ldc_w(cpool_index);
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   134
  }
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::ldc(u1 index) {
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   138
  _code->append(Bytecodes::_ldc);
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   139
  append(index);
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   140
}
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   141
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   142
void BytecodeAssembler::ldc_w(u2 index) {
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   143
  _code->append(Bytecodes::_ldc_w);
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   144
  append(index);
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   145
}
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   146
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   147
void BytecodeAssembler::athrow() {
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   148
  _code->append(Bytecodes::_athrow);
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::iload(u4 index) {
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   152
  xload(index, Bytecodes::_iload_0, Bytecodes::_iload);
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   153
}
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   154
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   155
void BytecodeAssembler::lload(u4 index) {
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   156
  xload(index, Bytecodes::_lload_0, Bytecodes::_lload);
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   157
}
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   158
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   159
void BytecodeAssembler::fload(u4 index) {
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   160
  xload(index, Bytecodes::_fload_0, Bytecodes::_fload);
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   161
}
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   162
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   163
void BytecodeAssembler::dload(u4 index) {
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   164
  xload(index, Bytecodes::_dload_0, Bytecodes::_dload);
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   165
}
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   166
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   167
void BytecodeAssembler::aload(u4 index) {
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   168
  xload(index, Bytecodes::_aload_0, Bytecodes::_aload);
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   169
}
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   170
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   171
void BytecodeAssembler::load(BasicType bt, u4 index) {
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   172
  switch (bt) {
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   173
    case T_BOOLEAN:
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   174
    case T_CHAR:
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   175
    case T_BYTE:
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   176
    case T_SHORT:
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   177
    case T_INT:     iload(index); break;
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   178
    case T_FLOAT:   fload(index); break;
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   179
    case T_DOUBLE:  dload(index); break;
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   180
    case T_LONG:    lload(index); break;
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   181
    case T_OBJECT:
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   182
    case T_ARRAY:   aload(index); break;
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   183
    default:
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   184
      ShouldNotReachHere();
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   185
  }
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   186
}
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   187
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   188
void BytecodeAssembler::checkcast(Symbol* sym) {
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   189
  u2 cpool_index = _cp->klass(sym);
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   190
  _code->append(Bytecodes::_checkcast);
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   191
  append(cpool_index);
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   192
}
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   193
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   194
void BytecodeAssembler::invokespecial(Method* method) {
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   195
  invokespecial(method->klass_name(), method->name(), method->signature());
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
void BytecodeAssembler::invokespecial(Symbol* klss, Symbol* name, Symbol* sig) {
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   199
  u2 methodref_index = _cp->methodref(klss, name, sig);
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   200
  _code->append(Bytecodes::_invokespecial);
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   201
  append(methodref_index);
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   202
}
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   203
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   204
void BytecodeAssembler::invokevirtual(Method* method) {
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   205
  invokevirtual(method->klass_name(), method->name(), method->signature());
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   206
}
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   207
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   208
void BytecodeAssembler::invokevirtual(Symbol* klss, Symbol* name, Symbol* sig) {
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   209
  u2 methodref_index = _cp->methodref(klss, name, sig);
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   210
  _code->append(Bytecodes::_invokevirtual);
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   211
  append(methodref_index);
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   212
}
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   213
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   214
void BytecodeAssembler::ireturn() {
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   215
  _code->append(Bytecodes::_ireturn);
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   216
}
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   217
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   218
void BytecodeAssembler::lreturn() {
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   219
  _code->append(Bytecodes::_lreturn);
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   220
}
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   221
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   222
void BytecodeAssembler::freturn() {
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   223
  _code->append(Bytecodes::_freturn);
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   224
}
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   225
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   226
void BytecodeAssembler::dreturn() {
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   227
  _code->append(Bytecodes::_dreturn);
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   228
}
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   229
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   230
void BytecodeAssembler::areturn() {
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   231
  _code->append(Bytecodes::_areturn);
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   232
}
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   233
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   234
void BytecodeAssembler::_return() {
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   235
  _code->append(Bytecodes::_return);
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   236
}
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   237
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   238
void BytecodeAssembler::_return(BasicType bt) {
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   239
  switch (bt) {
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   240
    case T_BOOLEAN:
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   241
    case T_CHAR:
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   242
    case T_BYTE:
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   243
    case T_SHORT:
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   244
    case T_INT:     ireturn(); break;
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   245
    case T_FLOAT:   freturn(); break;
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   246
    case T_DOUBLE:  dreturn(); break;
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   247
    case T_LONG:    lreturn(); break;
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   248
    case T_OBJECT:
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   249
    case T_ARRAY:   areturn(); break;
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   250
    case T_VOID:    _return(); break;
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   251
    default:
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   252
      ShouldNotReachHere();
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   253
  }
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   254
}