hotspot/src/share/vm/prims/methodHandleWalk.hpp
author never
Tue, 17 May 2011 19:11:51 -0700
changeset 9946 b3d5b50e2289
parent 9638 a9e79f5cd83b
child 9963 4a783069663c
permissions -rw-r--r--
7045513: JSR 292 inlining causes crashes in methodHandleWalk.cpp Reviewed-by: jrose
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
4562
5d93cb2d2090 6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff changeset
     1
/*
8676
9098d4e927e1 7012648: move JSR 292 to package java.lang.invoke and adjust names
jrose
parents: 8076
diff changeset
     2
 * Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved.
4562
5d93cb2d2090 6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5d93cb2d2090 6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff changeset
     4
 *
5d93cb2d2090 6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
5d93cb2d2090 6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5d93cb2d2090 6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff changeset
     7
 * published by the Free Software Foundation.
5d93cb2d2090 6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff changeset
     8
 *
5d93cb2d2090 6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
5d93cb2d2090 6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
5d93cb2d2090 6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
5d93cb2d2090 6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
5d93cb2d2090 6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff changeset
    13
 * accompanied this code).
5d93cb2d2090 6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff changeset
    14
 *
5d93cb2d2090 6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
5d93cb2d2090 6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
5d93cb2d2090 6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
5d93cb2d2090 6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff changeset
    18
 *
5547
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 4581
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 4581
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 4581
diff changeset
    21
 * questions.
4562
5d93cb2d2090 6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff changeset
    22
 *
5d93cb2d2090 6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff changeset
    23
 */
5d93cb2d2090 6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff changeset
    24
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    25
#ifndef SHARE_VM_PRIMS_METHODHANDLEWALK_HPP
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    26
#define SHARE_VM_PRIMS_METHODHANDLEWALK_HPP
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    27
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    28
#include "prims/methodHandles.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    29
4562
5d93cb2d2090 6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff changeset
    30
// Low-level parser for method handle chains.
5d93cb2d2090 6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff changeset
    31
class MethodHandleChain : StackObj {
5d93cb2d2090 6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff changeset
    32
public:
5d93cb2d2090 6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff changeset
    33
  typedef MethodHandles::EntryKind EntryKind;
5d93cb2d2090 6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff changeset
    34
5d93cb2d2090 6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff changeset
    35
private:
5d93cb2d2090 6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff changeset
    36
  Handle        _root;          // original target
5d93cb2d2090 6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff changeset
    37
  Handle        _method_handle; // current target
5d93cb2d2090 6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff changeset
    38
  bool          _is_last;       // final guy in chain
5d93cb2d2090 6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff changeset
    39
  bool          _is_bound;      // has a bound argument
5d93cb2d2090 6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff changeset
    40
  BasicType     _arg_type;      // if is_bound, the bound argument type
5d93cb2d2090 6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff changeset
    41
  int           _arg_slot;      // if is_bound or is_adapter, affected argument slot
5d93cb2d2090 6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff changeset
    42
  jint          _conversion;    // conversion field of AMH or -1
5d93cb2d2090 6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff changeset
    43
  methodHandle  _last_method;   // if is_last, which method we target
5d93cb2d2090 6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff changeset
    44
  Bytecodes::Code _last_invoke; // if is_last, type of invoke
5d93cb2d2090 6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff changeset
    45
  const char*   _lose_message;  // saved argument to lose()
5d93cb2d2090 6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff changeset
    46
5d93cb2d2090 6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff changeset
    47
  void set_method_handle(Handle target, TRAPS);
5d93cb2d2090 6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff changeset
    48
  void set_last_method(oop target, TRAPS);
5d93cb2d2090 6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff changeset
    49
  static BasicType compute_bound_arg_type(oop target, methodOop m, int arg_slot, TRAPS);
5d93cb2d2090 6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff changeset
    50
8676
9098d4e927e1 7012648: move JSR 292 to package java.lang.invoke and adjust names
jrose
parents: 8076
diff changeset
    51
  oop MethodHandle_type_oop()          { return java_lang_invoke_MethodHandle::type(method_handle_oop()); }
9098d4e927e1 7012648: move JSR 292 to package java.lang.invoke and adjust names
jrose
parents: 8076
diff changeset
    52
  oop MethodHandle_vmtarget_oop()      { return java_lang_invoke_MethodHandle::vmtarget(method_handle_oop()); }
9098d4e927e1 7012648: move JSR 292 to package java.lang.invoke and adjust names
jrose
parents: 8076
diff changeset
    53
  int MethodHandle_vmslots()           { return java_lang_invoke_MethodHandle::vmslots(method_handle_oop()); }
9098d4e927e1 7012648: move JSR 292 to package java.lang.invoke and adjust names
jrose
parents: 8076
diff changeset
    54
  int DirectMethodHandle_vmindex()     { return java_lang_invoke_DirectMethodHandle::vmindex(method_handle_oop()); }
9098d4e927e1 7012648: move JSR 292 to package java.lang.invoke and adjust names
jrose
parents: 8076
diff changeset
    55
  oop BoundMethodHandle_argument_oop() { return java_lang_invoke_BoundMethodHandle::argument(method_handle_oop()); }
9098d4e927e1 7012648: move JSR 292 to package java.lang.invoke and adjust names
jrose
parents: 8076
diff changeset
    56
  int BoundMethodHandle_vmargslot()    { return java_lang_invoke_BoundMethodHandle::vmargslot(method_handle_oop()); }
9098d4e927e1 7012648: move JSR 292 to package java.lang.invoke and adjust names
jrose
parents: 8076
diff changeset
    57
  int AdapterMethodHandle_conversion() { return java_lang_invoke_AdapterMethodHandle::conversion(method_handle_oop()); }
4562
5d93cb2d2090 6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff changeset
    58
5d93cb2d2090 6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff changeset
    59
public:
5d93cb2d2090 6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff changeset
    60
  MethodHandleChain(Handle root, TRAPS)
5d93cb2d2090 6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff changeset
    61
    : _root(root)
5d93cb2d2090 6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff changeset
    62
  { set_method_handle(root, THREAD); }
5d93cb2d2090 6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff changeset
    63
5d93cb2d2090 6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff changeset
    64
  bool is_adapter()             { return _conversion != -1; }
5d93cb2d2090 6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff changeset
    65
  bool is_bound()               { return _is_bound; }
5d93cb2d2090 6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff changeset
    66
  bool is_last()                { return _is_last; }
5d93cb2d2090 6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff changeset
    67
5d93cb2d2090 6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff changeset
    68
  void next(TRAPS) {
5d93cb2d2090 6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff changeset
    69
    assert(!is_last(), "");
5d93cb2d2090 6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff changeset
    70
    set_method_handle(MethodHandle_vmtarget_oop(), THREAD);
5d93cb2d2090 6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff changeset
    71
  }
5d93cb2d2090 6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff changeset
    72
5d93cb2d2090 6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff changeset
    73
  Handle method_handle()        { return _method_handle; }
5d93cb2d2090 6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff changeset
    74
  oop    method_handle_oop()    { return _method_handle(); }
5d93cb2d2090 6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff changeset
    75
  oop    method_type_oop()      { return MethodHandle_type_oop(); }
4567
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4562
diff changeset
    76
  oop    vmtarget_oop()         { return MethodHandle_vmtarget_oop(); }
4562
5d93cb2d2090 6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff changeset
    77
5d93cb2d2090 6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff changeset
    78
  jint adapter_conversion()     { assert(is_adapter(), ""); return _conversion; }
5d93cb2d2090 6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff changeset
    79
  int  adapter_conversion_op()  { return MethodHandles::adapter_conversion_op(adapter_conversion()); }
5d93cb2d2090 6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff changeset
    80
  BasicType adapter_conversion_src_type()
5d93cb2d2090 6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff changeset
    81
                                { return MethodHandles::adapter_conversion_src_type(adapter_conversion()); }
5d93cb2d2090 6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff changeset
    82
  BasicType adapter_conversion_dest_type()
5d93cb2d2090 6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff changeset
    83
                                { return MethodHandles::adapter_conversion_dest_type(adapter_conversion()); }
5d93cb2d2090 6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff changeset
    84
  int  adapter_conversion_stack_move()
5d93cb2d2090 6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff changeset
    85
                                { return MethodHandles::adapter_conversion_stack_move(adapter_conversion()); }
5d93cb2d2090 6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff changeset
    86
  int  adapter_conversion_stack_pushes()
5d93cb2d2090 6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff changeset
    87
                                { return adapter_conversion_stack_move() / MethodHandles::stack_move_unit(); }
5d93cb2d2090 6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff changeset
    88
  int  adapter_conversion_vminfo()
5d93cb2d2090 6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff changeset
    89
                                { return MethodHandles::adapter_conversion_vminfo(adapter_conversion()); }
5d93cb2d2090 6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff changeset
    90
  int adapter_arg_slot()        { assert(is_adapter(), ""); return _arg_slot; }
5d93cb2d2090 6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff changeset
    91
  oop adapter_arg_oop()         { assert(is_adapter(), ""); return BoundMethodHandle_argument_oop(); }
5d93cb2d2090 6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff changeset
    92
5d93cb2d2090 6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff changeset
    93
  BasicType bound_arg_type()    { assert(is_bound(), ""); return _arg_type; }
5d93cb2d2090 6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff changeset
    94
  int       bound_arg_slot()    { assert(is_bound(), ""); return _arg_slot; }
5d93cb2d2090 6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff changeset
    95
  oop       bound_arg_oop()     { assert(is_bound(), ""); return BoundMethodHandle_argument_oop(); }
5d93cb2d2090 6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff changeset
    96
5d93cb2d2090 6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff changeset
    97
  methodOop last_method_oop()   { assert(is_last(), ""); return _last_method(); }
5d93cb2d2090 6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff changeset
    98
  Bytecodes::Code last_invoke_code() { assert(is_last(), ""); return _last_invoke; }
5d93cb2d2090 6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff changeset
    99
5d93cb2d2090 6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff changeset
   100
  void lose(const char* msg, TRAPS);
5d93cb2d2090 6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff changeset
   101
  const char* lose_message()    { return _lose_message; }
5d93cb2d2090 6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff changeset
   102
};
5d93cb2d2090 6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff changeset
   103
5d93cb2d2090 6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff changeset
   104
5d93cb2d2090 6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff changeset
   105
// Structure walker for method handles.
5d93cb2d2090 6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff changeset
   106
// Does abstract interpretation on top of low-level parsing.
5d93cb2d2090 6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff changeset
   107
// You supply the tokens shuffled by the abstract interpretation.
5d93cb2d2090 6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff changeset
   108
class MethodHandleWalker : StackObj {
5d93cb2d2090 6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff changeset
   109
public:
4567
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4562
diff changeset
   110
  // Stack values:
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4562
diff changeset
   111
  enum TokenType {
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4562
diff changeset
   112
    tt_void,
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4562
diff changeset
   113
    tt_parameter,
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4562
diff changeset
   114
    tt_temporary,
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4562
diff changeset
   115
    tt_constant,
9638
a9e79f5cd83b 6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents: 9633
diff changeset
   116
    tt_symbolic,
4567
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4562
diff changeset
   117
    tt_illegal
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4562
diff changeset
   118
  };
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4562
diff changeset
   119
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4562
diff changeset
   120
  // Argument token:
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4562
diff changeset
   121
  class ArgToken {
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4562
diff changeset
   122
  private:
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4562
diff changeset
   123
    TokenType _tt;
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4562
diff changeset
   124
    BasicType _bt;
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4562
diff changeset
   125
    jvalue    _value;
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4562
diff changeset
   126
    Handle    _handle;
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4562
diff changeset
   127
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4562
diff changeset
   128
  public:
9946
b3d5b50e2289 7045513: JSR 292 inlining causes crashes in methodHandleWalk.cpp
never
parents: 9638
diff changeset
   129
    ArgToken(TokenType tt = tt_illegal) : _tt(tt) {
b3d5b50e2289 7045513: JSR 292 inlining causes crashes in methodHandleWalk.cpp
never
parents: 9638
diff changeset
   130
      assert(tt == tt_illegal || tt == tt_void, "invalid token type");
b3d5b50e2289 7045513: JSR 292 inlining causes crashes in methodHandleWalk.cpp
never
parents: 9638
diff changeset
   131
    }
4567
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4562
diff changeset
   132
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4562
diff changeset
   133
    ArgToken(TokenType tt, BasicType bt, int index) : _tt(tt), _bt(bt) {
9946
b3d5b50e2289 7045513: JSR 292 inlining causes crashes in methodHandleWalk.cpp
never
parents: 9638
diff changeset
   134
      assert(_tt == tt_parameter || _tt == tt_temporary, "must have index");
4567
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4562
diff changeset
   135
      _value.i = index;
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4562
diff changeset
   136
    }
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4562
diff changeset
   137
9946
b3d5b50e2289 7045513: JSR 292 inlining causes crashes in methodHandleWalk.cpp
never
parents: 9638
diff changeset
   138
    ArgToken(BasicType bt, jvalue value) : _tt(tt_constant), _bt(bt), _value(value) {}
b3d5b50e2289 7045513: JSR 292 inlining causes crashes in methodHandleWalk.cpp
never
parents: 9638
diff changeset
   139
    ArgToken(BasicType bt, Handle value) : _tt(tt_constant), _bt(bt), _handle(value) {}
b3d5b50e2289 7045513: JSR 292 inlining causes crashes in methodHandleWalk.cpp
never
parents: 9638
diff changeset
   140
b3d5b50e2289 7045513: JSR 292 inlining causes crashes in methodHandleWalk.cpp
never
parents: 9638
diff changeset
   141
b3d5b50e2289 7045513: JSR 292 inlining causes crashes in methodHandleWalk.cpp
never
parents: 9638
diff changeset
   142
    ArgToken(const char* str) : _tt(tt_symbolic), _bt(T_LONG) {
b3d5b50e2289 7045513: JSR 292 inlining causes crashes in methodHandleWalk.cpp
never
parents: 9638
diff changeset
   143
      _value.j = (intptr_t)str;
4567
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4562
diff changeset
   144
    }
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4562
diff changeset
   145
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4562
diff changeset
   146
    TokenType token_type()  const { return _tt; }
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4562
diff changeset
   147
    BasicType basic_type()  const { return _bt; }
9946
b3d5b50e2289 7045513: JSR 292 inlining causes crashes in methodHandleWalk.cpp
never
parents: 9638
diff changeset
   148
    bool      has_index()   const { return _tt == tt_parameter || _tt == tt_temporary; }
b3d5b50e2289 7045513: JSR 292 inlining causes crashes in methodHandleWalk.cpp
never
parents: 9638
diff changeset
   149
    int       index()       const { assert(has_index(), "must have index");; return _value.i; }
b3d5b50e2289 7045513: JSR 292 inlining causes crashes in methodHandleWalk.cpp
never
parents: 9638
diff changeset
   150
    Handle    object()      const { assert(_tt == tt_constant, "value type"); return _handle; }
b3d5b50e2289 7045513: JSR 292 inlining causes crashes in methodHandleWalk.cpp
never
parents: 9638
diff changeset
   151
    const char* str()       const { assert(_tt == tt_symbolic, "string type"); return (const char*)_value.j; }
4567
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4562
diff changeset
   152
9946
b3d5b50e2289 7045513: JSR 292 inlining causes crashes in methodHandleWalk.cpp
never
parents: 9638
diff changeset
   153
    jint      get_jint()    const { assert(_tt == tt_constant, "value types"); return _value.i; }
b3d5b50e2289 7045513: JSR 292 inlining causes crashes in methodHandleWalk.cpp
never
parents: 9638
diff changeset
   154
    jlong     get_jlong()   const { assert(_tt == tt_constant, "value types"); return _value.j; }
b3d5b50e2289 7045513: JSR 292 inlining causes crashes in methodHandleWalk.cpp
never
parents: 9638
diff changeset
   155
    jfloat    get_jfloat()  const { assert(_tt == tt_constant, "value types"); return _value.f; }
b3d5b50e2289 7045513: JSR 292 inlining causes crashes in methodHandleWalk.cpp
never
parents: 9638
diff changeset
   156
    jdouble   get_jdouble() const { assert(_tt == tt_constant, "value types"); return _value.d; }
4567
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4562
diff changeset
   157
  };
4562
5d93cb2d2090 6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff changeset
   158
5d93cb2d2090 6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff changeset
   159
  // Abstract interpretation state:
5d93cb2d2090 6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff changeset
   160
  struct SlotState {
5d93cb2d2090 6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff changeset
   161
    BasicType _type;
5d93cb2d2090 6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff changeset
   162
    ArgToken  _arg;
5d93cb2d2090 6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff changeset
   163
    SlotState() : _type(), _arg() {}
5d93cb2d2090 6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff changeset
   164
  };
5d93cb2d2090 6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff changeset
   165
  static SlotState make_state(BasicType type, ArgToken arg) {
5d93cb2d2090 6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff changeset
   166
    SlotState ss;
5d93cb2d2090 6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff changeset
   167
    ss._type = type; ss._arg = arg;
5d93cb2d2090 6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff changeset
   168
    return ss;
5d93cb2d2090 6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff changeset
   169
  }
5d93cb2d2090 6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff changeset
   170
5d93cb2d2090 6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff changeset
   171
private:
5d93cb2d2090 6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff changeset
   172
  MethodHandleChain _chain;
4567
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4562
diff changeset
   173
  bool              _for_invokedynamic;
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4562
diff changeset
   174
  int               _local_index;
4562
5d93cb2d2090 6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff changeset
   175
9638
a9e79f5cd83b 6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents: 9633
diff changeset
   176
  // This array is kept in an unusual order, indexed by low-level "slot number".
a9e79f5cd83b 6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents: 9633
diff changeset
   177
  // TOS is always _outgoing.at(0), so simple pushes and pops shift the whole _outgoing array.
a9e79f5cd83b 6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents: 9633
diff changeset
   178
  // If there is a receiver in the current argument list, it is at _outgoing.at(_outgoing.length()-1).
a9e79f5cd83b 6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents: 9633
diff changeset
   179
  // If a value at _outgoing.at(n) is T_LONG or T_DOUBLE, the value at _outgoing.at(n+1) is T_VOID.
4567
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4562
diff changeset
   180
  GrowableArray<SlotState> _outgoing;       // current outgoing parameter slots
4562
5d93cb2d2090 6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff changeset
   181
  int                      _outgoing_argc;  // # non-empty outgoing slots
5d93cb2d2090 6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff changeset
   182
5d93cb2d2090 6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff changeset
   183
  // Replace a value of type old_type at slot (and maybe slot+1) with the new value.
5d93cb2d2090 6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff changeset
   184
  // If old_type != T_VOID, remove the old argument at that point.
5d93cb2d2090 6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff changeset
   185
  // If new_type != T_VOID, insert the new argument at that point.
5d93cb2d2090 6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff changeset
   186
  // Insert or delete a second empty slot as needed.
4567
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4562
diff changeset
   187
  void change_argument(BasicType old_type, int slot, BasicType new_type, const ArgToken& new_arg);
4562
5d93cb2d2090 6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff changeset
   188
9638
a9e79f5cd83b 6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents: 9633
diff changeset
   189
  // Raw retype conversions for OP_RAW_RETYPE.
a9e79f5cd83b 6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents: 9633
diff changeset
   190
  void retype_raw_conversion(BasicType src, BasicType dst, bool for_return, int slot, TRAPS);
a9e79f5cd83b 6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents: 9633
diff changeset
   191
  void retype_raw_argument_type(BasicType src, BasicType dst, int slot, TRAPS) { retype_raw_conversion(src, dst, false, slot, CHECK); }
a9e79f5cd83b 6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents: 9633
diff changeset
   192
  void retype_raw_return_type(  BasicType src, BasicType dst,           TRAPS) { retype_raw_conversion(src, dst, true,  -1,   CHECK); }
a9e79f5cd83b 6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents: 9633
diff changeset
   193
4562
5d93cb2d2090 6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff changeset
   194
  SlotState* slot_state(int slot) {
5d93cb2d2090 6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff changeset
   195
    if (slot < 0 || slot >= _outgoing.length())
5d93cb2d2090 6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff changeset
   196
      return NULL;
5d93cb2d2090 6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff changeset
   197
    return _outgoing.adr_at(slot);
5d93cb2d2090 6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff changeset
   198
  }
5d93cb2d2090 6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff changeset
   199
  BasicType slot_type(int slot) {
5d93cb2d2090 6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff changeset
   200
    SlotState* ss = slot_state(slot);
5d93cb2d2090 6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff changeset
   201
    if (ss == NULL)
5d93cb2d2090 6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff changeset
   202
      return T_ILLEGAL;
5d93cb2d2090 6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff changeset
   203
    return ss->_type;
5d93cb2d2090 6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff changeset
   204
  }
5d93cb2d2090 6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff changeset
   205
  bool slot_has_argument(int slot) {
5d93cb2d2090 6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff changeset
   206
    return slot_type(slot) < T_VOID;
5d93cb2d2090 6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff changeset
   207
  }
5d93cb2d2090 6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff changeset
   208
5d93cb2d2090 6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff changeset
   209
#ifdef ASSERT
5d93cb2d2090 6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff changeset
   210
  int argument_count_slow();
5d93cb2d2090 6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff changeset
   211
#endif
5d93cb2d2090 6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff changeset
   212
5d93cb2d2090 6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff changeset
   213
  // Return a bytecode for converting src to dest, if one exists.
5d93cb2d2090 6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff changeset
   214
  Bytecodes::Code conversion_code(BasicType src, BasicType dest);
5d93cb2d2090 6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff changeset
   215
5d93cb2d2090 6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff changeset
   216
  void walk_incoming_state(TRAPS);
5d93cb2d2090 6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff changeset
   217
5d93cb2d2090 6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff changeset
   218
public:
4567
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4562
diff changeset
   219
  MethodHandleWalker(Handle root, bool for_invokedynamic, TRAPS)
4562
5d93cb2d2090 6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff changeset
   220
    : _chain(root, THREAD),
4567
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4562
diff changeset
   221
      _for_invokedynamic(for_invokedynamic),
4562
5d93cb2d2090 6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff changeset
   222
      _outgoing(THREAD, 10),
5d93cb2d2090 6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff changeset
   223
      _outgoing_argc(0)
4567
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4562
diff changeset
   224
  {
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4562
diff changeset
   225
    _local_index = for_invokedynamic ? 0 : 1;
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4562
diff changeset
   226
  }
4562
5d93cb2d2090 6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff changeset
   227
5d93cb2d2090 6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff changeset
   228
  MethodHandleChain& chain() { return _chain; }
5d93cb2d2090 6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff changeset
   229
4567
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4562
diff changeset
   230
  bool for_invokedynamic() const { return _for_invokedynamic; }
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4562
diff changeset
   231
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4562
diff changeset
   232
  int new_local_index(BasicType bt) {
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4562
diff changeset
   233
    //int index = _for_invokedynamic ? _local_index : _local_index - 1;
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4562
diff changeset
   234
    int index = _local_index;
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4562
diff changeset
   235
    _local_index += type2size[bt];
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4562
diff changeset
   236
    return index;
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4562
diff changeset
   237
  }
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4562
diff changeset
   238
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4562
diff changeset
   239
  int max_locals() const { return _local_index; }
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4562
diff changeset
   240
4562
5d93cb2d2090 6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff changeset
   241
  // plug-in abstract interpretation steps:
9638
a9e79f5cd83b 6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents: 9633
diff changeset
   242
  virtual ArgToken make_parameter(BasicType type, klassOop tk, int argnum, TRAPS) = 0;
a9e79f5cd83b 6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents: 9633
diff changeset
   243
  virtual ArgToken make_prim_constant(BasicType type, jvalue* con, TRAPS) = 0;
a9e79f5cd83b 6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents: 9633
diff changeset
   244
  virtual ArgToken make_oop_constant(oop con, TRAPS) = 0;
a9e79f5cd83b 6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents: 9633
diff changeset
   245
  virtual ArgToken make_conversion(BasicType type, klassOop tk, Bytecodes::Code op, const ArgToken& src, TRAPS) = 0;
a9e79f5cd83b 6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents: 9633
diff changeset
   246
  virtual ArgToken make_fetch(BasicType type, klassOop tk, Bytecodes::Code op, const ArgToken& base, const ArgToken& offset, TRAPS) = 0;
a9e79f5cd83b 6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents: 9633
diff changeset
   247
  virtual ArgToken make_invoke(methodOop m, vmIntrinsics::ID iid, Bytecodes::Code op, bool tailcall, int argc, ArgToken* argv, TRAPS) = 0;
4562
5d93cb2d2090 6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff changeset
   248
5d93cb2d2090 6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff changeset
   249
  // For make_invoke, the methodOop can be NULL if the intrinsic ID
5d93cb2d2090 6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff changeset
   250
  // is something other than vmIntrinsics::_none.
5d93cb2d2090 6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff changeset
   251
5d93cb2d2090 6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff changeset
   252
  // and in case anyone cares to related the previous actions to the chain:
5d93cb2d2090 6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff changeset
   253
  virtual void set_method_handle(oop mh) { }
5d93cb2d2090 6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff changeset
   254
5d93cb2d2090 6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff changeset
   255
  void lose(const char* msg, TRAPS) { chain().lose(msg, THREAD); }
5d93cb2d2090 6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff changeset
   256
  const char* lose_message()        { return chain().lose_message(); }
5d93cb2d2090 6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff changeset
   257
5d93cb2d2090 6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff changeset
   258
  ArgToken walk(TRAPS);
5d93cb2d2090 6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff changeset
   259
};
5d93cb2d2090 6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff changeset
   260
5d93cb2d2090 6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff changeset
   261
5d93cb2d2090 6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff changeset
   262
// An abstract interpreter for method handle chains.
5d93cb2d2090 6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff changeset
   263
// Produces an account of the semantics of a chain, in terms of a static IR.
5d93cb2d2090 6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff changeset
   264
// The IR happens to be JVM bytecodes.
5d93cb2d2090 6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff changeset
   265
class MethodHandleCompiler : public MethodHandleWalker {
5d93cb2d2090 6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff changeset
   266
private:
9633
92a7a2841a16 7042122: JSR 292: adjust various inline thresholds for JSR 292 API methods and method handle adapters
twisti
parents: 9134
diff changeset
   267
  int          _invoke_count;  // count the original call site has been executed
4567
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4562
diff changeset
   268
  KlassHandle  _rklass;        // Return type for casting.
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4562
diff changeset
   269
  BasicType    _rtype;
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4562
diff changeset
   270
  KlassHandle  _target_klass;
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4562
diff changeset
   271
  Thread*      _thread;
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4562
diff changeset
   272
9638
a9e79f5cd83b 6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents: 9633
diff changeset
   273
  // Values used by the compiler.
a9e79f5cd83b 6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents: 9633
diff changeset
   274
  static jvalue zero_jvalue;
a9e79f5cd83b 6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents: 9633
diff changeset
   275
  static jvalue one_jvalue;
a9e79f5cd83b 6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents: 9633
diff changeset
   276
4567
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4562
diff changeset
   277
  // Fake constant pool entry.
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4562
diff changeset
   278
  class ConstantValue {
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4562
diff changeset
   279
  private:
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4562
diff changeset
   280
    int       _tag;   // Constant pool tag type.
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4562
diff changeset
   281
    JavaValue _value;
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4562
diff changeset
   282
    Handle    _handle;
8076
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7426
diff changeset
   283
    Symbol*   _sym;
4567
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4562
diff changeset
   284
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4562
diff changeset
   285
  public:
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4562
diff changeset
   286
    // Constructor for oop types.
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4562
diff changeset
   287
    ConstantValue(int tag, Handle con) : _tag(tag), _handle(con) {
8076
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7426
diff changeset
   288
      assert(tag == JVM_CONSTANT_Class  ||
4567
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4562
diff changeset
   289
             tag == JVM_CONSTANT_String ||
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4562
diff changeset
   290
             tag == JVM_CONSTANT_Object, "must be oop type");
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4562
diff changeset
   291
    }
4562
5d93cb2d2090 6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff changeset
   292
8076
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7426
diff changeset
   293
    ConstantValue(int tag, Symbol* con) : _tag(tag), _sym(con) {
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7426
diff changeset
   294
      assert(tag == JVM_CONSTANT_Utf8, "must be symbol type");
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7426
diff changeset
   295
    }
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7426
diff changeset
   296
4567
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4562
diff changeset
   297
    // Constructor for oop reference types.
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4562
diff changeset
   298
    ConstantValue(int tag, int index) : _tag(tag) {
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4562
diff changeset
   299
      assert(JVM_CONSTANT_Fieldref <= tag && tag <= JVM_CONSTANT_NameAndType, "must be ref type");
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4562
diff changeset
   300
      _value.set_jint(index);
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4562
diff changeset
   301
    }
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4562
diff changeset
   302
    ConstantValue(int tag, int first_index, int second_index) : _tag(tag) {
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4562
diff changeset
   303
      assert(JVM_CONSTANT_Fieldref <= tag && tag <= JVM_CONSTANT_NameAndType, "must be ref type");
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4562
diff changeset
   304
      _value.set_jint(first_index << 16 | second_index);
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4562
diff changeset
   305
    }
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4562
diff changeset
   306
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4562
diff changeset
   307
    // Constructor for primitive types.
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4562
diff changeset
   308
    ConstantValue(BasicType bt, jvalue con) {
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4562
diff changeset
   309
      _value.set_type(bt);
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4562
diff changeset
   310
      switch (bt) {
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4562
diff changeset
   311
      case T_INT:    _tag = JVM_CONSTANT_Integer; _value.set_jint(   con.i); break;
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4562
diff changeset
   312
      case T_LONG:   _tag = JVM_CONSTANT_Long;    _value.set_jlong(  con.j); break;
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4562
diff changeset
   313
      case T_FLOAT:  _tag = JVM_CONSTANT_Float;   _value.set_jfloat( con.f); break;
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4562
diff changeset
   314
      case T_DOUBLE: _tag = JVM_CONSTANT_Double;  _value.set_jdouble(con.d); break;
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4562
diff changeset
   315
      default: ShouldNotReachHere();
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4562
diff changeset
   316
      }
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4562
diff changeset
   317
    }
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4562
diff changeset
   318
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4562
diff changeset
   319
    int       tag()          const { return _tag; }
8076
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7426
diff changeset
   320
    Symbol*   symbol()       const { return _sym; }
4567
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4562
diff changeset
   321
    klassOop  klass_oop()    const { return (klassOop)  _handle(); }
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4562
diff changeset
   322
    oop       object_oop()   const { return _handle(); }
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4562
diff changeset
   323
    int       index()        const { return _value.get_jint(); }
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4562
diff changeset
   324
    int       first_index()  const { return _value.get_jint() >> 16; }
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4562
diff changeset
   325
    int       second_index() const { return _value.get_jint() & 0x0000FFFF; }
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4562
diff changeset
   326
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4562
diff changeset
   327
    bool      is_primitive() const { return is_java_primitive(_value.get_type()); }
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4562
diff changeset
   328
    jint      get_jint()     const { return _value.get_jint();    }
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4562
diff changeset
   329
    jlong     get_jlong()    const { return _value.get_jlong();   }
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4562
diff changeset
   330
    jfloat    get_jfloat()   const { return _value.get_jfloat();  }
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4562
diff changeset
   331
    jdouble   get_jdouble()  const { return _value.get_jdouble(); }
4562
5d93cb2d2090 6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff changeset
   332
  };
5d93cb2d2090 6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff changeset
   333
4567
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4562
diff changeset
   334
  // Fake constant pool.
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4562
diff changeset
   335
  GrowableArray<ConstantValue*> _constants;
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4562
diff changeset
   336
4562
5d93cb2d2090 6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff changeset
   337
  // Accumulated compiler state:
4567
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4562
diff changeset
   338
  GrowableArray<unsigned char> _bytecode;
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4562
diff changeset
   339
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4562
diff changeset
   340
  int _cur_stack;
4562
5d93cb2d2090 6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff changeset
   341
  int _max_stack;
5d93cb2d2090 6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff changeset
   342
  int _num_params;
5d93cb2d2090 6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff changeset
   343
  int _name_index;
5d93cb2d2090 6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff changeset
   344
  int _signature_index;
5d93cb2d2090 6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff changeset
   345
4567
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4562
diff changeset
   346
  void stack_push(BasicType bt) {
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4562
diff changeset
   347
    _cur_stack += type2size[bt];
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4562
diff changeset
   348
    if (_cur_stack > _max_stack) _max_stack = _cur_stack;
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4562
diff changeset
   349
  }
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4562
diff changeset
   350
  void stack_pop(BasicType bt) {
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4562
diff changeset
   351
    _cur_stack -= type2size[bt];
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4562
diff changeset
   352
    assert(_cur_stack >= 0, "sanity");
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4562
diff changeset
   353
  }
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4562
diff changeset
   354
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4562
diff changeset
   355
  unsigned char* bytecode()        const { return _bytecode.adr_at(0); }
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4562
diff changeset
   356
  int            bytecode_length() const { return _bytecode.length(); }
4562
5d93cb2d2090 6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff changeset
   357
4567
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4562
diff changeset
   358
  // Fake constant pool.
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4562
diff changeset
   359
  int cpool_oop_put(int tag, Handle con) {
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4562
diff changeset
   360
    if (con.is_null())  return 0;
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4562
diff changeset
   361
    ConstantValue* cv = new ConstantValue(tag, con);
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4562
diff changeset
   362
    return _constants.append(cv);
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4562
diff changeset
   363
  }
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4562
diff changeset
   364
8076
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7426
diff changeset
   365
  int cpool_symbol_put(int tag, Symbol* con) {
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7426
diff changeset
   366
    if (con == NULL)  return 0;
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7426
diff changeset
   367
    ConstantValue* cv = new ConstantValue(tag, con);
9134
189a8c094016 6987991: JSR 292 phpreboot test/testtracefun2.phpr segfaults
jrose
parents: 8676
diff changeset
   368
    con->increment_refcount();
8076
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7426
diff changeset
   369
    return _constants.append(cv);
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7426
diff changeset
   370
  }
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7426
diff changeset
   371
4567
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4562
diff changeset
   372
  int cpool_oop_reference_put(int tag, int first_index, int second_index) {
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4562
diff changeset
   373
    if (first_index == 0 && second_index == 0)  return 0;
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4562
diff changeset
   374
    assert(first_index != 0 && second_index != 0, "no zero indexes");
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4562
diff changeset
   375
    ConstantValue* cv = new ConstantValue(tag, first_index, second_index);
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4562
diff changeset
   376
    return _constants.append(cv);
4562
5d93cb2d2090 6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff changeset
   377
  }
5d93cb2d2090 6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff changeset
   378
4567
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4562
diff changeset
   379
  int cpool_primitive_put(BasicType type, jvalue* con);
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4562
diff changeset
   380
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4562
diff changeset
   381
  int cpool_int_put(jint value) {
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4562
diff changeset
   382
    jvalue con; con.i = value;
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4562
diff changeset
   383
    return cpool_primitive_put(T_INT, &con);
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4562
diff changeset
   384
  }
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4562
diff changeset
   385
  int cpool_long_put(jlong value) {
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4562
diff changeset
   386
    jvalue con; con.j = value;
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4562
diff changeset
   387
    return cpool_primitive_put(T_LONG, &con);
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4562
diff changeset
   388
  }
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4562
diff changeset
   389
  int cpool_float_put(jfloat value) {
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4562
diff changeset
   390
    jvalue con; con.f = value;
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4562
diff changeset
   391
    return cpool_primitive_put(T_FLOAT, &con);
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4562
diff changeset
   392
  }
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4562
diff changeset
   393
  int cpool_double_put(jdouble value) {
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4562
diff changeset
   394
    jvalue con; con.d = value;
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4562
diff changeset
   395
    return cpool_primitive_put(T_DOUBLE, &con);
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4562
diff changeset
   396
  }
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4562
diff changeset
   397
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4562
diff changeset
   398
  int cpool_object_put(Handle obj) {
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4562
diff changeset
   399
    return cpool_oop_put(JVM_CONSTANT_Object, obj);
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4562
diff changeset
   400
  }
8076
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7426
diff changeset
   401
  int cpool_symbol_put(Symbol* sym) {
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7426
diff changeset
   402
    return cpool_symbol_put(JVM_CONSTANT_Utf8, sym);
4567
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4562
diff changeset
   403
  }
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4562
diff changeset
   404
  int cpool_klass_put(klassOop klass) {
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4562
diff changeset
   405
    return cpool_oop_put(JVM_CONSTANT_Class, klass);
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4562
diff changeset
   406
  }
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4562
diff changeset
   407
  int cpool_methodref_put(int class_index, int name_and_type_index) {
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4562
diff changeset
   408
    return cpool_oop_reference_put(JVM_CONSTANT_Methodref, class_index, name_and_type_index);
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4562
diff changeset
   409
  }
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4562
diff changeset
   410
  int cpool_name_and_type_put(int name_index, int signature_index) {
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4562
diff changeset
   411
    return cpool_oop_reference_put(JVM_CONSTANT_NameAndType, name_index, signature_index);
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4562
diff changeset
   412
  }
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4562
diff changeset
   413
9946
b3d5b50e2289 7045513: JSR 292 inlining causes crashes in methodHandleWalk.cpp
never
parents: 9638
diff changeset
   414
  void emit_bc(Bytecodes::Code op, int index = 0, int args_size = -1);
4567
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4562
diff changeset
   415
  void emit_load(BasicType bt, int index);
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4562
diff changeset
   416
  void emit_store(BasicType bt, int index);
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4562
diff changeset
   417
  void emit_load_constant(ArgToken arg);
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4562
diff changeset
   418
4562
5d93cb2d2090 6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff changeset
   419
  virtual ArgToken make_parameter(BasicType type, klassOop tk, int argnum, TRAPS) {
4567
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4562
diff changeset
   420
    return ArgToken(tt_parameter, type, argnum);
4562
5d93cb2d2090 6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff changeset
   421
  }
5d93cb2d2090 6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff changeset
   422
  virtual ArgToken make_oop_constant(oop con, TRAPS) {
4567
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4562
diff changeset
   423
    Handle h(THREAD, con);
9946
b3d5b50e2289 7045513: JSR 292 inlining causes crashes in methodHandleWalk.cpp
never
parents: 9638
diff changeset
   424
    return ArgToken(T_OBJECT, h);
4562
5d93cb2d2090 6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff changeset
   425
  }
5d93cb2d2090 6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff changeset
   426
  virtual ArgToken make_prim_constant(BasicType type, jvalue* con, TRAPS) {
9946
b3d5b50e2289 7045513: JSR 292 inlining causes crashes in methodHandleWalk.cpp
never
parents: 9638
diff changeset
   427
    return ArgToken(type, *con);
4562
5d93cb2d2090 6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff changeset
   428
  }
4567
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4562
diff changeset
   429
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4562
diff changeset
   430
  virtual ArgToken make_conversion(BasicType type, klassOop tk, Bytecodes::Code op, const ArgToken& src, TRAPS);
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4562
diff changeset
   431
  virtual ArgToken make_fetch(BasicType type, klassOop tk, Bytecodes::Code op, const ArgToken& base, const ArgToken& offset, TRAPS);
4562
5d93cb2d2090 6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff changeset
   432
  virtual ArgToken make_invoke(methodOop m, vmIntrinsics::ID iid, Bytecodes::Code op, bool tailcall, int argc, ArgToken* argv, TRAPS);
5d93cb2d2090 6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff changeset
   433
4567
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4562
diff changeset
   434
  // Get a real constant pool.
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4562
diff changeset
   435
  constantPoolHandle get_constant_pool(TRAPS) const;
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4562
diff changeset
   436
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4562
diff changeset
   437
  // Get a real methodOop.
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4562
diff changeset
   438
  methodHandle get_method_oop(TRAPS) const;
4562
5d93cb2d2090 6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff changeset
   439
5d93cb2d2090 6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff changeset
   440
public:
9946
b3d5b50e2289 7045513: JSR 292 inlining causes crashes in methodHandleWalk.cpp
never
parents: 9638
diff changeset
   441
  MethodHandleCompiler(Handle root, Symbol* name, Symbol* signature, int invoke_count, bool for_invokedynamic, TRAPS);
4562
5d93cb2d2090 6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff changeset
   442
5d93cb2d2090 6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff changeset
   443
  // Compile the given MH chain into bytecode.
4567
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4562
diff changeset
   444
  methodHandle compile(TRAPS);
4581
e89fbd1bcb3d 6914206: change way of permission checking for generated MethodHandle adapters
twisti
parents: 4567
diff changeset
   445
e89fbd1bcb3d 6914206: change way of permission checking for generated MethodHandle adapters
twisti
parents: 4567
diff changeset
   446
  // Tests if the given class is a MH adapter holder.
e89fbd1bcb3d 6914206: change way of permission checking for generated MethodHandle adapters
twisti
parents: 4567
diff changeset
   447
  static bool klass_is_method_handle_adapter_holder(klassOop klass) {
7426
dba53a0065f8 7001363: java/dyn/InvokeDynamic should not be a well-known class in the JVM
twisti
parents: 7397
diff changeset
   448
    return (klass == SystemDictionary::MethodHandle_klass());
4581
e89fbd1bcb3d 6914206: change way of permission checking for generated MethodHandle adapters
twisti
parents: 4567
diff changeset
   449
  }
4562
5d93cb2d2090 6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff changeset
   450
};
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
   451
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
   452
#endif // SHARE_VM_PRIMS_METHODHANDLEWALK_HPP