Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughAdds a public Changes
Sequence Diagram(s)(omitted) Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 1 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
📝 Coding Plan
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
crates/compiler-core/src/bytecode/instruction.rs (1)
1713-1713: Minor style inconsistency:PopBlockhas no fields.
PopBlockis defined as a unit variant (line 1608), so the{ .. }pattern is unnecessary. Other unit-like matches in this block don't use this pattern.Proposed fix
- Self::PopBlock { .. } => "POP_BLOCK", + Self::PopBlock => "POP_BLOCK",🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@crates/compiler-core/src/bytecode/instruction.rs` at line 1713, The match arm for the enum variant PopBlock unnecessarily uses a struct pattern with `{ .. }`; update the pattern in the match (the arm mapping to "POP_BLOCK") from Self::PopBlock { .. } to the unit pattern Self::PopBlock so it matches the unit variant definition of PopBlock in the Instruction enum.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@crates/compiler-core/src/bytecode/instruction.rs`:
- Line 1248: The match arm for Self::CallMethodDescriptorO returns the wrong
opcode name; update the returned string from "CALL_METHOD_DESCRIPTOR" to
"CALL_METHOD_DESCRIPTOR_O" so the name matches the enum variant
CallMethodDescriptorO and CPython 3.14 naming; locate the mapping in
instruction.rs where CallMethodDescriptorO is handled and change the string
literal accordingly.
- Line 1236: The match arm for the opcode name is returning the wrong string for
the enum variant Self::CallBuiltinO; update the returned name from
"CALL_BUILTIN" to "CALL_BUILTIN_O" in the function that maps instructions to
their names (the match arm handling Self::CallBuiltinO) so the opcode string
matches the enum variant and CPython 3.14 naming.
---
Nitpick comments:
In `@crates/compiler-core/src/bytecode/instruction.rs`:
- Line 1713: The match arm for the enum variant PopBlock unnecessarily uses a
struct pattern with `{ .. }`; update the pattern in the match (the arm mapping
to "POP_BLOCK") from Self::PopBlock { .. } to the unit pattern Self::PopBlock so
it matches the unit variant definition of PopBlock in the Instruction enum.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yml
Review profile: CHILL
Plan: Pro
Run ID: f06d764e-9e82-49fb-9879-9fd028212ffa
📒 Files selected for processing (1)
crates/compiler-core/src/bytecode/instruction.rs
edf5793 to
ebbcc89
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@crates/compiler-core/src/bytecode/instruction.rs`:
- Line 1248: The returned opcode name mismatches the enum variant
Self::CallMethodDescriptorO by using a digit "0" instead of letter "O"; update
the string literal "CALL_METHOD_DESCRIPTOR_0" to "CALL_METHOD_DESCRIPTOR_O" in
the match arm for CallMethodDescriptorO so the opcode name matches the enum
variant and CPython 3.14 naming convention.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yml
Review profile: CHILL
Plan: Pro
Run ID: e0bbe3dc-727e-40f5-aec1-8953371dc951
📒 Files selected for processing (1)
crates/compiler-core/src/bytecode/instruction.rs
ebbcc89 to
ffe1708
Compare
There was a problem hiding this comment.
🧹 Nitpick comments (1)
crates/compiler-core/src/bytecode/instruction.rs (1)
1705-1719: Minor style inconsistency in pattern matching.Line 1713 uses
Self::PopBlock { .. }butPopBlockis a unit variant (no fields). While valid Rust, this is inconsistent with line 1707 whereSelf::AnnotationsPlaceholder(also a unit variant) uses no braces.Optional: Use consistent pattern style
- Self::PopBlock { .. } => "POP_BLOCK", + Self::PopBlock => "POP_BLOCK",🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@crates/compiler-core/src/bytecode/instruction.rs` around lines 1705 - 1719, The pattern match in the name() method mixes unit-variant style and struct-like style; change the unit variant match Self::PopBlock { .. } to the consistent unit pattern Self::PopBlock (same style as Self::AnnotationsPlaceholder) inside the name() function so all unit variants use the same pattern form.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@crates/compiler-core/src/bytecode/instruction.rs`:
- Around line 1705-1719: The pattern match in the name() method mixes
unit-variant style and struct-like style; change the unit variant match
Self::PopBlock { .. } to the consistent unit pattern Self::PopBlock (same style
as Self::AnnotationsPlaceholder) inside the name() function so all unit variants
use the same pattern form.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yml
Review profile: CHILL
Plan: Pro
Run ID: cbbc07cf-671c-4202-9a08-e334c4503173
📒 Files selected for processing (1)
crates/compiler-core/src/bytecode/instruction.rs
ffe1708 to
1ff97e5
Compare
There was a problem hiding this comment.
🧹 Nitpick comments (1)
crates/compiler-core/src/bytecode/instruction.rs (1)
1479-1508: Consider extracting commonLoadGlobal*formatting logic.The formatting logic for
LoadGlobal,LoadGlobalBuiltin, andLoadGlobalModuleis nearly identical. Per coding guidelines, when branches share common logic differing only in value, consider extracting to avoid duplication.♻️ Suggested refactor
- Self::LoadGlobal { namei } => { - let oparg = namei.get(arg); - let name_idx = oparg >> 1; - let opname = self.name(); - if (oparg & 1) != 0 { - write!(f, "{:pad$}({}, NULL + {})", opname, oparg, name(name_idx)) - } else { - write!(f, "{:pad$}({}, {})", opname, oparg, name(name_idx)) - } - } - Self::LoadGlobalBuiltin => { - let oparg = u32::from(arg); - let name_idx = oparg >> 1; - let opname = self.name(); - if (oparg & 1) != 0 { - write!(f, "{:pad$}({}, NULL + {})", opname, oparg, name(name_idx)) - } else { - write!(f, "{:pad$}({}, {})", opname, oparg, name(name_idx)) - } - } - Self::LoadGlobalModule => { - let oparg = u32::from(arg); - let name_idx = oparg >> 1; - let opname = self.name(); - if (oparg & 1) != 0 { - write!(f, "{:pad$}({}, NULL + {})", opname, oparg, name(name_idx)) - } else { - write!(f, "{:pad$}({}, {})", opname, oparg, name(name_idx)) - } - } + Self::LoadGlobal { namei } => { + let oparg = namei.get(arg); + fmt_load_global(f, self.name(), oparg, name(oparg >> 1), pad) + } + Self::LoadGlobalBuiltin | Self::LoadGlobalModule => { + let oparg = u32::from(arg); + fmt_load_global(f, self.name(), oparg, name(oparg >> 1), pad) + }Where
fmt_load_globalis a local closure or helper:let fmt_load_global = |f: &mut fmt::Formatter<'_>, opname: &str, oparg: u32, resolved_name: &str, pad: usize| -> fmt::Result { if (oparg & 1) != 0 { write!(f, "{:pad$}({}, NULL + {})", opname, oparg, resolved_name) } else { write!(f, "{:pad$}({}, {})", opname, oparg, resolved_name) } };As per coding guidelines: "When branches differ only in a value but share common logic, extract the differing value first, then call the common logic once to avoid duplicate code."
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@crates/compiler-core/src/bytecode/instruction.rs` around lines 1479 - 1508, The three match arms Self::LoadGlobal, Self::LoadGlobalBuiltin, and Self::LoadGlobalModule duplicate identical formatting logic; extract the shared formatting into a small helper or closure (e.g., fmt_load_global) that accepts opname (from self.name()), oparg (u32 from arg), resolved_name (result of name(name_idx)) and pad, then call that helper from each arm after computing name_idx and converting arg as needed; ensure you reuse the existing write!(f, ...) calls inside the helper so each arm only computes its specific inputs and invokes fmt_load_global.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@crates/compiler-core/src/bytecode/instruction.rs`:
- Around line 1479-1508: The three match arms Self::LoadGlobal,
Self::LoadGlobalBuiltin, and Self::LoadGlobalModule duplicate identical
formatting logic; extract the shared formatting into a small helper or closure
(e.g., fmt_load_global) that accepts opname (from self.name()), oparg (u32 from
arg), resolved_name (result of name(name_idx)) and pad, then call that helper
from each arm after computing name_idx and converting arg as needed; ensure you
reuse the existing write!(f, ...) calls inside the helper so each arm only
computes its specific inputs and invokes fmt_load_global.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yml
Review profile: CHILL
Plan: Pro
Run ID: 9e29d217-1308-40ca-acf8-648f6853f03e
📒 Files selected for processing (1)
crates/compiler-core/src/bytecode/instruction.rs
youknowone
left a comment
There was a problem hiding this comment.
Could you explain more about the motivation? The metadata seems to be described in a single function before. Now we have to edit 2 places to edit the instruction. There must be benefits to justify this inconvenience
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@crates/compiler-core/src/bytecode/instruction.rs`:
- Around line 1552-1556: The StoreFastLoadFast display arm currently writes an
extra leading space and prints raw indices; change it to match the other arms by
removing the extra leading space in the format string (use "{:pad$}" instead of
" {:pad$}") and resolve the indices to variable names before printing (use the
same resolution helper used by LoadFastLoadFast/StoreFastStoreFast on
var_nums.get(arg) to obtain store_name and load_name, then write them as
"opname{:pad$}({store_name}, {load_name})"). Ensure you still call
var_nums.get(arg) and extract the two positions but format the output with
names, not numeric indexes.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yml
Review profile: CHILL
Plan: Pro
Run ID: 9da50c58-8802-4a52-9193-6060e6fa4226
📒 Files selected for processing (1)
crates/compiler-core/src/bytecode/instruction.rs
| Self::StoreFastLoadFast { var_nums } => { | ||
| let oparg = var_nums.get(arg); | ||
| let (store_idx, load_idx) = oparg.indexes(); | ||
| write!(f, "STORE_FAST_LOAD_FAST")?; | ||
| write!(f, " ({}, {})", store_idx, load_idx) | ||
| write!(f, " {:pad$}({}, {})", opname, store_idx, load_idx) | ||
| } |
There was a problem hiding this comment.
Formatting inconsistencies in StoreFastLoadFast display.
Two issues:
- Extra leading space in
{:pad$}causes misaligned disassembly output. - Outputs raw indices instead of resolved variable names, unlike
LoadFastLoadFastandStoreFastStoreFast.
Proposed fix
Self::StoreFastLoadFast { var_nums } => {
let oparg = var_nums.get(arg);
let (store_idx, load_idx) = oparg.indexes();
- write!(f, " {:pad$}({}, {})", opname, store_idx, load_idx)
+ write!(f, "{:pad$}({}, {})", opname, varname(store_idx), varname(load_idx))
}🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@crates/compiler-core/src/bytecode/instruction.rs` around lines 1552 - 1556,
The StoreFastLoadFast display arm currently writes an extra leading space and
prints raw indices; change it to match the other arms by removing the extra
leading space in the format string (use "{:pad$}" instead of " {:pad$}") and
resolve the indices to variable names before printing (use the same resolution
helper used by LoadFastLoadFast/StoreFastStoreFast on var_nums.get(arg) to
obtain store_name and load_name, then write them as "opname{:pad$}({store_name},
{load_name})"). Ensure you still call var_nums.get(arg) and extract the two
positions but format the output with names, not numeric indexes.
ofc, I was working on auto-generating the rust code for the opcodes (and methods). This change is extracted from those changes so the final PR wouldn't be that big. I guess it would have made more sense to implement |
Summary by CodeRabbit