1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/src/share/vm/shark/sharkState.hpp Wed Aug 11 05:51:21 2010 -0700 1.3 @@ -0,0 +1,188 @@ 1.4 +/* 1.5 + * Copyright (c) 1999, 2007, Oracle and/or its affiliates. All rights reserved. 1.6 + * Copyright 2008, 2009 Red Hat, Inc. 1.7 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 1.8 + * 1.9 + * This code is free software; you can redistribute it and/or modify it 1.10 + * under the terms of the GNU General Public License version 2 only, as 1.11 + * published by the Free Software Foundation. 1.12 + * 1.13 + * This code is distributed in the hope that it will be useful, but WITHOUT 1.14 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 1.15 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 1.16 + * version 2 for more details (a copy is included in the LICENSE file that 1.17 + * accompanied this code). 1.18 + * 1.19 + * You should have received a copy of the GNU General Public License version 1.20 + * 2 along with this work; if not, write to the Free Software Foundation, 1.21 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 1.22 + * 1.23 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 1.24 + * or visit www.oracle.com if you need additional information or have any 1.25 + * questions. 1.26 + * 1.27 + */ 1.28 + 1.29 +class SharkState : public SharkTargetInvariants { 1.30 + public: 1.31 + SharkState(const SharkTargetInvariants* parent) 1.32 + : SharkTargetInvariants(parent), 1.33 + _method(NULL), 1.34 + _oop_tmp(NULL), 1.35 + _has_safepointed(false) { initialize(NULL); } 1.36 + 1.37 + SharkState(const SharkState* state) 1.38 + : SharkTargetInvariants(state), 1.39 + _method(state->_method), 1.40 + _oop_tmp(state->_oop_tmp), 1.41 + _has_safepointed(state->_has_safepointed) { initialize(state); } 1.42 + 1.43 + private: 1.44 + void initialize(const SharkState* state); 1.45 + 1.46 + private: 1.47 + llvm::Value* _method; 1.48 + SharkValue** _locals; 1.49 + SharkValue** _stack; 1.50 + SharkValue** _sp; 1.51 + int _num_monitors; 1.52 + llvm::Value* _oop_tmp; 1.53 + bool _has_safepointed; 1.54 + 1.55 + // Method 1.56 + public: 1.57 + llvm::Value** method_addr() { 1.58 + return &_method; 1.59 + } 1.60 + llvm::Value* method() const { 1.61 + return _method; 1.62 + } 1.63 + protected: 1.64 + void set_method(llvm::Value* method) { 1.65 + _method = method; 1.66 + } 1.67 + 1.68 + // Local variables 1.69 + public: 1.70 + SharkValue** local_addr(int index) const { 1.71 + assert(index >= 0 && index < max_locals(), "bad local variable index"); 1.72 + return &_locals[index]; 1.73 + } 1.74 + SharkValue* local(int index) const { 1.75 + return *local_addr(index); 1.76 + } 1.77 + void set_local(int index, SharkValue* value) { 1.78 + *local_addr(index) = value; 1.79 + } 1.80 + 1.81 + // Expression stack 1.82 + public: 1.83 + SharkValue** stack_addr(int slot) const { 1.84 + assert(slot >= 0 && slot < stack_depth(), "bad stack slot"); 1.85 + return &_sp[-(slot + 1)]; 1.86 + } 1.87 + SharkValue* stack(int slot) const { 1.88 + return *stack_addr(slot); 1.89 + } 1.90 + protected: 1.91 + void set_stack(int slot, SharkValue* value) { 1.92 + *stack_addr(slot) = value; 1.93 + } 1.94 + public: 1.95 + int stack_depth() const { 1.96 + return _sp - _stack; 1.97 + } 1.98 + void push(SharkValue* value) { 1.99 + assert(stack_depth() < max_stack(), "stack overrun"); 1.100 + *(_sp++) = value; 1.101 + } 1.102 + SharkValue* pop() { 1.103 + assert(stack_depth() > 0, "stack underrun"); 1.104 + return *(--_sp); 1.105 + } 1.106 + 1.107 + // Monitors 1.108 + public: 1.109 + int num_monitors() const { 1.110 + return _num_monitors; 1.111 + } 1.112 + void set_num_monitors(int num_monitors) { 1.113 + _num_monitors = num_monitors; 1.114 + } 1.115 + 1.116 + // Temporary oop slot 1.117 + public: 1.118 + llvm::Value** oop_tmp_addr() { 1.119 + return &_oop_tmp; 1.120 + } 1.121 + llvm::Value* oop_tmp() const { 1.122 + return _oop_tmp; 1.123 + } 1.124 + void set_oop_tmp(llvm::Value* oop_tmp) { 1.125 + _oop_tmp = oop_tmp; 1.126 + } 1.127 + 1.128 + // Safepointed status 1.129 + public: 1.130 + bool has_safepointed() const { 1.131 + return _has_safepointed; 1.132 + } 1.133 + void set_has_safepointed(bool has_safepointed) { 1.134 + _has_safepointed = has_safepointed; 1.135 + } 1.136 + 1.137 + // Comparison 1.138 + public: 1.139 + bool equal_to(SharkState* other); 1.140 + 1.141 + // Copy and merge 1.142 + public: 1.143 + SharkState* copy() const { 1.144 + return new SharkState(this); 1.145 + } 1.146 + void merge(SharkState* other, 1.147 + llvm::BasicBlock* other_block, 1.148 + llvm::BasicBlock* this_block); 1.149 + 1.150 + // Value replacement 1.151 + public: 1.152 + void replace_all(SharkValue* old_value, SharkValue* new_value); 1.153 +}; 1.154 + 1.155 +class SharkTopLevelBlock; 1.156 + 1.157 +// SharkNormalEntryState objects are used to create the state 1.158 +// that the method will be entered with for a normal invocation. 1.159 +class SharkNormalEntryState : public SharkState { 1.160 + public: 1.161 + SharkNormalEntryState(SharkTopLevelBlock* block, 1.162 + llvm::Value* method); 1.163 +}; 1.164 + 1.165 +// SharkOSREntryState objects are used to create the state 1.166 +// that the method will be entered with for an OSR invocation. 1.167 +class SharkOSREntryState : public SharkState { 1.168 + public: 1.169 + SharkOSREntryState(SharkTopLevelBlock* block, 1.170 + llvm::Value* method, 1.171 + llvm::Value* osr_buf); 1.172 +}; 1.173 + 1.174 +// SharkPHIState objects are used to manage the entry state 1.175 +// for blocks with more than one entry path or for blocks 1.176 +// entered from blocks that will be compiled later. 1.177 +class SharkPHIState : public SharkState { 1.178 + public: 1.179 + SharkPHIState(SharkTopLevelBlock* block); 1.180 + 1.181 + private: 1.182 + SharkTopLevelBlock* _block; 1.183 + 1.184 + private: 1.185 + SharkTopLevelBlock* block() const { 1.186 + return _block; 1.187 + } 1.188 + 1.189 + public: 1.190 + void add_incoming(SharkState* incoming_state); 1.191 +};