hotspot/src/cpu/sparc/vm/frame_sparc.hpp
author twisti
Fri, 13 Feb 2009 09:09:35 -0800
changeset 2031 24e034f56dcb
parent 1 489c9b5090e2
child 5547 f4b087cbb361
permissions -rw-r--r--
6800154: Add comments to long_by_long_mulhi() for better understandability Summary: This patch adds a comment pointing to the Hacker's Delight version of the algorithm plus a verbatim copy of it. Furthermore it adds inline comments. Reviewed-by: kvn, jrose
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
489c9b5090e2 Initial load
duke
parents:
diff changeset
     2
 * Copyright 1997-2006 Sun Microsystems, Inc.  All Rights Reserved.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     4
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
489c9b5090e2 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
489c9b5090e2 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     8
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
489c9b5090e2 Initial load
duke
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
489c9b5090e2 Initial load
duke
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
489c9b5090e2 Initial load
duke
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
489c9b5090e2 Initial load
duke
parents:
diff changeset
    13
 * accompanied this code).
489c9b5090e2 Initial load
duke
parents:
diff changeset
    14
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
489c9b5090e2 Initial load
duke
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    18
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    19
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    20
 * CA 95054 USA or visit www.sun.com if you need additional information or
489c9b5090e2 Initial load
duke
parents:
diff changeset
    21
 * have any questions.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    22
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    23
 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    24
489c9b5090e2 Initial load
duke
parents:
diff changeset
    25
// A frame represents a physical stack frame (an activation).  Frames can be
489c9b5090e2 Initial load
duke
parents:
diff changeset
    26
// C or Java frames, and the Java frames can be interpreted or compiled.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    27
// In contrast, vframes represent source-level activations, so that one physical frame
489c9b5090e2 Initial load
duke
parents:
diff changeset
    28
// can correspond to multiple source level frames because of inlining.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    29
// A frame is comprised of {pc, sp, younger_sp}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    30
489c9b5090e2 Initial load
duke
parents:
diff changeset
    31
489c9b5090e2 Initial load
duke
parents:
diff changeset
    32
// Layout of asm interpreter frame:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    33
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    34
//  0xfffffff
489c9b5090e2 Initial load
duke
parents:
diff changeset
    35
//  ......
489c9b5090e2 Initial load
duke
parents:
diff changeset
    36
// [last  extra incoming arg,  (local # Nargs > 6 ? Nargs-1 : undef)]
489c9b5090e2 Initial load
duke
parents:
diff changeset
    37
// .. Note: incoming args are copied to local frame area upon entry
489c9b5090e2 Initial load
duke
parents:
diff changeset
    38
// [first extra incoming arg,  (local # Nargs > 6 ? 6       : undef)]
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
// [6 words for C-arg storage (unused)] Are this and next one really needed?
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
// [C-aggregate-word (unused)] Yes, if want extra params to be  in same place as C convention
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
// [16 words for register saving]                                    <--- FP
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
// [interpreter_frame_vm_locals ] (see below)
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
//              Note: Llocals is always double-word aligned
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
// [first local i.e. local # 0]        <-- Llocals
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
// ...
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
// [last local, i.e. local # Nlocals-1]
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
// [monitors                 ]
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
// ....
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
// [monitors                 ]    <-- Lmonitors (same as Llocals + 6*4 if none)
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
//                                    (must be double-word aligned because
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
//                                     monitor element size is constrained to
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
//                                     doubleword)
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
//                                <-- Lesp (points 1 past TOS)
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
// [bottom word used for stack ]
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
// ...
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
// [top word used for stack]    (first word of stack is double-word aligned)
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
// [space for outgoing args (conservatively allocated as max_stack - 6 + interpreter_frame_extra_outgoing_argument_words)]
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
// [6 words for C-arg storage]
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
// [C-aggregate-word (unused)]
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
// [16 words for register saving]                                    <--- SP
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
// ...
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
// 0x0000000
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
// The in registers and local registers are preserved in a block at SP.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
// The first six in registers (I0..I5) hold the first six locals.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
// The locals are used as follows:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
//    Lesp         first free element of expression stack
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
//                 (which grows towards __higher__ addresses)
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
//    Lbcp         is set to address of bytecode to execute
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
//                 It is accessed in the frame under the name "bcx".
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
//                 It may at times (during GC) be an index instead.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
//    Lmethod      the method being interpreted
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
//    Llocals      the base pointer for accessing the locals array
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
//                 (lower-numbered locals have lower addresses)
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
//    Lmonitors    the base pointer for accessing active monitors
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
//    Lcache       a saved pointer to the method's constant pool cache
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
// When calling out to another method,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
// G5_method is set to method to call, G5_inline_cache_klass may be set,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
// parameters are put in O registers, and also extra parameters
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
// must be cleverly copied from the top of stack to the outgoing param area in the frame,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
// ------------------------------ C++ interpreter ----------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
// Layout of C++ interpreter frame:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
// All frames:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
  enum {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
    // normal return address is 2 words past PC
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
    pc_return_offset                             = 2 * BytesPerInstWord,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
    // size of each block, in order of increasing address:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
    register_save_words                          = 16,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
#ifdef _LP64
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
    callee_aggregate_return_pointer_words        =  0,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
#else
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
    callee_aggregate_return_pointer_words        =  1,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
    callee_register_argument_save_area_words     =  6,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
    // memory_parameter_words                    = <arbitrary>,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
    // offset of each block, in order of increasing address:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
    // (note: callee_register_argument_save_area_words == Assembler::n_register_parameters)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
    register_save_words_sp_offset                = 0,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
    callee_aggregate_return_pointer_sp_offset    = register_save_words_sp_offset + register_save_words,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
    callee_register_argument_save_area_sp_offset = callee_aggregate_return_pointer_sp_offset + callee_aggregate_return_pointer_words,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
    memory_parameter_word_sp_offset              = callee_register_argument_save_area_sp_offset + callee_register_argument_save_area_words,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
    varargs_offset                               = memory_parameter_word_sp_offset
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
  };
489c9b5090e2 Initial load
duke
parents:
diff changeset
   120
489c9b5090e2 Initial load
duke
parents:
diff changeset
   121
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   122
  intptr_t*  _younger_sp;                 // optional SP of callee (used to locate O7)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   123
  int        _sp_adjustment_by_callee;   // adjustment in words to SP by callee for making locals contiguous
489c9b5090e2 Initial load
duke
parents:
diff changeset
   124
489c9b5090e2 Initial load
duke
parents:
diff changeset
   125
  // Note:  On SPARC, unlike Intel, the saved PC for a stack frame
489c9b5090e2 Initial load
duke
parents:
diff changeset
   126
  // is stored at a __variable__ distance from that frame's SP.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   127
  // (In fact, it may be in the register save area of the callee frame,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   128
  // but that fact need not bother us.)  Thus, we must store the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   129
  // address of that saved PC explicitly.  On the other hand, SPARC
489c9b5090e2 Initial load
duke
parents:
diff changeset
   130
  // stores the FP for a frame at a fixed offset from the frame's SP,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   131
  // so there is no need for a separate "frame::_fp" field.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   132
489c9b5090e2 Initial load
duke
parents:
diff changeset
   133
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   134
  // Accessors
489c9b5090e2 Initial load
duke
parents:
diff changeset
   135
489c9b5090e2 Initial load
duke
parents:
diff changeset
   136
  intptr_t* younger_sp() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   137
    assert(_younger_sp != NULL, "frame must possess a younger_sp");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   138
    return _younger_sp;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   139
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   140
489c9b5090e2 Initial load
duke
parents:
diff changeset
   141
  int callee_sp_adjustment() const { return _sp_adjustment_by_callee; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   142
  void set_sp_adjustment_by_callee(int number_of_words) { _sp_adjustment_by_callee = number_of_words; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   143
489c9b5090e2 Initial load
duke
parents:
diff changeset
   144
  // Constructors
489c9b5090e2 Initial load
duke
parents:
diff changeset
   145
489c9b5090e2 Initial load
duke
parents:
diff changeset
   146
  // This constructor relies on the fact that the creator of a frame
489c9b5090e2 Initial load
duke
parents:
diff changeset
   147
  // has flushed register windows which the frame will refer to, and
489c9b5090e2 Initial load
duke
parents:
diff changeset
   148
  // that those register windows will not be reloaded until the frame is
489c9b5090e2 Initial load
duke
parents:
diff changeset
   149
  // done reading and writing the stack.  Moreover, if the "younger_sp"
489c9b5090e2 Initial load
duke
parents:
diff changeset
   150
  // argument points into the register save area of the next younger
489c9b5090e2 Initial load
duke
parents:
diff changeset
   151
  // frame (though it need not), the register window for that next
489c9b5090e2 Initial load
duke
parents:
diff changeset
   152
  // younger frame must also stay flushed.  (The caller is responsible
489c9b5090e2 Initial load
duke
parents:
diff changeset
   153
  // for ensuring this.)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   154
489c9b5090e2 Initial load
duke
parents:
diff changeset
   155
  frame(intptr_t* sp, intptr_t* younger_sp, bool younger_frame_adjusted_stack = false);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   156
489c9b5090e2 Initial load
duke
parents:
diff changeset
   157
  // make a deficient frame which doesn't know where its PC is:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   158
  enum unpatchable_t { unpatchable };
489c9b5090e2 Initial load
duke
parents:
diff changeset
   159
  frame(intptr_t* sp, unpatchable_t, address pc = NULL, CodeBlob* cb = NULL);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   160
489c9b5090e2 Initial load
duke
parents:
diff changeset
   161
  // Walk from sp outward looking for old_sp, and return old_sp's predecessor
489c9b5090e2 Initial load
duke
parents:
diff changeset
   162
  // (i.e. return the sp from the frame where old_sp is the fp).
489c9b5090e2 Initial load
duke
parents:
diff changeset
   163
  // Register windows are assumed to be flushed for the stack in question.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   164
489c9b5090e2 Initial load
duke
parents:
diff changeset
   165
  static intptr_t* next_younger_sp_or_null(intptr_t* old_sp, intptr_t* sp);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   166
489c9b5090e2 Initial load
duke
parents:
diff changeset
   167
  // Return true if sp is a younger sp in the stack described by valid_sp.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   168
  static bool is_valid_stack_pointer(intptr_t* valid_sp, intptr_t* sp);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   169
489c9b5090e2 Initial load
duke
parents:
diff changeset
   170
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   171
  // accessors for the instance variables
489c9b5090e2 Initial load
duke
parents:
diff changeset
   172
  intptr_t*   fp() const { return (intptr_t*) ((intptr_t)(sp()[FP->sp_offset_in_saved_window()]) + STACK_BIAS ); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   173
489c9b5090e2 Initial load
duke
parents:
diff changeset
   174
  // All frames
489c9b5090e2 Initial load
duke
parents:
diff changeset
   175
489c9b5090e2 Initial load
duke
parents:
diff changeset
   176
  intptr_t*  fp_addr_at(int index) const   { return &fp()[index];    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   177
  intptr_t*  sp_addr_at(int index) const   { return &sp()[index];    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   178
  intptr_t   fp_at(     int index) const   { return *fp_addr_at(index); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   179
  intptr_t   sp_at(     int index) const   { return *sp_addr_at(index); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   180
489c9b5090e2 Initial load
duke
parents:
diff changeset
   181
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   182
  inline address* I7_addr() const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   183
  inline address* O7_addr() const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   184
489c9b5090e2 Initial load
duke
parents:
diff changeset
   185
  inline address* I0_addr() const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   186
  inline address* O0_addr() const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   187
  intptr_t*  younger_sp_addr_at(int index) const   { return &younger_sp()[index];    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   188
489c9b5090e2 Initial load
duke
parents:
diff changeset
   189
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   190
  // access to SPARC arguments and argument registers
489c9b5090e2 Initial load
duke
parents:
diff changeset
   191
489c9b5090e2 Initial load
duke
parents:
diff changeset
   192
  // Assumes reg is an in/local register
489c9b5090e2 Initial load
duke
parents:
diff changeset
   193
  intptr_t*     register_addr(Register reg) const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   194
    return sp_addr_at(reg->sp_offset_in_saved_window());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   195
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   196
489c9b5090e2 Initial load
duke
parents:
diff changeset
   197
  // Assumes reg is an out register
489c9b5090e2 Initial load
duke
parents:
diff changeset
   198
  intptr_t*     out_register_addr(Register reg) const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   199
    return younger_sp_addr_at(reg->after_save()->sp_offset_in_saved_window());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   200
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   201
  intptr_t* memory_param_addr(int param_ix, bool is_in) const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   202
    int offset = callee_register_argument_save_area_sp_offset + param_ix;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   203
    if (is_in)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   204
      return fp_addr_at(offset);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   205
    else
489c9b5090e2 Initial load
duke
parents:
diff changeset
   206
      return sp_addr_at(offset);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   207
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   208
  intptr_t*        param_addr(int param_ix, bool is_in) const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   209
    if (param_ix >= callee_register_argument_save_area_words)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   210
      return memory_param_addr(param_ix, is_in);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   211
    else if (is_in)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   212
      return register_addr(Argument(param_ix, true).as_register());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   213
    else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   214
      // the registers are stored in the next younger frame
489c9b5090e2 Initial load
duke
parents:
diff changeset
   215
      // %%% is this really necessary?
489c9b5090e2 Initial load
duke
parents:
diff changeset
   216
      ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   217
      return NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   218
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   219
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   220
489c9b5090e2 Initial load
duke
parents:
diff changeset
   221
489c9b5090e2 Initial load
duke
parents:
diff changeset
   222
  // Interpreter frames
489c9b5090e2 Initial load
duke
parents:
diff changeset
   223
489c9b5090e2 Initial load
duke
parents:
diff changeset
   224
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   225
  // Asm interpreter
489c9b5090e2 Initial load
duke
parents:
diff changeset
   226
#ifndef CC_INTERP
489c9b5090e2 Initial load
duke
parents:
diff changeset
   227
  enum interpreter_frame_vm_locals {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   228
       // 2 words, also used to save float regs across  calls to C
489c9b5090e2 Initial load
duke
parents:
diff changeset
   229
       interpreter_frame_d_scratch_fp_offset          = -2,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   230
       interpreter_frame_l_scratch_fp_offset          = -4,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   231
       interpreter_frame_padding_offset               = -5, // for native calls only
489c9b5090e2 Initial load
duke
parents:
diff changeset
   232
       interpreter_frame_oop_temp_offset              = -6, // for native calls only
489c9b5090e2 Initial load
duke
parents:
diff changeset
   233
       interpreter_frame_vm_locals_fp_offset          = -6, // should be same as above, and should be zero mod 8
489c9b5090e2 Initial load
duke
parents:
diff changeset
   234
489c9b5090e2 Initial load
duke
parents:
diff changeset
   235
       interpreter_frame_vm_local_words = -interpreter_frame_vm_locals_fp_offset,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   236
489c9b5090e2 Initial load
duke
parents:
diff changeset
   237
489c9b5090e2 Initial load
duke
parents:
diff changeset
   238
       // interpreter frame set-up needs to save 2 extra words in outgoing param area
489c9b5090e2 Initial load
duke
parents:
diff changeset
   239
       // for class and jnienv arguments for native stubs (see nativeStubGen_sparc.cpp_
489c9b5090e2 Initial load
duke
parents:
diff changeset
   240
489c9b5090e2 Initial load
duke
parents:
diff changeset
   241
       interpreter_frame_extra_outgoing_argument_words = 2
489c9b5090e2 Initial load
duke
parents:
diff changeset
   242
  };
489c9b5090e2 Initial load
duke
parents:
diff changeset
   243
#else
489c9b5090e2 Initial load
duke
parents:
diff changeset
   244
  enum interpreter_frame_vm_locals {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   245
       // 2 words, also used to save float regs across  calls to C
489c9b5090e2 Initial load
duke
parents:
diff changeset
   246
       interpreter_state_ptr_offset                   = 0,  // Is in L0 (Lstate) in save area
489c9b5090e2 Initial load
duke
parents:
diff changeset
   247
       interpreter_frame_mirror_offset                = 1,  // Is in L1 (Lmirror) in save area (for native calls only)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   248
489c9b5090e2 Initial load
duke
parents:
diff changeset
   249
       // interpreter frame set-up needs to save 2 extra words in outgoing param area
489c9b5090e2 Initial load
duke
parents:
diff changeset
   250
       // for class and jnienv arguments for native stubs (see nativeStubGen_sparc.cpp_
489c9b5090e2 Initial load
duke
parents:
diff changeset
   251
489c9b5090e2 Initial load
duke
parents:
diff changeset
   252
       interpreter_frame_extra_outgoing_argument_words = 2
489c9b5090e2 Initial load
duke
parents:
diff changeset
   253
  };
489c9b5090e2 Initial load
duke
parents:
diff changeset
   254
#endif /* CC_INTERP */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   255
489c9b5090e2 Initial load
duke
parents:
diff changeset
   256
  // the compiler frame has many of the same fields as the interpreter frame
489c9b5090e2 Initial load
duke
parents:
diff changeset
   257
  // %%%%% factor out declarations of the shared fields
489c9b5090e2 Initial load
duke
parents:
diff changeset
   258
  enum compiler_frame_fixed_locals {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   259
       compiler_frame_d_scratch_fp_offset          = -2,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   260
       compiler_frame_vm_locals_fp_offset          = -2, // should be same as above
489c9b5090e2 Initial load
duke
parents:
diff changeset
   261
489c9b5090e2 Initial load
duke
parents:
diff changeset
   262
       compiler_frame_vm_local_words = -compiler_frame_vm_locals_fp_offset
489c9b5090e2 Initial load
duke
parents:
diff changeset
   263
  };
489c9b5090e2 Initial load
duke
parents:
diff changeset
   264
489c9b5090e2 Initial load
duke
parents:
diff changeset
   265
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   266
489c9b5090e2 Initial load
duke
parents:
diff changeset
   267
  constantPoolCacheOop* frame::interpreter_frame_cpoolcache_addr() const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   268
489c9b5090e2 Initial load
duke
parents:
diff changeset
   269
#ifndef CC_INTERP
489c9b5090e2 Initial load
duke
parents:
diff changeset
   270
489c9b5090e2 Initial load
duke
parents:
diff changeset
   271
  // where Lmonitors is saved:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   272
  BasicObjectLock**  interpreter_frame_monitors_addr() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   273
    return (BasicObjectLock**) sp_addr_at(Lmonitors->sp_offset_in_saved_window());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   274
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   275
  intptr_t** interpreter_frame_esp_addr() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   276
    return (intptr_t**)sp_addr_at(Lesp->sp_offset_in_saved_window());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   277
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   278
489c9b5090e2 Initial load
duke
parents:
diff changeset
   279
  inline void interpreter_frame_set_tos_address(intptr_t* x);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   280
489c9b5090e2 Initial load
duke
parents:
diff changeset
   281
489c9b5090e2 Initial load
duke
parents:
diff changeset
   282
  // %%%%% Another idea: instead of defining 3 fns per item, just define one returning a ref
489c9b5090e2 Initial load
duke
parents:
diff changeset
   283
489c9b5090e2 Initial load
duke
parents:
diff changeset
   284
  // monitors:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   285
489c9b5090e2 Initial load
duke
parents:
diff changeset
   286
  // next two fns read and write Lmonitors value,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   287
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   288
  BasicObjectLock* interpreter_frame_monitors()           const  { return *interpreter_frame_monitors_addr(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   289
  void interpreter_frame_set_monitors(BasicObjectLock* monitors) {        *interpreter_frame_monitors_addr() = monitors; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   290
#else
489c9b5090e2 Initial load
duke
parents:
diff changeset
   291
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   292
  inline interpreterState get_interpreterState() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   293
    return ((interpreterState)sp_at(interpreter_state_ptr_offset));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   294
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   295
489c9b5090e2 Initial load
duke
parents:
diff changeset
   296
489c9b5090e2 Initial load
duke
parents:
diff changeset
   297
#endif /* CC_INTERP */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   298
489c9b5090e2 Initial load
duke
parents:
diff changeset
   299
489c9b5090e2 Initial load
duke
parents:
diff changeset
   300
489c9b5090e2 Initial load
duke
parents:
diff changeset
   301
 // Compiled frames
489c9b5090e2 Initial load
duke
parents:
diff changeset
   302
489c9b5090e2 Initial load
duke
parents:
diff changeset
   303
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   304
  // Tells if this register can hold 64 bits on V9 (really, V8+).
489c9b5090e2 Initial load
duke
parents:
diff changeset
   305
  static bool holds_a_doubleword(Register reg) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   306
#ifdef _LP64
489c9b5090e2 Initial load
duke
parents:
diff changeset
   307
    //    return true;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   308
    return reg->is_out() || reg->is_global();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   309
#else
489c9b5090e2 Initial load
duke
parents:
diff changeset
   310
    return reg->is_out() || reg->is_global();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   311
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   312
  }