Mais conteúdo relacionado Shark 2. 6 JVM (OpenJDK6) Zero/
Shark
http://today.java.net/pub/a/today/2009/05/21/zero-
and-shark-openjdk-port.html
7. hg clone http://icedtea.classpath.org/hg/release/
icedtea6-1.11
sh autogen.sh
./configure --enable-zero --enable-shark
:
checking for a JamVM source zip... not specified
checking whether to disable optimizations and build
with -O0 -g... no
checking whether to use the Shark JIT... yes
configure: error: shark is unsupported in this
release
8. void TemplateTable::initialize() {
def(Bytecodes::_iadd , ____|____|____|____, itos, itos,
iop2 , add );
def(Bytecodes::_ladd , ____|____|____|____, ltos, ltos,
lop2 , add );
0 templateTable.hpp <global> 267 static void invokevirtual(int
byte_no);
1 templateTable_sparc.cpp invokevirtual 2947 void
TemplateTable::invokevirtual(int byte_no)
{
2 templateTable_x86_32.cpp invokevirtual 2993 void
TemplateTable::invokevirtual(int byte_no)
{
3 templateTable_x86_64.cpp invokevirtual 3001 void
TemplateTable::invokevirtual(int byte_no)
{
4 templateTable.cpp initialize 441 def
(Bytecodes::_invokevirtual ,
ubcp|disp|clvm|____, vtos,
vtos, invokevirtual
, f2_byte );
9. 0 cpu/sparc/vm/templateTable_sparc.cpp
1 cpu/sparc/vm/templateTable_sparc.hpp
2 cpu/x86/vm/templateTable_x86_32.cpp
3 cpu/x86/vm/templateTable_x86_32.hpp
4 cpu/x86/vm/templateTable_x86_64.cpp
5 cpu/x86/vm/templateTable_x86_64.hpp
6 cpu/zero/vm/templateTable_zero.cpp // empty
7 cpu/zero/vm/templateTable_zero.hpp // empty
8 share/vm/interpreter/templateTable.cpp
9 share/vm/interpreter/templateTable.hpp
10. No template interpreter for zero...
$ more cpu/zero/vm/*
...
SharkFrame : public ZeroFrame
ZeroStack
$ ls share/vm/shark
llvmHeaders.hpp sharkEntry.hpp sharkStack.cpp
llvmValue.hpp sharkFunction.cpp sharkStack.hpp
sharkBlock.cpp sharkFunction.hpp sharkState.cpp
sharkBlock.hpp sharkInliner.cpp sharkState.hpp
sharkBuilder.cpp sharkInliner.hpp sharkStateScanner.cpp
11. ** llvmHeaders.hpp
#include <llvm/Argument.h>
#include <llvm/Constants.h>
#include <llvm/DerivedTypes.h>
#include <llvm/ExecutionEngine/ExecutionEngine.h>
#include <llvm/Instructions.h>
#include <llvm/LLVMContext.h>
#include <llvm/Module.h>
#if SHARK_LLVM_VERSION < 27
#include <llvm/ModuleProvider.h>
#endif
13. // Create the JIT. This takes ownership of the module.
TheExecutionEngine = EngineBuilder(TheModule).create();
--- back to shark
$ grep ExecutionEngine *
llvmHeaders.hpp:#include <llvm/ExecutionEngine/ExecutionEngine.h>
llvmHeaders.hpp:#include <llvm/ExecutionEngine/JITMemoryManager.h>
llvmHeaders.hpp:#include <llvm/ExecutionEngine/JIT.h>
sharkCompiler.cpp: _execution_engine_lock = new Monitor(Mutex::leaf,
"SharkExecutionEngineLock");
sharkCompiler.cpp: _execution_engine = ExecutionEngine::createJIT(
sharkCompiler.hpp: llvm::ExecutionEngine* _execution_engine;
sharkCompiler.hpp: llvm::ExecutionEngine* execution_engine() const {
14. SharkCompiler::compile_method()
SharkFunction::build() native code register_method.
class SharkFunction : public SharkTargetInvariants {
friend class SharkStackWithNormalFrame;
public:
static llvm::Function* build(ciEnv* env,
SharkBuilder* builder,
ciTypeFlow* flow,
const char* name) {
SharkFunction function(env, builder, flow, name);
return function.function();
}
15. sharkBlock.cpp:void SharkBlock::parse_bytecode(int start, int limit)
case Bytecodes::_iadd:
b = pop();
a = pop();
push(SharkValue::create_jint(
builder()->CreateAdd(a->jint_value(), b->jint_value()), false));
// Create the JIT
std::string ErrorMsg;
EngineBuilder builder(_normal_context->module());
builder.setMCPU(MCPU);
builder.setMAttrs(MAttrs);
builder.setJITMemoryManager(memory_manager());
builder.setEngineKind(EngineKind::JIT);
builder.setErrorStr(&ErrorMsg);
_execution_engine = builder.create();