Skip to content

Commit 97712b8

Browse files
committed
Undo the last change set. I don't think I'm going to go forward with that setup because it's just adding overhead and compile size isn't a factor - if it becomes one then it can be mitigated by compression.
1 parent 5e012f8 commit 97712b8

File tree

1 file changed

+4
-25
lines changed

1 file changed

+4
-25
lines changed

redox-core/src/mem/memory_handler.rs

+4-25
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use prettytable::{row, Table};
33

44
use crate::{
55
ins::{instruction::Instruction, op_codes::OpCode},
6-
reg::registers::RegisterId, utils,
6+
reg::registers::RegisterId,
77
};
88

99
use super::mapped_memory::MappedMemory;
@@ -12,7 +12,7 @@ use super::mapped_memory::MappedMemory;
1212
pub const MEGABYTE: usize = 1024 * 1024;
1313

1414
/// The size of an instruction, in bytes.
15-
//pub const SIZE_OF_INSTRUCTION: usize = 4;
15+
pub const SIZE_OF_INSTRUCTION: usize = 4;
1616
/// The size of a u32 value, in bytes.
1717
pub const SIZE_OF_U32: usize = 4;
1818
/// The size of a f32 value, in bytes.
@@ -313,29 +313,8 @@ impl MemoryHandler {
313313
use Instruction as I;
314314
use OpCode as O;
315315

316-
let prefetch = self.get_range_clone(pos, 4);
317-
318-
let mut opcode_size = 1;
319-
let mut opcode_bits: [u8; 4] = [0; 4];
320-
opcode_bits[3] = prefetch[0];
321-
322-
if utils::is_bit_set_u8(prefetch[0], 8) {
323-
opcode_bits[2] = prefetch[1];
324-
opcode_size += 1;
325-
326-
if utils::is_bit_set_u8(prefetch[1], 8) {
327-
opcode_bits[1] = prefetch[2];
328-
opcode_size += 1;
329-
330-
if utils::is_bit_set_u8(prefetch[2], 8) {
331-
opcode_bits[0] = prefetch[3];
332-
opcode_size += 1;
333-
}
334-
}
335-
}
336-
337316
// Read the OpCode ID.
338-
let opcode_id = u32::from_le_bytes(opcode_bits);
317+
let opcode_id = self.get_u32(pos);
339318

340319
// Validate the opcode is one of the ones we know about.
341320
// In the case we encounter an unrecognized opcode ID then we will
@@ -347,7 +326,7 @@ impl MemoryHandler {
347326

348327
// We will assert here if we can't read enough bytes to meet the expected amount.
349328
// This means that subsequent "unsafe" reads are actually safe.
350-
let arg_bytes = self.get_range_ptr(pos + opcode_size, arg_len);
329+
let arg_bytes = self.get_range_ptr(pos + SIZE_OF_INSTRUCTION, arg_len);
351330

352331
let mut cursor = 0;
353332

0 commit comments

Comments
 (0)