porffor 0.14.0-cdebd5442 โ†’ 0.14.0-db4b90996

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/CONTRIBUTING.md CHANGED
@@ -231,7 +231,11 @@ builtins/tostring_number: impl radix
231
231
 
232
232
  Make sure you have Test262 cloned already **inside of `test262/`** (`git clone https://github.com/tc39/test262.git test262/test262`) and run `npm install` inside `test262/` too.
233
233
 
234
- Run `node test262` to run all the tests and get an output of total overall test results. The main thing you want to pay attention to is the emoji summary (lol):
234
+ Run `node test262` to run all the tests and get an output of total overall test results.
235
+
236
+ Warning: this will consume 1-6GB of memory and ~90% of all CPU cores while running (depending on thread count), it should take 15-120s depending on machine. You can specify how many threads with `--threads=N`, it will use the number of CPU threads by default.
237
+
238
+ The main thing you want to pay attention to is the emoji summary (lol):
235
239
  ```
236
240
  ๐Ÿงช 50005 | ๐Ÿค  7007 (-89) | โŒ 1914 (-32) | ๐Ÿ’€ 13904 (-61) | ๐Ÿ“ 23477 (-120) | โฐ 2 | ๐Ÿ— 2073 (+302) | ๐Ÿ’ฅ 1628
237
241
  ```
package/asur/index.js CHANGED
@@ -1155,7 +1155,7 @@ if (bc.porfFunc && paused && op) {
1155
1155
  switch (byg(
1156
1156
  paused,
1157
1157
  funcLines[currentFunc] + currentLine,
1158
- '\x1b[1masur\x1b[22m: ' + callStack.join(' -> ') + (parents.length > 1 ? \` | \${parents.slice(1).map(x => invOpcodes[x.opcode]).join(' -> ')}\` : ''),
1158
+ '\x1b[1masur debugger\x1b[22m: ' + callStack.join(' -> ') + (parents.length > 1 ? \` | \${parents.slice(1).map(x => invOpcodes[x.opcode]).join(' -> ')}\` : ''),
1159
1159
  [
1160
1160
  {
1161
1161
  x: termWidth - 1 - width - 6,
@@ -116,6 +116,20 @@ export default (funcs, globals, tags, pages, data, flags) => {
116
116
  ] ])
117
117
  );
118
118
 
119
+ if (pages.has('func argc lut')) {
120
+ // generate func argc lut data
121
+ const bytes = [];
122
+ for (let i = 0; i < funcs.length; i++) {
123
+ const argc = Math.floor(funcs[i].params.length / 2);
124
+ bytes.push(argc % 256, (argc / 256 | 0) % 256);
125
+ }
126
+
127
+ data.push({
128
+ offset: pages.get('func argc lut').ind * pageSize,
129
+ bytes
130
+ });
131
+ }
132
+
119
133
  // const t0 = performance.now();
120
134
 
121
135
  // specially optimized assembly for globals as this version is much (>5x) faster than traditional createSection()
@@ -27,14 +27,16 @@ export const __Array_prototype_slice = (_this: any[], start: number, end: number
27
27
  let outPtr: i32 = Porffor.wasm`local.get ${out}`;
28
28
  let thisPtr: i32 = Porffor.wasm`local.get ${_this}`;
29
29
 
30
- const thisPtrEnd: i32 = thisPtr + end * 8;
30
+ const thisPtrEnd: i32 = thisPtr + end * 9;
31
31
 
32
- thisPtr += start * 8;
32
+ thisPtr += start * 9;
33
33
 
34
34
  while (thisPtr < thisPtrEnd) {
35
35
  Porffor.wasm.f64.store(outPtr, Porffor.wasm.f64.load(thisPtr, 0, 4), 0, 4);
36
- thisPtr += 8;
37
- outPtr += 8;
36
+ Porffor.wasm.i32.store8(outPtr + 8, Porffor.wasm.i32.load8_u(thisPtr + 8, 0, 4), 0, 4);
37
+
38
+ thisPtr += 9;
39
+ outPtr += 9;
38
40
  }
39
41
 
40
42
  out.length = end - start;
@@ -142,4 +144,26 @@ export const __Array_prototype_toReversed = (_this: any[]) => {
142
144
 
143
145
  export const __Array_prototype_valueOf = (_this: any[]) => {
144
146
  return _this;
147
+ };
148
+
149
+
150
+ export const __Array_prototype_forEach = (_this: any[], callbackFn: Function) => {
151
+ const len: i32 = _this.length;
152
+ let i: i32 = 0;
153
+ while (i < len) {
154
+ callbackFn(_this[i], i++, _this);
155
+ }
156
+ };
157
+
158
+ export const __Array_prototype_filter = (_this: any[], callbackFn: Function) => {
159
+ const out: any[] = [];
160
+
161
+ const len: i32 = _this.length;
162
+ let i: i32 = 0;
163
+ while (i < len) {
164
+ const el: any = _this[i];
165
+ if (callbackFn(el, i++, _this)) out.push(el);
166
+ }
167
+
168
+ return out;
145
169
  };
@@ -0,0 +1,22 @@
1
+ export default () => {
2
+ let out = '';
3
+
4
+ const error = name => out += `export const ${name} = (message: bytestring) => {
5
+ return {};
6
+ };
7
+
8
+ export const ${name}$constructor = (message: bytestring) => {
9
+ return {};
10
+ };`;
11
+
12
+ error('Error');
13
+ error('AggregateError');
14
+ error('TypeError');
15
+ error('ReferenceError');
16
+ error('SyntaxError');
17
+ error('RangeError');
18
+ error('EvalError');
19
+ error('URIError');
20
+
21
+ return out;
22
+ };
@@ -56,14 +56,13 @@ i32.store8 0 12`;
56
56
  };
57
57
 
58
58
 
59
- // todo: this should be a getter somehow not a method
60
- export const __Set_prototype_size = (_this: Set) => {
59
+ export const __Set_prototype_size$get = (_this: Set) => {
61
60
  return Porffor.wasm.i32.load(_this, 0, 0);
62
61
  };
63
62
 
64
63
  export const __Set_prototype_values = (_this: Set) => {
65
64
  // todo: this should return an iterator not array
66
- const size: number = __Set_prototype_size(_this);
65
+ const size: number = Porffor.wasm.i32.load(_this, 0, 0);
67
66
 
68
67
  const out: any[] = __Porffor_allocate();
69
68
  for (let i: number = 0; i < size; i++) {
@@ -79,7 +78,7 @@ export const __Set_prototype_keys = (_this: Set) => {
79
78
  };
80
79
 
81
80
  export const __Set_prototype_has = (_this: Set, value: any) => {
82
- const size: number = __Set_prototype_size(_this);
81
+ const size: number = Porffor.wasm.i32.load(_this, 0, 0);
83
82
 
84
83
  for (let i: number = 0; i < size; i++) {
85
84
  if (__Porffor_set_read(_this, i) === value) return true;
@@ -89,7 +88,7 @@ export const __Set_prototype_has = (_this: Set, value: any) => {
89
88
  };
90
89
 
91
90
  export const __Set_prototype_add = (_this: Set, value: any) => {
92
- const size: number = __Set_prototype_size(_this);
91
+ const size: number = Porffor.wasm.i32.load(_this, 0, 0);
93
92
 
94
93
  // check if already in set
95
94
  for (let i: number = 0; i < size; i++) {
@@ -107,7 +106,7 @@ export const __Set_prototype_add = (_this: Set, value: any) => {
107
106
  };
108
107
 
109
108
  export const __Set_prototype_delete = (_this: Set, value: any) => {
110
- const size: number = __Set_prototype_size(_this);
109
+ const size: number = Porffor.wasm.i32.load(_this, 0, 0);
111
110
 
112
111
  // check if already in set
113
112
  for (let i: number = 0; i < size; i++) {
@@ -19,7 +19,7 @@ export const Symbol = (description: any): Symbol => {
19
19
  };
20
20
 
21
21
  // todo: this should be a getter somehow not a method
22
- export const __Symbol_prototype_description = (_this: Symbol) => {
22
+ export const __Symbol_prototype_description$get = (_this: Symbol) => {
23
23
  const description: bytestring = __Porffor_symbol_descStore(false,
24
24
  Porffor.wasm`local.get ${_this}` - 1);
25
25
  return description;
@@ -221,6 +221,7 @@ export const BuiltinFuncs = function() {
221
221
  typedParams: true,
222
222
  locals: [ Valtype.i32, Valtype.i32 ],
223
223
  returns: [],
224
+ callsSelf: true,
224
225
  wasm: (scope, { typeSwitch }) => [
225
226
  ...typeSwitch(scope, [ [ Opcodes.local_get, 1 ] ], {
226
227
  [TYPES.number]: [
@@ -317,7 +318,7 @@ export const BuiltinFuncs = function() {
317
318
 
318
319
  // make end pointer
319
320
  [ Opcodes.i32_load, Math.log2(ValtypeSize.i32) - 1, 0 ],
320
- ...number(ValtypeSize[valtype], Valtype.i32),
321
+ ...number(ValtypeSize[valtype] + 1, Valtype.i32),
321
322
  [ Opcodes.i32_mul ],
322
323
 
323
324
  [ Opcodes.local_get, 2 ],
@@ -328,12 +329,16 @@ export const BuiltinFuncs = function() {
328
329
 
329
330
  // print current char
330
331
  [ Opcodes.local_get, 2 ],
331
- [ Opcodes.load, Math.log2(ValtypeSize.i16) - 1, ValtypeSize.i32 ],
332
- [ Opcodes.call, importedFuncs.print ],
332
+ [ Opcodes.load, 0, ValtypeSize.i32 ],
333
+
334
+ [ Opcodes.local_get, 2 ],
335
+ [ Opcodes.i32_load8_u, 0, ValtypeSize.i32 + ValtypeSize[valtype] ],
336
+
337
+ [ Opcodes.call, -1 ],
333
338
 
334
339
  // increment pointer by sizeof valtype
335
340
  [ Opcodes.local_get, 2 ],
336
- ...number(ValtypeSize[valtype], Valtype.i32),
341
+ ...number(ValtypeSize[valtype] + 1, Valtype.i32),
337
342
  [ Opcodes.i32_add ],
338
343
  [ Opcodes.local_tee, 2 ],
339
344