mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge pull request #10315 from ethereum/fixToStorageCopy
[SolYul] Fix bug in array to storage copy routine.
This commit is contained in:
commit
df53b53aa5
@ -1542,7 +1542,7 @@ string YulUtilFunctions::copyArrayToStorageFunction(ArrayType const& _fromType,
|
|||||||
|
|
||||||
<updateStorageValue>(elementSlot<?isValueType>, elementOffset</isValueType>, <elementValues>)
|
<updateStorageValue>(elementSlot<?isValueType>, elementOffset</isValueType>, <elementValues>)
|
||||||
|
|
||||||
srcPtr := add(srcPtr, <stride>)
|
srcPtr := add(srcPtr, <srcStride>)
|
||||||
|
|
||||||
<?multipleItemsPerSlot>
|
<?multipleItemsPerSlot>
|
||||||
elementOffset := add(elementOffset, <storageStride>)
|
elementOffset := add(elementOffset, <storageStride>)
|
||||||
@ -1552,7 +1552,6 @@ string YulUtilFunctions::copyArrayToStorageFunction(ArrayType const& _fromType,
|
|||||||
}
|
}
|
||||||
<!multipleItemsPerSlot>
|
<!multipleItemsPerSlot>
|
||||||
elementSlot := add(elementSlot, <storageSize>)
|
elementSlot := add(elementSlot, <storageSize>)
|
||||||
elementOffset := 0
|
|
||||||
</multipleItemsPerSlot>
|
</multipleItemsPerSlot>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1568,7 +1567,6 @@ string YulUtilFunctions::copyArrayToStorageFunction(ArrayType const& _fromType,
|
|||||||
templ("fromCalldata", fromCalldata);
|
templ("fromCalldata", fromCalldata);
|
||||||
templ("isToDynamic", _toType.isDynamicallySized());
|
templ("isToDynamic", _toType.isDynamicallySized());
|
||||||
templ("srcDataLocation", arrayDataAreaFunction(_fromType));
|
templ("srcDataLocation", arrayDataAreaFunction(_fromType));
|
||||||
templ("isFromMemoryDynamic", _fromType.isDynamicallySized() && _fromType.dataStoredIn(DataLocation::Memory));
|
|
||||||
if (fromCalldata)
|
if (fromCalldata)
|
||||||
{
|
{
|
||||||
templ("dynamicallySizedBase", _fromType.baseType()->isDynamicallySized());
|
templ("dynamicallySizedBase", _fromType.baseType()->isDynamicallySized());
|
||||||
@ -1589,7 +1587,13 @@ string YulUtilFunctions::copyArrayToStorageFunction(ArrayType const& _fromType,
|
|||||||
_fromType.baseType()->stackItems().size()
|
_fromType.baseType()->stackItems().size()
|
||||||
));
|
));
|
||||||
templ("updateStorageValue", updateStorageValueFunction(*_fromType.baseType(), *_toType.baseType()));
|
templ("updateStorageValue", updateStorageValueFunction(*_fromType.baseType(), *_toType.baseType()));
|
||||||
templ("stride", to_string(fromCalldata ? _fromType.calldataStride() : _fromType.memoryStride()));
|
templ("srcStride",
|
||||||
|
fromCalldata ?
|
||||||
|
to_string(_fromType.calldataStride()) :
|
||||||
|
fromMemory ?
|
||||||
|
to_string(_fromType.memoryStride()) :
|
||||||
|
formatNumber(_fromType.baseType()->storageSize())
|
||||||
|
);
|
||||||
templ("multipleItemsPerSlot", _toType.storageStride() <= 16);
|
templ("multipleItemsPerSlot", _toType.storageStride() <= 16);
|
||||||
templ("storageStride", to_string(_toType.storageStride()));
|
templ("storageStride", to_string(_toType.storageStride()));
|
||||||
templ("storageSize", _toType.baseType()->storageSize().str());
|
templ("storageSize", _toType.baseType()->storageSize().str());
|
||||||
|
@ -11,5 +11,7 @@ contract c {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ====
|
||||||
|
// compileViaYul: also
|
||||||
// ----
|
// ----
|
||||||
// test(uint256[2][]): 32, 3, 7, 8, 9, 10, 11, 12 -> 10
|
// test(uint256[2][]): 32, 3, 7, 8, 9, 10, 11, 12 -> 10
|
||||||
|
@ -15,6 +15,8 @@ contract c {
|
|||||||
data2 = data1;
|
data2 = data1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// ====
|
||||||
|
// compileViaYul: also
|
||||||
// ----
|
// ----
|
||||||
// test() -> 4, 5
|
// test() -> 4, 5
|
||||||
// storage: empty
|
// storage: empty
|
||||||
|
Loading…
Reference in New Issue
Block a user