hotspot/src/cpu/x86/vm/methodHandles_x86.hpp
author never
Fri, 03 Jun 2011 22:31:43 -0700
changeset 9976 6fef34e63df1
parent 9630 d6419e4395e3
child 10031 e81ae8b523dc
permissions -rw-r--r--
7045514: SPARC assembly code for JSR 292 ricochet frames Reviewed-by: kvn, jrose
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
9630
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
     1
/*
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
     2
 * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved.
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
     4
 *
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
     7
 * published by the Free Software Foundation.
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
     8
 *
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
    13
 * accompanied this code).
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
    14
 *
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
    18
 *
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
    21
 * questions.
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
    22
 *
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
    23
 */
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
    24
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
    25
// Platform-specific definitions for method handles.
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
    26
// These definitions are inlined into class MethodHandles.
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
    27
9976
6fef34e63df1 7045514: SPARC assembly code for JSR 292 ricochet frames
never
parents: 9630
diff changeset
    28
// Adapters
6fef34e63df1 7045514: SPARC assembly code for JSR 292 ricochet frames
never
parents: 9630
diff changeset
    29
enum /* platform_dependent_constants */ {
6fef34e63df1 7045514: SPARC assembly code for JSR 292 ricochet frames
never
parents: 9630
diff changeset
    30
  adapter_code_size = NOT_LP64(30000 DEBUG_ONLY(+ 10000)) LP64_ONLY(80000 DEBUG_ONLY(+ 120000))
6fef34e63df1 7045514: SPARC assembly code for JSR 292 ricochet frames
never
parents: 9630
diff changeset
    31
};
6fef34e63df1 7045514: SPARC assembly code for JSR 292 ricochet frames
never
parents: 9630
diff changeset
    32
9630
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
    33
public:
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
    34
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
    35
// The stack just after the recursive call from a ricochet frame
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
    36
// looks something like this.  Offsets are marked in words, not bytes.
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
    37
// rsi (r13 on LP64) is part of the interpreter calling sequence
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
    38
// which tells the callee where is my real rsp (for frame walking).
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
    39
// (...lower memory addresses)
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
    40
// rsp:     [ return pc                 ]   always the global RicochetBlob::bounce_addr
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
    41
// rsp+1:   [ recursive arg N           ]
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
    42
// rsp+2:   [ recursive arg N-1         ]
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
    43
// ...
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
    44
// rsp+N:   [ recursive arg 1           ]
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
    45
// rsp+N+1: [ recursive method handle   ]
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
    46
// ...
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
    47
// rbp-6:   [ cleanup continuation pc   ]   <-- (struct RicochetFrame)
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
    48
// rbp-5:   [ saved target MH           ]   the MH we will call on the saved args
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
    49
// rbp-4:   [ saved args layout oop     ]   an int[] array which describes argument layout
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
    50
// rbp-3:   [ saved args pointer        ]   address of transformed adapter arg M (slot 0)
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
    51
// rbp-2:   [ conversion                ]   information about how the return value is used
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
    52
// rbp-1:   [ exact sender sp           ]   exact TOS (rsi/r13) of original sender frame
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
    53
// rbp+0:   [ saved sender fp           ]   (for original sender of AMH)
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
    54
// rbp+1:   [ saved sender pc           ]   (back to original sender of AMH)
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
    55
// rbp+2:   [ transformed adapter arg M ]   <-- (extended TOS of original sender)
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
    56
// rbp+3:   [ transformed adapter arg M-1]
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
    57
// ...
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
    58
// rbp+M+1: [ transformed adapter arg 1 ]
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
    59
// rbp+M+2: [ padding                   ] <-- (rbp + saved args base offset)
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
    60
// ...      [ optional padding]
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
    61
// (higher memory addresses...)
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
    62
//
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
    63
// The arguments originally passed by the original sender
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
    64
// are lost, and arbitrary amounts of stack motion might have
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
    65
// happened due to argument transformation.
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
    66
// (This is done by C2I/I2C adapters and non-direct method handles.)
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
    67
// This is why there is an unpredictable amount of memory between
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
    68
// the extended and exact TOS of the sender.
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
    69
// The ricochet adapter itself will also (in general) perform
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
    70
// transformations before the recursive call.
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
    71
//
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
    72
// The transformed and saved arguments, immediately above the saved
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
    73
// return PC, are a well-formed method handle invocation ready to execute.
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
    74
// When the GC needs to walk the stack, these arguments are described
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
    75
// via the saved arg types oop, an int[] array with a private format.
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
    76
// This array is derived from the type of the transformed adapter
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
    77
// method handle, which also sits at the base of the saved argument
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
    78
// bundle.  Since the GC may not be able to fish out the int[]
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
    79
// array, so it is pushed explicitly on the stack.  This may be
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
    80
// an unnecessary expense.
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
    81
//
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
    82
// The following register conventions are significant at this point:
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
    83
// rsp       the thread stack, as always; preserved by caller
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
    84
// rsi/r13   exact TOS of recursive frame (contents of [rbp-2])
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
    85
// rcx       recursive method handle (contents of [rsp+N+1])
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
    86
// rbp       preserved by caller (not used by caller)
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
    87
// Unless otherwise specified, all registers can be blown by the call.
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
    88
//
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
    89
// If this frame must be walked, the transformed adapter arguments
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
    90
// will be found with the help of the saved arguments descriptor.
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
    91
//
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
    92
// Therefore, the descriptor must match the referenced arguments.
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
    93
// The arguments must be followed by at least one word of padding,
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
    94
// which will be necessary to complete the final method handle call.
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
    95
// That word is not treated as holding an oop.  Neither is the word
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
    96
//
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
    97
// The word pointed to by the return argument pointer is not
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
    98
// treated as an oop, even if points to a saved argument.
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
    99
// This allows the saved argument list to have a "hole" in it
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
   100
// to receive an oop from the recursive call.
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
   101
// (The hole might temporarily contain RETURN_VALUE_PLACEHOLDER.)
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
   102
//
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
   103
// When the recursive callee returns, RicochetBlob::bounce_addr will
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
   104
// immediately jump to the continuation stored in the RF.
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
   105
// This continuation will merge the recursive return value
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
   106
// into the saved argument list.  At that point, the original
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
   107
// rsi, rbp, and rsp will be reloaded, the ricochet frame will
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
   108
// disappear, and the final target of the adapter method handle
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
   109
// will be invoked on the transformed argument list.
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
   110
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
   111
class RicochetFrame {
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
   112
  friend class MethodHandles;
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
   113
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
   114
 private:
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
   115
  intptr_t* _continuation;          // what to do when control gets back here
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
   116
  oopDesc*  _saved_target;          // target method handle to invoke on saved_args
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
   117
  oopDesc*  _saved_args_layout;     // caching point for MethodTypeForm.vmlayout cookie
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
   118
  intptr_t* _saved_args_base;       // base of pushed arguments (slot 0, arg N) (-3)
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
   119
  intptr_t  _conversion;            // misc. information from original AdapterMethodHandle (-2)
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
   120
  intptr_t* _exact_sender_sp;       // parallel to interpreter_frame_sender_sp (-1)
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
   121
  intptr_t* _sender_link;           // *must* coincide with frame::link_offset (0)
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
   122
  address   _sender_pc;             // *must* coincide with frame::return_addr_offset (1)
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
   123
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
   124
 public:
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
   125
  intptr_t* continuation() const        { return _continuation; }
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
   126
  oop       saved_target() const        { return _saved_target; }
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
   127
  oop       saved_args_layout() const   { return _saved_args_layout; }
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
   128
  intptr_t* saved_args_base() const     { return _saved_args_base; }
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
   129
  intptr_t  conversion() const          { return _conversion; }
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
   130
  intptr_t* exact_sender_sp() const     { return _exact_sender_sp; }
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
   131
  intptr_t* sender_link() const         { return _sender_link; }
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
   132
  address   sender_pc() const           { return _sender_pc; }
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
   133
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
   134
  intptr_t* extended_sender_sp() const  { return saved_args_base(); }
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
   135
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
   136
  intptr_t  return_value_slot_number() const {
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
   137
    return adapter_conversion_vminfo(conversion());
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
   138
  }
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
   139
  BasicType return_value_type() const {
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
   140
    return adapter_conversion_dest_type(conversion());
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
   141
  }
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
   142
  bool has_return_value_slot() const {
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
   143
    return return_value_type() != T_VOID;
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
   144
  }
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
   145
  intptr_t* return_value_slot_addr() const {
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
   146
    assert(has_return_value_slot(), "");
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
   147
    return saved_arg_slot_addr(return_value_slot_number());
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
   148
  }
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
   149
  intptr_t* saved_target_slot_addr() const {
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
   150
    return saved_arg_slot_addr(saved_args_length());
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
   151
  }
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
   152
  intptr_t* saved_arg_slot_addr(int slot) const {
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
   153
    assert(slot >= 0, "");
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
   154
    return (intptr_t*)( (address)saved_args_base() + (slot * Interpreter::stackElementSize) );
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
   155
  }
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
   156
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
   157
  jint      saved_args_length() const;
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
   158
  jint      saved_arg_offset(int arg) const;
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
   159
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
   160
  // GC interface
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
   161
  oop*  saved_target_addr()                     { return (oop*)&_saved_target; }
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
   162
  oop*  saved_args_layout_addr()                { return (oop*)&_saved_args_layout; }
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
   163
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
   164
  oop  compute_saved_args_layout(bool read_cache, bool write_cache);
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
   165
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
   166
  // Compiler/assembler interface.
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
   167
  static int continuation_offset_in_bytes()     { return offset_of(RicochetFrame, _continuation); }
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
   168
  static int saved_target_offset_in_bytes()     { return offset_of(RicochetFrame, _saved_target); }
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
   169
  static int saved_args_layout_offset_in_bytes(){ return offset_of(RicochetFrame, _saved_args_layout); }
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
   170
  static int saved_args_base_offset_in_bytes()  { return offset_of(RicochetFrame, _saved_args_base); }
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
   171
  static int conversion_offset_in_bytes()       { return offset_of(RicochetFrame, _conversion); }
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
   172
  static int exact_sender_sp_offset_in_bytes()  { return offset_of(RicochetFrame, _exact_sender_sp); }
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
   173
  static int sender_link_offset_in_bytes()      { return offset_of(RicochetFrame, _sender_link); }
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
   174
  static int sender_pc_offset_in_bytes()        { return offset_of(RicochetFrame, _sender_pc); }
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
   175
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
   176
  // This value is not used for much, but it apparently must be nonzero.
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
   177
  static int frame_size_in_bytes()              { return sender_link_offset_in_bytes(); }
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
   178
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
   179
#ifdef ASSERT
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
   180
  // The magic number is supposed to help find ricochet frames within the bytes of stack dumps.
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
   181
  enum { MAGIC_NUMBER_1 = 0xFEED03E, MAGIC_NUMBER_2 = 0xBEEF03E };
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
   182
  static int magic_number_1_offset_in_bytes()   { return -wordSize; }
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
   183
  static int magic_number_2_offset_in_bytes()   { return sizeof(RicochetFrame); }
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
   184
  intptr_t magic_number_1() const               { return *(intptr_t*)((address)this + magic_number_1_offset_in_bytes()); };
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
   185
  intptr_t magic_number_2() const               { return *(intptr_t*)((address)this + magic_number_2_offset_in_bytes()); };
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
   186
#endif //ASSERT
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
   187
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
   188
  enum { RETURN_VALUE_PLACEHOLDER = (NOT_DEBUG(0) DEBUG_ONLY(42)) };
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
   189
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
   190
  static void verify_offsets() NOT_DEBUG_RETURN;
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
   191
  void verify() const NOT_DEBUG_RETURN; // check for MAGIC_NUMBER, etc.
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
   192
  void zap_arguments() NOT_DEBUG_RETURN;
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
   193
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
   194
  static void generate_ricochet_blob(MacroAssembler* _masm,
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
   195
                                     // output params:
9976
6fef34e63df1 7045514: SPARC assembly code for JSR 292 ricochet frames
never
parents: 9630
diff changeset
   196
                                     int* bounce_offset,
6fef34e63df1 7045514: SPARC assembly code for JSR 292 ricochet frames
never
parents: 9630
diff changeset
   197
                                     int* exception_offset,
6fef34e63df1 7045514: SPARC assembly code for JSR 292 ricochet frames
never
parents: 9630
diff changeset
   198
                                     int* frame_size_in_words);
9630
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
   199
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
   200
  static void enter_ricochet_frame(MacroAssembler* _masm,
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
   201
                                   Register rcx_recv,
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
   202
                                   Register rax_argv,
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
   203
                                   address return_handler,
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
   204
                                   Register rbx_temp);
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
   205
  static void leave_ricochet_frame(MacroAssembler* _masm,
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
   206
                                   Register rcx_recv,
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
   207
                                   Register new_sp_reg,
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
   208
                                   Register sender_pc_reg);
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
   209
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
   210
  static Address frame_address(int offset = 0) {
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
   211
    // The RicochetFrame is found by subtracting a constant offset from rbp.
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
   212
    return Address(rbp, - sender_link_offset_in_bytes() + offset);
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
   213
  }
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
   214
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
   215
  static RicochetFrame* from_frame(const frame& fr) {
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
   216
    address bp = (address) fr.fp();
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
   217
    RicochetFrame* rf = (RicochetFrame*)(bp - sender_link_offset_in_bytes());
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
   218
    rf->verify();
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
   219
    return rf;
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
   220
  }
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
   221
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
   222
  static void verify_clean(MacroAssembler* _masm) NOT_DEBUG_RETURN;
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
   223
};
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
   224
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
   225
// Additional helper methods for MethodHandles code generation:
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
   226
public:
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
   227
  static void load_klass_from_Class(MacroAssembler* _masm, Register klass_reg);
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
   228
  static void load_conversion_vminfo(MacroAssembler* _masm, Register reg, Address conversion_field_addr);
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
   229
  static void load_conversion_dest_type(MacroAssembler* _masm, Register reg, Address conversion_field_addr);
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
   230
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
   231
  static void load_stack_move(MacroAssembler* _masm,
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
   232
                              Register rdi_stack_move,
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
   233
                              Register rcx_amh,
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
   234
                              bool might_be_negative);
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
   235
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
   236
  static void insert_arg_slots(MacroAssembler* _masm,
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
   237
                               RegisterOrConstant arg_slots,
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
   238
                               Register rax_argslot,
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
   239
                               Register rbx_temp, Register rdx_temp);
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
   240
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
   241
  static void remove_arg_slots(MacroAssembler* _masm,
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
   242
                               RegisterOrConstant arg_slots,
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
   243
                               Register rax_argslot,
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
   244
                               Register rbx_temp, Register rdx_temp);
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
   245
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
   246
  static void push_arg_slots(MacroAssembler* _masm,
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
   247
                                   Register rax_argslot,
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
   248
                                   RegisterOrConstant slot_count,
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
   249
                                   int skip_words_count,
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
   250
                                   Register rbx_temp, Register rdx_temp);
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
   251
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
   252
  static void move_arg_slots_up(MacroAssembler* _masm,
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
   253
                                Register rbx_bottom,  // invariant
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
   254
                                Address  top_addr,    // can use rax_temp
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
   255
                                RegisterOrConstant positive_distance_in_slots,
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
   256
                                Register rax_temp, Register rdx_temp);
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
   257
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
   258
  static void move_arg_slots_down(MacroAssembler* _masm,
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
   259
                                  Address  bottom_addr,  // can use rax_temp
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
   260
                                  Register rbx_top,      // invariant
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
   261
                                  RegisterOrConstant negative_distance_in_slots,
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
   262
                                  Register rax_temp, Register rdx_temp);
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
   263
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
   264
  static void move_typed_arg(MacroAssembler* _masm,
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
   265
                             BasicType type, bool is_element,
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
   266
                             Address slot_dest, Address value_src,
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
   267
                             Register rbx_temp, Register rdx_temp);
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
   268
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
   269
  static void move_return_value(MacroAssembler* _masm, BasicType type,
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
   270
                                Address return_slot);
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
   271
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
   272
  static void verify_argslot(MacroAssembler* _masm, Register argslot_reg,
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
   273
                             const char* error_message) NOT_DEBUG_RETURN;
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
   274
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
   275
  static void verify_argslots(MacroAssembler* _masm,
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
   276
                              RegisterOrConstant argslot_count,
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
   277
                              Register argslot_reg,
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
   278
                              bool negate_argslot,
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
   279
                              const char* error_message) NOT_DEBUG_RETURN;
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
   280
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
   281
  static void verify_stack_move(MacroAssembler* _masm,
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
   282
                                RegisterOrConstant arg_slots,
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
   283
                                int direction) NOT_DEBUG_RETURN;
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
   284
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
   285
  static void verify_klass(MacroAssembler* _masm,
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
   286
                           Register obj, KlassHandle klass,
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
   287
                           const char* error_message = "wrong klass") NOT_DEBUG_RETURN;
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
   288
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
   289
  static void verify_method_handle(MacroAssembler* _masm, Register mh_reg) {
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
   290
    verify_klass(_masm, mh_reg, SystemDictionaryHandles::MethodHandle_klass(),
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
   291
                 "reference is a MH");
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
   292
  }
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
   293
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
   294
  static void trace_method_handle(MacroAssembler* _masm, const char* adaptername) PRODUCT_RETURN;
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
   295
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
   296
  static Register saved_last_sp_register() {
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
   297
    // Should be in sharedRuntime, not here.
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
   298
    return LP64_ONLY(r13) NOT_LP64(rsi);
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents:
diff changeset
   299
  }