src/share/vm/shark/sharkInvariants.hpp

Wed, 27 Apr 2016 01:25:04 +0800

author
aoqi
date
Wed, 27 Apr 2016 01:25:04 +0800
changeset 0
f90c822e73f8
child 6876
710a3c8b516e
permissions
-rw-r--r--

Initial load
http://hg.openjdk.java.net/jdk8u/jdk8u/hotspot/
changeset: 6782:28b50d07f6f8
tag: jdk8u25-b17

aoqi@0 1 /*
aoqi@0 2 * Copyright (c) 1999, 2013, 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_SHARKINVARIANTS_HPP
aoqi@0 27 #define SHARE_VM_SHARK_SHARKINVARIANTS_HPP
aoqi@0 28
aoqi@0 29 #include "ci/ciEnv.hpp"
aoqi@0 30 #include "ci/ciInstanceKlass.hpp"
aoqi@0 31 #include "ci/ciMethod.hpp"
aoqi@0 32 #include "ci/ciTypeFlow.hpp"
aoqi@0 33 #include "code/debugInfoRec.hpp"
aoqi@0 34 #include "code/dependencies.hpp"
aoqi@0 35 #include "memory/allocation.hpp"
aoqi@0 36 #include "shark/llvmHeaders.hpp"
aoqi@0 37 #include "shark/sharkBuilder.hpp"
aoqi@0 38
aoqi@0 39 // Base classes used to track various values through the compilation.
aoqi@0 40 // SharkCompileInvariants is used to track values which remain the
aoqi@0 41 // same for the top-level method and any inlined methods it may have
aoqi@0 42 // (ie for the whole compilation). SharkTargetInvariants is used to
aoqi@0 43 // track values which differ between methods.
aoqi@0 44
aoqi@0 45 class SharkCompileInvariants : public ResourceObj {
aoqi@0 46 protected:
aoqi@0 47 SharkCompileInvariants(ciEnv* env, SharkBuilder* builder)
aoqi@0 48 : _env(env),
aoqi@0 49 _builder(builder),
aoqi@0 50 _thread(NULL) {}
aoqi@0 51
aoqi@0 52 SharkCompileInvariants(const SharkCompileInvariants* parent)
aoqi@0 53 : _env(parent->_env),
aoqi@0 54 _builder(parent->_builder),
aoqi@0 55 _thread(parent->_thread) {}
aoqi@0 56
aoqi@0 57 private:
aoqi@0 58 ciEnv* _env;
aoqi@0 59 SharkBuilder* _builder;
aoqi@0 60 llvm::Value* _thread;
aoqi@0 61
aoqi@0 62 // Top-level broker for HotSpot's Compiler Interface.
aoqi@0 63 //
aoqi@0 64 // Its main purpose is to allow the various CI classes to access
aoqi@0 65 // oops in the VM without having to worry about safepointing. In
aoqi@0 66 // addition to this it acts as a holder for various recorders and
aoqi@0 67 // memory allocators.
aoqi@0 68 //
aoqi@0 69 // Accessing this directly is kind of ugly, so it's private. Add
aoqi@0 70 // new accessors below if you need something from it.
aoqi@0 71 protected:
aoqi@0 72 ciEnv* env() const {
aoqi@0 73 assert(_env != NULL, "env not available");
aoqi@0 74 return _env;
aoqi@0 75 }
aoqi@0 76
aoqi@0 77 // The SharkBuilder that is used to build LLVM IR.
aoqi@0 78 protected:
aoqi@0 79 SharkBuilder* builder() const {
aoqi@0 80 return _builder;
aoqi@0 81 }
aoqi@0 82
aoqi@0 83 // Pointer to this thread's JavaThread object. This is not
aoqi@0 84 // available until a short way into SharkFunction creation
aoqi@0 85 // so a setter is required. Assertions are used to enforce
aoqi@0 86 // invariance.
aoqi@0 87 protected:
aoqi@0 88 llvm::Value* thread() const {
aoqi@0 89 assert(_thread != NULL, "thread not available");
aoqi@0 90 return _thread;
aoqi@0 91 }
aoqi@0 92 void set_thread(llvm::Value* thread) {
aoqi@0 93 assert(_thread == NULL, "thread already set");
aoqi@0 94 _thread = thread;
aoqi@0 95 }
aoqi@0 96
aoqi@0 97 // Objects that handle various aspects of the compilation.
aoqi@0 98 protected:
aoqi@0 99 DebugInformationRecorder* debug_info() const {
aoqi@0 100 return env()->debug_info();
aoqi@0 101 }
aoqi@0 102 SharkCodeBuffer* code_buffer() const {
aoqi@0 103 return builder()->code_buffer();
aoqi@0 104 }
aoqi@0 105
aoqi@0 106 public:
aoqi@0 107 Dependencies* dependencies() const {
aoqi@0 108 return env()->dependencies();
aoqi@0 109 }
aoqi@0 110
aoqi@0 111 // Commonly used classes
aoqi@0 112 protected:
aoqi@0 113 ciInstanceKlass* java_lang_Object_klass() const {
aoqi@0 114 return env()->Object_klass();
aoqi@0 115 }
aoqi@0 116 ciInstanceKlass* java_lang_Throwable_klass() const {
aoqi@0 117 return env()->Throwable_klass();
aoqi@0 118 }
aoqi@0 119 };
aoqi@0 120
aoqi@0 121 class SharkTargetInvariants : public SharkCompileInvariants {
aoqi@0 122 protected:
aoqi@0 123 SharkTargetInvariants(ciEnv* env, SharkBuilder* builder, ciTypeFlow* flow)
aoqi@0 124 : SharkCompileInvariants(env, builder),
aoqi@0 125 _target(flow->method()),
aoqi@0 126 _flow(flow),
aoqi@0 127 _max_monitors(count_monitors()) {}
aoqi@0 128
aoqi@0 129 SharkTargetInvariants(const SharkCompileInvariants* parent, ciMethod* target)
aoqi@0 130 : SharkCompileInvariants(parent),
aoqi@0 131 _target(target),
aoqi@0 132 _flow(NULL),
aoqi@0 133 _max_monitors(count_monitors()) {}
aoqi@0 134
aoqi@0 135 SharkTargetInvariants(const SharkTargetInvariants* parent)
aoqi@0 136 : SharkCompileInvariants(parent),
aoqi@0 137 _target(parent->_target),
aoqi@0 138 _flow(parent->_flow),
aoqi@0 139 _max_monitors(parent->_max_monitors) {}
aoqi@0 140
aoqi@0 141 private:
aoqi@0 142 int count_monitors();
aoqi@0 143
aoqi@0 144 private:
aoqi@0 145 ciMethod* _target;
aoqi@0 146 ciTypeFlow* _flow;
aoqi@0 147 int _max_monitors;
aoqi@0 148
aoqi@0 149 // The method being compiled.
aoqi@0 150 protected:
aoqi@0 151 ciMethod* target() const {
aoqi@0 152 return _target;
aoqi@0 153 }
aoqi@0 154
aoqi@0 155 // Typeflow analysis of the method being compiled.
aoqi@0 156 protected:
aoqi@0 157 ciTypeFlow* flow() const {
aoqi@0 158 assert(_flow != NULL, "typeflow not available");
aoqi@0 159 return _flow;
aoqi@0 160 }
aoqi@0 161
aoqi@0 162 // Properties of the method.
aoqi@0 163 protected:
aoqi@0 164 int max_locals() const {
aoqi@0 165 return target()->max_locals();
aoqi@0 166 }
aoqi@0 167 int max_stack() const {
aoqi@0 168 return target()->max_stack();
aoqi@0 169 }
aoqi@0 170 int max_monitors() const {
aoqi@0 171 return _max_monitors;
aoqi@0 172 }
aoqi@0 173 int arg_size() const {
aoqi@0 174 return target()->arg_size();
aoqi@0 175 }
aoqi@0 176 bool is_static() const {
aoqi@0 177 return target()->is_static();
aoqi@0 178 }
aoqi@0 179 bool is_synchronized() const {
aoqi@0 180 return target()->is_synchronized();
aoqi@0 181 }
aoqi@0 182 };
aoqi@0 183
aoqi@0 184 #endif // SHARE_VM_SHARK_SHARKINVARIANTS_HPP

mercurial