mirror of
				https://github.com/ethereum/solidity
				synced 2023-10-03 13:03:40 +00:00 
			
		
		
		
	Merge pull request #9092 from ethereum/libEvmasmConversionWarnings
Fixing signedness conversion warnings in libevmasm
This commit is contained in:
		
						commit
						59fc88ca17
					
				| @ -41,7 +41,7 @@ using namespace solidity::util; | |||||||
| AssemblyItem const& Assembly::append(AssemblyItem const& _i) | AssemblyItem const& Assembly::append(AssemblyItem const& _i) | ||||||
| { | { | ||||||
| 	assertThrow(m_deposit >= 0, AssemblyException, "Stack underflow."); | 	assertThrow(m_deposit >= 0, AssemblyException, "Stack underflow."); | ||||||
| 	m_deposit += _i.deposit(); | 	m_deposit += static_cast<int>(_i.deposit()); | ||||||
| 	m_items.emplace_back(_i); | 	m_items.emplace_back(_i); | ||||||
| 	if (!m_items.back().location().isValid() && m_currentSourceLocation.isValid()) | 	if (!m_items.back().location().isValid() && m_currentSourceLocation.isValid()) | ||||||
| 		m_items.back().setLocation(m_currentSourceLocation); | 		m_items.back().setLocation(m_currentSourceLocation); | ||||||
| @ -77,10 +77,10 @@ string locationFromSources(StringMap const& _sourceCodes, SourceLocation const& | |||||||
| 		return ""; | 		return ""; | ||||||
| 
 | 
 | ||||||
| 	string const& source = it->second; | 	string const& source = it->second; | ||||||
| 	if (size_t(_location.start) >= source.size()) | 	if (static_cast<size_t>(_location.start) >= source.size()) | ||||||
| 		return ""; | 		return ""; | ||||||
| 
 | 
 | ||||||
| 	string cut = source.substr(_location.start, _location.end - _location.start); | 	string cut = source.substr(static_cast<size_t>(_location.start), static_cast<size_t>(_location.end - _location.start)); | ||||||
| 	auto newLinePos = cut.find_first_of("\n"); | 	auto newLinePos = cut.find_first_of("\n"); | ||||||
| 	if (newLinePos != string::npos) | 	if (newLinePos != string::npos) | ||||||
| 		cut = cut.substr(0, newLinePos) + "..."; | 		cut = cut.substr(0, newLinePos) + "..."; | ||||||
| @ -106,7 +106,7 @@ public: | |||||||
| 		if (!( | 		if (!( | ||||||
| 			_item.canBeFunctional() && | 			_item.canBeFunctional() && | ||||||
| 			_item.returnValues() <= 1 && | 			_item.returnValues() <= 1 && | ||||||
| 			_item.arguments() <= int(m_pending.size()) | 			_item.arguments() <= m_pending.size() | ||||||
| 		)) | 		)) | ||||||
| 		{ | 		{ | ||||||
| 			flush(); | 			flush(); | ||||||
| @ -117,7 +117,7 @@ public: | |||||||
| 		if (_item.arguments() > 0) | 		if (_item.arguments() > 0) | ||||||
| 		{ | 		{ | ||||||
| 			expression += "("; | 			expression += "("; | ||||||
| 			for (int i = 0; i < _item.arguments(); ++i) | 			for (size_t i = 0; i < _item.arguments(); ++i) | ||||||
| 			{ | 			{ | ||||||
| 				expression += m_pending.back(); | 				expression += m_pending.back(); | ||||||
| 				m_pending.pop_back(); | 				m_pending.pop_back(); | ||||||
| @ -225,12 +225,12 @@ Json::Value Assembly::assemblyJSON(map<string, unsigned> const& _sourceIndices) | |||||||
| 	Json::Value& collection = root[".code"] = Json::arrayValue; | 	Json::Value& collection = root[".code"] = Json::arrayValue; | ||||||
| 	for (AssemblyItem const& i: m_items) | 	for (AssemblyItem const& i: m_items) | ||||||
| 	{ | 	{ | ||||||
| 		unsigned sourceIndex = unsigned(-1); | 		int sourceIndex = -1; | ||||||
| 		if (i.location().source) | 		if (i.location().source) | ||||||
| 		{ | 		{ | ||||||
| 			auto iter = _sourceIndices.find(i.location().source->name()); | 			auto iter = _sourceIndices.find(i.location().source->name()); | ||||||
| 			if (iter != _sourceIndices.end()) | 			if (iter != _sourceIndices.end()) | ||||||
| 				sourceIndex = iter->second; | 				sourceIndex = static_cast<int>(iter->second); | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
| 		switch (i.type()) | 		switch (i.type()) | ||||||
| @ -340,7 +340,7 @@ AssemblyItem Assembly::namedTag(string const& _name) | |||||||
| { | { | ||||||
| 	assertThrow(!_name.empty(), AssemblyException, "Empty named tag."); | 	assertThrow(!_name.empty(), AssemblyException, "Empty named tag."); | ||||||
| 	if (!m_namedTags.count(_name)) | 	if (!m_namedTags.count(_name)) | ||||||
| 		m_namedTags[_name] = size_t(newTag().data()); | 		m_namedTags[_name] = static_cast<size_t>(newTag().data()); | ||||||
| 	return AssemblyItem{Tag, m_namedTags.at(_name)}; | 	return AssemblyItem{Tag, m_namedTags.at(_name)}; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| @ -441,7 +441,7 @@ map<u256, u256> Assembly::optimiseInternal( | |||||||
| 				for (auto const& replacement: deduplicator.replacedTags()) | 				for (auto const& replacement: deduplicator.replacedTags()) | ||||||
| 				{ | 				{ | ||||||
| 					assertThrow( | 					assertThrow( | ||||||
| 						replacement.first <= size_t(-1) && replacement.second <= size_t(-1), | 						replacement.first <= numeric_limits<size_t>::max() && replacement.second <= numeric_limits<size_t>::max(), | ||||||
| 						OptimizerException, | 						OptimizerException, | ||||||
| 						"Invalid tag replacement." | 						"Invalid tag replacement." | ||||||
| 					); | 					); | ||||||
| @ -451,8 +451,8 @@ map<u256, u256> Assembly::optimiseInternal( | |||||||
| 						"Replacement already known." | 						"Replacement already known." | ||||||
| 					); | 					); | ||||||
| 					tagReplacements[replacement.first] = replacement.second; | 					tagReplacements[replacement.first] = replacement.second; | ||||||
| 					if (_tagsReferencedFromOutside.erase(size_t(replacement.first))) | 					if (_tagsReferencedFromOutside.erase(static_cast<size_t>(replacement.first))) | ||||||
| 						_tagsReferencedFromOutside.insert(size_t(replacement.second)); | 						_tagsReferencedFromOutside.insert(static_cast<size_t>(replacement.second)); | ||||||
| 				} | 				} | ||||||
| 				count++; | 				count++; | ||||||
| 			} | 			} | ||||||
| @ -479,7 +479,7 @@ map<u256, u256> Assembly::optimiseInternal( | |||||||
| 				try | 				try | ||||||
| 				{ | 				{ | ||||||
| 					optimisedChunk = eliminator.getOptimizedItems(); | 					optimisedChunk = eliminator.getOptimizedItems(); | ||||||
| 					shouldReplace = (optimisedChunk.size() < size_t(iter - orig)); | 					shouldReplace = (optimisedChunk.size() < static_cast<size_t>(iter - orig)); | ||||||
| 				} | 				} | ||||||
| 				catch (StackTooDeepException const&) | 				catch (StackTooDeepException const&) | ||||||
| 				{ | 				{ | ||||||
| @ -544,7 +544,7 @@ LinkerObject const& Assembly::assemble() const | |||||||
| 			immutableReferencesBySub = linkerObject.immutableReferences; | 			immutableReferencesBySub = linkerObject.immutableReferences; | ||||||
| 		} | 		} | ||||||
| 		for (size_t tagPos: sub->m_tagPositionsInBytecode) | 		for (size_t tagPos: sub->m_tagPositionsInBytecode) | ||||||
| 			if (tagPos != size_t(-1) && tagPos > subTagSize) | 			if (tagPos != numeric_limits<size_t>::max() && tagPos > subTagSize) | ||||||
| 				subTagSize = tagPos; | 				subTagSize = tagPos; | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| @ -567,7 +567,7 @@ LinkerObject const& Assembly::assemble() const | |||||||
| 		); | 		); | ||||||
| 
 | 
 | ||||||
| 	size_t bytesRequiredForCode = bytesRequired(subTagSize); | 	size_t bytesRequiredForCode = bytesRequired(subTagSize); | ||||||
| 	m_tagPositionsInBytecode = vector<size_t>(m_usedTags, -1); | 	m_tagPositionsInBytecode = vector<size_t>(m_usedTags, numeric_limits<size_t>::max()); | ||||||
| 	map<size_t, pair<size_t, size_t>> tagRef; | 	map<size_t, pair<size_t, size_t>> tagRef; | ||||||
| 	multimap<h256, unsigned> dataRef; | 	multimap<h256, unsigned> dataRef; | ||||||
| 	multimap<size_t, size_t> subRef; | 	multimap<size_t, size_t> subRef; | ||||||
| @ -586,7 +586,7 @@ LinkerObject const& Assembly::assemble() const | |||||||
| 	for (AssemblyItem const& i: m_items) | 	for (AssemblyItem const& i: m_items) | ||||||
| 	{ | 	{ | ||||||
| 		// store position of the invalid jump destination
 | 		// store position of the invalid jump destination
 | ||||||
| 		if (i.type() != Tag && m_tagPositionsInBytecode[0] == size_t(-1)) | 		if (i.type() != Tag && m_tagPositionsInBytecode[0] == numeric_limits<size_t>::max()) | ||||||
| 			m_tagPositionsInBytecode[0] = ret.bytecode.size(); | 			m_tagPositionsInBytecode[0] = ret.bytecode.size(); | ||||||
| 
 | 
 | ||||||
| 		switch (i.type()) | 		switch (i.type()) | ||||||
| @ -629,15 +629,15 @@ LinkerObject const& Assembly::assemble() const | |||||||
| 			ret.bytecode.resize(ret.bytecode.size() + bytesPerDataRef); | 			ret.bytecode.resize(ret.bytecode.size() + bytesPerDataRef); | ||||||
| 			break; | 			break; | ||||||
| 		case PushSub: | 		case PushSub: | ||||||
| 			assertThrow(i.data() <= size_t(-1), AssemblyException, ""); | 			assertThrow(i.data() <= numeric_limits<size_t>::max(), AssemblyException, ""); | ||||||
| 			ret.bytecode.push_back(dataRefPush); | 			ret.bytecode.push_back(dataRefPush); | ||||||
| 			subRef.insert(make_pair(size_t(i.data()), ret.bytecode.size())); | 			subRef.insert(make_pair(static_cast<size_t>(i.data()), ret.bytecode.size())); | ||||||
| 			ret.bytecode.resize(ret.bytecode.size() + bytesPerDataRef); | 			ret.bytecode.resize(ret.bytecode.size() + bytesPerDataRef); | ||||||
| 			break; | 			break; | ||||||
| 		case PushSubSize: | 		case PushSubSize: | ||||||
| 		{ | 		{ | ||||||
| 			assertThrow(i.data() <= size_t(-1), AssemblyException, ""); | 			assertThrow(i.data() <= numeric_limits<size_t>::max(), AssemblyException, ""); | ||||||
| 			auto s = m_subs.at(size_t(i.data()))->assemble().bytecode.size(); | 			auto s = m_subs.at(static_cast<size_t>(i.data()))->assemble().bytecode.size(); | ||||||
| 			i.setPushedValue(u256(s)); | 			i.setPushedValue(u256(s)); | ||||||
| 			uint8_t b = max<unsigned>(1, util::bytesRequired(s)); | 			uint8_t b = max<unsigned>(1, util::bytesRequired(s)); | ||||||
| 			ret.bytecode.push_back((uint8_t)Instruction::PUSH1 - 1 + b); | 			ret.bytecode.push_back((uint8_t)Instruction::PUSH1 - 1 + b); | ||||||
| @ -683,10 +683,10 @@ LinkerObject const& Assembly::assemble() const | |||||||
| 			break; | 			break; | ||||||
| 		case Tag: | 		case Tag: | ||||||
| 			assertThrow(i.data() != 0, AssemblyException, "Invalid tag position."); | 			assertThrow(i.data() != 0, AssemblyException, "Invalid tag position."); | ||||||
| 			assertThrow(i.splitForeignPushTag().first == size_t(-1), AssemblyException, "Foreign tag."); | 			assertThrow(i.splitForeignPushTag().first == numeric_limits<size_t>::max(), AssemblyException, "Foreign tag."); | ||||||
| 			assertThrow(ret.bytecode.size() < 0xffffffffL, AssemblyException, "Tag too large."); | 			assertThrow(ret.bytecode.size() < 0xffffffffL, AssemblyException, "Tag too large."); | ||||||
| 			assertThrow(m_tagPositionsInBytecode[size_t(i.data())] == size_t(-1), AssemblyException, "Duplicate tag position."); | 			assertThrow(m_tagPositionsInBytecode[static_cast<size_t>(i.data())] == numeric_limits<size_t>::max(), AssemblyException, "Duplicate tag position."); | ||||||
| 			m_tagPositionsInBytecode[size_t(i.data())] = ret.bytecode.size(); | 			m_tagPositionsInBytecode[static_cast<size_t>(i.data())] = ret.bytecode.size(); | ||||||
| 			ret.bytecode.push_back((uint8_t)Instruction::JUMPDEST); | 			ret.bytecode.push_back((uint8_t)Instruction::JUMPDEST); | ||||||
| 			break; | 			break; | ||||||
| 		default: | 		default: | ||||||
| @ -722,14 +722,14 @@ LinkerObject const& Assembly::assemble() const | |||||||
| 		size_t subId; | 		size_t subId; | ||||||
| 		size_t tagId; | 		size_t tagId; | ||||||
| 		tie(subId, tagId) = i.second; | 		tie(subId, tagId) = i.second; | ||||||
| 		assertThrow(subId == size_t(-1) || subId < m_subs.size(), AssemblyException, "Invalid sub id"); | 		assertThrow(subId == numeric_limits<size_t>::max() || subId < m_subs.size(), AssemblyException, "Invalid sub id"); | ||||||
| 		std::vector<size_t> const& tagPositions = | 		std::vector<size_t> const& tagPositions = | ||||||
| 			subId == size_t(-1) ? | 			subId == numeric_limits<size_t>::max() ? | ||||||
| 			m_tagPositionsInBytecode : | 			m_tagPositionsInBytecode : | ||||||
| 			m_subs[subId]->m_tagPositionsInBytecode; | 			m_subs[subId]->m_tagPositionsInBytecode; | ||||||
| 		assertThrow(tagId < tagPositions.size(), AssemblyException, "Reference to non-existing tag."); | 		assertThrow(tagId < tagPositions.size(), AssemblyException, "Reference to non-existing tag."); | ||||||
| 		size_t pos = tagPositions[tagId]; | 		size_t pos = tagPositions[tagId]; | ||||||
| 		assertThrow(pos != size_t(-1), AssemblyException, "Reference to tag without position."); | 		assertThrow(pos != numeric_limits<size_t>::max(), AssemblyException, "Reference to tag without position."); | ||||||
| 		assertThrow(util::bytesRequired(pos) <= bytesPerTag, AssemblyException, "Tag too large for reserved space."); | 		assertThrow(util::bytesRequired(pos) <= bytesPerTag, AssemblyException, "Tag too large for reserved space."); | ||||||
| 		bytesRef r(ret.bytecode.data() + i.first, bytesPerTag); | 		bytesRef r(ret.bytecode.data() + i.first, bytesPerTag); | ||||||
| 		toBigEndian(pos, r); | 		toBigEndian(pos, r); | ||||||
|  | |||||||
| @ -34,7 +34,7 @@ AssemblyItem AssemblyItem::toSubAssemblyTag(size_t _subId) const | |||||||
| { | { | ||||||
| 	assertThrow(data() < (u256(1) << 64), util::Exception, "Tag already has subassembly set."); | 	assertThrow(data() < (u256(1) << 64), util::Exception, "Tag already has subassembly set."); | ||||||
| 	assertThrow(m_type == PushTag || m_type == Tag, util::Exception, ""); | 	assertThrow(m_type == PushTag || m_type == Tag, util::Exception, ""); | ||||||
| 	size_t tag = size_t(u256(data()) & 0xffffffffffffffffULL); | 	auto tag = static_cast<size_t>(u256(data()) & 0xffffffffffffffffULL); | ||||||
| 	AssemblyItem r = *this; | 	AssemblyItem r = *this; | ||||||
| 	r.m_type = PushTag; | 	r.m_type = PushTag; | ||||||
| 	r.setPushTagSubIdAndTag(_subId, tag); | 	r.setPushTagSubIdAndTag(_subId, tag); | ||||||
| @ -45,8 +45,8 @@ pair<size_t, size_t> AssemblyItem::splitForeignPushTag() const | |||||||
| { | { | ||||||
| 	assertThrow(m_type == PushTag || m_type == Tag, util::Exception, ""); | 	assertThrow(m_type == PushTag || m_type == Tag, util::Exception, ""); | ||||||
| 	u256 combined = u256(data()); | 	u256 combined = u256(data()); | ||||||
| 	size_t subId = size_t((combined >> 64) - 1); | 	size_t subId = static_cast<size_t>((combined >> 64) - 1); | ||||||
| 	size_t tag = size_t(combined & 0xffffffffffffffffULL); | 	size_t tag = static_cast<size_t>(combined & 0xffffffffffffffffULL); | ||||||
| 	return make_pair(subId, tag); | 	return make_pair(subId, tag); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| @ -54,7 +54,7 @@ void AssemblyItem::setPushTagSubIdAndTag(size_t _subId, size_t _tag) | |||||||
| { | { | ||||||
| 	assertThrow(m_type == PushTag || m_type == Tag, util::Exception, ""); | 	assertThrow(m_type == PushTag || m_type == Tag, util::Exception, ""); | ||||||
| 	u256 data = _tag; | 	u256 data = _tag; | ||||||
| 	if (_subId != size_t(-1)) | 	if (_subId != numeric_limits<size_t>::max()) | ||||||
| 		data |= (u256(_subId) + 1) << 64; | 		data |= (u256(_subId) + 1) << 64; | ||||||
| 	setData(data); | 	setData(data); | ||||||
| } | } | ||||||
| @ -93,22 +93,22 @@ unsigned AssemblyItem::bytesRequired(unsigned _addressLength) const | |||||||
| 	assertThrow(false, InvalidOpcode, ""); | 	assertThrow(false, InvalidOpcode, ""); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| int AssemblyItem::arguments() const | size_t AssemblyItem::arguments() const | ||||||
| { | { | ||||||
| 	if (type() == Operation) | 	if (type() == Operation) | ||||||
| 		return instructionInfo(instruction()).args; | 		return static_cast<size_t>(instructionInfo(instruction()).args); | ||||||
| 	else if (type() == AssignImmutable) | 	else if (type() == AssignImmutable) | ||||||
| 		return 1; | 		return 1; | ||||||
| 	else | 	else | ||||||
| 		return 0; | 		return 0; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| int AssemblyItem::returnValues() const | size_t AssemblyItem::returnValues() const | ||||||
| { | { | ||||||
| 	switch (m_type) | 	switch (m_type) | ||||||
| 	{ | 	{ | ||||||
| 	case Operation: | 	case Operation: | ||||||
| 		return instructionInfo(instruction()).ret; | 		return static_cast<size_t>(instructionInfo(instruction()).ret); | ||||||
| 	case Push: | 	case Push: | ||||||
| 	case PushString: | 	case PushString: | ||||||
| 	case PushTag: | 	case PushTag: | ||||||
| @ -193,7 +193,7 @@ string AssemblyItem::toAssemblyText() const | |||||||
| 		size_t sub{0}; | 		size_t sub{0}; | ||||||
| 		size_t tag{0}; | 		size_t tag{0}; | ||||||
| 		tie(sub, tag) = splitForeignPushTag(); | 		tie(sub, tag) = splitForeignPushTag(); | ||||||
| 		if (sub == size_t(-1)) | 		if (sub == numeric_limits<size_t>::max()) | ||||||
| 			text = string("tag_") + to_string(tag); | 			text = string("tag_") + to_string(tag); | ||||||
| 		else | 		else | ||||||
| 			text = string("tag_") + to_string(sub) + "_" + to_string(tag); | 			text = string("tag_") + to_string(sub) + "_" + to_string(tag); | ||||||
| @ -201,16 +201,16 @@ string AssemblyItem::toAssemblyText() const | |||||||
| 	} | 	} | ||||||
| 	case Tag: | 	case Tag: | ||||||
| 		assertThrow(data() < 0x10000, AssemblyException, "Declaration of sub-assembly tag."); | 		assertThrow(data() < 0x10000, AssemblyException, "Declaration of sub-assembly tag."); | ||||||
| 		text = string("tag_") + to_string(size_t(data())) + ":"; | 		text = string("tag_") + to_string(static_cast<size_t>(data())) + ":"; | ||||||
| 		break; | 		break; | ||||||
| 	case PushData: | 	case PushData: | ||||||
| 		text = string("data_") + util::toHex(data()); | 		text = string("data_") + util::toHex(data()); | ||||||
| 		break; | 		break; | ||||||
| 	case PushSub: | 	case PushSub: | ||||||
| 		text = string("dataOffset(sub_") + to_string(size_t(data())) + ")"; | 		text = string("dataOffset(sub_") + to_string(static_cast<size_t>(data())) + ")"; | ||||||
| 		break; | 		break; | ||||||
| 	case PushSubSize: | 	case PushSubSize: | ||||||
| 		text = string("dataSize(sub_") + to_string(size_t(data())) + ")"; | 		text = string("dataSize(sub_") + to_string(static_cast<size_t>(data())) + ")"; | ||||||
| 		break; | 		break; | ||||||
| 	case PushProgramSize: | 	case PushProgramSize: | ||||||
| 		text = string("bytecodeSize"); | 		text = string("bytecodeSize"); | ||||||
| @ -262,7 +262,7 @@ ostream& solidity::evmasm::operator<<(ostream& _out, AssemblyItem const& _item) | |||||||
| 	case PushTag: | 	case PushTag: | ||||||
| 	{ | 	{ | ||||||
| 		size_t subId = _item.splitForeignPushTag().first; | 		size_t subId = _item.splitForeignPushTag().first; | ||||||
| 		if (subId == size_t(-1)) | 		if (subId == numeric_limits<size_t>::max()) | ||||||
| 			_out << " PushTag " << _item.splitForeignPushTag().second; | 			_out << " PushTag " << _item.splitForeignPushTag().second; | ||||||
| 		else | 		else | ||||||
| 			_out << " PushTag " << subId << ":" << _item.splitForeignPushTag().second; | 			_out << " PushTag " << subId << ":" << _item.splitForeignPushTag().second; | ||||||
| @ -272,13 +272,13 @@ ostream& solidity::evmasm::operator<<(ostream& _out, AssemblyItem const& _item) | |||||||
| 		_out << " Tag " << _item.data(); | 		_out << " Tag " << _item.data(); | ||||||
| 		break; | 		break; | ||||||
| 	case PushData: | 	case PushData: | ||||||
| 		_out << " PushData " << hex << (unsigned)_item.data() << dec; | 		_out << " PushData " << hex << static_cast<unsigned>(_item.data()) << dec; | ||||||
| 		break; | 		break; | ||||||
| 	case PushSub: | 	case PushSub: | ||||||
| 		_out << " PushSub " << hex << size_t(_item.data()) << dec; | 		_out << " PushSub " << hex << static_cast<size_t>(_item.data()) << dec; | ||||||
| 		break; | 		break; | ||||||
| 	case PushSubSize: | 	case PushSubSize: | ||||||
| 		_out << " PushSubSize " << hex << size_t(_item.data()) << dec; | 		_out << " PushSubSize " << hex << static_cast<size_t>(_item.data()) << dec; | ||||||
| 		break; | 		break; | ||||||
| 	case PushProgramSize: | 	case PushProgramSize: | ||||||
| 		_out << " PushProgramSize"; | 		_out << " PushProgramSize"; | ||||||
| @ -317,7 +317,7 @@ std::string AssemblyItem::computeSourceMapping( | |||||||
| 	int prevStart = -1; | 	int prevStart = -1; | ||||||
| 	int prevLength = -1; | 	int prevLength = -1; | ||||||
| 	int prevSourceIndex = -1; | 	int prevSourceIndex = -1; | ||||||
| 	size_t prevModifierDepth = -1; | 	int prevModifierDepth = -1; | ||||||
| 	char prevJump = 0; | 	char prevJump = 0; | ||||||
| 	for (auto const& item: _items) | 	for (auto const& item: _items) | ||||||
| 	{ | 	{ | ||||||
| @ -328,14 +328,14 @@ std::string AssemblyItem::computeSourceMapping( | |||||||
| 		int length = location.start != -1 && location.end != -1 ? location.end - location.start : -1; | 		int length = location.start != -1 && location.end != -1 ? location.end - location.start : -1; | ||||||
| 		int sourceIndex = | 		int sourceIndex = | ||||||
| 			location.source && _sourceIndicesMap.count(location.source->name()) ? | 			location.source && _sourceIndicesMap.count(location.source->name()) ? | ||||||
| 			_sourceIndicesMap.at(location.source->name()) : | 			static_cast<int>(_sourceIndicesMap.at(location.source->name())) : | ||||||
| 			-1; | 			-1; | ||||||
| 		char jump = '-'; | 		char jump = '-'; | ||||||
| 		if (item.getJumpType() == evmasm::AssemblyItem::JumpType::IntoFunction) | 		if (item.getJumpType() == evmasm::AssemblyItem::JumpType::IntoFunction) | ||||||
| 			jump = 'i'; | 			jump = 'i'; | ||||||
| 		else if (item.getJumpType() == evmasm::AssemblyItem::JumpType::OutOfFunction) | 		else if (item.getJumpType() == evmasm::AssemblyItem::JumpType::OutOfFunction) | ||||||
| 			jump = 'o'; | 			jump = 'o'; | ||||||
| 		size_t modifierDepth = item.m_modifierDepth; | 		int modifierDepth = static_cast<int>(item.m_modifierDepth); | ||||||
| 
 | 
 | ||||||
| 		unsigned components = 5; | 		unsigned components = 5; | ||||||
| 		if (modifierDepth == prevModifierDepth) | 		if (modifierDepth == prevModifierDepth) | ||||||
|  | |||||||
| @ -134,9 +134,9 @@ public: | |||||||
| 	/// @returns an upper bound for the number of bytes required by this item, assuming that
 | 	/// @returns an upper bound for the number of bytes required by this item, assuming that
 | ||||||
| 	/// the value of a jump tag takes @a _addressLength bytes.
 | 	/// the value of a jump tag takes @a _addressLength bytes.
 | ||||||
| 	unsigned bytesRequired(unsigned _addressLength) const; | 	unsigned bytesRequired(unsigned _addressLength) const; | ||||||
| 	int arguments() const; | 	size_t arguments() const; | ||||||
| 	int returnValues() const; | 	size_t returnValues() const; | ||||||
| 	int deposit() const { return returnValues() - arguments(); } | 	size_t deposit() const { return returnValues() - arguments(); } | ||||||
| 
 | 
 | ||||||
| 	/// @returns true if the assembly item can be used in a functional context.
 | 	/// @returns true if the assembly item can be used in a functional context.
 | ||||||
| 	bool canBeFunctional() const; | 	bool canBeFunctional() const; | ||||||
|  | |||||||
| @ -63,8 +63,9 @@ bool BlockDeduplicator::deduplicate() | |||||||
| 		if (_j < m_items.size() && m_items.at(_j).type() == Tag) | 		if (_j < m_items.size() && m_items.at(_j).type() == Tag) | ||||||
| 			pushSecondTag = m_items.at(_j).pushTag(); | 			pushSecondTag = m_items.at(_j).pushTag(); | ||||||
| 
 | 
 | ||||||
| 		BlockIterator first{m_items.begin() + _i, m_items.end(), &pushFirstTag, &pushSelf}; | 		using diff_type = BlockIterator::difference_type; | ||||||
| 		BlockIterator second{m_items.begin() + _j, m_items.end(), &pushSecondTag, &pushSelf}; | 		BlockIterator first{m_items.begin() + diff_type(_i), m_items.end(), &pushFirstTag, &pushSelf}; | ||||||
|  | 		BlockIterator second{m_items.begin() + diff_type(_j), m_items.end(), &pushSecondTag, &pushSelf}; | ||||||
| 		BlockIterator end{m_items.end(), m_items.end()}; | 		BlockIterator end{m_items.end(), m_items.end()}; | ||||||
| 
 | 
 | ||||||
| 		if (first != end && (*first).type() == Tag) | 		if (first != end && (*first).type() == Tag) | ||||||
| @ -120,7 +121,7 @@ bool BlockDeduplicator::applyTagReplacement( | |||||||
| 			if (it != _replacements.end()) | 			if (it != _replacements.end()) | ||||||
| 			{ | 			{ | ||||||
| 				changed = true; | 				changed = true; | ||||||
| 				item.setPushTagSubIdAndTag(subId, size_t(it->second)); | 				item.setPushTagSubIdAndTag(subId, static_cast<size_t>(it->second)); | ||||||
| 			} | 			} | ||||||
| 		} | 		} | ||||||
| 	return changed; | 	return changed; | ||||||
|  | |||||||
| @ -386,7 +386,11 @@ void CSECodeGenerator::generateClassElement(Id _c, bool _allowSequenced) | |||||||
| 			"Opcodes with more than two arguments not implemented yet." | 			"Opcodes with more than two arguments not implemented yet." | ||||||
| 		); | 		); | ||||||
| 	for (size_t i = 0; i < arguments.size(); ++i) | 	for (size_t i = 0; i < arguments.size(); ++i) | ||||||
| 		assertThrow(m_stack[m_stackHeight - i] == arguments[i], OptimizerException, "Expected arguments not present." ); | 		assertThrow( | ||||||
|  | 			m_stack[m_stackHeight - static_cast<int>(i)] == arguments[i], | ||||||
|  | 			OptimizerException, | ||||||
|  | 			"Expected arguments not present." | ||||||
|  | 		); | ||||||
| 
 | 
 | ||||||
| 	while (SemanticInformation::isCommutativeOperation(*expr.item) && | 	while (SemanticInformation::isCommutativeOperation(*expr.item) && | ||||||
| 			!m_generatedItems.empty() && | 			!m_generatedItems.empty() && | ||||||
| @ -395,8 +399,8 @@ void CSECodeGenerator::generateClassElement(Id _c, bool _allowSequenced) | |||||||
| 		appendOrRemoveSwap(m_stackHeight - 1, itemLocation); | 		appendOrRemoveSwap(m_stackHeight - 1, itemLocation); | ||||||
| 	for (size_t i = 0; i < arguments.size(); ++i) | 	for (size_t i = 0; i < arguments.size(); ++i) | ||||||
| 	{ | 	{ | ||||||
| 		m_classPositions[m_stack[m_stackHeight - i]].erase(m_stackHeight - i); | 		m_classPositions[m_stack[m_stackHeight - static_cast<int>(i)]].erase(m_stackHeight - static_cast<int>(i)); | ||||||
| 		m_stack.erase(m_stackHeight - i); | 		m_stack.erase(m_stackHeight - static_cast<int>(i)); | ||||||
| 	} | 	} | ||||||
| 	appendItem(*expr.item); | 	appendItem(*expr.item); | ||||||
| 	if (expr.item->type() != Operation || instructionInfo(expr.item->instruction()).ret == 1) | 	if (expr.item->type() != Operation || instructionInfo(expr.item->instruction()).ret == 1) | ||||||
| @ -467,7 +471,7 @@ void CSECodeGenerator::appendDup(int _fromPosition, SourceLocation const& _locat | |||||||
| 	int instructionNum = 1 + m_stackHeight - _fromPosition; | 	int instructionNum = 1 + m_stackHeight - _fromPosition; | ||||||
| 	assertThrow(instructionNum <= 16, StackTooDeepException, "Stack too deep, try removing local variables."); | 	assertThrow(instructionNum <= 16, StackTooDeepException, "Stack too deep, try removing local variables."); | ||||||
| 	assertThrow(1 <= instructionNum, OptimizerException, "Invalid stack access."); | 	assertThrow(1 <= instructionNum, OptimizerException, "Invalid stack access."); | ||||||
| 	appendItem(AssemblyItem(dupInstruction(instructionNum), _location)); | 	appendItem(AssemblyItem(dupInstruction(static_cast<unsigned>(instructionNum)), _location)); | ||||||
| 	m_stack[m_stackHeight] = m_stack[_fromPosition]; | 	m_stack[m_stackHeight] = m_stack[_fromPosition]; | ||||||
| 	m_classPositions[m_stack[m_stackHeight]].insert(m_stackHeight); | 	m_classPositions[m_stack[m_stackHeight]].insert(m_stackHeight); | ||||||
| } | } | ||||||
| @ -480,7 +484,7 @@ void CSECodeGenerator::appendOrRemoveSwap(int _fromPosition, SourceLocation cons | |||||||
| 	int instructionNum = m_stackHeight - _fromPosition; | 	int instructionNum = m_stackHeight - _fromPosition; | ||||||
| 	assertThrow(instructionNum <= 16, StackTooDeepException, "Stack too deep, try removing local variables."); | 	assertThrow(instructionNum <= 16, StackTooDeepException, "Stack too deep, try removing local variables."); | ||||||
| 	assertThrow(1 <= instructionNum, OptimizerException, "Invalid stack access."); | 	assertThrow(1 <= instructionNum, OptimizerException, "Invalid stack access."); | ||||||
| 	appendItem(AssemblyItem(swapInstruction(instructionNum), _location)); | 	appendItem(AssemblyItem(swapInstruction(static_cast<unsigned>(instructionNum)), _location)); | ||||||
| 
 | 
 | ||||||
| 	if (m_stack[m_stackHeight] != m_stack[_fromPosition]) | 	if (m_stack[m_stackHeight] != m_stack[_fromPosition]) | ||||||
| 	{ | 	{ | ||||||
| @ -502,5 +506,5 @@ void CSECodeGenerator::appendOrRemoveSwap(int _fromPosition, SourceLocation cons | |||||||
| void CSECodeGenerator::appendItem(AssemblyItem const& _item) | void CSECodeGenerator::appendItem(AssemblyItem const& _item) | ||||||
| { | { | ||||||
| 	m_generatedItems.push_back(_item); | 	m_generatedItems.push_back(_item); | ||||||
| 	m_stackHeight += _item.deposit(); | 	m_stackHeight += static_cast<int>(_item.deposit()); | ||||||
| } | } | ||||||
|  | |||||||
| @ -262,7 +262,7 @@ bool ComputeMethod::checkRepresentation(u256 const& _value, AssemblyItems const& | |||||||
| 		{ | 		{ | ||||||
| 		case Operation: | 		case Operation: | ||||||
| 		{ | 		{ | ||||||
| 			if (stack.size() < size_t(item.arguments())) | 			if (stack.size() < item.arguments()) | ||||||
| 				return false; | 				return false; | ||||||
| 			u256* sp = &stack.back(); | 			u256* sp = &stack.back(); | ||||||
| 			switch (item.instruction()) | 			switch (item.instruction()) | ||||||
| @ -320,7 +320,7 @@ bool ComputeMethod::checkRepresentation(u256 const& _value, AssemblyItems const& | |||||||
| 
 | 
 | ||||||
| bigint ComputeMethod::gasNeeded(AssemblyItems const& _routine) const | bigint ComputeMethod::gasNeeded(AssemblyItems const& _routine) const | ||||||
| { | { | ||||||
| 	size_t numExps = count(_routine.begin(), _routine.end(), Instruction::EXP); | 	auto numExps = static_cast<size_t>(count(_routine.begin(), _routine.end(), Instruction::EXP)); | ||||||
| 	return combineGas( | 	return combineGas( | ||||||
| 		simpleRunGas(_routine) + numExps * (GasCosts::expGas + GasCosts::expByteGas(m_params.evmVersion)), | 		simpleRunGas(_routine) + numExps * (GasCosts::expGas + GasCosts::expByteGas(m_params.evmVersion)), | ||||||
| 		// Data gas for routine: Some bytes are zero, but we ignore them.
 | 		// Data gas for routine: Some bytes are zero, but we ignore them.
 | ||||||
|  | |||||||
| @ -45,8 +45,8 @@ public: | |||||||
| 	BlockId() { *this = invalid(); } | 	BlockId() { *this = invalid(); } | ||||||
| 	explicit BlockId(unsigned _id): m_id(_id) {} | 	explicit BlockId(unsigned _id): m_id(_id) {} | ||||||
| 	explicit BlockId(u256 const& _id); | 	explicit BlockId(u256 const& _id); | ||||||
| 	static BlockId initial() { return BlockId(-2); } | 	static BlockId initial() { return BlockId(std::numeric_limits<unsigned>::max() - 1); } | ||||||
| 	static BlockId invalid() { return BlockId(-1); } | 	static BlockId invalid() { return BlockId(std::numeric_limits<unsigned>::max()); } | ||||||
| 
 | 
 | ||||||
| 	bool operator==(BlockId const& _other) const { return m_id == _other.m_id; } | 	bool operator==(BlockId const& _other) const { return m_id == _other.m_id; } | ||||||
| 	bool operator!=(BlockId const& _other) const { return m_id != _other.m_id; } | 	bool operator!=(BlockId const& _other) const { return m_id != _other.m_id; } | ||||||
|  | |||||||
| @ -190,7 +190,7 @@ ExpressionClasses::Id ExpressionClasses::tryToSimplify(Expression const& _expr) | |||||||
| 		_expr.item->type() != Operation || | 		_expr.item->type() != Operation || | ||||||
| 		!SemanticInformation::isDeterministic(*_expr.item) | 		!SemanticInformation::isDeterministic(*_expr.item) | ||||||
| 	) | 	) | ||||||
| 		return -1; | 		return numeric_limits<unsigned>::max(); | ||||||
| 
 | 
 | ||||||
| 	if (auto match = rules.findFirstMatch(_expr, *this)) | 	if (auto match = rules.findFirstMatch(_expr, *this)) | ||||||
| 	{ | 	{ | ||||||
| @ -208,7 +208,7 @@ ExpressionClasses::Id ExpressionClasses::tryToSimplify(Expression const& _expr) | |||||||
| 		return rebuildExpression(ExpressionTemplate(match->action(), _expr.item->location())); | 		return rebuildExpression(ExpressionTemplate(match->action(), _expr.item->location())); | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	return -1; | 	return numeric_limits<unsigned>::max(); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| ExpressionClasses::Id ExpressionClasses::rebuildExpression(ExpressionTemplate const& _template) | ExpressionClasses::Id ExpressionClasses::rebuildExpression(ExpressionTemplate const& _template) | ||||||
|  | |||||||
| @ -330,8 +330,8 @@ void solidity::evmasm::eachInstruction( | |||||||
| { | { | ||||||
| 	for (auto it = _mem.begin(); it < _mem.end(); ++it) | 	for (auto it = _mem.begin(); it < _mem.end(); ++it) | ||||||
| 	{ | 	{ | ||||||
| 		Instruction instr = Instruction(*it); | 		auto instr = Instruction(*it); | ||||||
| 		size_t additional = 0; | 		int additional = 0; | ||||||
| 		if (isValidInstruction(instr)) | 		if (isValidInstruction(instr)) | ||||||
| 			additional = instructionInfo(instr).additional; | 			additional = instructionInfo(instr).additional; | ||||||
| 
 | 
 | ||||||
| @ -357,7 +357,7 @@ string solidity::evmasm::disassemble(bytes const& _mem) | |||||||
| 	stringstream ret; | 	stringstream ret; | ||||||
| 	eachInstruction(_mem, [&](Instruction _instr, u256 const& _data) { | 	eachInstruction(_mem, [&](Instruction _instr, u256 const& _data) { | ||||||
| 		if (!isValidInstruction(_instr)) | 		if (!isValidInstruction(_instr)) | ||||||
| 			ret << "0x" << std::uppercase << std::hex << int(_instr) << " "; | 			ret << "0x" << std::uppercase << std::hex << static_cast<int>(_instr) << " "; | ||||||
| 		else | 		else | ||||||
| 		{ | 		{ | ||||||
| 			InstructionInfo info = instructionInfo(_instr); | 			InstructionInfo info = instructionInfo(_instr); | ||||||
|  | |||||||
| @ -30,7 +30,7 @@ using namespace solidity::evmasm; | |||||||
| 
 | 
 | ||||||
| bool JumpdestRemover::optimise(set<size_t> const& _tagsReferencedFromOutside) | bool JumpdestRemover::optimise(set<size_t> const& _tagsReferencedFromOutside) | ||||||
| { | { | ||||||
| 	set<size_t> references{referencedTags(m_items, -1)}; | 	set<size_t> references{referencedTags(m_items, numeric_limits<size_t>::max())}; | ||||||
| 	references.insert(_tagsReferencedFromOutside.begin(), _tagsReferencedFromOutside.end()); | 	references.insert(_tagsReferencedFromOutside.begin(), _tagsReferencedFromOutside.end()); | ||||||
| 
 | 
 | ||||||
| 	size_t initialSize = m_items.size(); | 	size_t initialSize = m_items.size(); | ||||||
| @ -43,7 +43,7 @@ bool JumpdestRemover::optimise(set<size_t> const& _tagsReferencedFromOutside) | |||||||
| 			if (_item.type() != Tag) | 			if (_item.type() != Tag) | ||||||
| 				return false; | 				return false; | ||||||
| 			auto asmIdAndTag = _item.splitForeignPushTag(); | 			auto asmIdAndTag = _item.splitForeignPushTag(); | ||||||
| 			assertThrow(asmIdAndTag.first == size_t(-1), OptimizerException, "Sub-assembly tag used as label."); | 			assertThrow(asmIdAndTag.first == numeric_limits<size_t>::max(), OptimizerException, "Sub-assembly tag used as label."); | ||||||
| 			size_t tag = asmIdAndTag.second; | 			size_t tag = asmIdAndTag.second; | ||||||
| 			return !references.count(tag); | 			return !references.count(tag); | ||||||
| 		} | 		} | ||||||
|  | |||||||
| @ -41,7 +41,7 @@ ostream& KnownState::stream(ostream& _out) const | |||||||
| 		if (!expr.item) | 		if (!expr.item) | ||||||
| 			_out << " no item"; | 			_out << " no item"; | ||||||
| 		else if (expr.item->type() == UndefinedItem) | 		else if (expr.item->type() == UndefinedItem) | ||||||
| 			_out << " unknown " << int(expr.item->data()); | 			_out << " unknown " << static_cast<int>(expr.item->data()); | ||||||
| 		else | 		else | ||||||
| 			_out << *expr.item; | 			_out << *expr.item; | ||||||
| 		if (expr.sequenceNumber) | 		if (expr.sequenceNumber) | ||||||
| @ -112,21 +112,21 @@ KnownState::StoreOperation KnownState::feedItem(AssemblyItem const& _item, bool | |||||||
| 			setStackElement( | 			setStackElement( | ||||||
| 				m_stackHeight + 1, | 				m_stackHeight + 1, | ||||||
| 				stackElement( | 				stackElement( | ||||||
| 					m_stackHeight - int(instruction) + int(Instruction::DUP1), | 					m_stackHeight - static_cast<int>(instruction) + static_cast<int>(Instruction::DUP1), | ||||||
| 					_item.location() | 					_item.location() | ||||||
| 				) | 				) | ||||||
| 			); | 			); | ||||||
| 		else if (SemanticInformation::isSwapInstruction(_item)) | 		else if (SemanticInformation::isSwapInstruction(_item)) | ||||||
| 			swapStackElements( | 			swapStackElements( | ||||||
| 				m_stackHeight, | 				m_stackHeight, | ||||||
| 				m_stackHeight - 1 - int(instruction) + int(Instruction::SWAP1), | 				m_stackHeight - 1 - static_cast<int>(instruction) + static_cast<int>(Instruction::SWAP1), | ||||||
| 				_item.location() | 				_item.location() | ||||||
| 			); | 			); | ||||||
| 		else if (instruction != Instruction::POP) | 		else if (instruction != Instruction::POP) | ||||||
| 		{ | 		{ | ||||||
| 			vector<Id> arguments(info.args); | 			vector<Id> arguments(static_cast<size_t>(info.args)); | ||||||
| 			for (int i = 0; i < info.args; ++i) | 			for (size_t i = 0; i < static_cast<size_t>(info.args); ++i) | ||||||
| 				arguments[i] = stackElement(m_stackHeight - i, _item.location()); | 				arguments[i] = stackElement(m_stackHeight - static_cast<int>(i), _item.location()); | ||||||
| 			switch (_item.instruction()) | 			switch (_item.instruction()) | ||||||
| 			{ | 			{ | ||||||
| 			case Instruction::SSTORE: | 			case Instruction::SSTORE: | ||||||
| @ -134,7 +134,7 @@ KnownState::StoreOperation KnownState::feedItem(AssemblyItem const& _item, bool | |||||||
| 				break; | 				break; | ||||||
| 			case Instruction::SLOAD: | 			case Instruction::SLOAD: | ||||||
| 				setStackElement( | 				setStackElement( | ||||||
| 					m_stackHeight + _item.deposit(), | 					m_stackHeight + static_cast<int>(_item.deposit()), | ||||||
| 					loadFromStorage(arguments[0], _item.location()) | 					loadFromStorage(arguments[0], _item.location()) | ||||||
| 				); | 				); | ||||||
| 				break; | 				break; | ||||||
| @ -143,13 +143,13 @@ KnownState::StoreOperation KnownState::feedItem(AssemblyItem const& _item, bool | |||||||
| 				break; | 				break; | ||||||
| 			case Instruction::MLOAD: | 			case Instruction::MLOAD: | ||||||
| 				setStackElement( | 				setStackElement( | ||||||
| 					m_stackHeight + _item.deposit(), | 					m_stackHeight + static_cast<int>(_item.deposit()), | ||||||
| 					loadFromMemory(arguments[0], _item.location()) | 					loadFromMemory(arguments[0], _item.location()) | ||||||
| 				); | 				); | ||||||
| 				break; | 				break; | ||||||
| 			case Instruction::KECCAK256: | 			case Instruction::KECCAK256: | ||||||
| 				setStackElement( | 				setStackElement( | ||||||
| 					m_stackHeight + _item.deposit(), | 					m_stackHeight + static_cast<int>(_item.deposit()), | ||||||
| 					applyKeccak256(arguments.at(0), arguments.at(1), _item.location()) | 					applyKeccak256(arguments.at(0), arguments.at(1), _item.location()) | ||||||
| 				); | 				); | ||||||
| 				break; | 				break; | ||||||
| @ -167,16 +167,16 @@ KnownState::StoreOperation KnownState::feedItem(AssemblyItem const& _item, bool | |||||||
| 				assertThrow(info.ret <= 1, InvalidDeposit, ""); | 				assertThrow(info.ret <= 1, InvalidDeposit, ""); | ||||||
| 				if (info.ret == 1) | 				if (info.ret == 1) | ||||||
| 					setStackElement( | 					setStackElement( | ||||||
| 						m_stackHeight + _item.deposit(), | 						m_stackHeight + static_cast<int>(_item.deposit()), | ||||||
| 						m_expressionClasses->find(_item, arguments, _copyItem) | 						m_expressionClasses->find(_item, arguments, _copyItem) | ||||||
| 					); | 					); | ||||||
| 			} | 			} | ||||||
| 		} | 		} | ||||||
| 		m_stackElements.erase( | 		m_stackElements.erase( | ||||||
| 			m_stackElements.upper_bound(m_stackHeight + _item.deposit()), | 			m_stackElements.upper_bound(m_stackHeight + static_cast<int>(_item.deposit())), | ||||||
| 			m_stackElements.end() | 			m_stackElements.end() | ||||||
| 		); | 		); | ||||||
| 		m_stackHeight += _item.deposit(); | 		m_stackHeight += static_cast<int>(_item.deposit()); | ||||||
| 	} | 	} | ||||||
| 	return op; | 	return op; | ||||||
| } | } | ||||||
| @ -388,7 +388,7 @@ KnownState::Id KnownState::applyKeccak256( | |||||||
| 		bytes data; | 		bytes data; | ||||||
| 		for (Id a: arguments) | 		for (Id a: arguments) | ||||||
| 			data += util::toBigEndian(*m_expressionClasses->knownConstant(a)); | 			data += util::toBigEndian(*m_expressionClasses->knownConstant(a)); | ||||||
| 		data.resize(size_t(*l)); | 		data.resize(static_cast<size_t>(*l)); | ||||||
| 		v = m_expressionClasses->find(AssemblyItem(u256(util::keccak256(data)), _location)); | 		v = m_expressionClasses->find(AssemblyItem(u256(util::keccak256(data)), _location)); | ||||||
| 	} | 	} | ||||||
| 	else | 	else | ||||||
|  | |||||||
| @ -40,7 +40,7 @@ void LinkerObject::link(map<string, h160> const& _libraryAddresses) | |||||||
| 	std::map<size_t, std::string> remainingRefs; | 	std::map<size_t, std::string> remainingRefs; | ||||||
| 	for (auto const& linkRef: linkReferences) | 	for (auto const& linkRef: linkReferences) | ||||||
| 		if (h160 const* address = matchLibrary(linkRef.second, _libraryAddresses)) | 		if (h160 const* address = matchLibrary(linkRef.second, _libraryAddresses)) | ||||||
| 			copy(address->data(), address->data() + 20, bytecode.begin() + linkRef.first); | 			copy(address->data(), address->data() + 20, bytecode.begin() + vector<uint8_t>::difference_type(linkRef.first)); | ||||||
| 		else | 		else | ||||||
| 			remainingRefs.insert(linkRef); | 			remainingRefs.insert(linkRef); | ||||||
| 	linkReferences.swap(remainingRefs); | 	linkReferences.swap(remainingRefs); | ||||||
|  | |||||||
| @ -84,7 +84,7 @@ struct SimplePeepholeOptimizerMethod | |||||||
| 	{ | 	{ | ||||||
| 		if ( | 		if ( | ||||||
| 			_state.i + WindowSize <= _state.items.size() && | 			_state.i + WindowSize <= _state.items.size() && | ||||||
| 			ApplyRule<Method, WindowSize>::applyRule(_state.items.begin() + _state.i, _state.out) | 			ApplyRule<Method, WindowSize>::applyRule(_state.items.begin() + static_cast<ptrdiff_t>(_state.i), _state.out) | ||||||
| 		) | 		) | ||||||
| 		{ | 		{ | ||||||
| 			_state.i += WindowSize; | 			_state.i += WindowSize; | ||||||
| @ -303,7 +303,7 @@ struct UnreachableCode | |||||||
| { | { | ||||||
| 	static bool apply(OptimiserState& _state) | 	static bool apply(OptimiserState& _state) | ||||||
| 	{ | 	{ | ||||||
| 		auto it = _state.items.begin() + _state.i; | 		auto it = _state.items.begin() + static_cast<ptrdiff_t>(_state.i); | ||||||
| 		auto end = _state.items.end(); | 		auto end = _state.items.end(); | ||||||
| 		if (it == end) | 		if (it == end) | ||||||
| 			return false; | 			return false; | ||||||
| @ -317,13 +317,13 @@ struct UnreachableCode | |||||||
| 		) | 		) | ||||||
| 			return false; | 			return false; | ||||||
| 
 | 
 | ||||||
| 		size_t i = 1; | 		ptrdiff_t i = 1; | ||||||
| 		while (it + i != end && it[i].type() != Tag) | 		while (it + i != end && it[i].type() != Tag) | ||||||
| 			i++; | 			i++; | ||||||
| 		if (i > 1) | 		if (i > 1) | ||||||
| 		{ | 		{ | ||||||
| 			*_state.out = it[0]; | 			*_state.out = it[0]; | ||||||
| 			_state.i += i; | 			_state.i += static_cast<size_t>(i); | ||||||
| 			return true; | 			return true; | ||||||
| 		} | 		} | ||||||
| 		else | 		else | ||||||
| @ -345,7 +345,7 @@ void applyMethods(OptimiserState& _state, Method, OtherMethods... _other) | |||||||
| 
 | 
 | ||||||
| size_t numberOfPops(AssemblyItems const& _items) | size_t numberOfPops(AssemblyItems const& _items) | ||||||
| { | { | ||||||
| 	return std::count(_items.begin(), _items.end(), Instruction::POP); | 	return static_cast<size_t>(std::count(_items.begin(), _items.end(), Instruction::POP)); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| } | } | ||||||
|  | |||||||
| @ -85,7 +85,7 @@ BOOST_AUTO_TEST_CASE(all_assembly_items) | |||||||
| 	// PushSubSize
 | 	// PushSubSize
 | ||||||
| 	auto sub = _assembly.appendSubroutine(_subAsmPtr); | 	auto sub = _assembly.appendSubroutine(_subAsmPtr); | ||||||
| 	// PushSub
 | 	// PushSub
 | ||||||
| 	_assembly.pushSubroutineOffset(size_t(sub.data())); | 	_assembly.pushSubroutineOffset(static_cast<size_t>(sub.data())); | ||||||
| 	// PushDeployTimeAddress
 | 	// PushDeployTimeAddress
 | ||||||
| 	_assembly.append(PushDeployTimeAddress); | 	_assembly.append(PushDeployTimeAddress); | ||||||
| 	// AssignImmutable.
 | 	// AssignImmutable.
 | ||||||
| @ -187,7 +187,7 @@ BOOST_AUTO_TEST_CASE(immutable) | |||||||
| 	_assembly.appendImmutableAssignment("someOtherImmutable"); | 	_assembly.appendImmutableAssignment("someOtherImmutable"); | ||||||
| 
 | 
 | ||||||
| 	auto sub = _assembly.appendSubroutine(_subAsmPtr); | 	auto sub = _assembly.appendSubroutine(_subAsmPtr); | ||||||
| 	_assembly.pushSubroutineOffset(size_t(sub.data())); | 	_assembly.pushSubroutineOffset(static_cast<size_t>(sub.data())); | ||||||
| 
 | 
 | ||||||
| 	checkCompilation(_assembly); | 	checkCompilation(_assembly); | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -1227,7 +1227,7 @@ BOOST_AUTO_TEST_CASE(jumpdest_removal_subassemblies) | |||||||
| 	sub->append(t4.pushTag()); | 	sub->append(t4.pushTag()); | ||||||
| 	sub->append(Instruction::JUMP); | 	sub->append(Instruction::JUMP); | ||||||
| 
 | 
 | ||||||
| 	size_t subId = size_t(main.appendSubroutine(sub).data()); | 	size_t subId = static_cast<size_t>(main.appendSubroutine(sub).data()); | ||||||
| 	main.append(t1.toSubAssemblyTag(subId)); | 	main.append(t1.toSubAssemblyTag(subId)); | ||||||
| 	main.append(t1.toSubAssemblyTag(subId)); | 	main.append(t1.toSubAssemblyTag(subId)); | ||||||
| 	main.append(u256(8)); | 	main.append(u256(8)); | ||||||
| @ -1281,10 +1281,10 @@ BOOST_AUTO_TEST_CASE(cse_remove_redundant_shift_masking) | |||||||
| 	if (!solidity::test::CommonOptions::get().evmVersion().hasBitwiseShifting()) | 	if (!solidity::test::CommonOptions::get().evmVersion().hasBitwiseShifting()) | ||||||
| 		return; | 		return; | ||||||
| 
 | 
 | ||||||
| 	for (int i = 1; i < 256; i++) | 	for (size_t i = 1; i < 256; i++) | ||||||
| 	{ | 	{ | ||||||
| 		checkCSE({ | 		checkCSE({ | ||||||
| 			u256(boost::multiprecision::pow(u256(2), i)-1), | 			u256(boost::multiprecision::pow(u256(2), i) - 1), | ||||||
| 			Instruction::CALLVALUE, | 			Instruction::CALLVALUE, | ||||||
| 			u256(256-i), | 			u256(256-i), | ||||||
| 			Instruction::SHR, | 			Instruction::SHR, | ||||||
| @ -1309,10 +1309,10 @@ BOOST_AUTO_TEST_CASE(cse_remove_redundant_shift_masking) | |||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	// Check that opt. does NOT trigger
 | 	// Check that opt. does NOT trigger
 | ||||||
| 	for (int i = 1; i < 255; i++) | 	for (size_t i = 1; i < 255; i++) | ||||||
| 	{ | 	{ | ||||||
| 		checkCSE({ | 		checkCSE({ | ||||||
| 			u256(boost::multiprecision::pow(u256(2), i)-1), | 			u256(boost::multiprecision::pow(u256(2), i) - 1), | ||||||
| 			Instruction::CALLVALUE, | 			Instruction::CALLVALUE, | ||||||
| 			u256(255-i), | 			u256(255-i), | ||||||
| 			Instruction::SHR, | 			Instruction::SHR, | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user