porffor 0.18.40 → 0.18.42

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.
@@ -103,59 +103,45 @@ export const __DataView_prototype_getUint16 = (_this: DataView, byteOffset: numb
103
103
  const len: i32 = Porffor.wasm.i32.load(_this, 0, 0);
104
104
  if (Porffor.fastOr(byteOffset < 0, byteOffset + 1 >= len)) throw new RangeError('Byte offset is out of bounds of the DataView');
105
105
 
106
- let byte1: i32 = 0, byte2: i32 = 0;
107
- Porffor.wasm`local ptr i32
106
+ let int: i32 = 0;
107
+ Porffor.wasm`
108
108
  local.get ${_this}
109
109
  i32.to_u
110
110
  i32.load 0 4
111
111
  local.get ${byteOffset}
112
112
  i32.to_u
113
113
  i32.add
114
- local.set ptr
115
114
 
116
- local.get ptr
117
- i32.load8_u 0 4
115
+ i32.load16_u 0 4
118
116
  i32.from_u
119
- local.set ${byte1}
120
- local.get ptr
121
- i32.load8_u 0 5
122
- i32.from_u
123
- local.set ${byte2}`;
117
+ local.set ${int}`;
124
118
 
125
- if (Boolean(littleEndian)) return byte1 | (byte2 << 8);
126
- return (byte1 << 8) | byte2;
119
+ if (Boolean(littleEndian)) return int;
120
+ return (int >>> 8) | ((int & 0xFF) << 8);
127
121
  };
128
122
 
129
123
  export const __DataView_prototype_setUint16 = (_this: DataView, byteOffset: number, value: number, littleEndian: any) => {
130
124
  const len: i32 = Porffor.wasm.i32.load(_this, 0, 0);
131
125
  if (Porffor.fastOr(byteOffset < 0, byteOffset + 1 >= len)) throw new RangeError('Byte offset is out of bounds of the DataView');
132
126
 
133
- let byte1: i32 = 0, byte2: i32 = 0;
134
- if (littleEndian) {
135
- byte1 = value & 0xff;
136
- byte2 = (value >>> 8) & 0xff;
127
+ let int: i32 = 0;
128
+ if (Boolean(littleEndian)) {
129
+ int = value;
137
130
  } else {
138
- byte1 = (value >>> 8) & 0xff;
139
- byte2 = value & 0xff;
131
+ int = (value >>> 8) | ((value & 0xFF) << 8);
140
132
  }
141
133
 
142
- Porffor.wasm`local ptr i32
134
+ Porffor.wasm`
143
135
  local.get ${_this}
144
136
  i32.to_u
145
137
  i32.load 0 4
146
138
  local.get ${byteOffset}
147
139
  i32.to_u
148
140
  i32.add
149
- local.set ptr
150
141
 
151
- local.get ptr
152
- local.get ${byte1}
142
+ local.get ${int}
153
143
  i32.to_u
154
- i32.store8 0 4
155
- local.get ptr
156
- local.get ${byte2}
157
- i32.to_u
158
- i32.store8 0 5`;
144
+ i32.store16 0 4`;
159
145
 
160
146
  return undefined;
161
147
  };
@@ -174,79 +160,51 @@ export const __DataView_prototype_getUint32 = (_this: DataView, byteOffset: numb
174
160
  const len: i32 = Porffor.wasm.i32.load(_this, 0, 0);
175
161
  if (Porffor.fastOr(byteOffset < 0, byteOffset + 3 >= len)) throw new RangeError('Byte offset is out of bounds of the DataView');
176
162
 
177
- let byte1: i32 = 0, byte2: i32 = 0, byte3: i32 = 0, byte4: i32 = 0;
178
- Porffor.wasm`local ptr i32
163
+ let int: i32 = 0;
164
+ Porffor.wasm`
179
165
  local.get ${_this}
180
166
  i32.to_u
181
167
  i32.load 0 4
182
168
  local.get ${byteOffset}
183
169
  i32.to_u
184
170
  i32.add
185
- local.set ptr
186
171
 
187
- local.get ptr
188
- i32.load8_u 0 4
189
- i32.from_u
190
- local.set ${byte1}
191
- local.get ptr
192
- i32.load8_u 0 5
193
- i32.from_u
194
- local.set ${byte2}
195
- local.get ptr
196
- i32.load8_u 0 6
197
- i32.from_u
198
- local.set ${byte3}
199
- local.get ptr
200
- i32.load8_u 0 7
172
+ i32.load 0 4
201
173
  i32.from_u
202
- local.set ${byte4}`;
174
+ local.set ${int}`;
203
175
 
204
- if (Boolean(littleEndian)) return byte1 | (byte2 << 8) | (byte3 << 16) | (byte4 << 24);
205
- return (byte1 << 24) | (byte2 << 16) | (byte3 << 8) | byte4;
176
+ if (Boolean(littleEndian)) return int;
177
+ return (int >>> 24) |
178
+ ((int >>> 8) & 0x0000ff00) |
179
+ ((int << 8) & 0x00ff0000) |
180
+ (int << 24);
206
181
  };
207
182
 
208
183
  export const __DataView_prototype_setUint32 = (_this: DataView, byteOffset: number, value: number, littleEndian: any) => {
209
184
  const len: i32 = Porffor.wasm.i32.load(_this, 0, 0);
210
185
  if (Porffor.fastOr(byteOffset < 0, byteOffset + 3 >= len)) throw new RangeError('Byte offset is out of bounds of the DataView');
211
186
 
212
- let byte1: i32 = 0, byte2: i32 = 0, byte3: i32 = 0, byte4: i32 = 0;
213
- if (littleEndian) {
214
- byte1 = value & 0xff;
215
- byte2 = (value >>> 8) & 0xff;
216
- byte3 = (value >>> 16) & 0xff;
217
- byte4 = (value >>> 24) & 0xff;
187
+ let int: i32 = 0;
188
+ if (Boolean(littleEndian)) {
189
+ int = value;
218
190
  } else {
219
- byte1 = (value >>> 24) & 0xff;
220
- byte2 = (value >>> 16) & 0xff;
221
- byte3 = (value >>> 8) & 0xff;
222
- byte4 = value & 0xff;
191
+ int = (value >>> 24) |
192
+ ((value >>> 8) & 0x0000FF00) |
193
+ ((value << 8) & 0x00FF0000) |
194
+ (value << 24);
223
195
  }
224
196
 
225
- Porffor.wasm`local ptr i32
197
+ Porffor.wasm`
226
198
  local.get ${_this}
227
199
  i32.to_u
228
200
  i32.load 0 4
229
201
  local.get ${byteOffset}
230
202
  i32.to_u
231
203
  i32.add
232
- local.set ptr
233
204
 
234
- local.get ptr
235
- local.get ${byte1}
236
- i32.to_u
237
- i32.store8 0 4
238
- local.get ptr
239
- local.get ${byte2}
205
+ local.get ${int}
240
206
  i32.to_u
241
- i32.store8 0 5
242
- local.get ptr
243
- local.get ${byte3}
244
- i32.to_u
245
- i32.store8 0 6
246
- local.get ptr
247
- local.get ${byte4}
248
- i32.to_u
249
- i32.store8 0 7`;
207
+ i32.store 0 4`;
250
208
 
251
209
  return undefined;
252
210
  };
@@ -258,4 +216,26 @@ export const __DataView_prototype_getInt32 = (_this: DataView, byteOffset: numbe
258
216
 
259
217
  export const __DataView_prototype_setInt32 = (_this: DataView, byteOffset: number, value: number, littleEndian: any) => {
260
218
  return __DataView_prototype_setUint32(_this, byteOffset, value < 0 ? value | 0x100000000 : value, littleEndian);
219
+ };
220
+
221
+ export const __DataView_prototype_getFloat32 = (_this: DataView, byteOffset: number, littleEndian: any) => {
222
+ const int: i32 = __DataView_prototype_getUint32(_this, byteOffset, littleEndian);
223
+ Porffor.wasm`
224
+ local.get ${int}
225
+ i32.to_u
226
+ f32.reinterpret_i32
227
+ f64.promote_f32
228
+ i32.const 0
229
+ return`;
230
+ };
231
+
232
+ export const __DataView_prototype_setFloat32 = (_this: DataView, byteOffset: number, value: number, littleEndian: any) => {
233
+ let int: i32 = 0;
234
+ Porffor.wasm`
235
+ local.get ${value}
236
+ f32.demote_f64
237
+ i32.reinterpret_f32
238
+ i32.from_u
239
+ local.set ${int}`;
240
+ return __DataView_prototype_setUint32(_this, byteOffset, int, littleEndian);
261
241
  };
@@ -142,12 +142,20 @@ export const read_unsignedLEB128 = _input => {
142
142
  };
143
143
 
144
144
  // ieee 754 binary64
145
- // const ieee754Cache = {};
146
- // export const ieee754_binary64 = value => {
147
- // if (ieee754Cache[value]) return ieee754Cache[value];
148
- // return ieee754Cache[value] = [...new Uint8Array(new Float64Array([ value ]).buffer)];
149
- // };
150
- export const ieee754_binary64 = value => [...new Uint8Array(new Float64Array([ value ]).buffer)];
145
+ const ieee754Buffer = new Float64Array(1);
146
+ const ieee754Cache = {};
147
+ export const ieee754_binary64 = value => {
148
+ if (value === 0) {
149
+ if (1 / value === -Infinity) return [ 0, 0, 0, 0, 0, 0, 0, 128 ]; // -0
150
+ return [ 0, 0, 0, 0, 0, 0, 0, 0 ]; // +0
151
+ }
152
+
153
+ if (ieee754Cache[value]) return ieee754Cache[value].slice();
154
+
155
+ ieee754Buffer[0] = value;
156
+ return ieee754Cache[value] = [...new Uint8Array(ieee754Buffer.buffer)];
157
+ };
158
+
151
159
  export const read_ieee754_binary64 = buffer => new Float64Array(new Uint8Array(buffer).buffer)[0];
152
160
 
153
161
 
@@ -627,16 +627,16 @@ export const BuiltinFuncs = function() {
627
627
  locals: [127], localNames: ["_this","_this#type","byteOffset","byteOffset#type","value","value#type","#last_type"],
628
628
  };
629
629
  this.__DataView_prototype_getUint16 = {
630
- wasm: (scope, {builtin,internalThrow}) => [[32,0],[252,2],[40,0,0],[183],[33,6],[32,2],[68,0,0,0,0,0,0,0,0],[99],[32,2],[68,0,0,0,0,0,0,240,63],[160],[32,6],[102],[114],[4,64],...internalThrow(scope, 'RangeError', `Byte offset is out of bounds of the DataView`),[11],[68,0,0,0,0,0,0,0,0],[33,7],[68,0,0,0,0,0,0,0,0],[33,8],[32,0],[252,3],[40,0,4],[32,2],[252,3],[106],[34,9],[45,0,4],[184],[33,7],[32,9],[45,0,5],[184],[33,8],[32,4],[33,10],[32,5],[33,11],[2,124],[32,11],[65,194,0],[70],[4,64,"TYPESWITCH|String"],[32,10],[252,3],[40,1,0],[184],[12,1],[11],[32,11],[65,194,1],[70],[4,64,"TYPESWITCH|ByteString"],[32,10],[252,3],[40,1,0],[184],[12,1],[11],[32,10],[252,2],[69],[69],[183],[11,"TYPESWITCH_end"],[252,3],[4,64],[32,7],[32,8],[68,0,0,0,0,0,0,32,64],[16, builtin('f64_<<')],[16, builtin('f64_|')],[65,0],[15],[11],[32,7],[68,0,0,0,0,0,0,32,64],[16, builtin('f64_<<')],[32,8],[16, builtin('f64_|')],[65,0],[15]],
630
+ wasm: (scope, {builtin,internalThrow}) => [[32,0],[252,2],[40,0,0],[183],[33,6],[32,2],[68,0,0,0,0,0,0,0,0],[99],[32,2],[68,0,0,0,0,0,0,240,63],[160],[32,6],[102],[114],[4,64],...internalThrow(scope, 'RangeError', `Byte offset is out of bounds of the DataView`),[11],[68,0,0,0,0,0,0,0,0],[33,7],[32,0],[252,3],[40,0,4],[32,2],[252,3],[106],[47,0,4],[184],[33,7],[32,4],[33,8],[32,5],[33,9],[2,124],[32,9],[65,194,0],[70],[4,64,"TYPESWITCH|String"],[32,8],[252,3],[40,1,0],[184],[12,1],[11],[32,9],[65,194,1],[70],[4,64,"TYPESWITCH|ByteString"],[32,8],[252,3],[40,1,0],[184],[12,1],[11],[32,8],[252,2],[69],[69],[183],[11,"TYPESWITCH_end"],[252,3],[4,64],[32,7],[65,0],[15],[11],[32,7],[68,0,0,0,0,0,0,32,64],[16, builtin('f64_>>>')],[32,7],[68,0,0,0,0,0,224,111,64],[16, builtin('f64_&')],[68,0,0,0,0,0,0,32,64],[16, builtin('f64_<<')],[16, builtin('f64_|')],[65,0],[15]],
631
631
  params: [124,127,124,127,124,127], typedParams: 1,
632
632
  returns: [124,127], typedReturns: 1,
633
- locals: [124,124,124,127,124,127], localNames: ["_this","_this#type","byteOffset","byteOffset#type","littleEndian","littleEndian#type","len","byte1","byte2","ptr","#logicinner_tmp","#typeswitch_tmp"],
633
+ locals: [124,124,124,127], localNames: ["_this","_this#type","byteOffset","byteOffset#type","littleEndian","littleEndian#type","len","int","#logicinner_tmp","#typeswitch_tmp"],
634
634
  };
635
635
  this.__DataView_prototype_setUint16 = {
636
- wasm: (scope, {builtin,internalThrow}) => [[32,0],[252,2],[40,0,0],[183],[33,8],[32,2],[68,0,0,0,0,0,0,0,0],[99],[32,2],[68,0,0,0,0,0,0,240,63],[160],[32,8],[102],[114],[4,64],...internalThrow(scope, 'RangeError', `Byte offset is out of bounds of the DataView`),[11],[68,0,0,0,0,0,0,0,0],[33,9],[68,0,0,0,0,0,0,0,0],[33,10],[32,6],[33,11],[32,7],[33,12],[2,127],[32,12],[65,194,0],[70],[4,64,"TYPESWITCH|String"],[32,11],[252,3],[40,1,0],[12,1],[11],[32,12],[65,194,1],[70],[4,64,"TYPESWITCH|ByteString"],[32,11],[252,3],[40,1,0],[12,1],[11],[32,11],[252,3],[11,"TYPESWITCH_end"],[4,64],[32,4],[68,0,0,0,0,0,224,111,64],[16, builtin('f64_&')],[33,9],[32,4],[68,0,0,0,0,0,0,32,64],[16, builtin('f64_>>>')],[68,0,0,0,0,0,224,111,64],[16, builtin('f64_&')],[33,10],[5],[32,4],[68,0,0,0,0,0,0,32,64],[16, builtin('f64_>>>')],[68,0,0,0,0,0,224,111,64],[16, builtin('f64_&')],[33,9],[32,4],[68,0,0,0,0,0,224,111,64],[16, builtin('f64_&')],[33,10],[11],[32,0],[252,3],[40,0,4],[32,2],[252,3],[106],[34,13],[32,9],[252,3],[58,0,4],[32,13],[32,10],[252,3],[58,0,5],[68,0,0,0,0,0,0,0,0],[65,3],[15]],
636
+ wasm: (scope, {builtin,internalThrow}) => [[32,0],[252,2],[40,0,0],[183],[33,8],[32,2],[68,0,0,0,0,0,0,0,0],[99],[32,2],[68,0,0,0,0,0,0,240,63],[160],[32,8],[102],[114],[4,64],...internalThrow(scope, 'RangeError', `Byte offset is out of bounds of the DataView`),[11],[68,0,0,0,0,0,0,0,0],[33,9],[32,6],[33,10],[32,7],[33,11],[2,124],[32,11],[65,194,0],[70],[4,64,"TYPESWITCH|String"],[32,10],[252,3],[40,1,0],[184],[12,1],[11],[32,11],[65,194,1],[70],[4,64,"TYPESWITCH|ByteString"],[32,10],[252,3],[40,1,0],[184],[12,1],[11],[32,10],[252,2],[69],[69],[183],[11,"TYPESWITCH_end"],[252,3],[4,64],[32,4],[33,9],[5],[32,4],[68,0,0,0,0,0,0,32,64],[16, builtin('f64_>>>')],[32,4],[68,0,0,0,0,0,224,111,64],[16, builtin('f64_&')],[68,0,0,0,0,0,0,32,64],[16, builtin('f64_<<')],[16, builtin('f64_|')],[33,9],[11],[32,0],[252,3],[40,0,4],[32,2],[252,3],[106],[32,9],[252,3],[59,0,4],[68,0,0,0,0,0,0,0,0],[65,3],[15]],
637
637
  params: [124,127,124,127,124,127,124,127], typedParams: 1,
638
638
  returns: [124,127], typedReturns: 1,
639
- locals: [124,124,124,124,127,127], localNames: ["_this","_this#type","byteOffset","byteOffset#type","value","value#type","littleEndian","littleEndian#type","len","byte1","byte2","#logicinner_tmp","#typeswitch_tmp","ptr"],
639
+ locals: [124,124,124,127], localNames: ["_this","_this#type","byteOffset","byteOffset#type","value","value#type","littleEndian","littleEndian#type","len","int","#logicinner_tmp","#typeswitch_tmp"],
640
640
  };
641
641
  this.__DataView_prototype_getInt16 = {
642
642
  wasm: (scope, {builtin}) => [[32,0],[65,22],[32,2],[65,0],[32,4],[32,5],[16, builtin('__DataView_prototype_getUint16')],[33,7],[34,6],[68,0,0,0,0,0,0,224,64],[16, builtin('f64_&')],[252,3],[4,124],[32,6],[68,0,0,0,0,0,0,240,192],[16, builtin('f64_^')],[65,0],[33,7],[5],[32,6],[65,0],[33,7],[11],[32,7],[15]],
@@ -651,16 +651,16 @@ export const BuiltinFuncs = function() {
651
651
  locals: [127], localNames: ["_this","_this#type","byteOffset","byteOffset#type","value","value#type","littleEndian","littleEndian#type","#last_type"],
652
652
  };
653
653
  this.__DataView_prototype_getUint32 = {
654
- wasm: (scope, {builtin,internalThrow}) => [[32,0],[252,2],[40,0,0],[183],[33,6],[32,2],[68,0,0,0,0,0,0,0,0],[99],[32,2],[68,0,0,0,0,0,0,8,64],[160],[32,6],[102],[114],[4,64],...internalThrow(scope, 'RangeError', `Byte offset is out of bounds of the DataView`),[11],[68,0,0,0,0,0,0,0,0],[33,7],[68,0,0,0,0,0,0,0,0],[33,8],[68,0,0,0,0,0,0,0,0],[33,9],[68,0,0,0,0,0,0,0,0],[33,10],[32,0],[252,3],[40,0,4],[32,2],[252,3],[106],[34,11],[45,0,4],[184],[33,7],[32,11],[45,0,5],[184],[33,8],[32,11],[45,0,6],[184],[33,9],[32,11],[45,0,7],[184],[33,10],[32,4],[33,12],[32,5],[33,13],[2,124],[32,13],[65,194,0],[70],[4,64,"TYPESWITCH|String"],[32,12],[252,3],[40,1,0],[184],[12,1],[11],[32,13],[65,194,1],[70],[4,64,"TYPESWITCH|ByteString"],[32,12],[252,3],[40,1,0],[184],[12,1],[11],[32,12],[252,2],[69],[69],[183],[11,"TYPESWITCH_end"],[252,3],[4,64],[32,7],[32,8],[68,0,0,0,0,0,0,32,64],[16, builtin('f64_<<')],[16, builtin('f64_|')],[32,9],[68,0,0,0,0,0,0,48,64],[16, builtin('f64_<<')],[16, builtin('f64_|')],[32,10],[68,0,0,0,0,0,0,56,64],[16, builtin('f64_<<')],[16, builtin('f64_|')],[65,0],[15],[11],[32,7],[68,0,0,0,0,0,0,56,64],[16, builtin('f64_<<')],[32,8],[68,0,0,0,0,0,0,48,64],[16, builtin('f64_<<')],[16, builtin('f64_|')],[32,9],[68,0,0,0,0,0,0,32,64],[16, builtin('f64_<<')],[16, builtin('f64_|')],[32,10],[16, builtin('f64_|')],[65,0],[15]],
654
+ wasm: (scope, {builtin,internalThrow}) => [[32,0],[252,2],[40,0,0],[183],[33,6],[32,2],[68,0,0,0,0,0,0,0,0],[99],[32,2],[68,0,0,0,0,0,0,8,64],[160],[32,6],[102],[114],[4,64],...internalThrow(scope, 'RangeError', `Byte offset is out of bounds of the DataView`),[11],[68,0,0,0,0,0,0,0,0],[33,7],[32,0],[252,3],[40,0,4],[32,2],[252,3],[106],[40,0,4],[184],[33,7],[32,4],[33,8],[32,5],[33,9],[2,124],[32,9],[65,194,0],[70],[4,64,"TYPESWITCH|String"],[32,8],[252,3],[40,1,0],[184],[12,1],[11],[32,9],[65,194,1],[70],[4,64,"TYPESWITCH|ByteString"],[32,8],[252,3],[40,1,0],[184],[12,1],[11],[32,8],[252,2],[69],[69],[183],[11,"TYPESWITCH_end"],[252,3],[4,64],[32,7],[65,0],[15],[11],[32,7],[68,0,0,0,0,0,0,56,64],[16, builtin('f64_>>>')],[32,7],[68,0,0,0,0,0,0,32,64],[16, builtin('f64_>>>')],[68,0,0,0,0,0,224,239,64],[16, builtin('f64_&')],[16, builtin('f64_|')],[32,7],[68,0,0,0,0,0,0,32,64],[16, builtin('f64_<<')],[68,0,0,0,0,0,224,111,65],[16, builtin('f64_&')],[16, builtin('f64_|')],[32,7],[68,0,0,0,0,0,0,56,64],[16, builtin('f64_<<')],[16, builtin('f64_|')],[65,0],[15]],
655
655
  params: [124,127,124,127,124,127], typedParams: 1,
656
656
  returns: [124,127], typedReturns: 1,
657
- locals: [124,124,124,124,124,127,124,127], localNames: ["_this","_this#type","byteOffset","byteOffset#type","littleEndian","littleEndian#type","len","byte1","byte2","byte3","byte4","ptr","#logicinner_tmp","#typeswitch_tmp"],
657
+ locals: [124,124,124,127], localNames: ["_this","_this#type","byteOffset","byteOffset#type","littleEndian","littleEndian#type","len","int","#logicinner_tmp","#typeswitch_tmp"],
658
658
  };
659
659
  this.__DataView_prototype_setUint32 = {
660
- wasm: (scope, {builtin,internalThrow}) => [[32,0],[252,2],[40,0,0],[183],[33,8],[32,2],[68,0,0,0,0,0,0,0,0],[99],[32,2],[68,0,0,0,0,0,0,8,64],[160],[32,8],[102],[114],[4,64],...internalThrow(scope, 'RangeError', `Byte offset is out of bounds of the DataView`),[11],[68,0,0,0,0,0,0,0,0],[33,9],[68,0,0,0,0,0,0,0,0],[33,10],[68,0,0,0,0,0,0,0,0],[33,11],[68,0,0,0,0,0,0,0,0],[33,12],[32,6],[33,13],[32,7],[33,14],[2,127],[32,14],[65,194,0],[70],[4,64,"TYPESWITCH|String"],[32,13],[252,3],[40,1,0],[12,1],[11],[32,14],[65,194,1],[70],[4,64,"TYPESWITCH|ByteString"],[32,13],[252,3],[40,1,0],[12,1],[11],[32,13],[252,3],[11,"TYPESWITCH_end"],[4,64],[32,4],[68,0,0,0,0,0,224,111,64],[16, builtin('f64_&')],[33,9],[32,4],[68,0,0,0,0,0,0,32,64],[16, builtin('f64_>>>')],[68,0,0,0,0,0,224,111,64],[16, builtin('f64_&')],[33,10],[32,4],[68,0,0,0,0,0,0,48,64],[16, builtin('f64_>>>')],[68,0,0,0,0,0,224,111,64],[16, builtin('f64_&')],[33,11],[32,4],[68,0,0,0,0,0,0,56,64],[16, builtin('f64_>>>')],[68,0,0,0,0,0,224,111,64],[16, builtin('f64_&')],[33,12],[5],[32,4],[68,0,0,0,0,0,0,56,64],[16, builtin('f64_>>>')],[68,0,0,0,0,0,224,111,64],[16, builtin('f64_&')],[33,9],[32,4],[68,0,0,0,0,0,0,48,64],[16, builtin('f64_>>>')],[68,0,0,0,0,0,224,111,64],[16, builtin('f64_&')],[33,10],[32,4],[68,0,0,0,0,0,0,32,64],[16, builtin('f64_>>>')],[68,0,0,0,0,0,224,111,64],[16, builtin('f64_&')],[33,11],[32,4],[68,0,0,0,0,0,224,111,64],[16, builtin('f64_&')],[33,12],[11],[32,0],[252,3],[40,0,4],[32,2],[252,3],[106],[34,15],[32,9],[252,3],[58,0,4],[32,15],[32,10],[252,3],[58,0,5],[32,15],[32,11],[252,3],[58,0,6],[32,15],[32,12],[252,3],[58,0,7],[68,0,0,0,0,0,0,0,0],[65,3],[15]],
660
+ wasm: (scope, {builtin,internalThrow}) => [[32,0],[252,2],[40,0,0],[183],[33,8],[32,2],[68,0,0,0,0,0,0,0,0],[99],[32,2],[68,0,0,0,0,0,0,8,64],[160],[32,8],[102],[114],[4,64],...internalThrow(scope, 'RangeError', `Byte offset is out of bounds of the DataView`),[11],[68,0,0,0,0,0,0,0,0],[33,9],[32,6],[33,10],[32,7],[33,11],[2,124],[32,11],[65,194,0],[70],[4,64,"TYPESWITCH|String"],[32,10],[252,3],[40,1,0],[184],[12,1],[11],[32,11],[65,194,1],[70],[4,64,"TYPESWITCH|ByteString"],[32,10],[252,3],[40,1,0],[184],[12,1],[11],[32,10],[252,2],[69],[69],[183],[11,"TYPESWITCH_end"],[252,3],[4,64],[32,4],[33,9],[5],[32,4],[68,0,0,0,0,0,0,56,64],[16, builtin('f64_>>>')],[32,4],[68,0,0,0,0,0,0,32,64],[16, builtin('f64_>>>')],[68,0,0,0,0,0,224,239,64],[16, builtin('f64_&')],[16, builtin('f64_|')],[32,4],[68,0,0,0,0,0,0,32,64],[16, builtin('f64_<<')],[68,0,0,0,0,0,224,111,65],[16, builtin('f64_&')],[16, builtin('f64_|')],[32,4],[68,0,0,0,0,0,0,56,64],[16, builtin('f64_<<')],[16, builtin('f64_|')],[33,9],[11],[32,0],[252,3],[40,0,4],[32,2],[252,3],[106],[32,9],[252,3],[54,0,4],[68,0,0,0,0,0,0,0,0],[65,3],[15]],
661
661
  params: [124,127,124,127,124,127,124,127], typedParams: 1,
662
662
  returns: [124,127], typedReturns: 1,
663
- locals: [124,124,124,124,124,124,127,127], localNames: ["_this","_this#type","byteOffset","byteOffset#type","value","value#type","littleEndian","littleEndian#type","len","byte1","byte2","byte3","byte4","#logicinner_tmp","#typeswitch_tmp","ptr"],
663
+ locals: [124,124,124,127], localNames: ["_this","_this#type","byteOffset","byteOffset#type","value","value#type","littleEndian","littleEndian#type","len","int","#logicinner_tmp","#typeswitch_tmp"],
664
664
  };
665
665
  this.__DataView_prototype_getInt32 = {
666
666
  wasm: (scope, {builtin}) => [[32,0],[65,22],[32,2],[65,0],[32,4],[32,5],[16, builtin('__DataView_prototype_getUint32')],[33,7],[34,6],[68,0,0,0,0,0,0,224,65],[16, builtin('f64_&')],[252,3],[4,124],[32,6],[68,0,0,0,0,0,0,240,193],[16, builtin('f64_^')],[65,0],[33,7],[5],[32,6],[65,0],[33,7],[11],[32,7],[15]],
@@ -674,6 +674,18 @@ export const BuiltinFuncs = function() {
674
674
  returns: [124,127], typedReturns: 1,
675
675
  locals: [127], localNames: ["_this","_this#type","byteOffset","byteOffset#type","value","value#type","littleEndian","littleEndian#type","#last_type"],
676
676
  };
677
+ this.__DataView_prototype_getFloat32 = {
678
+ wasm: (scope, {builtin}) => [[32,0],[65,22],[32,2],[65,0],[32,4],[32,5],[16, builtin('__DataView_prototype_getUint32')],[33,7],[34,6],[252,3],[190],[187],[65,0],[15]],
679
+ params: [124,127,124,127,124,127], typedParams: 1,
680
+ returns: [124,127], typedReturns: 1,
681
+ locals: [124,127], localNames: ["_this","_this#type","byteOffset","byteOffset#type","littleEndian","littleEndian#type","int","#last_type"],
682
+ };
683
+ this.__DataView_prototype_setFloat32 = {
684
+ wasm: (scope, {builtin}) => [[68,0,0,0,0,0,0,0,0],[33,8],[32,4],[182],[188],[184],[33,8],[32,0],[65,22],[32,2],[65,0],[32,8],[65,0],[32,6],[32,7],[16, builtin('__DataView_prototype_setUint32')],[34,9],[15]],
685
+ params: [124,127,124,127,124,127,124,127], typedParams: 1,
686
+ returns: [124,127], typedReturns: 1,
687
+ locals: [124,127], localNames: ["_this","_this#type","byteOffset","byteOffset#type","value","value#type","littleEndian","littleEndian#type","int","#last_type"],
688
+ };
677
689
  this.__ecma262_Day = {
678
690
  wasm: (scope, {builtin}) => [[32,0],[68,0,0,0,0,112,153,148,65],[163],[16, builtin('__Math_floor')],[65,0],[15]],
679
691
  params: [124,127], typedParams: 1,
@@ -99,9 +99,13 @@ const precompile = async () => {
99
99
  let funcs = [], globals = [];
100
100
  for (const file of fs.readdirSync(dir)) {
101
101
  if (file.endsWith('.d.ts')) continue;
102
- console.log(file);
103
102
 
103
+ console.log(`${' '.repeat(12)}${file}`);
104
+
105
+ const t = performance.now();
104
106
  await compile(join(dir, file), [ funcs, globals ]);
107
+
108
+ console.log(`\u001b[A${' '.repeat(100)}\r\u001b[90m${`[${(performance.now() - t).toFixed(2)}ms]`.padEnd(12, ' ')}\u001b[0m\u001b[92m${file}\u001b[0m`);
105
109
  }
106
110
 
107
111
  return `// autogenerated by compiler/precompile.js
@@ -189,6 +189,9 @@ export const Opcodes = {
189
189
  f64_convert_i64_s: 0xb9,
190
190
  f64_convert_i64_u: 0xba,
191
191
 
192
+ i32_reinterpret_f32: 0xbc,
193
+ i64_reinterpret_f64: 0xbd,
194
+ f32_reinterpret_i32: 0xbe,
192
195
  f64_reinterpret_i64: 0xbf,
193
196
 
194
197
  i32_trunc_sat_f64_s: [ 0xfc, 0x02 ],
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "porffor",
3
3
  "description": "a basic experimental wip aot optimizing js -> wasm engine/compiler/runtime in js",
4
- "version": "0.18.40+9c2421a79",
4
+ "version": "0.18.42+773821de9",
5
5
  "author": "CanadaHonk",
6
6
  "license": "MIT",
7
7
  "scripts": {},
package/runner/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  import fs from 'node:fs';
3
- globalThis.version = '0.18.40+9c2421a79';
3
+ globalThis.version = '0.18.42+773821de9';
4
4
 
5
5
  // deno compat
6
6
  if (typeof process === 'undefined' && typeof Deno !== 'undefined') {