Skip to content

Commit e89c602

Browse files
Fix_zero_offset_output_base_assumption
1 parent 03bc24f commit e89c602

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

vm/src/vm/runners/builtin_runner/output.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ pub struct OutputBuiltinState {
1414
pub base: usize,
1515
pub pages: Pages,
1616
pub attributes: Attributes,
17+
pub base_offset: usize,
1718
}
1819

1920
#[derive(Debug, Clone)]
@@ -23,6 +24,7 @@ pub struct OutputBuiltinRunner {
2324
pub(crate) attributes: Attributes,
2425
pub(crate) stop_ptr: Option<usize>,
2526
pub(crate) included: bool,
27+
pub base_offset: usize,
2628
}
2729

2830
impl OutputBuiltinRunner {
@@ -33,15 +35,17 @@ impl OutputBuiltinRunner {
3335
attributes: HashMap::default(),
3436
stop_ptr: None,
3537
included,
38+
base_offset: 0,
3639
}
3740
}
3841

39-
pub fn new_state(&mut self, base: usize, included: bool) {
42+
pub fn new_state(&mut self, base: usize, included: bool, base_offset: usize) {
4043
self.base = base;
4144
self.pages = HashMap::default();
4245
self.attributes = HashMap::default();
4346
self.stop_ptr = None;
4447
self.included = included;
48+
self.base_offset = base_offset;
4549
}
4650

4751
pub fn initialize_segments(&mut self, segments: &mut MemorySegmentManager) {
@@ -145,13 +149,15 @@ impl OutputBuiltinRunner {
145149
self.base = new_state.base;
146150
self.pages = new_state.pages;
147151
self.attributes = new_state.attributes;
152+
self.base_offset = new_state.base_offset;
148153
}
149154

150155
pub fn get_state(&mut self) -> OutputBuiltinState {
151156
OutputBuiltinState {
152157
base: self.base,
153158
pages: self.pages.clone(),
154159
attributes: self.attributes.clone(),
160+
base_offset: self.base_offset,
155161
}
156162
}
157163

@@ -168,7 +174,7 @@ impl OutputBuiltinRunner {
168174
self.pages.insert(
169175
page_id,
170176
PublicMemoryPage {
171-
start: page_start.offset,
177+
start: page_start.offset - self.base_offset,
172178
size: page_size,
173179
},
174180
);

0 commit comments

Comments
 (0)