Here we extend the machine JVMC to JVMO. This machine handles the result of the compilation of object-oriented features of Java programs, namely instances, instance creation and initialization, instance _eld access, instance method calls, type casts and null pointers. Therefore the extension consists in adding to the execVMC rules for the new instructions of JVMO and extending the Store, Load and Return instructions to handle addresses.
JVMO distinguishes two kinds of instance method calls. If the method is early bound (InvokeSpecial ), the class which implements the method is embedded in the method reference. In the case of late binding (InvokeVirtual), the method must be looked up dynamically.
Environment. JVMO uses the same environment and abstract class _le as JVMC. However, instance _elds and instance methods|in opposite to class _elds and class methods|are not static but dynamic. Java constructors appear in the JVM as instance initialization methods with the special name <init>.
Trustful execution of JVMO instructions
Values. References uniquely denote instances and belong to the abstract universe Ref , which is assumed to be a subset of Word. We assume that also null is an element of Word.
State. JVMO memorizes the class of an instance and the values of instance _elds in the heap. The heap is structured as in JavaO. data Heap = Object(Class; Map(Class=Field;Val ))
heap:Ref ! Heap
Two derived functions classOf and getField access the heap to select the class of the instance and the values of its _elds. The rule setField is used to assign to an instance _eld.
Rules. The trustfulVM for JVMO is the one for JVMC extended with the new execVMO rules appearing in Figure above.
trustfulVMO = trustfulSchemeC (execVMO; switchVMC )
If upon executing a New instruction the referenced class is initialized, a fresh reference r 62 dom(heap) is allocated. The class of the reference is set to the given class with its instance _elds set to the default values. The new reference is pushed on the operand stack. A GetField instruction pops the target reference from the stack and pushes the value of the _eld, determined using the function getField, from the dynamic store on the operand stack.
A PutField instruction pops a value and the target reference from the stack; using the rule setField(r ; c=f ; ws) it sets the dynamic store at the point of the target reference and the given _eld to the popped value. The instructions InvokeSpecial and InvokeVirtual pop from the stack the arguments and the target reference (which denotes the instance whose method is called). The class which implements the method is determined as follows: If the method is early bound (InvokeSpecial ), the class speci_ed by the instruction parameter is selected, otherwise the method is late bound (InvokeVirtual) and the implementing class is looked up dynamically, starting at the class of the given reference. (The function lookup returns, starting at the given class, the _rst (super) class for the given method reference that implements this method) The arguments for the invoked method are stored in the registers of the new stack frame, starting at the target reference which is placed in reg(0). Execution continues at the _rst instruction of the new method.
An InstanceOf instruction pops a reference from the operand stack. If the reference is not null and compatible with the required class, the integer 1 is pushed on the operand stack, otherwise 0 is pushed. A Checkcast instruction validates that the top value on the stack is an instance of the given class.
JVM Related Interview Questions
|Java Script Interview Questions||Adv Java Interview Questions|
|Core Java Interview Questions||AJAX Interview Questions|
|Android Interview Questions||Java applet Interview Questions|
|Java 8 Interview Questions||JBOSS Interview Questions|
|Advanced jQuery Interview Questions||Apache Tomcat Interview Questions|
|Application Virtualization Interview Questions||Java 9 Interview Questions|
The Imperative Core Javai Of Java
The Procedural Extension Javac Of Javai
The Object-oriented Extension Javao Of Javac
The Exception-handling Extension Javae Of Javao
The Concurrent Extension Javat Of Javae
Java Is Type Safe
The Jvmi Submachine
The Procedural Extension Jvmc Of Jvmi
The Object-oriented Extension Jvmo Of Jvmc
The Exception-handling Extension Jvme Of Jvmo
Correctness Of The Compiler
The Defensive Virtual Machine
Bytecode Type Assignments
The Diligent Virtual Machine
The Dynamic Virtual Machine
All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd
Wisdomjobs.com is one of the best job search sites in India.