Skip to content

Commit

Permalink
review 4
Browse files Browse the repository at this point in the history
  • Loading branch information
nagisa committed Jun 28, 2023
1 parent 4d90cf5 commit 43d1e69
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
3 changes: 2 additions & 1 deletion runtime/near-vm/engine/src/universal/code_memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,8 @@ pub struct CodeMemory {

/// Addresses `0..executable_end` contain executable memory.
///
/// This is always be page-aligned.
/// In a populated buffer rounding this up to the next page will give the address of the
/// read-write data portion of this memory.
executable_end: usize,
}

Expand Down
6 changes: 3 additions & 3 deletions runtime/near-vm/engine/src/universal/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -567,14 +567,14 @@ impl UniversalEngineInner {
let page_size = rustix::param::page_size();
let total_len = 0;
let total_len = function_bodies.iter().fold(total_len, |acc, func| {
round_up(acc + function_allocation_size(*func), ARCH_FUNCTION_ALIGNMENT.into())
round_up(acc, ARCH_FUNCTION_ALIGNMENT.into()) + function_allocation_size(*func)
});
let total_len = executable_sections.iter().fold(total_len, |acc, exec| {
round_up(acc + exec.bytes.len(), ARCH_FUNCTION_ALIGNMENT.into())
round_up(acc, ARCH_FUNCTION_ALIGNMENT.into()) + exec.bytes.len()
});
let total_len = round_up(total_len, page_size);
let total_len = data_sections.iter().fold(total_len, |acc, data| {
round_up(acc + data.bytes.len(), DATA_SECTION_ALIGNMENT.into())
round_up(acc, DATA_SECTION_ALIGNMENT.into()) + data.bytes.len()
});

let mut code_memory = code_memory_pool.get(total_len).map_err(|e| {
Expand Down

0 comments on commit 43d1e69

Please sign in to comment.