/*
* Copyright 2008, 2009, 2010, 2011 Red Hat, Inc.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*
*/
#ifndef SHARE_VM_SHARK_SHARKCOMPILER_HPP
#define SHARE_VM_SHARK_SHARKCOMPILER_HPP
#include "ci/ciMethod.hpp"
#include "compiler/abstractCompiler.hpp"
#include "compiler/compileBroker.hpp"
#include "shark/llvmHeaders.hpp"
#include "shark/sharkMemoryManager.hpp"
class SharkContext;
public:
// Creation
// Name of this compiler
// Missing feature tests
bool supports_native() { return true; }
bool supports_osr() { return true; }
// Customization
bool needs_adapters() { return false; }
bool needs_stubs() { return false; }
// Initialization
void initialize();
// Compile a normal (bytecode) method and install it in the VM
// Generate a wrapper for a native (JNI) method
int compile_id,
// Free compiled methods (and native wrappers)
// Each thread generating IR needs its own context. The normal
// context is used for bytecode methods, and is protected from
// multiple simultaneous accesses by being restricted to the
// compiler thread. The native context is used for JNI methods,
// and is protected from multiple simultaneous accesses by the
// adapter handler library lock.
private:
public:
return _normal_context;
}
else {
return _native_context;
}
}
// The LLVM execution engine is the JIT we use to generate native
// code. It is thread safe, but we need to protect it with a lock
// of our own because otherwise LLVM's lock and HotSpot's locks
// interleave and deadlock. The SharkMemoryManager is not thread
// safe, and is protected by the same lock as the execution engine.
private:
private:
return _execution_engine_lock;
}
return _memory_manager;
}
return _execution_engine;
}
// Global access
public:
return (SharkCompiler *) compiler;
}
// Helpers
private:
const char* name);
void free_queued_methods();
};
#endif // SHARE_VM_SHARK_SHARKCOMPILER_HPP