@@ -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 : {
@@ -289,6 +291,12 @@ function generateManifest (interfaceManifest, opts) {
289
291
locals += `(local $offset${ numOfLocals } i32)`
290
292
body += `(set_local $offset${ numOfLocals } ${ checkOverflowStackItem256 ( spOffset ) } )`
291
293
call += `(get_local $offset${ numOfLocals } )`
294
+ } else if ( input === 'callReturnMemoryOffset' || input === 'callReturnMemorySize' ) {
295
+ // FIXME: this should actually insert a wrapper for invoking returndatacopy
296
+ // with these arguments in the postprocessing step
297
+
298
+ // Remove (ignore) this stack item here
299
+ spOffset --
292
300
} else if ( input === 'length' && ( opcode === 'CALL' || opcode === 'CALLCODE' ) ) {
293
301
// CALLs in EVM have 7 arguments
294
302
// but in ewasm CALLs only have 5 arguments
@@ -303,12 +311,6 @@ function generateManifest (interfaceManifest, opts) {
303
311
304
312
call += `(get_local $length${ numOfLocals } )`
305
313
numOfLocals ++
306
-
307
- // delete 6th stack element
308
- spOffset --
309
-
310
- // delete 7th stack element
311
- spOffset --
312
314
} else if ( input === 'length' && ( opcode !== 'CALL' && opcode !== 'CALLCODE' ) ) {
313
315
locals += `(local $length${ numOfLocals } i32)`
314
316
body += `(set_local $length${ numOfLocals } ${ checkOverflowStackItem256 ( spOffset ) } )`
@@ -376,6 +378,8 @@ function generateManifest (interfaceManifest, opts) {
376
378
(i32.eqz ${ call } ) ;; flip CALL result from EEI to EVM convention (0 -> 1, 1,2,.. -> 1)
377
379
)))`
378
380
381
+ // FIXME: add callReturnMemory* handling here
382
+
379
383
} else {
380
384
call =
381
385
`(i64.store
0 commit comments