Skip to content
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

Refactored flexible memory implementation #378

Merged
merged 12 commits into from
Nov 8, 2023

Conversation

mohanson
Copy link
Collaborator

@mohanson mohanson commented Aug 24, 2023

The current dynamic memory implementation has several problems:

  • The alloced memory size is inconsistent with the actual size of the AsmCoreMachine structure. Although no bugs have been found so far, bugs may occur in the future.
  • No matter what the memory size is set to, flags and frames are always alloced according to the 4M memory size.

This PR will make AsmCoreMachine accept memory ptr, flags ptr and frames ptr instead of memory u8 array, flags array and frames array.

@mohanson mohanson changed the title [WIP] Refactored dynamic memory implementation Refactored dynamic memory implementation Aug 28, 2023
@mohanson mohanson requested a review from xxuejie August 28, 2023 01:58
src/machine/asm/mod.rs Outdated Show resolved Hide resolved
src/machine/asm/mod.rs Outdated Show resolved Hide resolved
@mohanson mohanson changed the title Refactored dynamic memory implementation Refactored flexibal memory implementation Oct 26, 2023
@XuJiandong XuJiandong changed the title Refactored flexibal memory implementation Refactored flexible memory implementation Oct 27, 2023
machine
}

pub fn set_max_cycles(&mut self, cycles: u64) {
self.max_cycles = cycles;
}
}

impl AsmCoreMachine {
pub fn cast_ptr_to_slice(&self, ptr: u64, offset: usize, size: usize) -> &[u8] {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

&self is not needed.

}
}

pub fn cast_ptr_to_slice_mut(&self, ptr: u64, offset: usize, size: usize) -> &mut [u8] {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

&self is not needed.

@mohanson mohanson merged commit 11a59cf into nervosnetwork:develop Nov 8, 2023
11 checks passed
@mohanson mohanson deleted the dynmem branch November 8, 2023 02:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants