src/share/vm/shark/sharkInvariants.hpp

Tue, 18 Jun 2013 12:31:07 -0700

author
johnc
date
Tue, 18 Jun 2013 12:31:07 -0700
changeset 5277
01522ca68fc7
parent 4443
c095a7f289aa
child 6198
55fb97c4c58d
permissions
-rw-r--r--

8015237: Parallelize string table scanning during strong root processing
Summary: Parallelize the scanning of the intern string table by having each GC worker claim a given number of buckets. Changes were also reviewed by Per Liden <per.liden@oracle.com>.
Reviewed-by: tschatzl, stefank, twisti

twisti@2047 1 /*
stefank@2314 2 * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
twisti@2047 3 * Copyright 2008, 2009 Red Hat, Inc.
twisti@2047 4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
twisti@2047 5 *
twisti@2047 6 * This code is free software; you can redistribute it and/or modify it
twisti@2047 7 * under the terms of the GNU General Public License version 2 only, as
twisti@2047 8 * published by the Free Software Foundation.
twisti@2047 9 *
twisti@2047 10 * This code is distributed in the hope that it will be useful, but WITHOUT
twisti@2047 11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
twisti@2047 12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
twisti@2047 13 * version 2 for more details (a copy is included in the LICENSE file that
twisti@2047 14 * accompanied this code).
twisti@2047 15 *
twisti@2047 16 * You should have received a copy of the GNU General Public License version
twisti@2047 17 * 2 along with this work; if not, write to the Free Software Foundation,
twisti@2047 18 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
twisti@2047 19 *
twisti@2047 20 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
twisti@2047 21 * or visit www.oracle.com if you need additional information or have any
twisti@2047 22 * questions.
twisti@2047 23 *
twisti@2047 24 */
twisti@2047 25
stefank@2314 26 #ifndef SHARE_VM_SHARK_SHARKINVARIANTS_HPP
stefank@2314 27 #define SHARE_VM_SHARK_SHARKINVARIANTS_HPP
stefank@2314 28
stefank@2314 29 #include "ci/ciEnv.hpp"
stefank@2314 30 #include "ci/ciInstanceKlass.hpp"
stefank@2314 31 #include "ci/ciMethod.hpp"
stefank@2314 32 #include "ci/ciTypeFlow.hpp"
stefank@2314 33 #include "code/debugInfoRec.hpp"
stefank@2314 34 #include "code/dependencies.hpp"
stefank@2314 35 #include "memory/allocation.hpp"
stefank@2314 36 #include "shark/llvmHeaders.hpp"
stefank@2314 37 #include "shark/sharkBuilder.hpp"
stefank@2314 38
twisti@2047 39 // Base classes used to track various values through the compilation.
twisti@2047 40 // SharkCompileInvariants is used to track values which remain the
twisti@2047 41 // same for the top-level method and any inlined methods it may have
twisti@2047 42 // (ie for the whole compilation). SharkTargetInvariants is used to
twisti@2047 43 // track values which differ between methods.
twisti@2047 44
twisti@2047 45 class SharkCompileInvariants : public ResourceObj {
twisti@2047 46 protected:
twisti@2047 47 SharkCompileInvariants(ciEnv* env, SharkBuilder* builder)
twisti@2047 48 : _env(env),
twisti@2047 49 _builder(builder),
twisti@2047 50 _thread(NULL) {}
twisti@2047 51
twisti@2047 52 SharkCompileInvariants(const SharkCompileInvariants* parent)
twisti@2047 53 : _env(parent->_env),
twisti@2047 54 _builder(parent->_builder),
twisti@2047 55 _thread(parent->_thread) {}
twisti@2047 56
twisti@2047 57 private:
twisti@2047 58 ciEnv* _env;
twisti@2047 59 SharkBuilder* _builder;
twisti@2047 60 llvm::Value* _thread;
twisti@2047 61
twisti@2047 62 // Top-level broker for HotSpot's Compiler Interface.
twisti@2047 63 //
twisti@2047 64 // Its main purpose is to allow the various CI classes to access
twisti@2047 65 // oops in the VM without having to worry about safepointing. In
twisti@2047 66 // addition to this it acts as a holder for various recorders and
twisti@2047 67 // memory allocators.
twisti@2047 68 //
twisti@2047 69 // Accessing this directly is kind of ugly, so it's private. Add
twisti@2047 70 // new accessors below if you need something from it.
twisti@4443 71 protected:
twisti@2047 72 ciEnv* env() const {
twisti@2047 73 assert(_env != NULL, "env not available");
twisti@2047 74 return _env;
twisti@2047 75 }
twisti@2047 76
twisti@2047 77 // The SharkBuilder that is used to build LLVM IR.
twisti@2047 78 protected:
twisti@2047 79 SharkBuilder* builder() const {
twisti@2047 80 return _builder;
twisti@2047 81 }
twisti@2047 82
twisti@2047 83 // Pointer to this thread's JavaThread object. This is not
twisti@2047 84 // available until a short way into SharkFunction creation
twisti@2047 85 // so a setter is required. Assertions are used to enforce
twisti@2047 86 // invariance.
twisti@2047 87 protected:
twisti@2047 88 llvm::Value* thread() const {
twisti@2047 89 assert(_thread != NULL, "thread not available");
twisti@2047 90 return _thread;
twisti@2047 91 }
twisti@2047 92 void set_thread(llvm::Value* thread) {
twisti@2047 93 assert(_thread == NULL, "thread already set");
twisti@2047 94 _thread = thread;
twisti@2047 95 }
twisti@2047 96
twisti@2047 97 // Objects that handle various aspects of the compilation.
twisti@2047 98 protected:
twisti@2047 99 DebugInformationRecorder* debug_info() const {
twisti@2047 100 return env()->debug_info();
twisti@2047 101 }
twisti@4442 102 SharkCodeBuffer* code_buffer() const {
twisti@4442 103 return builder()->code_buffer();
twisti@4442 104 }
twisti@4442 105
twisti@4442 106 public:
twisti@2047 107 Dependencies* dependencies() const {
twisti@2047 108 return env()->dependencies();
twisti@2047 109 }
twisti@2047 110
twisti@2047 111 // Commonly used classes
twisti@2047 112 protected:
twisti@2047 113 ciInstanceKlass* java_lang_Object_klass() const {
twisti@2047 114 return env()->Object_klass();
twisti@2047 115 }
twisti@2047 116 ciInstanceKlass* java_lang_Throwable_klass() const {
twisti@2047 117 return env()->Throwable_klass();
twisti@2047 118 }
twisti@2047 119 };
twisti@2047 120
twisti@2047 121 class SharkTargetInvariants : public SharkCompileInvariants {
twisti@2047 122 protected:
twisti@2047 123 SharkTargetInvariants(ciEnv* env, SharkBuilder* builder, ciTypeFlow* flow)
twisti@2047 124 : SharkCompileInvariants(env, builder),
twisti@2047 125 _target(flow->method()),
twisti@2047 126 _flow(flow),
twisti@2047 127 _max_monitors(count_monitors()) {}
twisti@2047 128
twisti@2047 129 SharkTargetInvariants(const SharkCompileInvariants* parent, ciMethod* target)
twisti@2047 130 : SharkCompileInvariants(parent),
twisti@2047 131 _target(target),
twisti@2047 132 _flow(NULL),
twisti@2047 133 _max_monitors(count_monitors()) {}
twisti@2047 134
twisti@2047 135 SharkTargetInvariants(const SharkTargetInvariants* parent)
twisti@2047 136 : SharkCompileInvariants(parent),
twisti@2047 137 _target(parent->_target),
twisti@2047 138 _flow(parent->_flow),
twisti@2047 139 _max_monitors(parent->_max_monitors) {}
twisti@2047 140
twisti@2047 141 private:
twisti@2047 142 int count_monitors();
twisti@2047 143
twisti@2047 144 private:
twisti@2047 145 ciMethod* _target;
twisti@2047 146 ciTypeFlow* _flow;
twisti@2047 147 int _max_monitors;
twisti@2047 148
twisti@2047 149 // The method being compiled.
twisti@2047 150 protected:
twisti@2047 151 ciMethod* target() const {
twisti@2047 152 return _target;
twisti@2047 153 }
twisti@2047 154
twisti@2047 155 // Typeflow analysis of the method being compiled.
twisti@2047 156 protected:
twisti@2047 157 ciTypeFlow* flow() const {
twisti@2047 158 assert(_flow != NULL, "typeflow not available");
twisti@2047 159 return _flow;
twisti@2047 160 }
twisti@2047 161
twisti@2047 162 // Properties of the method.
twisti@2047 163 protected:
twisti@2047 164 int max_locals() const {
twisti@2047 165 return target()->max_locals();
twisti@2047 166 }
twisti@2047 167 int max_stack() const {
twisti@2047 168 return target()->max_stack();
twisti@2047 169 }
twisti@2047 170 int max_monitors() const {
twisti@2047 171 return _max_monitors;
twisti@2047 172 }
twisti@2047 173 int arg_size() const {
twisti@2047 174 return target()->arg_size();
twisti@2047 175 }
twisti@2047 176 bool is_static() const {
twisti@2047 177 return target()->is_static();
twisti@2047 178 }
twisti@2047 179 bool is_synchronized() const {
twisti@2047 180 return target()->is_synchronized();
twisti@2047 181 }
twisti@2047 182 };
stefank@2314 183
stefank@2314 184 #endif // SHARE_VM_SHARK_SHARKINVARIANTS_HPP

mercurial