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.
Files changed (2) hide show
  1. package/doc/vm.md +110 -81
  2. package/package.json +1 -1
package/doc/vm.md CHANGED
@@ -1,60 +1,60 @@
1
1
  # VM
2
2
 
3
- ## Tagged Pointers
3
+ [Tagged Pointer](https://en.wikipedia.org/wiki/Tagged_pointer).
4
4
 
5
- https://en.wikipedia.org/wiki/Tagged_pointer
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
- ### 32 bit platform
19
-
20
- - `31` bigInt31 (-1_073_741_824..1_073_741_823)
21
- - `31`:
22
- - `30`: pointer + null, alignment - 4 bytes.
23
- - `30`:
24
- - `29`:
25
- - `28`: 4 x 7 bit string
26
- - `28`: 2 x 14 bit string
27
- - `29`:
28
- - `28`: int28 (-134_217_728..134_217_727)
29
- - `28`:
30
- - `27`: 3 x 9 bit string
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
- ### 64 bit platform
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
- - `62`:
40
- - `61`: pointer + null, alignment - 8 bytes
41
- - `61`: float61
42
- - `62`:
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
- - `60`: 4 x 15 bit string
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
- ### Float64
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
- ### Float61
78
+ ## Float60
79
79
 
80
80
  - 1 bit - sign
81
- - 8 bit - exponent
81
+ - 7 bit - exponent
82
82
  - 52 bit - fraction
83
83
 
84
- |E |Description|
85
- |---------|-----------|
86
- |0000_0000|E = 2^-127 |
87
- |... | |
88
- |0111_1111|E = 2^0 |
89
- |1000_0000|E = 2^1 |
90
- |... | |
91
- |1111_1111|E = 2^128 |
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
- - type&counter: 32 + float64: 64
96
- - type&counter: 32 + int32: 32
97
- - type&counter: 32 + object: len: 32 + payload
98
- - type&counter: 32 + array: len: 32 + payload
99
- - type&counter: 32 + function: 32 + 32
100
- - type&counter: 32 + string: len: 32 + payload
101
- - type&counter: 32 + bigint: len: 32 + payload
102
-
103
- minimal size: 64 bit = 8 byte. It means that a number of objects can't be more than 2^(32-3) on 32-bit platform and 2^(64-3) on 64-bit platform.
104
- counter:
105
- - 32 - 3 = 29 bit,
106
- - 64 - 3 = 61 bit.
107
-
108
- Max length of JS string/array/object can't be bigger that 2^53-1
109
-
110
- ## Type
111
-
112
- - 000 float64
113
- - 001 string
114
- - 010 object
115
- - 011 array
116
- - 100 function
117
- - 101 bigint
118
- - 110 int32
119
- - 111 ...
120
-
121
- ## Type & counter
122
-
123
- |field |x32 |x64 |
124
- |-------|------|------|
125
- |type |29..31|61..63|
126
- |counter|0..28 |0..62 |
127
-
128
- ## Using Pools for small objects
129
-
130
- |type |size on x32|size on x64|
131
- |------------|-----------|-----------|
132
- |float64 |4+8 = 12 |8+8 = 16 |
133
- |function |4+4 = 8 |8+8 = 16 |
134
- |int32 |4+4 = 8 |8+4 = 12 |
135
- |empty object|4+4 = 8 |8+8 = 16 |
136
- |empty array |4+4 = 8 |8+8 = 16 |
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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "functionalscript",
3
- "version": "0.0.385",
3
+ "version": "0.0.386",
4
4
  "description": "FunctionalScript is a functional subset of JavaScript",
5
5
  "main": "module.f.cjs",
6
6
  "scripts": {