-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Bytecode pseudo opcodes #6715
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
Bytecode pseudo opcodes #6715
Changes from 1 commit
fad76c6
af70361
ea53cec
1ca20a9
6f09ebe
6805175
046e17a
d627623
697fe41
11fc63f
33b4554
6140186
7acdc1a
0fad43f
24f5161
6e91410
8751953
8b73441
d6e46f8
0872cb6
0c7880d
1a5c72b
761fa4a
4eed137
8f777d2
bff25eb
91c01e6
f6a0b26
118ecf3
c517585
78958aa
a405cca
8ae98b2
1453726
f207284
a1555dc
c443f8e
453212e
1f8722a
0096a65
045d576
b00f81f
4823d17
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
repr(u16) for Instruction
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -887,7 +887,6 @@ impl InstructionMetadata for PseudoInstruction { | |
| } | ||
|
|
||
| #[derive(Clone, Copy, Debug)] | ||
| #[repr(u16)] | ||
| pub enum Instruction { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this type fit in u16? Otherwise union could be better
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ain't sure what you mean, could you please explain? And yes, this type fit in a
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please add
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I tried to add
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh, you are right! I didn't catch that.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
IMO yes it will. And we wouldn't gain a lot from it tbh as the instruction loop will only have
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you want me to remove the
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. hmm, if this is only used by compiler anyway, probably that could be better idea. I was originally thinking union Instruction {
real: RealInstruction,
pseudo: PseudoInstruction,
raw: u16,
}
impl Instruction {
fn real(&self) -> Option<RealInstruction> {
if self.raw < ... {
Some(...)
} else {
...
}
}
}btw, if The pseudo instruction is only used for compiler, vm only will have
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
While it's cool (and doable) I don't think we will gain much from doing that.
Sure, I can do that |
||
| Real(RealInstruction), | ||
| Pseudo(PseudoInstruction), | ||
|
|
||
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.
fmt_disforPseudoInstructionpanics unconditionally.This
unimplemented!()will panic ifInstruction::Pseudois ever formatted via theInstructionMetadatatrait (e.g., during debug/disassembly output). Consider providing a minimal implementation or at least usingtodo!("PseudoInstruction display not yet implemented")for a clearer error message.Minimal implementation suggestion
fn fmt_dis( &self, - _arg: OpArg, - _f: &mut fmt::Formatter<'_>, - _ctx: &impl InstrDisplayContext, + arg: OpArg, + f: &mut fmt::Formatter<'_>, + _ctx: &impl InstrDisplayContext, _expand_code_objects: bool, - _pad: usize, + pad: usize, _level: usize, ) -> fmt::Result { - unimplemented!() + match self { + Self::Jump { target } => write!(f, "{:pad$}({})", "JUMP", target.get(arg)), + Self::JumpNoInterrupt { target } => write!(f, "{:pad$}({})", "JUMP_NO_INTERRUPT", target.get(arg)), + Self::LoadAttrMethod { idx } => write!(f, "{:pad$}({})", "LOAD_ATTR_METHOD", idx.get(arg)), + Self::LoadSuperMethod { idx } => write!(f, "{:pad$}({})", "LOAD_SUPER_METHOD", idx.get(arg)), + Self::LoadZeroSuperAttr { idx } => write!(f, "{:pad$}({})", "LOAD_ZERO_SUPER_ATTR", idx.get(arg)), + Self::LoadZeroSuperMethod { idx } => write!(f, "{:pad$}({})", "LOAD_ZERO_SUPER_METHOD", idx.get(arg)), + Self::PopBlock => write!(f, "POP_BLOCK"), + _ => write!(f, "PSEUDO_PLACEHOLDER"), + } }📝 Committable suggestion
🤖 Prompt for AI Agents