@@ -13,6 +13,8 @@ const wasmTypes = {
13
13
ipointer : 'i32' ,
14
14
opointer : 'i32' ,
15
15
gasLimit : 'i64' ,
16
+ callReturnMemoryOffset : 'i32' ,
17
+ callReturnMemorySize : 'i32' ,
16
18
// FIXME: these are handled wrongly currently
17
19
address : 'i32' ,
18
20
i128 : 'i32' ,
@@ -140,19 +142,19 @@ const interfaceManifest = {
140
142
CALL : {
141
143
name : 'call' ,
142
144
async : true ,
143
- input : [ 'gasLimit' , 'address' , 'i128' , 'readOffset' , 'length' ] ,
145
+ input : [ 'gasLimit' , 'address' , 'i128' , 'readOffset' , 'length' , 'callReturnMemoryOffset' , 'callReturnMemorySize' ] ,
144
146
output : [ 'i32' ]
145
147
} ,
146
148
CALLCODE : {
147
149
name : 'callCode' ,
148
150
async : true ,
149
- input : [ 'gasLimit' , 'address' , 'i128' , 'readOffset' , 'length' ] ,
151
+ input : [ 'gasLimit' , 'address' , 'i128' , 'readOffset' , 'length' , 'callReturnMemoryOffset' , 'callReturnMemorySize' ] ,
150
152
output : [ 'i32' ]
151
153
} ,
152
154
DELEGATECALL : {
153
155
name : 'callDelegate' ,
154
156
async : true ,
155
- input : [ 'gasLimit' , 'address' , 'i128' , 'readOffset' , 'length' , 'writeOffset' , 'length' ] ,
157
+ input : [ 'gasLimit' , 'address' , 'i128' , 'readOffset' , 'length' , 'writeOffset' , 'length' , 'callReturnMemoryOffset' , 'callReturnMemorySize' ] ,
156
158
output : [ 'i32' ]
157
159
} ,
158
160
SSTORE : {
@@ -290,6 +292,12 @@ function generateManifest (interfaceManifest, opts) {
290
292
(i64.load (i32.add (get_global $sp) (i32.const ${ spOffset * 32 + 8 * 2 } )))
291
293
(i64.load (i32.add (get_global $sp) (i32.const ${ spOffset * 32 + 8 * 3 } )))))`
292
294
call += `(get_local $offset${ numOfLocals } )`
295
+ } else if ( input === 'callReturnMemoryOffset' || input === 'callReturnMemorySize' ) {
296
+ // FIXME: this should actually insert a wrapper for invoking returndatacopy
297
+ // with these arguments in the postprocessing step
298
+
299
+ // Remove (ignore) this stack item here
300
+ spOffset --
293
301
} else if ( input === 'length' && ( opcode === 'CALL' || opcode === 'CALLCODE' ) ) {
294
302
// CALLs in EVM have 7 arguments
295
303
// but in ewasm CALLs only have 5 arguments
@@ -308,12 +316,6 @@ function generateManifest (interfaceManifest, opts) {
308
316
309
317
call += `(get_local $length${ numOfLocals } )`
310
318
numOfLocals ++
311
-
312
- // delete 6th stack element
313
- spOffset --
314
-
315
- // delete 7th stack element
316
- spOffset --
317
319
} else if ( input === 'length' && ( opcode !== 'CALL' && opcode !== 'CALLCODE' ) ) {
318
320
locals += `(local $length${ numOfLocals } i32)`
319
321
body += `(set_local $length${ numOfLocals }
@@ -385,6 +387,8 @@ function generateManifest (interfaceManifest, opts) {
385
387
(i32.eqz ${ call } ) ;; flip CALL result from EEI to EVM convention (0 -> 1, 1,2,.. -> 1)
386
388
)))`
387
389
390
+ // FIXME: add callReturnMemory* handling here
391
+
388
392
} else {
389
393
call =
390
394
`(i64.store
0 commit comments