Skip to content
This repository has been archived by the owner on Jan 5, 2019. It is now read-only.

Commit

Permalink
Support STATICCALL
Browse files Browse the repository at this point in the history
  • Loading branch information
axic committed May 29, 2018
1 parent 6264c6c commit 03af844
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
1 change: 1 addition & 0 deletions opcodes.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ const codes = {
0xf2: ['CALLCODE', 0, 7, 1],
0xf3: ['RETURN', 0, 2, 0],
0xf4: ['DELEGATECALL', 0, 6, 1],
0xfa: ['STATICCALL', 0, 6, 1],

// '0x70', range - other
0xff: ['SELFDESTRUCT', 0, 1, 0]
Expand Down
10 changes: 8 additions & 2 deletions wasm/generateInterface.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,12 @@ const interfaceManifest = {
input: ['i64', 'address', 'readOffset', 'length'],
output: ['i32']
},
STATICCALL: {
name: 'callStatic',
async: true,
input: ['i64', 'address', 'i128', 'readOffset', 'length'],
output: ['i32']
},
SSTORE: {
name: 'storageStore',
async: true,
Expand Down Expand Up @@ -265,7 +271,7 @@ function generateManifest (interfaceManifest, opts) {
(i64.load (i32.add (get_global $sp) (i32.const ${spOffset * 32 + 8 * 2})))
(i64.load (i32.add (get_global $sp) (i32.const ${spOffset * 32 + 8 * 3})))))`
call += `(get_local $offset${numOfLocals})`
} else if (input === 'length' && (opcode === 'CALL' || opcode === 'CALLCODE' || opcode === 'DELEGATECALL')) {
} else if (input === 'length' && (opcode === 'CALL' || opcode === 'CALLCODE' || opcode === 'DELEGATECALL' || opcode === 'STATICCALL')) {
// CALLs in EVM have 7 arguments
// but in ewasm CALLs only have 5 arguments
// so delete the bottom two stack elements, after processing the 5th argument
Expand Down Expand Up @@ -365,7 +371,7 @@ function generateManifest (interfaceManifest, opts) {
call += '(get_local $callback)'
}

if (opcode === 'CALL' || opcode === 'CALLCODE' || opcode === 'DELEGATECALL') {
if (opcode === 'CALL' || opcode === 'CALLCODE' || opcode === 'DELEGATECALL' || opcode === 'STATICCALL') {
call =
`(i64.store
(i32.add (get_global $sp) (i32.const ${spOffset * 32}))
Expand Down

0 comments on commit 03af844

Please sign in to comment.