hotspot/src/share/vm/classfile/bytecodeAssembler.cpp
author ehelin
Tue, 25 Feb 2014 11:02:11 +0100
changeset 22905 4b1549d69106
parent 22234 da823d78ad65
child 25715 d5a8dbdc5150
permissions -rw-r--r--
Merge
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
14385
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
     1
/*
22234
da823d78ad65 8029233: Update copyright year to match last edit in jdk8 hotspot repository for 2013
mikael
parents: 17304
diff changeset
     2
 * Copyright (c) 2012, 2013, 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"
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    31
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    32
#ifdef TARGET_ARCH_x86
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    33
# include "bytes_x86.hpp"
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    34
#endif
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    35
#ifdef TARGET_ARCH_sparc
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    36
# include "bytes_sparc.hpp"
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    37
#endif
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    38
#ifdef TARGET_ARCH_zero
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    39
# include "bytes_zero.hpp"
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    40
#endif
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    41
#ifdef TARGET_ARCH_arm
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    42
# include "bytes_arm.hpp"
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    43
#endif
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    44
#ifdef TARGET_ARCH_ppc
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    45
# include "bytes_ppc.hpp"
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    46
#endif
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    47
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    48
u2 BytecodeConstantPool::find_or_add(BytecodeCPEntry const& bcpe) {
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    49
  u2 index;
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    50
  u2* probe = _indices.get(bcpe);
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    51
  if (probe == NULL) {
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    52
    index = _entries.length();
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    53
    _entries.append(bcpe);
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    54
    _indices.put(bcpe, index);
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    55
  } else {
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    56
    index = *probe;
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    57
  }
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    58
  return index + _orig->length();
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    59
}
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    60
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    61
ConstantPool* BytecodeConstantPool::create_constant_pool(TRAPS) const {
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    62
  if (_entries.length() == 0) {
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    63
    return _orig;
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    64
  }
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    65
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    66
  ConstantPool* cp = ConstantPool::allocate(
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    67
      _orig->pool_holder()->class_loader_data(),
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    68
      _orig->length() + _entries.length(), CHECK_NULL);
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    69
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    70
  cp->set_pool_holder(_orig->pool_holder());
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    71
  _orig->copy_cp_to(1, _orig->length() - 1, cp, 1, CHECK_NULL);
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    72
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    73
  for (int i = 0; i < _entries.length(); ++i) {
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    74
    BytecodeCPEntry entry = _entries.at(i);
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    75
    int idx = i + _orig->length();
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    76
    switch (entry._tag) {
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    77
      case BytecodeCPEntry::UTF8:
17304
436c6e158ce5 8010783: assert(s->refcount() != 0) failed: for create_overpasses
acorn
parents: 14385
diff changeset
    78
        entry._u.utf8->increment_refcount();
14385
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    79
        cp->symbol_at_put(idx, entry._u.utf8);
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    80
        break;
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    81
      case BytecodeCPEntry::KLASS:
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    82
        cp->unresolved_klass_at_put(
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    83
            idx, cp->symbol_at(entry._u.klass));
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::STRING:
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    86
        cp->unresolved_string_at_put(
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    87
            idx, cp->symbol_at(entry._u.string));
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    88
        break;
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    89
      case BytecodeCPEntry::NAME_AND_TYPE:
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    90
        cp->name_and_type_at_put(idx,
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    91
            entry._u.name_and_type.name_index,
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    92
            entry._u.name_and_type.type_index);
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    93
        break;
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    94
      case BytecodeCPEntry::METHODREF:
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    95
        cp->method_at_put(idx,
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    96
            entry._u.methodref.class_index,
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    97
            entry._u.methodref.name_and_type_index);
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    98
        break;
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
    99
      default:
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   100
        ShouldNotReachHere();
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   101
    }
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   102
  }
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   103
  return cp;
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   104
}
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   105
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   106
void BytecodeAssembler::append(u1 imm_u1) {
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   107
  _code->append(imm_u1);
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(u2 imm_u2) {
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
  Bytes::put_Java_u2(_code->adr_at(_code->length() - 2), imm_u2);
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   114
}
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   115
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   116
void BytecodeAssembler::append(u4 imm_u4) {
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   117
  _code->append(0);
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   118
  _code->append(0);
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   119
  _code->append(0);
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   120
  _code->append(0);
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   121
  Bytes::put_Java_u4(_code->adr_at(_code->length() - 4), imm_u4);
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   122
}
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   123
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   124
void BytecodeAssembler::xload(u4 index, u1 onebyteop, u1 twobyteop) {
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   125
  if (index < 4) {
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   126
    _code->append(onebyteop + index);
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   127
  } else {
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   128
    _code->append(twobyteop);
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   129
    _code->append((u2)index);
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   130
  }
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   131
}
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   132
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   133
void BytecodeAssembler::dup() {
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   134
  _code->append(Bytecodes::_dup);
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::_new(Symbol* sym) {
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   138
  u2 cpool_index = _cp->klass(sym);
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   139
  _code->append(Bytecodes::_new);
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   140
  append(cpool_index);
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   141
}
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   142
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   143
void BytecodeAssembler::load_string(Symbol* sym) {
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   144
  u2 cpool_index = _cp->string(sym);
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   145
  if (cpool_index < 0x100) {
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   146
    ldc(cpool_index);
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   147
  } else {
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   148
    ldc_w(cpool_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
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   152
void BytecodeAssembler::ldc(u1 index) {
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   153
  _code->append(Bytecodes::_ldc);
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   154
  append(index);
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   155
}
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   156
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   157
void BytecodeAssembler::ldc_w(u2 index) {
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   158
  _code->append(Bytecodes::_ldc_w);
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   159
  append(index);
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   160
}
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   161
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   162
void BytecodeAssembler::athrow() {
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   163
  _code->append(Bytecodes::_athrow);
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   164
}
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   165
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   166
void BytecodeAssembler::iload(u4 index) {
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   167
  xload(index, Bytecodes::_iload_0, Bytecodes::_iload);
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   168
}
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   169
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   170
void BytecodeAssembler::lload(u4 index) {
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   171
  xload(index, Bytecodes::_lload_0, Bytecodes::_lload);
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   172
}
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   173
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   174
void BytecodeAssembler::fload(u4 index) {
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   175
  xload(index, Bytecodes::_fload_0, Bytecodes::_fload);
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   176
}
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   177
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   178
void BytecodeAssembler::dload(u4 index) {
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   179
  xload(index, Bytecodes::_dload_0, Bytecodes::_dload);
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   180
}
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   181
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   182
void BytecodeAssembler::aload(u4 index) {
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   183
  xload(index, Bytecodes::_aload_0, Bytecodes::_aload);
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   184
}
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   185
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   186
void BytecodeAssembler::load(BasicType bt, u4 index) {
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   187
  switch (bt) {
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   188
    case T_BOOLEAN:
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   189
    case T_CHAR:
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   190
    case T_BYTE:
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   191
    case T_SHORT:
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   192
    case T_INT:     iload(index); break;
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   193
    case T_FLOAT:   fload(index); break;
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   194
    case T_DOUBLE:  dload(index); break;
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   195
    case T_LONG:    lload(index); break;
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   196
    case T_OBJECT:
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   197
    case T_ARRAY:   aload(index); break;
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   198
    default:
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   199
      ShouldNotReachHere();
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   200
  }
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   201
}
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   202
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   203
void BytecodeAssembler::checkcast(Symbol* sym) {
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   204
  u2 cpool_index = _cp->klass(sym);
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   205
  _code->append(Bytecodes::_checkcast);
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   206
  append(cpool_index);
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(Method* method) {
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   210
  invokespecial(method->klass_name(), method->name(), method->signature());
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   211
}
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   212
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   213
void BytecodeAssembler::invokespecial(Symbol* klss, Symbol* name, Symbol* sig) {
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   214
  u2 methodref_index = _cp->methodref(klss, name, sig);
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   215
  _code->append(Bytecodes::_invokespecial);
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   216
  append(methodref_index);
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(Method* method) {
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   220
  invokevirtual(method->klass_name(), method->name(), method->signature());
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   221
}
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   222
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   223
void BytecodeAssembler::invokevirtual(Symbol* klss, Symbol* name, Symbol* sig) {
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   224
  u2 methodref_index = _cp->methodref(klss, name, sig);
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   225
  _code->append(Bytecodes::_invokevirtual);
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   226
  append(methodref_index);
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::ireturn() {
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   230
  _code->append(Bytecodes::_ireturn);
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::lreturn() {
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   234
  _code->append(Bytecodes::_lreturn);
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::freturn() {
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   238
  _code->append(Bytecodes::_freturn);
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::dreturn() {
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   242
  _code->append(Bytecodes::_dreturn);
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::areturn() {
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   246
  _code->append(Bytecodes::_areturn);
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() {
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   250
  _code->append(Bytecodes::_return);
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   251
}
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   252
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   253
void BytecodeAssembler::_return(BasicType bt) {
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   254
  switch (bt) {
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   255
    case T_BOOLEAN:
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   256
    case T_CHAR:
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   257
    case T_BYTE:
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   258
    case T_SHORT:
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   259
    case T_INT:     ireturn(); break;
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   260
    case T_FLOAT:   freturn(); break;
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   261
    case T_DOUBLE:  dreturn(); break;
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   262
    case T_LONG:    lreturn(); break;
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   263
    case T_OBJECT:
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   264
    case T_ARRAY:   areturn(); break;
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   265
    case T_VOID:    _return(); break;
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   266
    default:
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   267
      ShouldNotReachHere();
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   268
  }
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents:
diff changeset
   269
}