Jamaica Seminar

download Jamaica Seminar

of 16

Transcript of Jamaica Seminar

  • 8/11/2019 Jamaica Seminar

    1/16

    F R I D T J O F S I E B E R T

    A N D Y W A L T E R -

    Determisnistic Execution of JavasPrimitive Bytecode Operation

    Rohit P. GuptaRoll No- 132010972

  • 8/11/2019 Jamaica Seminar

    2/16

    INTRODUCTION

    Java [AG98] is becoming increasingly popular forsoftware development, even in application domainswell beyond the original target domain of the language.

    The most obvious source for indeterministic

    execution is the use of garbage collection in Java.

    A deterministic implementation of Java must providemeans to determine worst-case execution timesfor Javas primitive operations. The dynamic structureof Java, with inheritance, virtual method callsand multiple-inheritance for interfaces, poses severaldifficulties for the implementation.

  • 8/11/2019 Jamaica Seminar

    3/16

    I n t e r f a c e C a l l

    The most difficult to implement calls are calls to interface methods via thebytecode operation invoke_ interface.

    The reason is that multiple inheritance makes it impossible to assignconstant indices to the methods as in the case of virtual calls.

    Every interface is assigned a unique identifier interface_id, starting at 0 forthe first interface loaded

    Each method within an interface is assigned an interface_method_ indexsimilar to the methods of normal classes

    The class descriptor of every class that implements one or several interfacescontains a reference to an array of references. This array is referred to asimplements array.

  • 8/11/2019 Jamaica Seminar

    4/16

    I n t e r f a c e C a l l s

  • 8/11/2019 Jamaica Seminar

    5/16

    Switch Statement

    The Java bytecode provides two different operationsfor switch-statements: tableswitch and lookupswitch.

    For a switch-statement with case-entries that are similar values,tableswitch is used. It permits a constant-time table lookup for thestatement sequence that needs to be executed.

    For case-entries that extend over a large range of values with unusedintervals tableswitchwould require a large table

    The lookup requires a binary search of this table, hence the runtime islogarithmic in the number of case-labels in the switch statement

    A Java compiler that generates native code can use perfect hashing

    here.

  • 8/11/2019 Jamaica Seminar

    6/16

    Memory Allocation

    The most difficult problem to be solved by a deterministic implementationof Java is to provide deterministic behaviour of dynamic memoryallocation.

    The implementation has to guarantee a hard upper bound for the execution

    time of an allocation.

    it also has to guarantee that the garbage collector recycles memorysufficiently quickly for the application not to run out of memory.

  • 8/11/2019 Jamaica Seminar

    7/16

    J V M G a r b a g e C o l l e c t o r

  • 8/11/2019 Jamaica Seminar

    8/16

    N o n F r a g m e n t i n g O b j e c t M o d e l

  • 8/11/2019 Jamaica Seminar

    9/16

    J a m a i c a G C P h a s e

  • 8/11/2019 Jamaica Seminar

    10/16

    Exceptions

    Javas exception mechanism enables control flow from an active methodback to a method with an exception handler that lies an arbitrary numberof stack frames above the current position in the call chain

    Throwing an exception that is handled by another method therefore

    requires removal of all active stack frames that lie in between the methodcausing the exception and the method handling it.

    Since exceptions are not supposed to be used for normal control flow, butfor exceptional control flow only, this behaviour should be acceptable evenwhen deterministic execution in the non exceptional case is required.

  • 8/11/2019 Jamaica Seminar

    11/16

    Memor y Access

    Field Accesses :

    Since a linear list of blocks is used to represent objects, the number ofmemory references required is linear in the offset of the field within theobject

    Fields that reside in the first block can be accessed using a singlememory access, while fields in the second block require two memoryaccesses, etc

    For any field, the position is known statically and hence the number ofmemory accesses required can be determined statically.

  • 8/11/2019 Jamaica Seminar

    12/16

    M e m o r y A c c e s s ( c o n t . . )

    Array Accesses :

    With array accesses, the situation is a bit more complex since arrays arerepresented as trees

    The trees use the highest branching factor allowed by the block size For a block size of 32 bytes on a 32-bitsystem, this means that the branching

    factor is 8. Even very large arrays can be represented in a fairly shallow tree.

    For a given system with a limited heap size h, the maximum depth dmax forthese trees can be determined statically using the following term (for a blocksize of 32 bytes).dmax = ln8( h / 32 ).

    For a heap of 32MB the resulting maximal depth is 7. For an array access, one additional memory access is required to read the

    arrays depth and one reference is needed to read the actual element. So thetotal number of memory references is dmax+2, or 9 for a heap size of32MB.This enables the determination of a worst-case execution time for arrayaccesses

  • 8/11/2019 Jamaica Seminar

    13/16

    Permormance Comparsion

  • 8/11/2019 Jamaica Seminar

    14/16

    CONCLUSION

    In this paper the Jamaica implementation of Java has been presented. Thedeterministic implementation of Javas primitive operations in thisimplementation has been explained. The implementation permits staticanalysis of the execution time of its primitive operations that is not possiblewith current Java implementations. The performance of the implementationhas then been measured and compared to different versions of Suns JDKimplementation using the SPECjvm98benchmark suite. The results show thatperformance that is comparable to Suns implementations canbe reached.These results encourage us to further improve our implementation and to

    further reduce the performance gap compared to non-deterministic Javaimplementations.

  • 8/11/2019 Jamaica Seminar

    15/16

    The deterministic implementation of a programming languages primitiveoperations provides only the basis for further analysis of the code. Tools forautomatic determination of worst-case execution times can be build on top of

    this. For an accurate analysis that is not too conservative, mechanisms tomodel the systems cache memories and the effects of modern superscalarprocessors on the execution time need to be developed.

    Future Work

  • 8/11/2019 Jamaica Seminar

    16/16

    Thank You!!