functionalscript 0.0.385 → 0.0.386
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/doc/vm.md +110 -81
- package/package.json +1 -1
package/doc/vm.md
CHANGED
|
@@ -1,60 +1,60 @@
|
|
|
1
1
|
# VM
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[Tagged Pointer](https://en.wikipedia.org/wiki/Tagged_pointer).
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
### Common (3 bit)
|
|
5
|
+
## Common (3 bit)
|
|
8
6
|
|
|
9
7
|
- `false`
|
|
10
8
|
- `true`
|
|
11
9
|
- `undefined`
|
|
12
10
|
- `""`
|
|
13
|
-
- `-infinity`
|
|
14
11
|
- `+infinity`
|
|
12
|
+
- `-infinity`
|
|
15
13
|
- `-0`
|
|
16
14
|
- `NaN`
|
|
17
15
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
- `20`: a UTF-16 surrogate pair
|
|
32
|
-
- `16`: 1 x 16 bit string
|
|
33
|
-
- `3`: common
|
|
16
|
+
## 6-bit Id String
|
|
17
|
+
|
|
18
|
+
|symbol |code |# |sum|
|
|
19
|
+
|--------|--------------|--|---|
|
|
20
|
+
|`$` |`\x24` | 1| 1|
|
|
21
|
+
|`0`..`9`|`\x30`..`\x39`| A| B|
|
|
22
|
+
|`A`..`Z`|`\x41`..`\x5A`|1A| 25|
|
|
23
|
+
|`_` |`\x5F` | 1| 26|
|
|
24
|
+
|`a`..`z`|`\x61`..`\x7A`|1A| 40|
|
|
25
|
+
|
|
26
|
+
## 64 bit platform
|
|
27
|
+
|
|
28
|
+
Alignment: 8 bytes.
|
|
34
29
|
|
|
35
|
-
|
|
30
|
+
Pointer: 2^64 / 2^3 = 2^61 bit
|
|
31
|
+
|
|
32
|
+
### Value
|
|
36
33
|
|
|
37
34
|
- `63`: 9 x 7 bit string
|
|
38
35
|
- `63`:
|
|
39
|
-
- `
|
|
40
|
-
|
|
41
|
-
- `
|
|
42
|
-
|
|
36
|
+
- `61`: pointer + null, alignment - 8 bytes
|
|
37
|
+
- `61`:
|
|
38
|
+
- `60`: 4 x 15 bit string
|
|
39
|
+
- `60`: 10 x 6 bit string
|
|
40
|
+
- `61`:
|
|
43
41
|
- `60`: 6 x 10 bit string
|
|
44
42
|
- `60`: 5 x 12 bit string
|
|
45
|
-
|
|
43
|
+
- `61`
|
|
44
|
+
- `60`: float60
|
|
46
45
|
- `60`:
|
|
47
46
|
- `59`: bigInt59 (-576_460_752_303_423_488..576_460_752_303_423_487)
|
|
48
47
|
- `59`:
|
|
49
48
|
- `56`: 8 x 7-bit string
|
|
50
49
|
- `56`: 7 x 8-bit string
|
|
50
|
+
- `53`: int53
|
|
51
|
+
- `53`: stringUInt53
|
|
51
52
|
- `48`: 3 x 16 bit string
|
|
52
53
|
- `32`: 2 x 16 bit string
|
|
53
|
-
- `32`: int32
|
|
54
54
|
- `16`: 1 x UTF16 string
|
|
55
55
|
- `3`: common
|
|
56
56
|
|
|
57
|
-
|
|
57
|
+
## Float64
|
|
58
58
|
|
|
59
59
|
https://en.wikipedia.org/wiki/Double-precision_floating-point_format
|
|
60
60
|
|
|
@@ -75,62 +75,91 @@ https://en.wikipedia.org/wiki/Double-precision_floating-point_format
|
|
|
75
75
|
|111_1111_1111|F = 0: signed infinities|
|
|
76
76
|
| |F != 0: NaN |
|
|
77
77
|
|
|
78
|
-
|
|
78
|
+
## Float60
|
|
79
79
|
|
|
80
80
|
- 1 bit - sign
|
|
81
|
-
-
|
|
81
|
+
- 7 bit - exponent
|
|
82
82
|
- 52 bit - fraction
|
|
83
83
|
|
|
84
|
-
|E
|
|
85
|
-
|
|
86
|
-
|
|
|
87
|
-
|...
|
|
88
|
-
|
|
|
89
|
-
|
|
|
90
|
-
|...
|
|
91
|
-
|
|
|
84
|
+
|E |Description|
|
|
85
|
+
|--------|-----------|
|
|
86
|
+
|000_0000|E = 2^-63 |
|
|
87
|
+
|... | |
|
|
88
|
+
|011_1111|E = 2^0 |
|
|
89
|
+
|100_0000|E = 2^1 |
|
|
90
|
+
|... | |
|
|
91
|
+
|111_1111|E = 2^64 |
|
|
92
|
+
|
|
93
|
+
Note: the type has no `+0`, `-0`, `+inf`, `-inf`, `NaN`.
|
|
92
94
|
|
|
93
95
|
## Object Structure
|
|
94
96
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
-
|
|
101
|
-
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
-
|
|
106
|
-
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
-
|
|
113
|
-
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
97
|
+
Value Size = 8
|
|
98
|
+
Counter size = max_memory_size / value_size.
|
|
99
|
+
|
|
100
|
+
### Type
|
|
101
|
+
|
|
102
|
+
- `000`: double
|
|
103
|
+
- `001`: string
|
|
104
|
+
- `010`: array
|
|
105
|
+
- `011`: object
|
|
106
|
+
- `100`: bigInt
|
|
107
|
+
- `101`: function
|
|
108
|
+
- `110`:
|
|
109
|
+
- `111`:
|
|
110
|
+
|
|
111
|
+
### Type & Counter
|
|
112
|
+
|
|
113
|
+
- AtomicUSize:
|
|
114
|
+
- `3`: type
|
|
115
|
+
- `...`: counter
|
|
116
|
+
|
|
117
|
+
### String
|
|
118
|
+
|
|
119
|
+
```rust
|
|
120
|
+
struct String {
|
|
121
|
+
length: u32,
|
|
122
|
+
array: [u16; self.length],
|
|
123
|
+
}
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
### Function
|
|
127
|
+
|
|
128
|
+
```rust
|
|
129
|
+
struct Function<length: u32> {
|
|
130
|
+
func: pointer,
|
|
131
|
+
array: [value; length]
|
|
132
|
+
}
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
### BigInt
|
|
136
|
+
|
|
137
|
+
```rust
|
|
138
|
+
struct BigInt {
|
|
139
|
+
length: u32,
|
|
140
|
+
array: [u64; self.length],
|
|
141
|
+
}
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
### Array
|
|
145
|
+
|
|
146
|
+
```rust
|
|
147
|
+
struct Array {
|
|
148
|
+
length: u32,
|
|
149
|
+
array: [Value; self.length],
|
|
150
|
+
}
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
### Object
|
|
154
|
+
|
|
155
|
+
```rust
|
|
156
|
+
struct Object {
|
|
157
|
+
length: u32,
|
|
158
|
+
array: [(Value, Value), self.length],
|
|
159
|
+
indexArray: [u32, (self.length * log2(self.length) + 31) / u32],
|
|
160
|
+
}
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
Note: see https://262.ecma-international.org/6.0/#sec-ordinary-object-internal-methods-and-internal-slots-ownpropertykeys and https://262.ecma-international.org/6.0/#sec-object-type
|
|
164
|
+
|
|
165
|
+
An integer index for Node.js, Deno and Bun means a value from `0` to `4294967294` including. 4_294_967_294 = 0xFFFF_FFFE. But an integer index in the ES6 standard is +0..2^53-1.
|