Path: blob/aarch64-shenandoah-jdk8u272-b10/hotspot/src/share/vm/shark/sharkInvariants.hpp
32285 views
/*1* Copyright (c) 1999, 2013, 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_SHARKINVARIANTS_HPP26#define SHARE_VM_SHARK_SHARKINVARIANTS_HPP2728#include "ci/ciEnv.hpp"29#include "ci/ciInstanceKlass.hpp"30#include "ci/ciMethod.hpp"31#include "ci/ciTypeFlow.hpp"32#include "code/debugInfoRec.hpp"33#include "code/dependencies.hpp"34#include "memory/allocation.hpp"35#include "shark/llvmHeaders.hpp"36#include "shark/sharkBuilder.hpp"3738// Base classes used to track various values through the compilation.39// SharkCompileInvariants is used to track values which remain the40// same for the top-level method and any inlined methods it may have41// (ie for the whole compilation). SharkTargetInvariants is used to42// track values which differ between methods.4344class SharkCompileInvariants : public ResourceObj {45protected:46SharkCompileInvariants(ciEnv* env, SharkBuilder* builder)47: _env(env),48_builder(builder),49_thread(NULL) {}5051SharkCompileInvariants(const SharkCompileInvariants* parent)52: _env(parent->_env),53_builder(parent->_builder),54_thread(parent->_thread) {}5556private:57ciEnv* _env;58SharkBuilder* _builder;59llvm::Value* _thread;6061// Top-level broker for HotSpot's Compiler Interface.62//63// Its main purpose is to allow the various CI classes to access64// oops in the VM without having to worry about safepointing. In65// addition to this it acts as a holder for various recorders and66// memory allocators.67//68// Accessing this directly is kind of ugly, so it's private. Add69// new accessors below if you need something from it.70protected:71ciEnv* env() const {72assert(_env != NULL, "env not available");73return _env;74}7576// The SharkBuilder that is used to build LLVM IR.77protected:78SharkBuilder* builder() const {79return _builder;80}8182// Pointer to this thread's JavaThread object. This is not83// available until a short way into SharkFunction creation84// so a setter is required. Assertions are used to enforce85// invariance.86protected:87llvm::Value* thread() const {88assert(_thread != NULL, "thread not available");89return _thread;90}91void set_thread(llvm::Value* thread) {92assert(_thread == NULL, "thread already set");93_thread = thread;94}9596// Objects that handle various aspects of the compilation.97protected:98DebugInformationRecorder* debug_info() const {99return env()->debug_info();100}101SharkCodeBuffer* code_buffer() const {102return builder()->code_buffer();103}104105public:106Dependencies* dependencies() const {107return env()->dependencies();108}109110// Commonly used classes111protected:112ciInstanceKlass* java_lang_Object_klass() const {113return env()->Object_klass();114}115ciInstanceKlass* java_lang_Throwable_klass() const {116return env()->Throwable_klass();117}118};119120class SharkTargetInvariants : public SharkCompileInvariants {121protected:122SharkTargetInvariants(ciEnv* env, SharkBuilder* builder, ciTypeFlow* flow)123: SharkCompileInvariants(env, builder),124_target(flow->method()),125_flow(flow),126_max_monitors(count_monitors()) {}127128SharkTargetInvariants(const SharkCompileInvariants* parent, ciMethod* target)129: SharkCompileInvariants(parent),130_target(target),131_flow(NULL),132_max_monitors(count_monitors()) {}133134SharkTargetInvariants(const SharkTargetInvariants* parent)135: SharkCompileInvariants(parent),136_target(parent->_target),137_flow(parent->_flow),138_max_monitors(parent->_max_monitors) {}139140private:141int count_monitors();142143private:144ciMethod* _target;145ciTypeFlow* _flow;146int _max_monitors;147148// The method being compiled.149protected:150ciMethod* target() const {151return _target;152}153154// Typeflow analysis of the method being compiled.155protected:156ciTypeFlow* flow() const {157assert(_flow != NULL, "typeflow not available");158return _flow;159}160161// Properties of the method.162protected:163int max_locals() const {164return target()->max_locals();165}166int max_stack() const {167return target()->max_stack();168}169int max_monitors() const {170return _max_monitors;171}172int arg_size() const {173return target()->arg_size();174}175bool is_static() const {176return target()->is_static();177}178bool is_synchronized() const {179return target()->is_synchronized();180}181};182183#endif // SHARE_VM_SHARK_SHARKINVARIANTS_HPP184185186