-
Notifications
You must be signed in to change notification settings - Fork 56
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
enable creating invalid programs #147
base: master
Are you sure you want to change the base?
Conversation
crates/polkavm-common/src/writer.rs
Outdated
if let InstructionOrBytes::Instruction(inst) = instruction { | ||
if inst.opcode().starts_new_basic_block() { | ||
basic_block_to_instruction_index.push(nth_instruction + 1); | ||
} |
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.
@koute This will pose a problem, if we ever would like to add a label to the instruction when writing a program in assembler, as load_imm_and_jump
is actually starting a new block but will not be taken into consideration when it is provided as bytes
.
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.
Hm, okay, good point. In that case maybe we could add a flag to the raw bytes to specify whether it's supposed to start a new basic block?
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.
Hm, yes. I will try it out and report back.
} else if let Some(offset) = parse_imm(line) { | ||
emit_and_continue!(MaybeInstruction::LoadImmAndJump(dst, value, TargetKind::Offset(offset))); |
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.
This should enforce that there's either a +
or a -
there at the start. (To make it explicit that this is supposed to be a relative offset, and not an absolute one like if a label is used.)
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.
Ah, got it now. Will make the parsing more strict.
No description provided.