hotspot/src/share/vm/shark/sharkCompiler.hpp

Print this page


   1 /*
   2  * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
   3  * Copyright 2008, 2009 Red Hat, Inc.
   4  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   5  *
   6  * This code is free software; you can redistribute it and/or modify it
   7  * under the terms of the GNU General Public License version 2 only, as
   8  * published by the Free Software Foundation.
   9  *
  10  * This code is distributed in the hope that it will be useful, but WITHOUT
  11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  12  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  13  * version 2 for more details (a copy is included in the LICENSE file that
  14  * accompanied this code).
  15  *
  16  * You should have received a copy of the GNU General Public License version
  17  * 2 along with this work; if not, write to the Free Software Foundation,
  18  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  19  *
  20  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  21  * or visit www.oracle.com if you need additional information or have any
  22  * questions.
  23  *


  43   // Name of this compiler
  44   const char *name()     { return "shark"; }
  45 
  46   // Missing feature tests
  47   bool supports_native() { return true; }
  48   bool supports_osr()    { return true; }
  49 
  50   // Customization
  51   bool needs_adapters()  { return false; }
  52   bool needs_stubs()     { return false; }
  53 
  54   // Initialization
  55   void initialize();
  56 
  57   // Compile a normal (bytecode) method and install it in the VM
  58   void compile_method(ciEnv* env, ciMethod* target, int entry_bci);
  59 
  60   // Generate a wrapper for a native (JNI) method
  61   nmethod* generate_native_wrapper(MacroAssembler* masm,
  62                                    methodHandle    target,

  63                                    BasicType*      arg_types,
  64                                    BasicType       return_type);
  65 
  66   // Free compiled methods (and native wrappers)
  67   void free_compiled_method(address code);
  68 
  69   // Each thread generating IR needs its own context.  The normal
  70   // context is used for bytecode methods, and is protected from
  71   // multiple simultaneous accesses by being restricted to the
  72   // compiler thread.  The native context is used for JNI methods,
  73   // and is protected from multiple simultaneous accesses by the
  74   // adapter handler library lock.
  75  private:
  76   SharkContext* _normal_context;
  77   SharkContext* _native_context;
  78 
  79  public:
  80   SharkContext* context() const {
  81     if (JavaThread::current()->is_Compiler_thread()) {
  82       return _normal_context;


  96   Monitor*               _execution_engine_lock;
  97   SharkMemoryManager*    _memory_manager;
  98   llvm::ExecutionEngine* _execution_engine;
  99 
 100  private:
 101   Monitor* execution_engine_lock() const {
 102     return _execution_engine_lock;
 103   }
 104   SharkMemoryManager* memory_manager() const {
 105     assert(execution_engine_lock()->owned_by_self(), "should be");
 106     return _memory_manager;
 107   }
 108   llvm::ExecutionEngine* execution_engine() const {
 109     assert(execution_engine_lock()->owned_by_self(), "should be");
 110     return _execution_engine;
 111   }
 112 
 113   // Global access
 114  public:
 115   static SharkCompiler* compiler() {
 116     AbstractCompiler *compiler = CompileBroker::compiler(CompLevel_simple);

 117     assert(compiler->is_shark() && compiler->is_initialized(), "should be");
 118     return (SharkCompiler *) compiler;
 119   }
 120 
 121   // Helpers
 122  private:
 123   static const char* methodname(const char* klass, const char* method);
 124   void generate_native_code(SharkEntry*     entry,
 125                             llvm::Function* function,
 126                             const char*     name);
 127   void free_queued_methods();
 128 };
 129 
 130 #endif // SHARE_VM_SHARK_SHARKCOMPILER_HPP
   1 /*
   2  * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
   3  * Copyright 2008, 2009, 2010, 2011 Red Hat, Inc.
   4  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   5  *
   6  * This code is free software; you can redistribute it and/or modify it
   7  * under the terms of the GNU General Public License version 2 only, as
   8  * published by the Free Software Foundation.
   9  *
  10  * This code is distributed in the hope that it will be useful, but WITHOUT
  11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  12  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  13  * version 2 for more details (a copy is included in the LICENSE file that
  14  * accompanied this code).
  15  *
  16  * You should have received a copy of the GNU General Public License version
  17  * 2 along with this work; if not, write to the Free Software Foundation,
  18  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  19  *
  20  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  21  * or visit www.oracle.com if you need additional information or have any
  22  * questions.
  23  *


  43   // Name of this compiler
  44   const char *name()     { return "shark"; }
  45 
  46   // Missing feature tests
  47   bool supports_native() { return true; }
  48   bool supports_osr()    { return true; }
  49 
  50   // Customization
  51   bool needs_adapters()  { return false; }
  52   bool needs_stubs()     { return false; }
  53 
  54   // Initialization
  55   void initialize();
  56 
  57   // Compile a normal (bytecode) method and install it in the VM
  58   void compile_method(ciEnv* env, ciMethod* target, int entry_bci);
  59 
  60   // Generate a wrapper for a native (JNI) method
  61   nmethod* generate_native_wrapper(MacroAssembler* masm,
  62                                    methodHandle    target,
  63                                    int             compile_id,
  64                                    BasicType*      arg_types,
  65                                    BasicType       return_type);
  66 
  67   // Free compiled methods (and native wrappers)
  68   void free_compiled_method(address code);
  69 
  70   // Each thread generating IR needs its own context.  The normal
  71   // context is used for bytecode methods, and is protected from
  72   // multiple simultaneous accesses by being restricted to the
  73   // compiler thread.  The native context is used for JNI methods,
  74   // and is protected from multiple simultaneous accesses by the
  75   // adapter handler library lock.
  76  private:
  77   SharkContext* _normal_context;
  78   SharkContext* _native_context;
  79 
  80  public:
  81   SharkContext* context() const {
  82     if (JavaThread::current()->is_Compiler_thread()) {
  83       return _normal_context;


  97   Monitor*               _execution_engine_lock;
  98   SharkMemoryManager*    _memory_manager;
  99   llvm::ExecutionEngine* _execution_engine;
 100 
 101  private:
 102   Monitor* execution_engine_lock() const {
 103     return _execution_engine_lock;
 104   }
 105   SharkMemoryManager* memory_manager() const {
 106     assert(execution_engine_lock()->owned_by_self(), "should be");
 107     return _memory_manager;
 108   }
 109   llvm::ExecutionEngine* execution_engine() const {
 110     assert(execution_engine_lock()->owned_by_self(), "should be");
 111     return _execution_engine;
 112   }
 113 
 114   // Global access
 115  public:
 116   static SharkCompiler* compiler() {
 117     AbstractCompiler *compiler =
 118       CompileBroker::compiler(CompLevel_full_optimization);
 119     assert(compiler->is_shark() && compiler->is_initialized(), "should be");
 120     return (SharkCompiler *) compiler;
 121   }
 122 
 123   // Helpers
 124  private:
 125   static const char* methodname(const char* klass, const char* method);
 126   void generate_native_code(SharkEntry*     entry,
 127                             llvm::Function* function,
 128                             const char*     name);
 129   void free_queued_methods();
 130 };
 131 
 132 #endif // SHARE_VM_SHARK_SHARKCOMPILER_HPP