-
Notifications
You must be signed in to change notification settings - Fork 1k
deduplication for COPY operations #1655
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from 1 commit
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
9d196f3
add copy_cost for *COPY operations
harsh-ps-2003 6b15eee
seperate common logic of opcodes to a method
harsh-ps-2003 1b72873
fmt nit
harsh-ps-2003 0453a50
performance nit
harsh-ps-2003 9c685ad
fmt nit
harsh-ps-2003 dbc2d57
test nits
harsh-ps-2003 1474059
fmt nit
harsh-ps-2003 a1a488b
refactor
harsh-ps-2003 f92ff49
Merge branch 'bluealloy:main' into copycode
harsh-ps-2003 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
performance nit
- Loading branch information
commit 0453a5015a830202e6611e387499bb405eb19317
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -42,8 +42,8 @@ pub fn codecopy<H: Host + ?Sized>(interpreter: &mut Interpreter, _host: &mut H) | |
| let len = as_usize_or_fail!(interpreter, len); | ||
| // Inform the optimizer that the bytecode cannot be EOF to remove a bounds check. | ||
| assume!(!interpreter.contract.bytecode.is_eof()); | ||
| let source = interpreter.contract.bytecode.original_byte_slice().to_vec(); | ||
| copy_to_memory(interpreter, memory_offset, code_offset, len, &source); | ||
| let source = interpreter.contract.bytecode.original_byte_slice().as_ptr(); | ||
| copy_to_memory(interpreter, memory_offset, code_offset, len, source); | ||
| } | ||
|
|
||
| pub fn calldataload<H: Host + ?Sized>(interpreter: &mut Interpreter, _host: &mut H) { | ||
|
|
@@ -83,8 +83,8 @@ pub fn calldatacopy<H: Host + ?Sized>(interpreter: &mut Interpreter, _host: &mut | |
| pop!(interpreter, memory_offset, data_offset, len); | ||
| let len = as_usize_or_fail!(interpreter, len); | ||
| let data_offset = as_usize_saturated!(data_offset); | ||
| let source = interpreter.contract.input.to_vec(); | ||
| copy_to_memory(interpreter, memory_offset, data_offset, len, &source); | ||
| let source = interpreter.contract.input.as_ptr(); | ||
| copy_to_memory(interpreter, memory_offset, data_offset, len, source); | ||
| } | ||
|
|
||
| /// EIP-211: New opcodes: RETURNDATASIZE and RETURNDATACOPY | ||
|
|
@@ -113,8 +113,8 @@ pub fn returndatacopy<H: Host + ?Sized, SPEC: Spec>(interpreter: &mut Interprete | |
| return; | ||
| } | ||
|
|
||
| let source = interpreter.return_data_buffer.to_vec(); | ||
| copy_to_memory(interpreter, memory_offset, data_offset, len, &source); | ||
| let source = interpreter.return_data_buffer.as_ptr(); | ||
| copy_to_memory(interpreter, memory_offset, data_offset, len, source); | ||
| } | ||
|
|
||
| /// Part of EOF `<https://eips.ethereum.org/EIPS/eip-7069>`. | ||
|
|
@@ -145,7 +145,7 @@ fn copy_to_memory( | |
| memory_offset: U256, | ||
| data_offset: usize, | ||
| len: usize, | ||
| source: &[u8], | ||
| source: *const u8, | ||
| ) { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would return a Without return function silently fails, and can work only if it is in the last line of instruction. |
||
| gas_or_fail!(interpreter, gas::verylowcopy_cost(len as u64)); | ||
| if len == 0 { | ||
|
|
@@ -155,9 +155,11 @@ fn copy_to_memory( | |
| resize_memory!(interpreter, memory_offset, len); | ||
|
|
||
| // Note: this can't panic because we resized memory to fit. | ||
| interpreter | ||
| .shared_memory | ||
| .set_data(memory_offset, data_offset, len, source); | ||
| unsafe { | ||
| interpreter | ||
| .shared_memory | ||
| .set_data(memory_offset, data_offset, len, std::slice::from_raw_parts(source, len)); | ||
| } | ||
| } | ||
|
|
||
| pub fn gas<H: Host + ?Sized>(interpreter: &mut Interpreter, _host: &mut H) { | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
source's length is notlen, this should be*const [u8]. This is why tests are failing