hotspot/src/share/vm/shark/sharkCacheDecache.hpp
author twisti
Wed, 11 Aug 2010 05:51:21 -0700
changeset 6187 4fa7845f7c14
child 7397 5b173b4ca846
permissions -rw-r--r--
6976186: integrate Shark HotSpot changes Summary: Shark is a JIT compiler for Zero that uses the LLVM compiler infrastructure. Reviewed-by: kvn, twisti Contributed-by: Gary Benson <gbenson@redhat.com>
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
6187
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
     1
/*
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
     2
 * Copyright (c) 1999, 2007, Oracle and/or its affiliates. All rights reserved.
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
     3
 * Copyright 2008, 2009 Red Hat, Inc.
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
     4
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
     5
 *
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
     6
 * This code is free software; you can redistribute it and/or modify it
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
     7
 * under the terms of the GNU General Public License version 2 only, as
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
     8
 * published by the Free Software Foundation.
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
     9
 *
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    10
 * This code is distributed in the hope that it will be useful, but WITHOUT
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    11
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    12
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    13
 * version 2 for more details (a copy is included in the LICENSE file that
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    14
 * accompanied this code).
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    15
 *
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    16
 * You should have received a copy of the GNU General Public License version
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    17
 * 2 along with this work; if not, write to the Free Software Foundation,
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    18
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    19
 *
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    20
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    21
 * or visit www.oracle.com if you need additional information or have any
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    22
 * questions.
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    23
 *
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    24
 */
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    25
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    26
// Class hierarchy:
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    27
// - SharkStateScanner
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    28
//   - SharkCacherDecacher
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    29
//     - SharkDecacher
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    30
//       - SharkJavaCallDecacher
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    31
//       - SharkVMCallDecacher
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    32
//       - SharkTrapDecacher
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    33
//     - SharkCacher
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    34
//       - SharkJavaCallCacher
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    35
//       - SharkVMCallCacher
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    36
//       - SharkFunctionEntryCacher
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    37
//         - SharkNormalEntryCacher
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    38
//         - SharkOSREntryCacher
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    39
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    40
class SharkCacherDecacher : public SharkStateScanner {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    41
 protected:
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    42
  SharkCacherDecacher(SharkFunction* function)
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    43
    : SharkStateScanner(function) {}
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    44
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    45
  // Helper
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    46
 protected:
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    47
  static int adjusted_offset(SharkValue* value, int offset) {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    48
    if (value->is_two_word())
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    49
      offset--;
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    50
    return offset;
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    51
  }
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    52
};
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    53
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    54
class SharkDecacher : public SharkCacherDecacher {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    55
 protected:
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    56
  SharkDecacher(SharkFunction* function, int bci)
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    57
    : SharkCacherDecacher(function), _bci(bci) {}
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    58
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    59
 private:
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    60
  int _bci;
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    61
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    62
 protected:
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    63
  int bci() const {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    64
    return _bci;
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    65
  }
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    66
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    67
 private:
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    68
  int                           _pc_offset;
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    69
  OopMap*                       _oopmap;
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    70
  GrowableArray<ScopeValue*>*   _exparray;
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    71
  GrowableArray<MonitorValue*>* _monarray;
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    72
  GrowableArray<ScopeValue*>*   _locarray;
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    73
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    74
 private:
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    75
  int pc_offset() const {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    76
    return _pc_offset;
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    77
  }
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    78
  OopMap* oopmap() const {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    79
    return _oopmap;
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    80
  }
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    81
  GrowableArray<ScopeValue*>* exparray() const {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    82
    return _exparray;
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    83
  }
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    84
  GrowableArray<MonitorValue*>* monarray() const {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    85
    return _monarray;
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    86
  }
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    87
  GrowableArray<ScopeValue*>* locarray() const {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    88
    return _locarray;
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    89
  }
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    90
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    91
  // Callbacks
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    92
 protected:
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    93
  void start_frame();
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    94
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    95
  void start_stack(int stack_depth);
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    96
  void process_stack_slot(int index, SharkValue** value, int offset);
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    97
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    98
  void start_monitors(int num_monitors);
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    99
  void process_monitor(int index, int box_offset, int obj_offset);
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   100
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   101
  void process_oop_tmp_slot(llvm::Value** value, int offset);
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   102
  void process_method_slot(llvm::Value** value, int offset);
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   103
  void process_pc_slot(int offset);
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   104
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   105
  void start_locals();
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   106
  void process_local_slot(int index, SharkValue** value, int offset);
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   107
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   108
  void end_frame();
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   109
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   110
  // oopmap and debuginfo helpers
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   111
 private:
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   112
  static int oopmap_slot_munge(int offset) {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   113
    return SharkStack::oopmap_slot_munge(offset);
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   114
  }
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   115
  static VMReg slot2reg(int offset) {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   116
    return SharkStack::slot2reg(offset);
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   117
  }
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   118
  static Location slot2loc(int offset, Location::Type type) {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   119
    return Location::new_stk_loc(type, offset * wordSize);
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   120
  }
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   121
  static LocationValue* slot2lv(int offset, Location::Type type) {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   122
    return new LocationValue(slot2loc(offset, type));
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   123
  }
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   124
  static Location::Type location_type(SharkValue** addr, bool maybe_two_word) {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   125
    // low addresses this end
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   126
    //                           Type       32-bit    64-bit
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   127
    //   ----------------------------------------------------
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   128
    //   stack[0]    local[3]    jobject    oop       oop
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   129
    //   stack[1]    local[2]    NULL       normal    lng
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   130
    //   stack[2]    local[1]    jlong      normal    invalid
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   131
    //   stack[3]    local[0]    jint       normal    normal
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   132
    //
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   133
    // high addresses this end
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   134
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   135
    SharkValue *value = *addr;
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   136
    if (value) {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   137
      if (value->is_jobject())
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   138
        return Location::oop;
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   139
#ifdef _LP64
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   140
      if (value->is_two_word())
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   141
        return Location::invalid;
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   142
#endif // _LP64
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   143
      return Location::normal;
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   144
    }
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   145
    else {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   146
      if (maybe_two_word) {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   147
        value = *(addr - 1);
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   148
        if (value && value->is_two_word()) {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   149
#ifdef _LP64
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   150
          if (value->is_jlong())
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   151
            return Location::lng;
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   152
          if (value->is_jdouble())
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   153
            return Location::dbl;
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   154
          ShouldNotReachHere();
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   155
#else
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   156
          return Location::normal;
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   157
#endif // _LP64
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   158
        }
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   159
      }
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   160
      return Location::invalid;
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   161
    }
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   162
  }
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   163
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   164
  // Stack slot helpers
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   165
 protected:
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   166
  virtual bool stack_slot_needs_write(int index, SharkValue* value) = 0;
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   167
  virtual bool stack_slot_needs_oopmap(int index, SharkValue* value) = 0;
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   168
  virtual bool stack_slot_needs_debuginfo(int index, SharkValue* value) = 0;
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   169
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   170
  static Location::Type stack_location_type(int index, SharkValue** addr) {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   171
    return location_type(addr, *addr == NULL);
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   172
  }
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   173
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   174
  // Local slot helpers
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   175
 protected:
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   176
  virtual bool local_slot_needs_write(int index, SharkValue* value) = 0;
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   177
  virtual bool local_slot_needs_oopmap(int index, SharkValue* value) = 0;
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   178
  virtual bool local_slot_needs_debuginfo(int index, SharkValue* value) = 0;
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   179
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   180
  static Location::Type local_location_type(int index, SharkValue** addr) {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   181
    return location_type(addr, index > 0);
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   182
  }
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   183
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   184
  // Writer helper
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   185
 protected:
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   186
  void write_value_to_frame(const llvm::Type* type,
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   187
                            llvm::Value*      value,
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   188
                            int               offset);
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   189
};
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   190
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   191
class SharkJavaCallDecacher : public SharkDecacher {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   192
 public:
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   193
  SharkJavaCallDecacher(SharkFunction* function, int bci, ciMethod* callee)
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   194
    : SharkDecacher(function, bci), _callee(callee) {}
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   195
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   196
 private:
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   197
  ciMethod* _callee;
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   198
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   199
 protected:
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   200
  ciMethod* callee() const {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   201
    return _callee;
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   202
  }
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   203
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   204
  // Stack slot helpers
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   205
 protected:
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   206
  bool stack_slot_needs_write(int index, SharkValue* value) {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   207
    return value && (index < callee()->arg_size() || value->is_jobject());
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   208
  }
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   209
  bool stack_slot_needs_oopmap(int index, SharkValue* value) {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   210
    return value && value->is_jobject() && index >= callee()->arg_size();
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   211
  }
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   212
  bool stack_slot_needs_debuginfo(int index, SharkValue* value) {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   213
    return index >= callee()->arg_size();
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   214
  }
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   215
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   216
  // Local slot helpers
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   217
 protected:
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   218
  bool local_slot_needs_write(int index, SharkValue* value) {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   219
    return value && value->is_jobject();
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   220
  }
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   221
  bool local_slot_needs_oopmap(int index, SharkValue* value) {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   222
    return value && value->is_jobject();
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   223
  }
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   224
  bool local_slot_needs_debuginfo(int index, SharkValue* value) {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   225
    return true;
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   226
  }
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   227
};
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   228
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   229
class SharkVMCallDecacher : public SharkDecacher {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   230
 public:
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   231
  SharkVMCallDecacher(SharkFunction* function, int bci)
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   232
    : SharkDecacher(function, bci) {}
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   233
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   234
  // Stack slot helpers
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   235
 protected:
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   236
  bool stack_slot_needs_write(int index, SharkValue* value) {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   237
    return value && value->is_jobject();
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   238
  }
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   239
  bool stack_slot_needs_oopmap(int index, SharkValue* value) {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   240
    return value && value->is_jobject();
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   241
  }
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   242
  bool stack_slot_needs_debuginfo(int index, SharkValue* value) {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   243
    return true;
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   244
  }
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   245
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   246
  // Local slot helpers
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   247
 protected:
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   248
  bool local_slot_needs_write(int index, SharkValue* value) {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   249
    return value && value->is_jobject();
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   250
  }
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   251
  bool local_slot_needs_oopmap(int index, SharkValue* value) {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   252
    return value && value->is_jobject();
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   253
  }
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   254
  bool local_slot_needs_debuginfo(int index, SharkValue* value) {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   255
    return true;
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   256
  }
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   257
};
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   258
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   259
class SharkTrapDecacher : public SharkDecacher {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   260
 public:
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   261
  SharkTrapDecacher(SharkFunction* function, int bci)
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   262
    : SharkDecacher(function, bci) {}
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   263
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   264
  // Stack slot helpers
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   265
 protected:
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   266
  bool stack_slot_needs_write(int index, SharkValue* value) {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   267
    return value != NULL;
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   268
  }
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   269
  bool stack_slot_needs_oopmap(int index, SharkValue* value) {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   270
    return value && value->is_jobject();
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   271
  }
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   272
  bool stack_slot_needs_debuginfo(int index, SharkValue* value) {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   273
    return true;
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   274
  }
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   275
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   276
  // Local slot helpers
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   277
 protected:
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   278
  bool local_slot_needs_write(int index, SharkValue* value) {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   279
    return value != NULL;
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   280
  }
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   281
  bool local_slot_needs_oopmap(int index, SharkValue* value) {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   282
    return value && value->is_jobject();
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   283
  }
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   284
  bool local_slot_needs_debuginfo(int index, SharkValue* value) {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   285
    return true;
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   286
  }
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   287
};
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   288
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   289
class SharkCacher : public SharkCacherDecacher {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   290
 protected:
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   291
  SharkCacher(SharkFunction* function)
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   292
    : SharkCacherDecacher(function) {}
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   293
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   294
  // Callbacks
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   295
 protected:
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   296
  void process_stack_slot(int index, SharkValue** value, int offset);
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   297
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   298
  void process_oop_tmp_slot(llvm::Value** value, int offset);
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   299
  virtual void process_method_slot(llvm::Value** value, int offset);
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   300
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   301
  virtual void process_local_slot(int index, SharkValue** value, int offset);
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   302
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   303
  // Stack slot helper
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   304
 protected:
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   305
  virtual bool stack_slot_needs_read(int index, SharkValue* value) = 0;
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   306
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   307
  // Local slot helper
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   308
 protected:
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   309
  virtual bool local_slot_needs_read(int index, SharkValue* value) {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   310
    return value && value->is_jobject();
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   311
  }
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   312
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   313
  // Writer helper
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   314
 protected:
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   315
  llvm::Value* read_value_from_frame(const llvm::Type* type, int offset);
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   316
};
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   317
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   318
class SharkJavaCallCacher : public SharkCacher {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   319
 public:
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   320
  SharkJavaCallCacher(SharkFunction* function, ciMethod* callee)
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   321
    : SharkCacher(function), _callee(callee) {}
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   322
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   323
 private:
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   324
  ciMethod* _callee;
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   325
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   326
 protected:
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   327
  ciMethod* callee() const {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   328
    return _callee;
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   329
  }
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   330
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   331
  // Stack slot helper
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   332
 protected:
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   333
  bool stack_slot_needs_read(int index, SharkValue* value) {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   334
    return value && (index < callee()->return_type()->size() ||
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   335
                     value->is_jobject());
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   336
  }
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   337
};
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   338
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   339
class SharkVMCallCacher : public SharkCacher {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   340
 public:
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   341
  SharkVMCallCacher(SharkFunction* function)
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   342
    : SharkCacher(function) {}
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   343
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   344
  // Stack slot helper
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   345
 protected:
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   346
  bool stack_slot_needs_read(int index, SharkValue* value) {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   347
    return value && value->is_jobject();
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   348
  }
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   349
};
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   350
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   351
class SharkFunctionEntryCacher : public SharkCacher {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   352
 public:
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   353
  SharkFunctionEntryCacher(SharkFunction* function, llvm::Value* method)
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   354
    : SharkCacher(function), _method(method) {}
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   355
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   356
 private:
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   357
  llvm::Value* _method;
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   358
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   359
 private:
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   360
  llvm::Value* method() const {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   361
    return _method;
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   362
  }
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   363
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   364
  // Method slot callback
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   365
 protected:
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   366
  void process_method_slot(llvm::Value** value, int offset);
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   367
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   368
  // Stack slot helper
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   369
 protected:
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   370
  bool stack_slot_needs_read(int index, SharkValue* value) {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   371
    ShouldNotReachHere(); // entry block shouldn't have stack
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   372
  }
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   373
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   374
  // Local slot helper
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   375
 protected:
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   376
  bool local_slot_needs_read(int index, SharkValue* value) {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   377
    return value != NULL;
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   378
  }
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   379
};
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   380
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   381
class SharkNormalEntryCacher : public SharkFunctionEntryCacher {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   382
 public:
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   383
  SharkNormalEntryCacher(SharkFunction* function, llvm::Value* method)
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   384
    : SharkFunctionEntryCacher(function, method) {}
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   385
};
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   386
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   387
class SharkOSREntryCacher : public SharkFunctionEntryCacher {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   388
 public:
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   389
  SharkOSREntryCacher(SharkFunction* function,
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   390
                      llvm::Value*   method,
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   391
                      llvm::Value*   osr_buf)
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   392
    : SharkFunctionEntryCacher(function, method),
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   393
      _osr_buf(
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   394
        builder()->CreateBitCast(
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   395
          osr_buf,
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   396
          llvm::PointerType::getUnqual(
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   397
            llvm::ArrayType::get(
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   398
              SharkType::intptr_type(),
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   399
              max_locals() + max_monitors() * 2)))) {}
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   400
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   401
 private:
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   402
  llvm::Value* _osr_buf;
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   403
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   404
 private:
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   405
  llvm::Value* osr_buf() const {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   406
    return _osr_buf;
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   407
  }
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   408
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   409
  // Callbacks
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   410
 protected:
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   411
  void process_monitor(int index, int box_offset, int obj_offset);
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   412
  void process_local_slot(int index, SharkValue** value, int offset);
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   413
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   414
  // Helper
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   415
 private:
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   416
  llvm::Value* CreateAddressOfOSRBufEntry(int offset, const llvm::Type* type);
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   417
};