src/share/vm/shark/sharkCompiler.hpp

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

author
johnc
date
Tue, 18 Jun 2013 12:31:07 -0700
changeset 5277
01522ca68fc7
parent 4444
606eada1bf86
child 5919
469216acdb28
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@2729 3 * Copyright 2008, 2009, 2010, 2011 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_SHARKCOMPILER_HPP
stefank@2314 27 #define SHARE_VM_SHARK_SHARKCOMPILER_HPP
stefank@2314 28
stefank@2314 29 #include "ci/ciEnv.hpp"
stefank@2314 30 #include "ci/ciMethod.hpp"
stefank@2314 31 #include "compiler/abstractCompiler.hpp"
stefank@2314 32 #include "compiler/compileBroker.hpp"
stefank@2314 33 #include "shark/llvmHeaders.hpp"
stefank@2314 34 #include "shark/sharkMemoryManager.hpp"
stefank@2314 35
twisti@2047 36 class SharkContext;
twisti@2047 37
twisti@2047 38 class SharkCompiler : public AbstractCompiler {
twisti@2047 39 public:
twisti@2047 40 // Creation
twisti@2047 41 SharkCompiler();
twisti@2047 42
twisti@2047 43 // Name of this compiler
twisti@2047 44 const char *name() { return "shark"; }
twisti@2047 45
twisti@2047 46 // Missing feature tests
twisti@2047 47 bool supports_native() { return true; }
twisti@2047 48 bool supports_osr() { return true; }
twisti@4444 49 bool can_compile_method(methodHandle method) {
twisti@4444 50 return ! (method->is_method_handle_intrinsic() || method->is_compiled_lambda_form());
twisti@4444 51 }
twisti@2047 52
twisti@2047 53 // Customization
twisti@2047 54 bool needs_adapters() { return false; }
twisti@2047 55 bool needs_stubs() { return false; }
twisti@2047 56
twisti@2047 57 // Initialization
twisti@2047 58 void initialize();
twisti@2047 59
twisti@2047 60 // Compile a normal (bytecode) method and install it in the VM
twisti@2047 61 void compile_method(ciEnv* env, ciMethod* target, int entry_bci);
twisti@2047 62
twisti@2047 63 // Generate a wrapper for a native (JNI) method
twisti@2047 64 nmethod* generate_native_wrapper(MacroAssembler* masm,
twisti@2047 65 methodHandle target,
twisti@2729 66 int compile_id,
twisti@2047 67 BasicType* arg_types,
twisti@2047 68 BasicType return_type);
twisti@2047 69
twisti@2047 70 // Free compiled methods (and native wrappers)
twisti@2047 71 void free_compiled_method(address code);
twisti@2047 72
twisti@2047 73 // Each thread generating IR needs its own context. The normal
twisti@2047 74 // context is used for bytecode methods, and is protected from
twisti@2047 75 // multiple simultaneous accesses by being restricted to the
twisti@2047 76 // compiler thread. The native context is used for JNI methods,
twisti@2047 77 // and is protected from multiple simultaneous accesses by the
twisti@2047 78 // adapter handler library lock.
twisti@2047 79 private:
twisti@2047 80 SharkContext* _normal_context;
twisti@2047 81 SharkContext* _native_context;
twisti@2047 82
twisti@2047 83 public:
twisti@2047 84 SharkContext* context() const {
twisti@2047 85 if (JavaThread::current()->is_Compiler_thread()) {
twisti@2047 86 return _normal_context;
twisti@2047 87 }
twisti@2047 88 else {
twisti@2047 89 assert(AdapterHandlerLibrary_lock->owned_by_self(), "should be");
twisti@2047 90 return _native_context;
twisti@2047 91 }
twisti@2047 92 }
twisti@2047 93
twisti@2047 94 // The LLVM execution engine is the JIT we use to generate native
twisti@2047 95 // code. It is thread safe, but we need to protect it with a lock
twisti@2047 96 // of our own because otherwise LLVM's lock and HotSpot's locks
twisti@2047 97 // interleave and deadlock. The SharkMemoryManager is not thread
twisti@2047 98 // safe, and is protected by the same lock as the execution engine.
twisti@2047 99 private:
twisti@2047 100 Monitor* _execution_engine_lock;
twisti@2047 101 SharkMemoryManager* _memory_manager;
twisti@2047 102 llvm::ExecutionEngine* _execution_engine;
twisti@2047 103
twisti@2047 104 private:
twisti@2047 105 Monitor* execution_engine_lock() const {
twisti@2047 106 return _execution_engine_lock;
twisti@2047 107 }
twisti@2047 108 SharkMemoryManager* memory_manager() const {
twisti@2047 109 assert(execution_engine_lock()->owned_by_self(), "should be");
twisti@2047 110 return _memory_manager;
twisti@2047 111 }
twisti@2047 112 llvm::ExecutionEngine* execution_engine() const {
twisti@2047 113 assert(execution_engine_lock()->owned_by_self(), "should be");
twisti@2047 114 return _execution_engine;
twisti@2047 115 }
twisti@2047 116
twisti@2047 117 // Global access
twisti@2047 118 public:
twisti@2047 119 static SharkCompiler* compiler() {
twisti@2729 120 AbstractCompiler *compiler =
twisti@2729 121 CompileBroker::compiler(CompLevel_full_optimization);
twisti@2047 122 assert(compiler->is_shark() && compiler->is_initialized(), "should be");
twisti@2047 123 return (SharkCompiler *) compiler;
twisti@2047 124 }
twisti@2047 125
twisti@2047 126 // Helpers
twisti@2047 127 private:
twisti@2047 128 static const char* methodname(const char* klass, const char* method);
twisti@2047 129 void generate_native_code(SharkEntry* entry,
twisti@2047 130 llvm::Function* function,
twisti@2047 131 const char* name);
twisti@2047 132 void free_queued_methods();
twisti@2047 133 };
stefank@2314 134
stefank@2314 135 #endif // SHARE_VM_SHARK_SHARKCOMPILER_HPP

mercurial