Path: blob/aarch64-shenandoah-jdk8u272-b10/hotspot/src/share/vm/shark/sharkState.hpp
32285 views
/*1* Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.2* Copyright 2008, 2009 Red Hat, Inc.3* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.4*5* This code is free software; you can redistribute it and/or modify it6* under the terms of the GNU General Public License version 2 only, as7* published by the Free Software Foundation.8*9* This code is distributed in the hope that it will be useful, but WITHOUT10* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or11* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License12* version 2 for more details (a copy is included in the LICENSE file that13* accompanied this code).14*15* You should have received a copy of the GNU General Public License version16* 2 along with this work; if not, write to the Free Software Foundation,17* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.18*19* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA20* or visit www.oracle.com if you need additional information or have any21* questions.22*23*/2425#ifndef SHARE_VM_SHARK_SHARKSTATE_HPP26#define SHARE_VM_SHARK_SHARKSTATE_HPP2728#include "ci/ciMethod.hpp"29#include "memory/allocation.hpp"30#include "shark/llvmHeaders.hpp"31#include "shark/sharkBuilder.hpp"32#include "shark/sharkInvariants.hpp"33#include "shark/sharkValue.hpp"3435class SharkState : public SharkTargetInvariants {36public:37SharkState(const SharkTargetInvariants* parent)38: SharkTargetInvariants(parent),39_method(NULL),40_oop_tmp(NULL),41_has_safepointed(false) { initialize(NULL); }4243SharkState(const SharkState* state)44: SharkTargetInvariants(state),45_method(state->_method),46_oop_tmp(state->_oop_tmp),47_has_safepointed(state->_has_safepointed) { initialize(state); }4849private:50void initialize(const SharkState* state);5152private:53llvm::Value* _method;54SharkValue** _locals;55SharkValue** _stack;56SharkValue** _sp;57int _num_monitors;58llvm::Value* _oop_tmp;59bool _has_safepointed;6061// Method62public:63llvm::Value** method_addr() {64return &_method;65}66llvm::Value* method() const {67return _method;68}69protected:70void set_method(llvm::Value* method) {71_method = method;72}7374// Local variables75public:76SharkValue** local_addr(int index) const {77assert(index >= 0 && index < max_locals(), "bad local variable index");78return &_locals[index];79}80SharkValue* local(int index) const {81return *local_addr(index);82}83void set_local(int index, SharkValue* value) {84*local_addr(index) = value;85}8687// Expression stack88public:89SharkValue** stack_addr(int slot) const {90assert(slot >= 0 && slot < stack_depth(), "bad stack slot");91return &_sp[-(slot + 1)];92}93SharkValue* stack(int slot) const {94return *stack_addr(slot);95}96protected:97void set_stack(int slot, SharkValue* value) {98*stack_addr(slot) = value;99}100public:101int stack_depth() const {102return _sp - _stack;103}104void push(SharkValue* value) {105assert(stack_depth() < max_stack(), "stack overrun");106*(_sp++) = value;107}108SharkValue* pop() {109assert(stack_depth() > 0, "stack underrun");110return *(--_sp);111}112113// Monitors114public:115int num_monitors() const {116return _num_monitors;117}118void set_num_monitors(int num_monitors) {119_num_monitors = num_monitors;120}121122// Temporary oop slot123public:124llvm::Value** oop_tmp_addr() {125return &_oop_tmp;126}127llvm::Value* oop_tmp() const {128return _oop_tmp;129}130void set_oop_tmp(llvm::Value* oop_tmp) {131_oop_tmp = oop_tmp;132}133134// Safepointed status135public:136bool has_safepointed() const {137return _has_safepointed;138}139void set_has_safepointed(bool has_safepointed) {140_has_safepointed = has_safepointed;141}142143// Comparison144public:145bool equal_to(SharkState* other);146147// Copy and merge148public:149SharkState* copy() const {150return new SharkState(this);151}152void merge(SharkState* other,153llvm::BasicBlock* other_block,154llvm::BasicBlock* this_block);155156// Value replacement157public:158void replace_all(SharkValue* old_value, SharkValue* new_value);159};160161class SharkTopLevelBlock;162163// SharkNormalEntryState objects are used to create the state164// that the method will be entered with for a normal invocation.165class SharkNormalEntryState : public SharkState {166public:167SharkNormalEntryState(SharkTopLevelBlock* block,168llvm::Value* method);169};170171// SharkOSREntryState objects are used to create the state172// that the method will be entered with for an OSR invocation.173class SharkOSREntryState : public SharkState {174public:175SharkOSREntryState(SharkTopLevelBlock* block,176llvm::Value* method,177llvm::Value* osr_buf);178};179180// SharkPHIState objects are used to manage the entry state181// for blocks with more than one entry path or for blocks182// entered from blocks that will be compiled later.183class SharkPHIState : public SharkState {184public:185SharkPHIState(SharkTopLevelBlock* block);186187private:188SharkTopLevelBlock* _block;189190private:191SharkTopLevelBlock* block() const {192return _block;193}194195public:196void add_incoming(SharkState* incoming_state);197};198199#endif // SHARE_VM_SHARK_SHARKSTATE_HPP200201202