diff options
author | chriseth <chris@ethereum.org> | 2018-02-27 01:25:36 +0800 |
---|---|---|
committer | chriseth <chris@ethereum.org> | 2018-03-06 02:32:12 +0800 |
commit | 83fcf007bfdf9c9c8b595369c0542d45943ee095 (patch) | |
tree | 59552f474bcb14df241d925e7b9cdca4a82b3365 /libsolidity/codegen/ExpressionCompiler.cpp | |
parent | f190b274313131bbc939815a00d49dcd2c3de10d (diff) | |
download | dexon-solidity-83fcf007bfdf9c9c8b595369c0542d45943ee095.tar.gz dexon-solidity-83fcf007bfdf9c9c8b595369c0542d45943ee095.tar.zst dexon-solidity-83fcf007bfdf9c9c8b595369c0542d45943ee095.zip |
Do not retain any gas in external calls (except if EVM version is set to homestead).
Diffstat (limited to 'libsolidity/codegen/ExpressionCompiler.cpp')
-rw-r--r-- | libsolidity/codegen/ExpressionCompiler.cpp | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/libsolidity/codegen/ExpressionCompiler.cpp b/libsolidity/codegen/ExpressionCompiler.cpp index 12881d63..441e4429 100644 --- a/libsolidity/codegen/ExpressionCompiler.cpp +++ b/libsolidity/codegen/ExpressionCompiler.cpp @@ -1671,16 +1671,19 @@ void ExpressionCompiler::appendExternalFunctionCall( utils().storeFreeMemoryPointer(); } - // Touch the end of the output area so that we do not pay for memory resize during the call - // (which we would have to subtract from the gas left) - // We could also just use MLOAD; POP right before the gas calculation, but the optimizer - // would remove that, so we use MSTORE here. - if (!_functionType.gasSet() && retSize > 0) + if (!m_context.evmVersion().canOverchargeGasForCall()) { - m_context << u256(0); - utils().fetchFreeMemoryPointer(); - // This touches too much, but that way we save some rounding arithmetics - m_context << u256(retSize) << Instruction::ADD << Instruction::MSTORE; + // Touch the end of the output area so that we do not pay for memory resize during the call + // (which we would have to subtract from the gas left) + // We could also just use MLOAD; POP right before the gas calculation, but the optimizer + // would remove that, so we use MSTORE here. + if (!_functionType.gasSet() && retSize > 0) + { + m_context << u256(0); + utils().fetchFreeMemoryPointer(); + // This touches too much, but that way we save some rounding arithmetics + m_context << u256(retSize) << Instruction::ADD << Instruction::MSTORE; + } } // Copy function identifier to memory. @@ -1749,7 +1752,7 @@ void ExpressionCompiler::appendExternalFunctionCall( if (_functionType.gasSet()) m_context << dupInstruction(m_context.baseToCurrentStackOffset(gasStackPos)); - else if (m_context.experimentalFeatureActive(ExperimentalFeature::V050)) + else if (m_context.evmVersion().canOverchargeGasForCall()) // Send all gas (requires tangerine whistle EVM) m_context << Instruction::GAS; else |