Skip to content

Commit 07d019a

Browse files
committed
let ir to decide exception depth
1 parent fb7c109 commit 07d019a

File tree

2 files changed

+15
-18
lines changed

2 files changed

+15
-18
lines changed

crates/codegen/src/compile.rs

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1277,9 +1277,7 @@ impl Compiler {
12771277
context: OpArgMarker::marker(),
12781278
}
12791279
.into(),
1280-
arg: OpArg::new(
1281-
oparg::ResumeContext::new(oparg::ResumeLocation::AtFuncStart, false).into(),
1282-
),
1280+
arg: OpArg::new(oparg::ResumeLocation::AtFuncStart.into()),
12831281
target: BlockIdx::NULL,
12841282
location,
12851283
end_location,
@@ -7201,14 +7199,11 @@ impl Compiler {
72017199
emit!(
72027200
self,
72037201
Instruction::Resume {
7204-
context: oparg::ResumeContext::new(
7205-
if is_await {
7206-
oparg::ResumeLocation::AfterAwait
7207-
} else {
7208-
oparg::ResumeLocation::AfterYieldFrom
7209-
},
7210-
false
7211-
)
7202+
context: if is_await {
7203+
oparg::ResumeContext::from(oparg::ResumeLocation::AfterAwait)
7204+
} else {
7205+
oparg::ResumeContext::from(oparg::ResumeLocation::AfterYieldFrom)
7206+
}
72127207
}
72137208
);
72147209

@@ -7379,10 +7374,7 @@ impl Compiler {
73797374
emit!(
73807375
self,
73817376
Instruction::Resume {
7382-
context: oparg::ResumeContext::new(
7383-
oparg::ResumeLocation::AfterYield,
7384-
true, // TODO: Is this always true?
7385-
)
7377+
context: oparg::ResumeContext::from(oparg::ResumeLocation::AfterYield)
73867378
}
73877379
);
73887380
}
@@ -7604,9 +7596,8 @@ impl Compiler {
76047596
emit!(
76057597
compiler,
76067598
Instruction::Resume {
7607-
context: oparg::ResumeContext::new(
7608-
oparg::ResumeLocation::AfterYield,
7609-
true, // TODO: Is this always true?
7599+
context: oparg::ResumeContext::from(
7600+
oparg::ResumeLocation::AfterYield
76107601
)
76117602
}
76127603
);

crates/compiler-core/src/bytecode/oparg.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -850,6 +850,12 @@ pub enum ResumeLocation {
850850
AfterAwait,
851851
}
852852

853+
impl From<ResumeLocation> for ResumeContext {
854+
fn from(location: ResumeLocation) -> Self {
855+
Self::new(location, false)
856+
}
857+
}
858+
853859
impl TryFrom<u32> for ResumeLocation {
854860
type Error = MarshalError;
855861

0 commit comments

Comments
 (0)