harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From var...@apache.org
Subject svn commit: r525110 [3/4] - in /harmony/enhanced/drlvm/trunk/vm: include/ include/open/ jitrino/src/codegenerator/ jitrino/src/codegenerator/ia32/ jitrino/src/codegenerator/ipf/ jitrino/src/codegenerator/ipf/include/ jitrino/src/dynopt/ jitrino/src/jet...
Date Tue, 03 Apr 2007 09:30:36 GMT
Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/vm/VMInterface.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/vm/VMInterface.h?view=diff&rev=525110&r1=525109&r2=525110
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/vm/VMInterface.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/vm/VMInterface.h Tue Apr  3 02:30:33 2007
@@ -15,303 +15,275 @@
  *  limitations under the License.
  */
 
-/**
- * @author Intel, Mikhail Y. Fursov
- * @version $Revision: 1.38.8.4.4.4 $
- */
-
 #ifndef _VMINTERFACE_H_
 #define _VMINTERFACE_H_
 
-#include <cstring>
-#include <string>
-#ifdef __GNUC__
-typedef ::std::size_t size_t;
-#endif
-
+#include <ostream>
+#include "open/em.h"
 #include "open/types.h"
-#include "jit_export.h"
+#include "jit_runtime_support.h"
 #include "jit_intf.h"
-#include <iostream>
-#include <ostream>
-#include "PlatformDependant.h"
-
-#define LOG_DOMAIN "jitrino"
 
 namespace Jitrino {
 
-// external declarations
+// external and forward declarations
 class TypeManager;
-class JITInstanceContext;
 class Type;
 class NamedType;
 class ObjectType;
 class MethodPtrType;
-class PersistentInstructionId;
 class MemoryManager;
 class CompilationContext;
+class CompilationInterface;
+template <class ELEM_TYPE> class PtrHashTable;
 
-///////////////////////////////////////////////////////////////////////////////////////
-///////////////////////////////////////////////////////////////////////////////////////
-//            O P A Q U E   D E S C' S  I M P L E M E N T E D   B Y    V M             //
-///////////////////////////////////////////////////////////////////////////////////////
-///////////////////////////////////////////////////////////////////////////////////////
 
-class ExceptionCallback {
+class VMInterface {
 public:
-    virtual ~ExceptionCallback() {}
+    //
+    // VM specific methods for types
+    //
+    static void*       getSystemObjectVMTypeHandle();
+    static void*       getSystemClassVMTypeHandle();
+    static void*       getSystemStringVMTypeHandle();
+    static void*       getArrayVMTypeHandle(void* elemVMTypeHandle,bool isUnboxed);
+    static const char* getTypeName(void* vmTypeHandle);
+    static const char* getTypeNameQualifier(void* vmTypeHandle);
+    static void*       getSuperTypeVMTypeHandle(void* vmTypeHandle);
+    static void*       getArrayElemVMTypeHandle(void* vmTypeHandle);
+    static bool        isArrayType(void* vmTypeHandle);
+    static bool        isArrayOfPrimitiveElements(void* vmTypeHandle);
+    static bool        isEnumType(void* vmTypeHandle);
+    static bool        isValueType(void* vmTypeHandle);
+    static bool        isFinalType(void* vmTypeHandle);
+    static bool        isLikelyExceptionType(void* vmTypeHandle);
+    static bool        isInterfaceType(void* vmTypeHandle);
+    static bool        isAbstractType(void* vmTypeHandle);
+    static bool        needsInitialization(void* vmTypeHandle);
+    static bool        isFinalizable(void* vmTypeHandle);
+    static bool        isBeforeFieldInit(void* vmTypeHandle);
+    static bool        getClassFastInstanceOfFlag(void* vmTypeHandle);
+    static int         getClassDepth(void* vmTypeHandle);
+    static bool        isInitialized(void* vmTypeHandle);
+    static void*       getVTable(void* vmTypeHandle);
+    static void*       getRuntimeClassHandle(void* vmTypeHandle);
+    static void*       getAllocationHandle(void* vmTypeHandle);
+    static bool        isSubClassOf(void* vmTypeHandle1,void* vmTypeHandle2);
+    static uint32      getArrayElemOffset(void* vmElemTypeHandle,bool isUnboxed);
+    static uint32      getObjectSize(void * vmTypeHandle);
+    static uint32      getArrayLengthOffset();
 
-    virtual bool catchBlock(uint32 tryOffset,
-                            uint32 tryLength,
-                            uint32 handlerOffset,
-                            uint32 handlerLength,
-                            uint32 exceptionTypeToken) = 0;    
-    virtual void finallyBlock(uint32 tryOffset,
-                            uint32 tryLength,
-                            uint32 handlerOffset,
-                            uint32 handlerLength) = 0;
-    virtual void filterBlock(uint32 tryOffset,
-                            uint32 tryLength,
-                            uint32 handlerOffset,
-                            uint32 handlerLength,
-                            uint32 expressionStart) = 0;
-    virtual void faultBlock(uint32 tryOffset,
-                            uint32 tryLength,
-                            uint32 handlerOffset,
-                            uint32 handlerLength) = 0;
-};
+    static void*       getTypeHandleFromAllocationHandle(void* vmAllocationHandle);
+    static void*       getTypeHandleFromVTable(void* vtHandle);
 
-//
-// calli standalone sig, fptr callback of type sig, and methodDesc.parseMethodSig
-//
-class MethodSignatureDesc {
-public:
-    virtual ~MethodSignatureDesc() {}
+    static uint32      flagTLSSuspendRequestOffset();
+    static uint32      flagTLSThreadStateOffset();
 
-    virtual uint32   getNumParams()                  = 0;
-    virtual Type**   getParamTypes()                 = 0;
-    virtual Type*    getParamType(uint32 paramIndex) = 0;
-    virtual Type*    getReturnType()                 = 0;
-};
 
-class TypeMemberDesc {
-public:
-    virtual ~TypeMemberDesc() {}
+    // returns true if vtable pointers are compressed
+    static bool          areVTablePtrsCompressed() {return vm_vtable_pointers_are_compressed();}
 
-    virtual const char* getName()            = 0;
-    virtual const char* getSignatureString() = 0;
-    virtual void  printFullName(::std::ostream& os) = 0;
-    virtual NamedType*  getParentType()      = 0;
-    virtual uint32      getId()              = 0;
-    virtual bool        isPrivate()          = 0;
-    virtual bool        isStatic()           = 0;
-};
+    // returns size of vtable pointer (currently 4 if compressed and 8 otherwise)
+    //static uint32      getVTablePtrSize() {return vm_get_vtable_ptr_size();}
 
-class FieldDesc : public TypeMemberDesc {
-public:
-    virtual ~FieldDesc() {}
+    // returns the offset of an object's virtual table
+    static uint32      getVTableOffset();
+    // returns the base for all vtables (addend to compressed vtable pointer)
+    static uint64      getVTableBase() {return vm_get_vtable_base();}
+
+    // returns true if instance fields that are references are compressed
+    static bool        areReferencesCompressed() {return vm_references_are_compressed();}
 
     //
-    // this field is constant after it is initialized
-    // can only be mutated by constructor (instance fields) or
-    // type initializer (static fields)
-    //
-    virtual bool    isInitOnly()         = 0;
-    // accesses to field cannot be reordered or CSEed
-    virtual bool    isVolatile()         = 0;
-    //
-    // this is a compile-time constant field -- static fields only
+    // returns the base for the heap (addend to compressed heap references)
     //
-    virtual bool    isLiteral()          = 0;
-    virtual bool    isUnmanagedStatic()  = 0;
-    virtual Type*   getFieldType()       = 0;
-    virtual uint32  getOffset()          = 0;    // for non-static fields
-    virtual void*   getAddress()         = 0;    // for static fields
+    static void*       getHeapBase();
+    static void*       getHeapCeiling();
+
+
+    static void        rewriteCodeBlock(Byte* codeBlock, Byte*  newCode, size_t size);
 };
 
-class MethodDesc : public TypeMemberDesc {
-public:
-    virtual ~MethodDesc() {}
 
-    virtual bool isNative()              = 0;
-    virtual bool isSynchronized()        = 0;
-    virtual bool isNoInlining()          = 0;
-    virtual bool isStatic()              = 0;
-    virtual bool isInstance()            = 0;    // In Java, all instance methods are virtual.  In CLI, not so.
-    virtual bool isFinal()               = 0;
-    virtual bool isVirtual()             = 0;
-    virtual bool isAbstract()            = 0;    // isAbstract is probably not needed
-    virtual bool isClassInitializer()    = 0;
-    virtual bool isInstanceInitializer() = 0;
-    virtual bool isMethodClassIsLikelyExceptionType() = 0;
-
-    virtual bool isStrict()              = 0;    // floating-point strict
-    virtual bool isRequireSecObject()    = 0;
-    virtual bool isInitLocals()          = 0;    // call default constructor on local vars
-    virtual bool isOverridden()          = 0;
-
-    virtual bool        isJavaByteCodes()   = 0;    // are bytecodes Java or CLI?
-    virtual const Byte* getByteCodes()      = 0;
-    virtual uint32      getByteCodeSize()   = 0;
-    virtual uint16      getMaxStack()       = 0;
-    virtual uint32      getOffset()         = 0;
-    virtual bool        isAddressFinal()    = 0;
-    virtual void*       getIndirectAddress()= 0;
-    virtual uint32      getNumHandlers()    = 0;
-    virtual uint32      getNumThrows()    = 0;
-    virtual NamedType*  getThrowType(uint32 i) = 0;
-    virtual bool        hasAnnotation(NamedType* type) = 0;
-    
-    // Exception handler and signature parsing API
-    virtual unsigned    parseJavaHandlers(ExceptionCallback&) = 0;
-    virtual void        parseCliHandlers(ExceptionCallback&) = 0;
-    virtual bool        isVarPinned(uint32 varIndex) = 0;
-    virtual Type*       getVarType(uint32 varType) = 0;
-    virtual uint32      getNumVars() = 0;
-    virtual MethodSignatureDesc* getMethodSig() = 0;
+///////////////////////////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////////////////////////
+//            O P A Q U E   D E S C' S  I M P L E M E N T E D   B Y    V M             //
+///////////////////////////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////////////////////////
 
-    //
-    // accessors for method info, code and data
-    //
-    virtual Byte*       getInfoBlock()        = 0;
-    virtual uint32      getInfoBlockSize()    = 0;
-    virtual Byte*       getCodeBlockAddress(int32 id) = 0;
-    virtual uint32      getCodeBlockSize(int32 id)    = 0;
+class TypeMemberDesc {
+public:
+    TypeMemberDesc(uint32 id, CompilationInterface* ci)
+        : id(id), compilationInterface(ci) {}
+    virtual ~TypeMemberDesc() {}
 
+    uint32      getId() const { return id; }
+    NamedType*  getParentType();
+    bool        isParentClassIsLikelyExceptionType() const;
 
-    //
-    // accessors for DynoptInfo of this method
-    // 
-    virtual POINTER_SIZE_INT    getUniqueId() = 0;
-    
-    virtual void* getHandleMap() = 0;
-    virtual void setHandleMap(void* ) = 0;
-};
 
-//
-// The Persistent Instruction Id is used to generate a profile instruction map and to 
-// feedback profile information into Jitrino.
-//
-class PersistentInstructionId {
-public:
-    PersistentInstructionId() 
-        : methodDesc(NULL), localInstructionId((uint32)-1) {}
+    virtual const char* getName() const           = 0;
+    virtual const char* getSignatureString() const = 0;
+    virtual void        printFullName(::std::ostream& os) = 0;
+    virtual Class_Handle getParentHandle() const  = 0;
 
-    PersistentInstructionId(MethodDesc* methodDesc, uint32 localInstructionId) 
-        : methodDesc(methodDesc), localInstructionId(localInstructionId) {}
+    virtual bool        isPrivate() const          = 0;
+    virtual bool        isStatic() const          = 0;
 
-    bool isValid() const { return (methodDesc != NULL); }
+protected:
+    uint32 id;
+    CompilationInterface* compilationInterface;
 
-    MethodDesc& getMethodDesc() const { return *methodDesc; }
-    uint32 getLocalInstructionId() const { return localInstructionId; }
+};
 
-    // For IPF codegen to store block ids into pid
-    bool hasValidLocalInstructionId() const { return localInstructionId != (uint32)-1; }
+class FieldDesc : public TypeMemberDesc {
+public:
+    FieldDesc(Field_Handle field, CompilationInterface* ci, uint32 id) 
+        : TypeMemberDesc(id, ci), drlField(field) {} 
+
+        const char*   getName() const       {return field_get_name(drlField);}
+        const char*   getSignatureString() const {return field_get_descriptor(drlField); }
+        void          printFullName(::std::ostream &os);
+        Class_Handle  getParentHandle() const;
+        bool          isPrivate() const     {return field_is_private(drlField)?true:false;}
+        bool          isStatic() const      {return field_is_static(drlField)?true:false;}
+        //
+        // this field is constant after it is initialized
+        // can only be mutated by constructor (instance fields) or
+        // type initializer (static fields)
+        //
+        bool          isInitOnly() const     {return field_is_final(drlField)?true:false;}    
+        // accesses to field cannot be reordered or CSEed
+        bool          isVolatile() const    {return field_is_volatile(drlField)?true:false;}
+        //
+        // this is a compile-time constant field -- static fields only
+        //
+        bool          isLiteral() const;
+        Type*         getFieldType();
+        uint32        getOffset() const; // for non-static fields
+        void*         getAddress() const    {return field_get_address(drlField);} // for static fields
+        Field_Handle  getFieldHandle() const  {return drlField; }
 
-    bool operator==(const PersistentInstructionId& pid) { return methodDesc == pid.methodDesc && localInstructionId == pid.localInstructionId; }
 private:
-    MethodDesc* methodDesc;     // The source method at point the id was generated
-    uint32 localInstructionId;  // The persistent local instruction id
+    Field_Handle drlField;
 };
 
-inline ::std::ostream& operator<<(::std::ostream& os, const PersistentInstructionId& pid) { 
-    os << (pid.isValid() ? pid.getMethodDesc().getName() : "NULL") << ":" 
-        << (unsigned int) pid.getLocalInstructionId(); 
-    return os;
-}
-
-class ClassHierarchyIterator {
+class MethodDesc : public TypeMemberDesc {
 public:
-    virtual ~ClassHierarchyIterator() {}
+    MethodDesc(Method_Handle m, JIT_Handle jit, CompilationInterface* ci = NULL, uint32 id = 0)
+        : TypeMemberDesc(id, ci), drlMethod(m),
+        methodSig(method_get_signature(m)),
+        handleMap(NULL),
+        jitHandle(jit){}
+
+        const char*  getName() const        {return method_get_name(drlMethod);}
+        const char*  getSignatureString() const {return method_get_descriptor(drlMethod); }
+        void         printFullName(::std::ostream& os);
+        Class_Handle getParentHandle() const;
+
+        bool         isPrivate() const      {return method_is_private(drlMethod)?true:false;}
+        bool         isStatic() const       {return method_is_static(drlMethod)?true:false;}
+        bool         isInstance() const     {return method_is_static(drlMethod)?false:true;}
+        bool         isNative() const       {return method_is_native(drlMethod)?true:false;}
+        bool         isSynchronized() const {return method_is_synchronized(drlMethod)?true:false;}
+        bool         isNoInlining() const;
+        bool         isFinal() const        {return method_is_final(drlMethod)?true:false;}
+        bool         isVirtual() const      {return isInstance() && !isPrivate();}
+        bool         isAbstract() const     {return method_is_abstract(drlMethod)?true:false;}
+        // FP strict
+        bool         isStrict() const       {return method_is_strict(drlMethod)?true:false;}
+        bool         isRequireSecObject(); //FIXME drop???
+        bool         isClassInitializer() const {return strcmp(getName(), "<clinit>") == 0; }
+        bool         isInstanceInitializer() const {return strcmp(getName(), "<init>") == 0; }
+
+        //
+        // Method info
+        //
+
+        const Byte*  getByteCodes() const   {return method_get_byte_code_addr(drlMethod);}
+        uint32       getByteCodeSize() const {return (uint32) method_get_byte_code_size(drlMethod);}
+        uint16       getMaxStack() const    {return (uint16) method_get_max_stack(drlMethod);}
+        uint32       getNumHandlers() const {return method_get_num_handlers(drlMethod);}
+        void getHandlerInfo(unsigned index, unsigned* beginOffset, 
+            unsigned* endOffset, unsigned* handlerOffset, unsigned* handlerClassIndex) const;
+        uint32       getNumThrows() const {return method_number_throws(drlMethod);}
+        NamedType*   getThrowType(uint32 i);
+        bool         hasAnnotation(NamedType* type) const;
+
+        //
+        // accessors for method info, code and data
+        //
+        Byte*    getInfoBlock() const;
+        uint32   getInfoBlockSize() const;
+        Byte*    getCodeBlockAddress(int32 id) const;
+        uint32   getCodeBlockSize(int32 id) const;
+
+        // sets and gets MethodSideEffect property for the compiled method
+        Method_Side_Effects getSideEffect() const;
+        void setSideEffect(Method_Side_Effects mse);
+
+        //
+        //    Exception registration API. 
+        //
+        void        setNumExceptionHandler(uint32 numHandlers);
+        void        setExceptionHandlerInfo(uint32 exceptionHandlerNumber,
+            Byte*  startAddr,
+            Byte*  endAddr,
+            Byte*  handlerAddr,
+            NamedType*  exceptionType,
+            bool   exceptionObjIsDead);
+
+
+        //
+        // DRL kernel
+        //
+        bool         isOverridden() const   {return method_is_overridden(drlMethod)?true:false;}
+        uint32       getOffset() const      {return method_get_offset(drlMethod);}
+        void*        getIndirectAddress() const {return method_get_indirect_address(drlMethod);}
+
+        uint32    getNumVars() const        {return method_vars_get_number(drlMethod);}
+
+        Method_Handle    getMethodHandle() const   {return drlMethod;}
+
+        //
+        // handleMap method are used to register/unregister main map for all Container handlers
+        void* getHandleMap() const {return handleMap;}
+        void setHandleMap(void* hndMap) {handleMap = hndMap;}
+
+        uint32    getNumParams() const;
+        Type*     getParamType(uint32 paramIndex) const;
+        Type*     getReturnType() const;
 
-    virtual bool isValid() = 0; // true if iterator is valid
-    virtual bool hasNext() = 0; // true if iterator is not done 
-    virtual ObjectType* getNext() = 0; // return next class in iterator and advance iterator
+private:
+    JIT_Handle   getJitHandle() const {return jitHandle;}
+    Method_Handle               drlMethod;
+    Method_Signature_Handle  methodSig;
+    void* handleMap;
+    JIT_Handle                  jitHandle;
 };
 
 class ClassHierarchyMethodIterator {
 public:
-    virtual ~ClassHierarchyMethodIterator() {}
-    virtual bool hasNext() = 0; // true if iterator is not done 
-    virtual MethodDesc* getNext() = 0; // return next class in iterator and advance iterator
+    ClassHierarchyMethodIterator(CompilationInterface& compilationInterface, ObjectType* objType, MethodDesc* methodDesc);
+    bool isValid() const { return valid; }
+    bool hasNext() const;
+    MethodDesc* getNext();
+
+private:
+    CompilationInterface& compilationInterface;
+    bool valid;
+    ChaMethodIterator iterator;
 };
 
 
 class CompilationInterface {
 public:
-
-    CompilationInterface(CompilationContext* cc) : compilationContext(cc){}
-    virtual ~CompilationInterface() {}
-
-    virtual TypeManager&  getTypeManager() = 0;
-    //
-    // returns the method to compile
-    //
-    virtual MethodDesc*   getMethodToCompile() = 0;
-    //
-    //returns the owner of a method
-    //
-    virtual Class_Handle methodGetClass(MethodDesc* method) = 0;
-    //
-    // resolution methods
-    //
-    virtual MethodSignatureDesc* resolveSignature(MethodDesc* enclosingMethodDesc,
-                                                  uint32 sigToken) = 0;
-    virtual FieldDesc*  resolveField(MethodDesc* enclosingMethod,
-                                     uint32 fieldToken,
-                                     bool putfield) = 0;
-    virtual FieldDesc*  resolveFieldByIndex(NamedType* klass, int index, NamedType **fieldType) = 0;
-    virtual FieldDesc*  resolveStaticField(MethodDesc* enclosingMethod,
-                                           uint32 fieldToken,
-                                           bool putfield) = 0;
-    virtual MethodDesc* resolveVirtualMethod(MethodDesc* enclosingMethod,
-                                             uint32 methodToken) = 0;
-    virtual MethodDesc* resolveSpecialMethod(MethodDesc* enclosingMethod,
-                                             uint32 methodToken) = 0;
-    virtual MethodDesc* resolveMethod(MethodDesc* enclosingMethod,
-                                      uint32 methodToken) = 0;
-    virtual MethodDesc* resolveStaticMethod(MethodDesc* enclosingMethod,
-                                            uint32 methodToken) = 0;
-    virtual MethodDesc* resolveInterfaceMethod(MethodDesc* enclosingMethod,
-                                               uint32 methodToken) = 0;
-    virtual NamedType*  resolveNamedType(MethodDesc* enclosingMethod,
-                                         uint32 typeToken) = 0;
-    virtual NamedType*  resolveNamedTypeNew(MethodDesc* enclosingMethod,
-                                            uint32 typeToken) = 0;
-    virtual Type*       getFieldType(MethodDesc* enclosingMethodDesc, uint32 entryCPIndex) = 0;
-    virtual const char* methodSignatureString(MethodDesc* enclosingMethodDesc, uint32 methodToken) = 0;
-    virtual void*       loadStringObject(MethodDesc* enclosingMethod,
-                                              uint32 stringToken)= 0;
-    virtual void*       loadToken(MethodDesc* enclosingMethod,uint32 token) = 0;
-    virtual Type*       getConstantType(MethodDesc* enclosingMethod,
-                                             uint32 constantToken) = 0;
-    virtual const void* getConstantValue(MethodDesc* enclosingMethod,
-                                              uint32 constantToken) = 0;
-        // resolve-by-name methods
-    /**
-     * Resolve a system class by its name. 
-     * Returns NULL if no such class found.
-     */
-    virtual ObjectType *    resolveClassUsingBootstrapClassloader( const char * klassName ) = 0;
-    /**
-     * Recursively looks up for a given method with a given signature in the given class.
-     * Returns NULL if no such method found.
-     */
-    virtual MethodDesc* resolveMethod(ObjectType * klass, const char * methodName, const char * methodSig) = 0;
-
-    // Class type is a subclass of ch=mh->getParentType()  The function returns
-    // a method description for a method overriding mh in type or in the closest
-    // superclass of ch that overrides mh.
-    virtual MethodDesc* getOverriddenMethod(NamedType *type, MethodDesc * methodDesc) = 0;
-
-    // Return NULL if an iterator is not available for this type
-    virtual ClassHierarchyIterator* getClassHierarchyIterator(ObjectType* baseType) = 0;
-
-    // Return NULL if an iterator is not available for this type and method
-    virtual ClassHierarchyMethodIterator* getClassHierarchyMethodIterator(ObjectType* baseType, MethodDesc* methodDesc) = 0;
-
-    // prints message, something about line and file, and hard-exits
-    virtual void hardAssert(const char *message, int line, const char *file) = 0;
+    CompilationInterface(Compile_Handle c,
+        Method_Handle m,
+        JIT_Handle jit,
+        MemoryManager& mm,
+        OpenMethodExecutionParams& comp_params, 
+        CompilationContext* cc, TypeManager& tpm);
 
     //
     //    System exceptions
@@ -380,17 +352,15 @@
         Helper_WriteBarrier,
         Num_Helpers
     };
-    //
-    // Code block heat - used when a method is split into hot and cold parts
-    //
-    enum CodeBlockHeat {
-        CodeBlockHeatMin,
-        CodeBlockHeatDefault,
-        CodeBlockHeatMax
+
+    enum VmCallingConvention {
+        CallingConvention_Drl = 0,
+        CallingConvention_Stdcall,
+        CallingConvention_Cdecl,
+        Num_CallingConvention
     };
 
-    virtual void*        getRuntimeHelperAddress(RuntimeHelperId) = 0;
-    virtual void*        getRuntimeHelperAddressForType(RuntimeHelperId id, Type* type) = 0;
+
     static const char*   getRuntimeHelperName(RuntimeHelperId helperId);
     /**
      * Returns RuntimeHelperId by its string representation. Name comparison 
@@ -399,73 +369,70 @@
      */
     static RuntimeHelperId str2rid( const char * helperName );
 
-    //
-    // method side effects (for lazy exception throwing optimization)
-    //
-    enum MethodSideEffect {
-        MSE_UNKNOWN,
-        MSE_YES,
-        MSE_NO,
-        MSE_NULL_PARAM
-    };
+    VmCallingConvention getRuntimeHelperCallingConvention(RuntimeHelperId id);
+    void*       getRuntimeHelperAddress(RuntimeHelperId);
+    void*       getRuntimeHelperAddressForType(RuntimeHelperId, Type*);
+
+
+    FieldDesc*  resolveField(MethodDesc* enclosingMethod,
+        uint32 fieldToken,
+        bool putfield);
+    FieldDesc*  resolveFieldByIndex(NamedType *klass, int index, NamedType **fieldType);
+    FieldDesc*  resolveStaticField(MethodDesc* enclosingMethod,
+        uint32 fieldToken,
+        bool putfield);
+    MethodDesc* resolveVirtualMethod(MethodDesc* enclosingMethod,
+        uint32 methodToken);
+    MethodDesc* resolveSpecialMethod(MethodDesc* enclosingMethod,
+        uint32 methodToken);
+    //FIXME
+    //MethodDesc* resolveMethod(MethodDesc* enclosingMethod,uint32 methodToken){assert(false); return 0;}
+    MethodDesc* resolveStaticMethod(MethodDesc* enclosingMethod,
+        uint32 methodToken);
+    MethodDesc* resolveInterfaceMethod(MethodDesc* enclosingMethod,
+        uint32 methodToken);
+    NamedType*  resolveNamedType(MethodDesc* enclosingMethod,
+        uint32 typeToken);
+    NamedType*  resolveNamedTypeNew(MethodDesc* enclosingMethod,
+        uint32 typeToken);
+    Type*       getFieldType(MethodDesc* enclosingMethodDesc, uint32 entryCPIndex);
 
-    virtual MethodSideEffect getMethodHasSideEffect(MethodDesc *m) = 0;
-    virtual void             setMethodHasSideEffect(MethodDesc *m, MethodSideEffect mse) = 0;
 
-    //
-    //    Exception registration API. 
-    //    All functions a for the method being compiled
-    //
-    virtual void        setNumExceptionHandler(uint32 numHandlers) = 0;
-    virtual void        setExceptionHandlerInfo(uint32 exceptionHandlerNumber,
-                                                Byte*  startAddr,
-                                                Byte*  endAddr,
-                                                Byte*  handlerAddr,
-                                                NamedType*  exceptionType,
-                                                bool   exceptionObjIsDead) = 0;
-    //
-    // returns true if instance fields that are references are compressed
-    //
-    virtual bool         areReferencesCompressed() = 0;
-    //
-    // returns the base for the heap (addend to compressed heap references)
-    //
-    virtual void*        getHeapBase() = 0;
-    //
-    // returns the offset of an object's virtual table
-    //
-    virtual uint32       getVTableOffset() = 0;
-    //
-    // returns true if vtable pointers are compressed
-    //
-    virtual bool         areVTablePtrsCompressed() = 0;
-    //
-    // returns size of vtable pointer (currently 4 if compressed and 
-    // 8 otherwise)
-    //
-    virtual uint32       getVTablePtrSize() = 0;
-    //
-    // returns the base for all vtables (addend to compressed vtable pointer)
-    //
-    virtual uint64       getVTableBase() = 0;
-    //
-    // accessors for method info, code and data
-    //
-    virtual Byte*        getInfoBlock(MethodDesc*)        = 0;
-    virtual uint32       getInfoBlockSize(MethodDesc*)    = 0;
-    virtual Byte*        getCodeBlockAddress(MethodDesc*, int32 id) = 0;
-    virtual uint32       getCodeBlockSize(MethodDesc*, int32 id)    = 0;
-    //
+    // resolve-by-name methods
+    /**
+     * Resolve a system class by its name. 
+     * Returns NULL if no such class found.
+     */
+    ObjectType * resolveClassUsingBootstrapClassloader( const char * klassName );
+    /**
+     * Recursively looks up for a given method with a given signature in the given class.
+     * Returns NULL if no such method found.
+     */
+    MethodDesc* resolveMethod(ObjectType * klass, const char * methodName, const char * methodSig);
+
+    // Class type is a subclass of ch=mh->getParentType()  The function returns
+    // a method description for a method overriding mh in type or in the closest
+    // superclass of ch that overrides mh.
+    MethodDesc* getOverriddenMethod(NamedType *type, MethodDesc * methodDesc);
+
+    ClassHierarchyMethodIterator* getClassHierarchyMethodIterator(ObjectType* baseType, MethodDesc* methodDesc);
+
+    void*        loadStringObject(MethodDesc* enclosingMethodDesc, uint32 stringToken);
+    Type*        getConstantType(MethodDesc* enclosingMethodDesc, uint32 constantToken);
+    const void*  getConstantValue(MethodDesc* enclosingMethodDesc, uint32 constantToken);
+    const char*  getSignatureString(MethodDesc* enclosingMethodDesc, uint32 methodToken);
+
     // Memory allocation API
     // all of these are for the method being compiled
-    virtual Byte*        allocateCodeBlock(size_t size, size_t alignment, CodeBlockHeat, int32, bool) = 0; 
-    virtual Byte*        allocateDataBlock(size_t size, size_t alignment) = 0;
-    virtual Byte*        allocateInfoBlock(size_t size) = 0;
-    virtual Byte*        allocateJITDataBlock(size_t size, size_t alignment)  = 0;
-    virtual Byte*        allocateMemoryBlock(size_t)   = 0;
-    //
-    //
-    
+    Byte*   allocateCodeBlock(size_t size, size_t alignment, CodeBlockHeat heat, 
+        int32 id, bool simulate);
+
+    Byte*   allocateDataBlock(size_t size, size_t alignment);
+
+    Byte*   allocateInfoBlock(size_t size);
+
+    Byte*   allocateJITDataBlock(size_t size, size_t alignment);
+
     /**
      * Acquires a lock to protect method's data modifications (i.e. code/info 
      * block allocations, exception handlers registration, etc) in 
@@ -478,141 +445,164 @@
      * Note, that the lock is *not* per-method, and shared across all the 
      * methods.
      */
-    virtual void         lockMethodData(void)   = 0;
-    
+    void    lockMethodData(void);
+
     /**
      * Releases a lock which protects method's data.
      */
-    virtual void         unlockMethodData(void) = 0;
-    
-    //
+    void    unlockMethodData(void);
+
     // methods that register JIT to be notified of various events
-    //
-    virtual void         setNotifyWhenClassIsExtended(ObjectType * type, 
-                                                      void *       callbackData) = 0;
-    virtual void         setNotifyWhenMethodIsOverridden(MethodDesc * methodDesc, 
-                                                         void *       callbackData) = 0;
-    virtual void         setNotifyWhenMethodIsRecompiled(MethodDesc * methodDesc, 
-                                                         void *       callbackData) = 0; 
+    void    setNotifyWhenClassIsExtended(ObjectType * type, void * callbackData);
+    void    setNotifyWhenMethodIsOverridden(MethodDesc * methodDesc, void * callbackData);
+    void    setNotifyWhenMethodIsRecompiled(MethodDesc * methodDesc, void * callbackData);
 
-    //
-    
     // write barrier instructions
-    virtual bool         insertWriteBarriers()        = 0;
-
-    // flush to zero allowed on floating-pointer operations
-    virtual bool         isFlushToZeroAllowed()         = 0;
-
-    // produce BC to native map info
-    virtual bool isBCMapInfoRequired() = 0;
+    bool    needWriteBarriers() const {
+        return compilation_params.exe_insert_write_barriers;
+    }
+
+    bool    isBCMapInfoRequired() const {
+        bool res = compilation_params.exe_do_code_mapping;
+        // exe_do_code_mapping should be used for different ti related byte code
+        // mapping calculations
+        // full byte code mapping could be enabled by IRBuilder flag now 
+        // this method used to access to byte code low level maps and
+        // enables byte codes for stack traces only
+        //        res = true;
+        return res;
+    }
+    void    setBCMapInfoRequired(bool is_supported) const {
+        compilation_params.exe_do_code_mapping = is_supported;
+    }
+
+    bool    isCompileLoadEventRequired() const {
+        return compilation_params.exe_notify_compiled_method_load;
+    }
 
-    virtual bool isCompileLoadEventRequired() = 0;
-
-    // send compile
-    virtual void sendCompiledMethodLoadEvent(MethodDesc* methodDesc, MethodDesc* outerDesc,
+    void    sendCompiledMethodLoadEvent(MethodDesc* methodDesc, MethodDesc* outerDesc,
         uint32 codeSize, void* codeAddr, uint32 mapLength, 
-        AddrLocation* addrLocationMap, void* compileInfo) = 0;
-
-    // get compilation params
-    virtual OpenMethodExecutionParams& getCompilationParams() = 0;
+        AddrLocation* addrLocationMap, void* compileInfo);
 
-    // synchronization inlining
-    struct ObjectSynchronizationInfo {
-        uint32 threadIdReg;      // the register number that holds id of the current thread
-        uint32 syncHeaderOffset; // offset in bytes of the sync header from the start of the object   
-        uint32 syncHeaderWidth;  // width in bytes of the sync header
-        uint32 lockOwnerOffset;  // offset in bytes of the lock owner field from the start of the object
-        uint32 lockOwnerWidth;   // width in bytes of the lock owner field in the sync header
-        bool   jitClearsCcv;     // whether the JIT needs to clear ar.ccv
-    };
-    //
-    //  Returns true if JIT may inline VM functionality for monitorenter and monitorexit
-    //  If true is returned 'syncInfo' is filled in with the synchronization parameters.
-    //
-    virtual bool         mayInlineObjectSynchronization(ObjectSynchronizationInfo & syncInfo) = 0;
-
-    enum VmCallingConvention {
-        CallingConvention_Drl = 0,
-        CallingConvention_Stdcall,
-        CallingConvention_Cdecl,
-        Num_CallingConvention
-    };
-
-    // 
-    // Returns the calling convention for managed code.
-    //
-    virtual VmCallingConvention getManagedCallingConvention() = 0;
-    virtual VmCallingConvention getRuntimeHelperCallingConvention(RuntimeHelperId id) = 0;
+    OpenMethodExecutionParams& getCompilationParams() const { 
+        return compilation_params;
+    }
 
     /**
      * Requests VM to request this JIT to synchronously (in the same thread) compile given method.
      * @param method method to compile
      * @return true on successful compilation, false otherwise
      */
-    virtual bool compileMethod(MethodDesc *method) = 0;
+    bool compileMethod(MethodDesc *method);
 
-    /**
-     * @param method JIT internal method descriptor
-     * @return runtime handle of the corresponding VM object for the method 
-     */
-    virtual void* getRuntimeMethodHandle(MethodDesc *method) = 0;
+    // returns the method to compile
+    MethodDesc*     getMethodToCompile() const {return methodToCompile;}
 
-    virtual CompilationContext* getCompilationContext() const {return compilationContext;}
+    TypeManager&    getTypeManager() const {return typeManager;}
+    MemoryManager&  getMemManager() const {return memManager;}
 
-protected:
-    /** Settings per compilation session: vminterface + optimizer flags and so on..
-      * Today we pass compilation interface through the all compilation. To avoid global
-      * changes in JIT subcomponents interfaces CompilationContext struct is placed here.
-      */
-    CompilationContext* compilationContext;
-};
+    Type*           getTypeFromDrlVMTypeHandle(Type_Info_Handle);
 
-class DataInterface {
-public:
-    virtual ~DataInterface() {}
+    FieldDesc*      getFieldDesc(Field_Handle field);
+    MethodDesc*     getMethodDesc(Method_Handle method);
 
-    //
-    // returns true if instance fields that are references are compressed
-    //
-    virtual bool         areReferencesCompressed() = 0;
-    //
-    // returns the base for the heap (addend to compressed heap references)
-    //
-    virtual void*        getHeapBase() = 0;
-};
+    void setCompilationContext(CompilationContext* cc) {compilationContext = cc;}
+
+    CompilationContext* getCompilationContext() const {return compilationContext;}
+
+private:
+    /** 
+     * Settings per compilation session: vminterface + optimizer flags and so on..
+     * Today we pass compilation interface through the all compilation. To avoid global
+     * changes in JIT subcomponents interfaces CompilationContext struct is placed here.
+     */
+    CompilationContext* compilationContext;
 
+    VM_RT_SUPPORT   translateHelperId(RuntimeHelperId runtimeHelperId);
+    JIT_Handle      getJitHandle() const;
+    MethodDesc*     getMethodDesc(Method_Handle method, JIT_Handle jit);
+
+    MemoryManager&              memManager;
+    PtrHashTable<FieldDesc>*    fieldDescs;
+    PtrHashTable<MethodDesc>*   methodDescs;
+    TypeManager&                typeManager;
+    MethodDesc*                 methodToCompile;
+    Compile_Handle              compileHandle;
+    bool                        flushToZeroAllowed;
+    uint32                      nextMemberId;
+    OpenMethodExecutionParams&  compilation_params;
+};
 
 class GCInterface {
 public:
+    GCInterface(GC_Enumeration_Handle gcHandle) : gcHandle(gcHandle) {}
     virtual ~GCInterface() {}
 
-    virtual void enumerateRootReference(void** reference) = 0;
-    virtual void enumerateCompressedRootReference(uint32* reference) = 0;
-    virtual void enumerateRootManagedReference(void** slotReference, int slotOffset) = 0;
-};
+    virtual void enumerateRootReference(void** reference) {
+        vm_enumerate_root_reference(reference, FALSE);
+    }
+
+    virtual void enumerateCompressedRootReference(uint32* reference) {
+        vm_enumerate_compressed_root_reference(reference, FALSE);
+    }
+
+    virtual void enumerateRootManagedReference(void** slotReference, int slotOffset) {
+        vm_enumerate_root_interior_pointer(slotReference, slotOffset, FALSE);
+    }
 
+private:
+    GC_Enumeration_Handle gcHandle;
+};
 
 
-class BinaryRewritingInterface {
+class ThreadDumpEnumerator : public GCInterface {
 public:
-    virtual ~BinaryRewritingInterface() {}
+    ThreadDumpEnumerator() : GCInterface(NULL) {}
 
-    virtual void rewriteCodeBlock(Byte* codeBlock, Byte* newCode, size_t length) = 0;
+    virtual void enumerateRootReference(void** reference) {
+        vm_check_if_monitor(reference, 0, 0, 0, FALSE, 1);
+    }
+
+    virtual void enumerateCompressedRootReference(uint32* reference) {
+        vm_check_if_monitor(0, 0, reference, 0, FALSE, 2);
+    }
+
+    virtual void enumerateRootManagedReference(void** slotReference, int slotOffset) {
+        vm_check_if_monitor(slotReference, 0, 0, slotOffset, FALSE, 3);
+    }
 };
 
-class Compiler {
+//
+// The Persistent Instruction Id is used to generate a profile instruction map and to 
+// feedback profile information into Jitrino.
+//
+class PersistentInstructionId {
 public:
-    virtual ~Compiler() {}
+    PersistentInstructionId() 
+        : methodDesc(NULL), localInstructionId((uint32)-1) {}
 
-    //
-    //  Return true if the method has been successfully compiled,
-    //  false - otherwise
-    //
-    virtual bool compileMethod(CompilationInterface*) = 0;
+        PersistentInstructionId(MethodDesc* methodDesc, uint32 localInstructionId) 
+            : methodDesc(methodDesc), localInstructionId(localInstructionId) {}
+
+            bool isValid() const { return (methodDesc != NULL); }
+
+            MethodDesc& getMethodDesc() const { return *methodDesc; }
+            uint32 getLocalInstructionId() const { return localInstructionId; }
+
+            // For IPF codegen to store block ids into pid
+            bool hasValidLocalInstructionId() const { return localInstructionId != (uint32)-1; }
+
+            bool operator==(const PersistentInstructionId& pid) { return methodDesc == pid.methodDesc && localInstructionId == pid.localInstructionId; }
+private:
+    MethodDesc* methodDesc;     // The source method at point the id was generated
+    uint32 localInstructionId;  // The persistent local instruction id
 };
 
-// assert which works even in release mode
-#define jitrino_assert(compInterface, e) { if (!(e)) { compInterface.hardAssert("Assertion failed", __LINE__, __FILE__); } }
+inline ::std::ostream& operator<<(::std::ostream& os, const PersistentInstructionId& pid) { 
+    os << (pid.isValid() ? pid.getMethodDesc().getName() : "NULL") << ":" 
+        << (unsigned int) pid.getLocalInstructionId(); 
+    return os;
+}
 
 } //namespace Jitrino 
 

Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/vm/drl/DrlEMInterface.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/vm/drl/DrlEMInterface.cpp?view=diff&rev=525110&r1=525109&r2=525110
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/vm/drl/DrlEMInterface.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/vm/drl/DrlEMInterface.cpp Tue Apr  3 02:30:33 2007
@@ -14,23 +14,15 @@
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */
-/* COPYRIGHT_NOTICE */
 
-/**
-* @author Mikhail Y. Fursov
-* @version $Revision$
-*/
-
-#include "open/em_profile_access.h"
-#include "DrlEMInterface.h"
-#include "DrlVMInterface.h"
+#include "EMInterface.h"
 #include "JITInstanceContext.h"
 
 #include <assert.h>
 
 namespace Jitrino {
 
-PC_Handle DrlProfilingInterface::getPCHandle(ProfileType type) const {
+PC_Handle ProfilingInterface::getPCHandle(ProfileType type) const {
     switch (type) {
         case ProfileType_EntryBackedge:
             return ebPCHandle;
@@ -44,31 +36,31 @@
     return NULL;
 }
 
-MethodProfile* DrlProfilingInterface::getMethodProfile(MemoryManager& mm, ProfileType type, MethodDesc& md, JITProfilingRole role) const {
+MethodProfile* ProfilingInterface::getMethodProfile(MemoryManager& mm, ProfileType type, MethodDesc& md, JITProfilingRole role) const {
     
-    Method_Profile_Handle mpHandle = profileAccessInterface->get_method_profile(emHandle, getPCHandle(type), ((DrlVMMethodDesc&)md).getDrlVMMethod());
+    Method_Profile_Handle mpHandle = profileAccessInterface->get_method_profile(emHandle, getPCHandle(type), md.getMethodHandle());
     if (mpHandle==0) {
         return NULL;
     }
     MethodProfile* p = NULL;
     if (type == ProfileType_Edge) {
-        p = new (mm) DrlEdgeMethodProfile(mpHandle, md, profileAccessInterface);
+        p = new (mm) EdgeMethodProfile(mpHandle, md, profileAccessInterface);
     } else if (type == ProfileType_Value) {
-        p = new (mm) DrlValueMethodProfile(mpHandle, md, profileAccessInterface);
+        p = new (mm) ValueMethodProfile(mpHandle, md, profileAccessInterface);
     } else {
         uint32* eCounter = (uint32*)profileAccessInterface->eb_profiler_get_entry_counter_addr(mpHandle);
         uint32* bCounter = (uint32*)profileAccessInterface->eb_profiler_get_backedge_counter_addr(mpHandle);
-        p = new (mm) DrlEntryBackedgeMethodProfile(mpHandle, md, eCounter, bCounter);
+        p = new (mm) EntryBackedgeMethodProfile(mpHandle, md, eCounter, bCounter);
     }
     return p;
 }
 
-Method_Profile_Handle DrlProfilingInterface::getMethodProfileHandle(ProfileType type, MethodDesc& md) const {
-    return profileAccessInterface->get_method_profile(emHandle, getPCHandle(type), ((DrlVMMethodDesc&)md).getDrlVMMethod());
+Method_Profile_Handle ProfilingInterface::getMethodProfileHandle(ProfileType type, MethodDesc& md) const {
+    return profileAccessInterface->get_method_profile(emHandle, getPCHandle(type), md.getMethodHandle());
 }
 
 
-bool DrlProfilingInterface::hasMethodProfile(ProfileType type, MethodDesc& md, JITProfilingRole role) const {
+bool ProfilingInterface::hasMethodProfile(ProfileType type, MethodDesc& md, JITProfilingRole role) const {
 
     PC_Handle pcHandle = getPCHandle(type);
 
@@ -79,13 +71,13 @@
         return false;
     }
     if (profileAccessInterface != NULL) {
-        Method_Profile_Handle mpHandle = profileAccessInterface->get_method_profile(emHandle, pcHandle, ((DrlVMMethodDesc&)md).getDrlVMMethod());
+        Method_Profile_Handle mpHandle = profileAccessInterface->get_method_profile(emHandle, pcHandle, md.getMethodHandle());
         return mpHandle!=0;
     }
     return false;
 }
 
-uint32 DrlProfilingInterface::getProfileMethodCount(MethodDesc& md, JITProfilingRole role) const {
+uint32 ProfilingInterface::getProfileMethodCount(MethodDesc& md, JITProfilingRole role) const {
     assert(jitRole == role);
     PC_Handle pcHandle = getPCHandle(ProfileType_Edge);
     ProfileType pcType = ProfileType_Edge;
@@ -94,7 +86,7 @@
         pcType = ProfileType_EntryBackedge;
     }
     assert (pcHandle != NULL);
-    Method_Handle methodHandle = ((DrlVMMethodDesc&)md).getDrlVMMethod();
+    Method_Handle methodHandle = md.getMethodHandle();
     Method_Profile_Handle mph = profileAccessInterface->get_method_profile(emHandle, pcHandle, methodHandle);
     if (mph == NULL) {
         return 0;
@@ -108,7 +100,7 @@
     return *counterAddr;
 }
 
-bool DrlProfilingInterface::enableProfiling(PC_Handle pc, JITProfilingRole role) {
+bool ProfilingInterface::enableProfiling(PC_Handle pc, JITProfilingRole role) {
     EM_PCTYPE _pcType =  profileAccessInterface->get_pc_type(emHandle, pc);
     if (_pcType != EM_PCTYPE_EDGE && _pcType != EM_PCTYPE_ENTRY_BACKEDGE && _pcType != EM_PCTYPE_VALUE) {
         return false;
@@ -144,27 +136,27 @@
     return profilingEnabled;
 }
 
-bool DrlProfilingInterface::isProfilingEnabled(ProfileType pcType, JITProfilingRole role) const {
+bool ProfilingInterface::isProfilingEnabled(ProfileType pcType, JITProfilingRole role) const {
     if(!profilingEnabled || (jitRole != role) || (getPCHandle(pcType) == NULL)){
         return false;
     }
     return true;
 }
 
-EntryBackedgeMethodProfile* DrlProfilingInterface::createEBMethodProfile(MemoryManager& mm, MethodDesc& md) {
+EntryBackedgeMethodProfile* ProfilingInterface::createEBMethodProfile(MemoryManager& mm, MethodDesc& md) {
     assert(isProfilingEnabled(ProfileType_EntryBackedge, JITProfilingRole_GEN));
     PC_Handle pcHandle = getPCHandle(ProfileType_EntryBackedge);
-    Method_Profile_Handle mpHandle = profileAccessInterface->eb_profiler_create_profile(pcHandle, ((DrlVMMethodDesc&)md).getDrlVMMethod());
+    Method_Profile_Handle mpHandle = profileAccessInterface->eb_profiler_create_profile(pcHandle, md.getMethodHandle());
     assert(mpHandle!=0);
     uint32* eCounter = (uint32*)profileAccessInterface->eb_profiler_get_entry_counter_addr(mpHandle);
     uint32* bCounter = (uint32*)profileAccessInterface->eb_profiler_get_backedge_counter_addr(mpHandle);
 
-    DrlEntryBackedgeMethodProfile* p = new (mm) DrlEntryBackedgeMethodProfile(mpHandle, md, eCounter, bCounter);
+    EntryBackedgeMethodProfile* p = new (mm) EntryBackedgeMethodProfile(mpHandle, md, eCounter, bCounter);
     return p;
 }
 
 
-EdgeMethodProfile* DrlProfilingInterface::createEdgeMethodProfile( MemoryManager& mm,
+EdgeMethodProfile* ProfilingInterface::createEdgeMethodProfile( MemoryManager& mm,
                                                                   MethodDesc& md,
                                                                   uint32 numCounters,
                                                                   uint32* counterKeys,
@@ -173,14 +165,14 @@
     assert(isProfilingEnabled(ProfileType_Edge, JITProfilingRole_GEN));
     PC_Handle pcHandle = getPCHandle(ProfileType_Edge);
     Method_Profile_Handle mpHandle =  profileAccessInterface->edge_profiler_create_profile( 
-        pcHandle, ((DrlVMMethodDesc&)md).getDrlVMMethod(), numCounters, counterKeys, checkSum);
+        pcHandle, md.getMethodHandle(), numCounters, counterKeys, checkSum);
     assert( mpHandle != NULL );
 
-    DrlEdgeMethodProfile* p = new (mm) DrlEdgeMethodProfile(mpHandle, md, profileAccessInterface);
+    EdgeMethodProfile* p = new (mm) EdgeMethodProfile(mpHandle, md, profileAccessInterface);
     return p;
 }
 
-ValueMethodProfile* DrlProfilingInterface::createValueMethodProfile(MemoryManager& mm,
+ValueMethodProfile* ProfilingInterface::createValueMethodProfile(MemoryManager& mm,
                                                                     MethodDesc& md,
                                                                     uint32 numKeys,
                                                                     uint32* Keys)
@@ -188,15 +180,15 @@
     assert(isProfilingEnabled(ProfileType_Value, JITProfilingRole_GEN));
     PC_Handle pcHandle = getPCHandle(ProfileType_Value);
     Method_Profile_Handle mpHandle =  profileAccessInterface->value_profiler_create_profile( 
-        pcHandle, ((DrlVMMethodDesc&)md).getDrlVMMethod(), numKeys, Keys);
+        pcHandle, md.getMethodHandle(), numKeys, Keys);
     assert(mpHandle != NULL);
 
-    DrlValueMethodProfile* p = new (mm) DrlValueMethodProfile(mpHandle, md, profileAccessInterface);
+    ValueMethodProfile* p = new (mm) ValueMethodProfile(mpHandle, md, profileAccessInterface);
     return p;
 }
 
 
-uint32 DrlProfilingInterface::getMethodEntryThreshold() const {
+uint32 ProfilingInterface::getMethodEntryThreshold() const {
     PC_Handle pcHandle = getPCHandle(ProfileType_Edge);
     if (pcHandle != NULL) {
         return profileAccessInterface->edge_profiler_get_entry_threshold(pcHandle);
@@ -207,7 +199,7 @@
     return 0;
 }
 
-uint32 DrlProfilingInterface::getBackedgeThreshold() const {
+uint32 ProfilingInterface::getBackedgeThreshold() const {
     PC_Handle pcHandle = getPCHandle(ProfileType_Edge);
     if (pcHandle != NULL) {
         return profileAccessInterface->edge_profiler_get_backedge_threshold(pcHandle);
@@ -218,58 +210,42 @@
     return 0;
 }
 
-bool DrlProfilingInterface::isEBProfilerInSyncMode() const {
+bool ProfilingInterface::isEBProfilerInSyncMode() const {
     PC_Handle pcHandle = getPCHandle(ProfileType_EntryBackedge);
     assert(pcHandle!=NULL);
     return profileAccessInterface->eb_profiler_is_in_sync_mode(pcHandle)!=0;
 }
 
-PC_Callback_Fn* DrlProfilingInterface::getEBProfilerSyncModeCallback() const {
+ProfilingInterface::PC_Callback_Fn* ProfilingInterface::getEBProfilerSyncModeCallback() const {
     assert(profileAccessInterface->eb_profiler_sync_mode_callback!=NULL);
     return (PC_Callback_Fn*)profileAccessInterface->eb_profiler_sync_mode_callback;
 }
 
 
-
-DrlEdgeMethodProfile::DrlEdgeMethodProfile (Method_Profile_Handle handle, MethodDesc& md, 
-                                            EM_ProfileAccessInterface* _profileAccessInterface) 
-: EdgeMethodProfile(handle, md),  profileAccessInterface(_profileAccessInterface)
-{
-}
-
-
-uint32  DrlEdgeMethodProfile::getNumCounters() const {
+uint32  EdgeMethodProfile::getNumCounters() const {
     return profileAccessInterface->edge_profiler_get_num_counters(getHandle());
 }
 
-uint32  DrlEdgeMethodProfile::getCheckSum() const {
+uint32  EdgeMethodProfile::getCheckSum() const {
     return profileAccessInterface->edge_profiler_get_checksum(getHandle());
 }
 
-uint32* DrlEdgeMethodProfile::getEntryCounter() const {
+uint32* EdgeMethodProfile::getEntryCounter() const {
     return (uint32*)profileAccessInterface->edge_profiler_get_entry_counter_addr(getHandle());
 }
 
-uint32* DrlEdgeMethodProfile::getCounter(uint32 key) const  {
+uint32* EdgeMethodProfile::getCounter(uint32 key) const  {
     uint32* counter = (uint32*)profileAccessInterface->edge_profiler_get_counter_addr(getHandle(), key);
     return counter;
 }
 
-// Value profile
-DrlValueMethodProfile::DrlValueMethodProfile(Method_Profile_Handle handle, MethodDesc& md,  EM_ProfileAccessInterface* _profileAccessInterface)
-: ValueMethodProfile(handle, md),  profileAccessInterface(_profileAccessInterface) {
-}
-
-POINTER_SIZE_INT DrlValueMethodProfile::getTopValue(uint32 instructionKey) const {
+POINTER_SIZE_INT ValueMethodProfile::getTopValue(uint32 instructionKey) const {
     return profileAccessInterface->value_profiler_get_top_value(getHandle(), instructionKey);
 }
 
-void DrlValueMethodProfile::dumpValues(std::ostream& os) const {
+void ValueMethodProfile::dumpValues(std::ostream& os) const {
     profileAccessInterface->value_profiler_dump_values(getHandle(), os);
 }
 
-
 } //namespace
-
-
 

Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/vm/drl/DrlEMInterface.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/vm/drl/DrlEMInterface.h?view=diff&rev=525110&r1=525109&r2=525110
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/vm/drl/DrlEMInterface.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/vm/drl/DrlEMInterface.h Tue Apr  3 02:30:33 2007
@@ -1,115 +0,0 @@
-/*
-*  Licensed to the Apache Software Foundation (ASF) under one or more
-*  contributor license agreements.  See the NOTICE file distributed with
-*  this work for additional information regarding copyright ownership.
-*  The ASF licenses this file to You under the Apache License, Version 2.0
-*  (the "License"); you may not use this file except in compliance with
-*  the License.  You may obtain a copy of the License at
-*
-*     http://www.apache.org/licenses/LICENSE-2.0
-*
-*  Unless required by applicable law or agreed to in writing, software
-*  distributed under the License is distributed on an "AS IS" BASIS,
-*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-*  See the License for the specific language governing permissions and
-*  limitations under the License.
-*/
-/* COPYRIGHT_NOTICE */
-
-/**
-* @author Mikhail Y. Fursov
-* @version $Revision$
-*/
-
-#ifndef _DRLEMINTERFACE_H_
-#define _DRLEMINTERFACE_H_
-
-#include "EMInterface.h"
-
-namespace Jitrino {
-
-class DrlProfilingInterface : public ProfilingInterface {
-public:
-    DrlProfilingInterface(EM_Handle _em, JIT_Handle _jit, EM_ProfileAccessInterface* emProfileAccess)
-        : emHandle(_em), ebPCHandle(NULL), edgePCHandle(NULL), valuePCHandle(NULL), jitHandle(_jit), profileAccessInterface(emProfileAccess), 
-        jitRole(JITProfilingRole_USE), profilingEnabled(false){}
-
-    PC_Handle getPCHandle(ProfileType type) const;
-    virtual EM_ProfileAccessInterface* getEMProfileAccessInterface() const { return profileAccessInterface; }
-
-    virtual MethodProfile* getMethodProfile(MemoryManager& mm, ProfileType type, MethodDesc& md, JITProfilingRole role=JITProfilingRole_USE) const;
-    virtual Method_Profile_Handle getMethodProfileHandle(ProfileType type, MethodDesc& md) const;
-    virtual bool hasMethodProfile(ProfileType type, MethodDesc& md, JITProfilingRole role=JITProfilingRole_USE) const;
-    virtual uint32 getProfileMethodCount(MethodDesc& md, JITProfilingRole role = JITProfilingRole_USE) const;
-
-    virtual bool enableProfiling(PC_Handle pc, JITProfilingRole role);
-    virtual bool isProfilingEnabled(ProfileType pcType, JITProfilingRole jitRole) const ;
-
-    virtual EntryBackedgeMethodProfile* createEBMethodProfile(MemoryManager& mm, MethodDesc& md);
-    virtual bool isEBProfilerInSyncMode() const;
-    virtual PC_Callback_Fn* getEBProfilerSyncModeCallback() const;
-    
-    virtual EdgeMethodProfile* createEdgeMethodProfile(MemoryManager& mm, MethodDesc& md, uint32 numEdgeCounters, uint32* counterKeys, uint32 checkSum);
-
-    virtual uint32 getMethodEntryThreshold() const;
-    virtual uint32 getBackedgeThreshold() const;
-
-    // value profiler
-    virtual ValueMethodProfile* createValueMethodProfile (MemoryManager& mm, MethodDesc& md, uint32 numKeys, uint32* Keys);
-
-private:
-    EM_Handle emHandle;
-    // Various types of the profile collectors
-    PC_Handle ebPCHandle, edgePCHandle, valuePCHandle;
-    // ProfileType pcType;
-    JIT_Handle jitHandle;
-    EM_ProfileAccessInterface* profileAccessInterface;
-    // Only one role supported at one time
-    JITProfilingRole jitRole;
-    // There is only one flag so edge and value profile may work only simultaneously
-    // TODO: Better solution is needed when we want to have independent profiles
-    bool profilingEnabled;
-};
-
-class DrlEntryBackedgeMethodProfile : public EntryBackedgeMethodProfile {
-public:
-    DrlEntryBackedgeMethodProfile(Method_Profile_Handle mph, MethodDesc& md, uint32* _entryCounter, uint32 *_backedgeCounter)
-        : EntryBackedgeMethodProfile(mph, md),  entryCounter(_entryCounter), backedgeCounter(_backedgeCounter){}
-
-    virtual uint32 getEntryExecCount() const {return *entryCounter;}
-    virtual uint32 getBackedgeExecCount() const {return *backedgeCounter;}
-    virtual uint32* getEntryCounter() const {return entryCounter;}
-    virtual uint32* getBackedgeCounter() const {return backedgeCounter;}
-
-private:
-    uint32* entryCounter;
-    uint32* backedgeCounter;
-};
-
-
-class DrlEdgeMethodProfile : public EdgeMethodProfile {
-public:
-    DrlEdgeMethodProfile (Method_Profile_Handle handle, MethodDesc& md,  EM_ProfileAccessInterface* profileAccessInterface);
-    virtual uint32  getNumCounters() const;
-    virtual uint32  getCheckSum() const;
-    virtual uint32* getEntryCounter() const;
-    virtual uint32* getCounter(uint32 key) const ;
-
-private:
-    EM_ProfileAccessInterface* profileAccessInterface;
-
-};
-
-class DrlValueMethodProfile: public ValueMethodProfile {
-public:
-    DrlValueMethodProfile (Method_Profile_Handle handle, MethodDesc& md,  EM_ProfileAccessInterface* profileAccessInterface);
-    virtual POINTER_SIZE_INT getTopValue(uint32 instructionKey) const;
-    virtual void dumpValues(std::ostream& os) const;
-private:
-    EM_ProfileAccessInterface* profileAccessInterface;
-
-};
-
-
-}
-#endif

Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/vm/drl/DrlJITInterface.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/vm/drl/DrlJITInterface.cpp?view=diff&rev=525110&r1=525109&r2=525110
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/vm/drl/DrlJITInterface.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/vm/drl/DrlJITInterface.cpp Tue Apr  3 02:30:33 2007
@@ -25,10 +25,10 @@
 #include <crtdbg.h>
 #endif
 
-
+#include "Type.h"
 #include "Jitrino.h"
-#include "DrlVMInterface.h"
-#include "DrlEMInterface.h"
+#include "VMInterface.h"
+#include "EMInterface.h"
 #include "MemoryEstimates.h"
 #include "Log.h"
 #include "PMF.h"
@@ -38,6 +38,8 @@
 #include "jit_export.h"
 #include "jit_export_jpda.h"
 #include "open/types.h"
+
+#define LOG_DOMAIN "jitrino"
 #include "cxxlog.h"
 
 #include <assert.h>
@@ -131,7 +133,7 @@
 {
     JITInstanceContext* jitContext = Jitrino::getJITInstanceContext(jit);
     MemoryManager& mm = Jitrino::getGlobalMM();
-    DrlProfilingInterface* pi = new (mm) DrlProfilingInterface(em, jit, pc_interface);
+    ProfilingInterface* pi = new (mm) ProfilingInterface(em, jit, pc_interface);
     jitContext->setProfilingInterface(pi);
 }
 
@@ -197,10 +199,8 @@
                                Method_Handle recompiled_method,
                                void *callback_data)
 {
-    DrlVMBinaryRewritingInterface binaryRewritingInterface;
-    DrlVMMethodDesc methodDesc(recompiled_method);
-    bool res = Jitrino::RecompiledMethodEvent(binaryRewritingInterface,
-                                              &methodDesc,callback_data);
+    MethodDesc methodDesc(recompiled_method, NULL);
+    bool res = Jitrino::RecompiledMethodEvent(&methodDesc,callback_data);
     return (res ? TRUE : FALSE);
 }
 
@@ -241,8 +241,9 @@
     JITInstanceContext* jitContext = Jitrino::getJITInstanceContext(jitHandle);
     assert(jitContext!= NULL);
 
-    DrlVMCompilationInterface  compilationInterface(compilation, method_handle, jit,
-            memManager, compilation_params, NULL);
+    TypeManager typeManager(memManager); typeManager.init();
+    CompilationInterface  compilationInterface(compilation, method_handle, jit,
+            memManager, compilation_params, NULL, typeManager);
     CompilationContext cs(memManager, &compilationInterface, jitContext);
     compilationInterface.setCompilationContext(&cs);
 
@@ -348,7 +349,7 @@
         return;
     }
 #endif
-    DrlVMMethodDesc methodDesc(method, jit);
+    MethodDesc methodDesc(method, jit);
     Jitrino::UnwindStack(&methodDesc, context, context->is_ip_past == FALSE);
 }
 
@@ -372,8 +373,8 @@
     }
 #endif
 
-    DrlVMMethodDesc methodDesc(method, jit);
-    DrlVMGCInterface gcInterface(enum_handle);
+    MethodDesc methodDesc(method, jit);
+    GCInterface gcInterface(enum_handle);
     Jitrino::GetGCRootSet(&methodDesc, &gcInterface, context,
                           context->is_ip_past == FALSE);
 }
@@ -413,7 +414,7 @@
 JITEXPORT Boolean
 JIT_can_enumerate(JIT_Handle jit, Method_Handle method, NativeCodePtr eip)
 {
-    DrlVMMethodDesc methodDesc(method, jit);
+    MethodDesc methodDesc(method, jit);
     bool result = Jitrino::CanEnumerate(&methodDesc, eip);
     return (result ? TRUE : FALSE);
 }
@@ -454,7 +455,7 @@
     }
 #endif
 
-    DrlVMMethodDesc methodDesc(method, jit);
+    MethodDesc methodDesc(method, jit);
     Jitrino::FixHandlerContext(&methodDesc, context,
                                context->is_ip_past == FALSE);
 }
@@ -469,7 +470,7 @@
         return Jet::rt_get_address_of_this(jit, method, context);
     }
 #endif
-    DrlVMMethodDesc methodDesc(method, jit);
+    MethodDesc methodDesc(method, jit);
     return Jitrino::GetAddressOfThis(&methodDesc, context,
                                      context->is_ip_past == FALSE);
 }
@@ -522,11 +523,7 @@
 #endif
     }
 #endif
-    DrlVMDataInterface dataIntf;
-    if (dataIntf.areReferencesCompressed())
-        return true;
-    else
-        return false;
+    return (vm_references_are_compressed() != 0);
 }
 
 extern "C"
@@ -540,8 +537,8 @@
         class_get_name(method_get_class(method)) << "." << 
         method_get_name(method) << ")" << ::std::endl;
     }
-    DrlVMMethodDesc methodDesc(method, jit);
-    DrlVMThreadDumpEnumerator gcInterface;
+    MethodDesc methodDesc(method, jit);
+    ThreadDumpEnumerator gcInterface;
     Jitrino::GetGCRootSet(&methodDesc, &gcInterface, context,
                           context->is_ip_past == FALSE);
 }
@@ -563,7 +560,7 @@
     }
 #endif
 
-    DrlVMMethodDesc methDesc(method, jit);
+    MethodDesc methDesc(method, jit);
     uint64* ncAddr = (uint64*) native_pc;
 
     if (Jitrino::GetNativeLocationForBc(&methDesc, bc_pc, ncAddr)) {
@@ -584,7 +581,7 @@
     }
 #endif
 
-    DrlVMMethodDesc methDesc(method, jit);
+    MethodDesc methDesc(method, jit);
     POINTER_SIZE_INT ncAddr = (POINTER_SIZE_INT) native_pc;
     if (Jitrino::GetBcLocationForNative(&methDesc, (uint64)ncAddr, bc_pc)) {
         return EXE_ERROR_NONE;
@@ -623,4 +620,5 @@
 }
 
 } //namespace Jitrino
+
 



Mime
View raw message