Skip to content

Commit

Permalink
float immediate done
Browse files Browse the repository at this point in the history
  • Loading branch information
Ducasse committed Dec 6, 2024
1 parent 23da0d5 commit 0f0524d
Show file tree
Hide file tree
Showing 9 changed files with 33 additions and 23 deletions.
15 changes: 15 additions & 0 deletions 32bitsimmediate2-ascii.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
|---+---+---+---+---+---+---+---|---+---+---+---+---+---+---+---|---+---+---+---+---+---+---+---|---+---+---+---+---+---+---+---|
| | | | | 0 | 0 |
|---+---+---+---+---+---+---+---|---+---+---+---+---+---+---+---|---+---+---+---+---+---+---+---|---+---+---+---+---+---+---+---|
pointer to an object in the heap

|---+---+---+---+---+---+---+---|---+---+---+---+---+---+---+---|---+---+---+---+---+---+---+---|---+---+---+---+---+---+---+---|
| | | | | | 1 |
|---+---+---+---+---+---+---+---|---+---+---+---+---+---+---+---|---+---+---+---+---+---+---+---|---+---+---+---+---+---+---+---|
a SmallInteger instance (31 bits signed int)

|---+---+---+---+---+---+---+---|---+---+---+---+---+---+---+---|---+---+---+---+---+---+---+---|---+---+---+---+---+---+---+---|
| | | | | 1 | 0 |
|---+---+---+---+---+---+---+---|---+---+---+---+---+---+---+---|---+---+---+---+---+---+---+---|---+---+---+---+---+---+---+---|
a character instance

Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@


8 bits exponent 52 bits mantissa
|---+---+---+---+---+---+---+---|---+---+---+---+---+---+---+---|---+---+---+---+---+---+---+---|---+---+---+---+---+---+---+---|
| e | e | e | e | e | e | e | e | | | |
|---+---+---+---+---+---+---+---|---+---+---+---+---+---+---+---|---+---+---+---+---+---+---+---|---+---+---+---+---+---+---+---|
| | | | | s | 1 | 0 | 0 |
|---+---+---+---+---+---+---+---|---+---+---+---+---+---+---+---|---+---+---+---+---+---+---+---|---+---+---+---+---+---+---+---|

sign bit
immediate tag
a small float instance
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@ a character instance
|---+---+---+---+---+---+---+---|---+---+---+---+---+---+---+---|---+---+---+---+---+---+---+---|---+---+---+---+---+---+---+---|
| | | | | 1 | 0 | 0 |
|---+---+---+---+---+---+---+---|---+---+---+---+---+---+---+---|---+---+---+---+---+---+---+---|---+---+---+---+---+---+---+---|
a float instance
a small float instance
Binary file modified Part0-Preamble/1-ObjectStructure/figures/64bitsimmediate2.pdf
Binary file not shown.
6 changes: 3 additions & 3 deletions Part0-Preamble/1-ObjectStructure/objectStructure.md
Original file line number Diff line number Diff line change
Expand Up @@ -261,8 +261,8 @@ Currently, Pharo supports integers, characters, and floating point numbers as im

- In 32-bit architectures, floats are not represented as immediate objects, integers present a 1-bit tag `1`, while characters are represented with the 2-bit tag `10`, as shown in Figure *@fig:32bitsimm@*.

![64-bit immediate objects. %width=100&anchor=fig:64bitsimm](figures/64bitsImmediate.pdf )
![32-bit immediate objects. %width=100&anchor=fig:32bitsimm](figures/32bitsImmediate.pdf )
![64-bit immediate objects. %width=100&anchor=fig:64bitsimm](figures/64bitsImmediate2.pdf )
![32-bit immediate objects. %width=100&anchor=fig:32bitsimm](figures/32bitsImmediate2.pdf )

The following code (Listing *@testingsmallintcaption@*) shows how we can tag, untag, and verify if a value is taggable.

Expand Down Expand Up @@ -357,7 +357,7 @@ However, to accommodate the 64 bits into 61 bits, immediate floats give up 3 bit
The VM verifies that only immediate floats that do not lose information in this format are encoded as immediates.
For floats that do not satisfy this constraint, floats use a boxed representation as explained in Section *@sec:boxing@*.

![64 bits `SmallFloat` immediate. %width=100&anchor=fig:64bitsfloatimm](figures/64bitsFloatImmediate.pdf )
![64 bits `SmallFloat` immediate. %width=100&anchor=fig:64bitsfloatimm](figures/64bitsFloatImmediate2.pdf )

Figure *@fig:64bitsfloatimm@* shows the structure of a `SmallFloat`.
The sign bit is moved to the lowest bit of the tagged value, and the highest 3 bits of the exponent are lost.
Expand Down

This file was deleted.

Binary file not shown.
4 changes: 2 additions & 2 deletions Part1-InterpreterAndBytecode/4-Interpreter/stackFrame.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ Thus, the stack can be reconstructed by iterating from the top frame up to its c

Notice that the stack pointer does not need to be stored: a suspended frame's stack pointer is the slot that precedes its suspended instruction pointer, which is found relative to its following frame.


![Creating a new stack frame main steps. %width=70&anchor=stackFrameCreation](figures/interpreter_variables_creation.pdf)


### Setting up a Stack Frame
Expand All @@ -154,7 +154,7 @@ Listing *@settingStackFrames@* presents an extract of the method `setUpFrameForM
- Once pushed, the `framePointer` can be overridden to mark the start of a new frame at the position of `stackPointer`.
- Then the method, `nil` for context, flags, receiver, and temps are pushed.

![Creating a new stack frame main steps. %width=70&anchor=stackFrameCreation](figures/interpreter_variables.pdf)



```caption=Setting up a frame&anchor=settingStackFrames
Expand Down

0 comments on commit 0f0524d

Please sign in to comment.