aboutsummaryrefslogtreecommitdiffstats
path: root/libsolidity/codegen
diff options
context:
space:
mode:
authorchriseth <chris@ethereum.org>2017-09-26 21:27:03 +0800
committerAlex Beregszaszi <alex@rtfs.hu>2018-03-06 22:30:18 +0800
commitb467116ea85383d5c8492e7f21ea16ce7c70ebc9 (patch)
treeb0bd8c7482d2f8c7b3716b11830990bd8a6fa110 /libsolidity/codegen
parent0df4c64884d1b8d3695dd59de5f828ba5298b313 (diff)
downloaddexon-solidity-b467116ea85383d5c8492e7f21ea16ce7c70ebc9.tar
dexon-solidity-b467116ea85383d5c8492e7f21ea16ce7c70ebc9.tar.gz
dexon-solidity-b467116ea85383d5c8492e7f21ea16ce7c70ebc9.tar.bz2
dexon-solidity-b467116ea85383d5c8492e7f21ea16ce7c70ebc9.tar.lz
dexon-solidity-b467116ea85383d5c8492e7f21ea16ce7c70ebc9.tar.xz
dexon-solidity-b467116ea85383d5c8492e7f21ea16ce7c70ebc9.tar.zst
dexon-solidity-b467116ea85383d5c8492e7f21ea16ce7c70ebc9.zip
Use STATICCALL for pure function calls if EVM version supports it and 0.5.0 is activated.
Diffstat (limited to 'libsolidity/codegen')
-rw-r--r--libsolidity/codegen/ExpressionCompiler.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/libsolidity/codegen/ExpressionCompiler.cpp b/libsolidity/codegen/ExpressionCompiler.cpp
index d27af7db..7162cb0d 100644
--- a/libsolidity/codegen/ExpressionCompiler.cpp
+++ b/libsolidity/codegen/ExpressionCompiler.cpp
@@ -1610,6 +1610,10 @@ void ExpressionCompiler::appendExternalFunctionCall(
bool returnSuccessCondition = funKind == FunctionType::Kind::BareCall || funKind == FunctionType::Kind::BareCallCode || funKind == FunctionType::Kind::BareDelegateCall;
bool isCallCode = funKind == FunctionType::Kind::BareCallCode || funKind == FunctionType::Kind::CallCode;
bool isDelegateCall = funKind == FunctionType::Kind::BareDelegateCall || funKind == FunctionType::Kind::DelegateCall;
+ bool useStaticCall =
+ _functionType.stateMutability() <= StateMutability::View &&
+ m_context.experimentalFeatureActive(ExperimentalFeature::V050) &&
+ m_context.evmVersion().hasStaticCall();
unsigned retSize = 0;
if (returnSuccessCondition)
@@ -1738,6 +1742,8 @@ void ExpressionCompiler::appendExternalFunctionCall(
// [value,] addr, gas (stack top)
if (isDelegateCall)
solAssert(!_functionType.valueSet(), "Value set for delegatecall");
+ else if (useStaticCall)
+ solAssert(!_functionType.valueSet(), "Value set for staticcall");
else if (_functionType.valueSet())
m_context << dupInstruction(m_context.baseToCurrentStackOffset(valueStackPos));
else
@@ -1769,10 +1775,13 @@ void ExpressionCompiler::appendExternalFunctionCall(
gasNeededByCaller += eth::GasCosts::callNewAccountGas; // we never know
m_context << gasNeededByCaller << Instruction::GAS << Instruction::SUB;
}
+ // Order is important here, STATICCALL might overlap with DELEGATECALL.
if (isDelegateCall)
m_context << Instruction::DELEGATECALL;
else if (isCallCode)
m_context << Instruction::CALLCODE;
+ else if (useStaticCall)
+ m_context << Instruction::STATICCALL;
else
m_context << Instruction::CALL;