Shark
Upcoming SlideShare
Loading in...5
×
 

Shark

on

  • 911 views

Memo for JVM source code reading event #6 on 2012-02-18.

Memo for JVM source code reading event #6 on 2012-02-18.

Statistics

Views

Total Views
911
Views on SlideShare
911
Embed Views
0

Actions

Likes
3
Downloads
11
Comments
0

0 Embeds 0

No embeds

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

Shark Shark Presentation Transcript

  • 6 JVM (OpenJDK6) Zero/Sharkhttp://today.java.net/pub/a/today/2009/05/21/zero-and-shark-openjdk-port.html
  • hg clone http://icedtea.classpath.org/hg/release/icedtea6-1.11sh autogen.sh./configure --enable-zero --enable-shark:checking for a JamVM source zip... not specifiedchecking whether to disable optimizations and buildwith -O0 -g... nochecking whether to use the Shark JIT... yesconfigure: error: shark is unsupported in thisrelease
  • 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(intbyte_no);1 templateTable_sparc.cpp  invokevirtual 2947 voidTemplateTable::invokevirtual(int byte_no)                                              {2 templateTable_x86_32.cpp invokevirtual 2993 voidTemplateTable::invokevirtual(int byte_no)                                              {3 templateTable_x86_64.cpp invokevirtual 3001 voidTemplateTable::invokevirtual(int byte_no)                                              {4 templateTable.cpp        initialize     441 def(Bytecodes::_invokevirtual ,                                              ubcp|disp|clvm|____, vtos,vtos, invokevirtual                                              , f2_byte );
  • 0 cpu/sparc/vm/templateTable_sparc.cpp1 cpu/sparc/vm/templateTable_sparc.hpp2 cpu/x86/vm/templateTable_x86_32.cpp3 cpu/x86/vm/templateTable_x86_32.hpp4 cpu/x86/vm/templateTable_x86_64.cpp5 cpu/x86/vm/templateTable_x86_64.hpp6 cpu/zero/vm/templateTable_zero.cpp          // empty7 cpu/zero/vm/templateTable_zero.hpp          // empty8 share/vm/interpreter/templateTable.cpp9 share/vm/interpreter/templateTable.hpp
  • No template interpreter for zero...$ more cpu/zero/vm/*...SharkFrame : public ZeroFrameZeroStack$ ls share/vm/sharkllvmHeaders.hpp          sharkEntry.hpp          sharkStack.cppllvmValue.hpp          sharkFunction.cpp     sharkStack.hppsharkBlock.cpp          sharkFunction.hpp     sharkState.cppsharkBlock.hpp          sharkInliner.cpp     sharkState.hppsharkBuilder.cpp     sharkInliner.hpp     sharkStateScanner.cpp
  • ** 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
  • IRBuilderBuilder.CreateAddBuilder.CreateCallBuilder.CreateRetFunction::CreateBasicBlock::Createfcmpuitofpsitofpcallret  FunctionPassManager OurFPM(TheModule);  // Set up the optimizer pipeline.  Start with registering info about howthe  // target lays out data structures.  OurFPM.add(new TargetData(*TheExecutionEngine->getTargetData()));  // Do simple "peephole" optimizations and bit-twiddling optzns.  OurFPM.add(createInstructionCombiningPass());
  •   // 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 {
  • 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();  }
  • 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();