src/share/vm/shark/sharkState.hpp

Tue, 08 Aug 2017 15:57:29 +0800

author
aoqi
date
Tue, 08 Aug 2017 15:57:29 +0800
changeset 6876
710a3c8b516e
parent 2314
f95d63e2154a
parent 0
f90c822e73f8
permissions
-rw-r--r--

merge

aoqi@0 1 /*
aoqi@0 2 * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
aoqi@0 3 * Copyright 2008, 2009 Red Hat, Inc.
aoqi@0 4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
aoqi@0 5 *
aoqi@0 6 * This code is free software; you can redistribute it and/or modify it
aoqi@0 7 * under the terms of the GNU General Public License version 2 only, as
aoqi@0 8 * published by the Free Software Foundation.
aoqi@0 9 *
aoqi@0 10 * This code is distributed in the hope that it will be useful, but WITHOUT
aoqi@0 11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
aoqi@0 12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
aoqi@0 13 * version 2 for more details (a copy is included in the LICENSE file that
aoqi@0 14 * accompanied this code).
aoqi@0 15 *
aoqi@0 16 * You should have received a copy of the GNU General Public License version
aoqi@0 17 * 2 along with this work; if not, write to the Free Software Foundation,
aoqi@0 18 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
aoqi@0 19 *
aoqi@0 20 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
aoqi@0 21 * or visit www.oracle.com if you need additional information or have any
aoqi@0 22 * questions.
aoqi@0 23 *
aoqi@0 24 */
aoqi@0 25
aoqi@0 26 #ifndef SHARE_VM_SHARK_SHARKSTATE_HPP
aoqi@0 27 #define SHARE_VM_SHARK_SHARKSTATE_HPP
aoqi@0 28
aoqi@0 29 #include "ci/ciMethod.hpp"
aoqi@0 30 #include "memory/allocation.hpp"
aoqi@0 31 #include "shark/llvmHeaders.hpp"
aoqi@0 32 #include "shark/sharkBuilder.hpp"
aoqi@0 33 #include "shark/sharkInvariants.hpp"
aoqi@0 34 #include "shark/sharkValue.hpp"
aoqi@0 35
aoqi@0 36 class SharkState : public SharkTargetInvariants {
aoqi@0 37 public:
aoqi@0 38 SharkState(const SharkTargetInvariants* parent)
aoqi@0 39 : SharkTargetInvariants(parent),
aoqi@0 40 _method(NULL),
aoqi@0 41 _oop_tmp(NULL),
aoqi@0 42 _has_safepointed(false) { initialize(NULL); }
aoqi@0 43
aoqi@0 44 SharkState(const SharkState* state)
aoqi@0 45 : SharkTargetInvariants(state),
aoqi@0 46 _method(state->_method),
aoqi@0 47 _oop_tmp(state->_oop_tmp),
aoqi@0 48 _has_safepointed(state->_has_safepointed) { initialize(state); }
aoqi@0 49
aoqi@0 50 private:
aoqi@0 51 void initialize(const SharkState* state);
aoqi@0 52
aoqi@0 53 private:
aoqi@0 54 llvm::Value* _method;
aoqi@0 55 SharkValue** _locals;
aoqi@0 56 SharkValue** _stack;
aoqi@0 57 SharkValue** _sp;
aoqi@0 58 int _num_monitors;
aoqi@0 59 llvm::Value* _oop_tmp;
aoqi@0 60 bool _has_safepointed;
aoqi@0 61
aoqi@0 62 // Method
aoqi@0 63 public:
aoqi@0 64 llvm::Value** method_addr() {
aoqi@0 65 return &_method;
aoqi@0 66 }
aoqi@0 67 llvm::Value* method() const {
aoqi@0 68 return _method;
aoqi@0 69 }
aoqi@0 70 protected:
aoqi@0 71 void set_method(llvm::Value* method) {
aoqi@0 72 _method = method;
aoqi@0 73 }
aoqi@0 74
aoqi@0 75 // Local variables
aoqi@0 76 public:
aoqi@0 77 SharkValue** local_addr(int index) const {
aoqi@0 78 assert(index >= 0 && index < max_locals(), "bad local variable index");
aoqi@0 79 return &_locals[index];
aoqi@0 80 }
aoqi@0 81 SharkValue* local(int index) const {
aoqi@0 82 return *local_addr(index);
aoqi@0 83 }
aoqi@0 84 void set_local(int index, SharkValue* value) {
aoqi@0 85 *local_addr(index) = value;
aoqi@0 86 }
aoqi@0 87
aoqi@0 88 // Expression stack
aoqi@0 89 public:
aoqi@0 90 SharkValue** stack_addr(int slot) const {
aoqi@0 91 assert(slot >= 0 && slot < stack_depth(), "bad stack slot");
aoqi@0 92 return &_sp[-(slot + 1)];
aoqi@0 93 }
aoqi@0 94 SharkValue* stack(int slot) const {
aoqi@0 95 return *stack_addr(slot);
aoqi@0 96 }
aoqi@0 97 protected:
aoqi@0 98 void set_stack(int slot, SharkValue* value) {
aoqi@0 99 *stack_addr(slot) = value;
aoqi@0 100 }
aoqi@0 101 public:
aoqi@0 102 int stack_depth() const {
aoqi@0 103 return _sp - _stack;
aoqi@0 104 }
aoqi@0 105 void push(SharkValue* value) {
aoqi@0 106 assert(stack_depth() < max_stack(), "stack overrun");
aoqi@0 107 *(_sp++) = value;
aoqi@0 108 }
aoqi@0 109 SharkValue* pop() {
aoqi@0 110 assert(stack_depth() > 0, "stack underrun");
aoqi@0 111 return *(--_sp);
aoqi@0 112 }
aoqi@0 113
aoqi@0 114 // Monitors
aoqi@0 115 public:
aoqi@0 116 int num_monitors() const {
aoqi@0 117 return _num_monitors;
aoqi@0 118 }
aoqi@0 119 void set_num_monitors(int num_monitors) {
aoqi@0 120 _num_monitors = num_monitors;
aoqi@0 121 }
aoqi@0 122
aoqi@0 123 // Temporary oop slot
aoqi@0 124 public:
aoqi@0 125 llvm::Value** oop_tmp_addr() {
aoqi@0 126 return &_oop_tmp;
aoqi@0 127 }
aoqi@0 128 llvm::Value* oop_tmp() const {
aoqi@0 129 return _oop_tmp;
aoqi@0 130 }
aoqi@0 131 void set_oop_tmp(llvm::Value* oop_tmp) {
aoqi@0 132 _oop_tmp = oop_tmp;
aoqi@0 133 }
aoqi@0 134
aoqi@0 135 // Safepointed status
aoqi@0 136 public:
aoqi@0 137 bool has_safepointed() const {
aoqi@0 138 return _has_safepointed;
aoqi@0 139 }
aoqi@0 140 void set_has_safepointed(bool has_safepointed) {
aoqi@0 141 _has_safepointed = has_safepointed;
aoqi@0 142 }
aoqi@0 143
aoqi@0 144 // Comparison
aoqi@0 145 public:
aoqi@0 146 bool equal_to(SharkState* other);
aoqi@0 147
aoqi@0 148 // Copy and merge
aoqi@0 149 public:
aoqi@0 150 SharkState* copy() const {
aoqi@0 151 return new SharkState(this);
aoqi@0 152 }
aoqi@0 153 void merge(SharkState* other,
aoqi@0 154 llvm::BasicBlock* other_block,
aoqi@0 155 llvm::BasicBlock* this_block);
aoqi@0 156
aoqi@0 157 // Value replacement
aoqi@0 158 public:
aoqi@0 159 void replace_all(SharkValue* old_value, SharkValue* new_value);
aoqi@0 160 };
aoqi@0 161
aoqi@0 162 class SharkTopLevelBlock;
aoqi@0 163
aoqi@0 164 // SharkNormalEntryState objects are used to create the state
aoqi@0 165 // that the method will be entered with for a normal invocation.
aoqi@0 166 class SharkNormalEntryState : public SharkState {
aoqi@0 167 public:
aoqi@0 168 SharkNormalEntryState(SharkTopLevelBlock* block,
aoqi@0 169 llvm::Value* method);
aoqi@0 170 };
aoqi@0 171
aoqi@0 172 // SharkOSREntryState objects are used to create the state
aoqi@0 173 // that the method will be entered with for an OSR invocation.
aoqi@0 174 class SharkOSREntryState : public SharkState {
aoqi@0 175 public:
aoqi@0 176 SharkOSREntryState(SharkTopLevelBlock* block,
aoqi@0 177 llvm::Value* method,
aoqi@0 178 llvm::Value* osr_buf);
aoqi@0 179 };
aoqi@0 180
aoqi@0 181 // SharkPHIState objects are used to manage the entry state
aoqi@0 182 // for blocks with more than one entry path or for blocks
aoqi@0 183 // entered from blocks that will be compiled later.
aoqi@0 184 class SharkPHIState : public SharkState {
aoqi@0 185 public:
aoqi@0 186 SharkPHIState(SharkTopLevelBlock* block);
aoqi@0 187
aoqi@0 188 private:
aoqi@0 189 SharkTopLevelBlock* _block;
aoqi@0 190
aoqi@0 191 private:
aoqi@0 192 SharkTopLevelBlock* block() const {
aoqi@0 193 return _block;
aoqi@0 194 }
aoqi@0 195
aoqi@0 196 public:
aoqi@0 197 void add_incoming(SharkState* incoming_state);
aoqi@0 198 };
aoqi@0 199
aoqi@0 200 #endif // SHARE_VM_SHARK_SHARKSTATE_HPP

mercurial