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

enable creating invalid programs #147

Open
wants to merge 10 commits into
base: master
Choose a base branch
from

Conversation

subotic
Copy link
Contributor

@subotic subotic commented Jul 28, 2024

No description provided.

crates/polkavm-common/src/writer.rs Show resolved Hide resolved
crates/polkavm-common/src/writer.rs Outdated Show resolved Hide resolved
crates/polkavm-common/src/writer.rs Outdated Show resolved Hide resolved
crates/polkavm-common/src/writer.rs Outdated Show resolved Hide resolved
tools/spectool/spec/src/inst_load_imm_and_jump_nok___.txt Outdated Show resolved Hide resolved
Comment on lines 159 to 162
if let InstructionOrBytes::Instruction(inst) = instruction {
if inst.opcode().starts_new_basic_block() {
basic_block_to_instruction_index.push(nth_instruction + 1);
}
Copy link
Contributor Author

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.

Copy link
Collaborator

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?

Copy link
Contributor Author

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.

Comment on lines 389 to 390
} else if let Some(offset) = parse_imm(line) {
emit_and_continue!(MaybeInstruction::LoadImmAndJump(dst, value, TargetKind::Offset(offset)));
Copy link
Collaborator

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.)

Copy link
Contributor Author

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.

@subotic subotic marked this pull request as ready for review September 8, 2024 19:14
@subotic subotic requested a review from koute September 8, 2024 19:14
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.

2 participants