Skip to content

Commit

Permalink
Reordered readme
Browse files Browse the repository at this point in the history
  • Loading branch information
ronyhe committed Jul 30, 2018
1 parent 3067708 commit b461825
Showing 1 changed file with 39 additions and 35 deletions.
74 changes: 39 additions & 35 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,25 +13,6 @@ The existing implementations are better in terms of security, compliance and per
Some might suggest that it's a good platform for experimentation with jvm features and modifications.
This might be true, but an implementation already exists for this purpose: [Metascala](https://github.com/lihaoyi/Metascala)

### Where does this JVM diverge from the spec?
This project was written against the [JVM 8 spec](https://docs.oracle.com/javase/specs/jvms/se8/html/index.html), except:

- It does not implement the invokedynamic instruction
- It does not obey JVM arithmetic overflow rules. Instead it uses python math operations directly.
- It does little to no verification of class files
- It does little to no verification of instruction preconditions
- It rarely complies with the exceptions that instructions should throw
- It does not implement native methods
- It does not implement the jsr and ret instructions*


Others are welcome to tackle these issues if they wish.
In fact, this might prove a useful didactic task for students of various advanced topics.

*Note that the jsr and ret instructions are, to my understanding, largely obsolete.
Modern Java compilers do not emit them (although other JVM languages might) and the specification discourages their use.
See [this stackoverflow discussion](https://stackoverflow.com/a/21150629).


### Installation
This project is compliant with usual python conventions.
Expand All @@ -50,6 +31,7 @@ pytest std_lib=path/to/std/lib/jar_file.jar
```
See the standard library section of this document to understand the `std_lib` command line variable.


### Usage
```bash
pyjvm run [OPTIONS] MAIN_CLASS
Expand All @@ -62,6 +44,44 @@ Be sure to add a standard library to your classpath. See the standard library se

There are other commands that are relevant to development and debugging, see pyjvm/main.py.


### High Level Architecture
The Machine in machine.py creates Frame objects that represent methods.
It loops through the frame's instructions and sends them to instructions/instructions.py, which dispatches it to
Instructor instances.
The Instructors produce instances of Action that the machine executes.

For example, let's assume that the current instruction is 'iload_0'.
This instruction should take a value, the one that resides in index 0 of the current frame's locals array.
It should push that value onto the the current frame's operand stack.

Thus, it will produce the following actions:
- Push(\<the value>)
- IncrementProgramCounter()

Which the machine will then execute.


### Where does this JVM diverge from the spec?
This project was written against the [JVM 8 spec](https://docs.oracle.com/javase/specs/jvms/se8/html/index.html), except:

- It does not implement the invokedynamic instruction
- It does not obey JVM arithmetic overflow rules. Instead it uses python math operations directly.
- It does little to no verification of class files
- It does little to no verification of instruction preconditions
- It rarely complies with the exceptions that instructions should throw
- It does not implement native methods
- It does not implement the jsr and ret instructions*


Others are welcome to tackle these issues if they wish.
In fact, this might prove a useful didactic task for students of various advanced topics.

*Note that the jsr and ret instructions are, to my understanding, largely obsolete.
Modern Java compilers do not emit them (although other JVM languages might) and the specification discourages their use.
See [this stackoverflow discussion](https://stackoverflow.com/a/21150629).


### Java Standard Library
All non trivial Java class files will need access to a standard library.
In fact, many trivial ones will need it as well.
Expand Down Expand Up @@ -101,22 +121,6 @@ to the ./configure program, which disables the compilation of native methods. Th
and are irrelevant for a JVM that won't execute them anyway.


### High Level Architecture
The Machine in machine.py creates Frame objects that represent methods.
It loops through the frame's instructions and sends them to instructions/instructions.py, which dispatches it to
Instructor instances.
The Instructors produce instances of Action that the machine executes.

For example, let's assume that the current instruction is 'iload_0'.
This instruction should take a value, the one that resides in index 0 of the current frame's locals array.
It should push that value onto the the current frame's operand stack.

Thus, it will produce the following actions:
- Push(\<the value>)
- IncrementProgramCounter()

Which the machine will then execute.

### Acknowledgements
There are dozens of people I learned from and dozens of tools I use every day.
Too many to list here, so I'll point out two that were especially relevant in this project.
Expand Down

0 comments on commit b461825

Please sign in to comment.