From 60448ce3c9eeee98c4c200f64752942a77c12885 Mon Sep 17 00:00:00 2001 From: chenqy930 Date: Mon, 18 Jul 2022 15:38:24 +0800 Subject: [PATCH] Implement insn rethrow for es2abc Issue: I5IV68 Signed-off-by: chenqy930 Change-Id: Ic35c4d07ead555cdf6cee5fd04c2eddb3ca8828d --- es2panda/compiler/core/pandagen.cpp | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/es2panda/compiler/core/pandagen.cpp b/es2panda/compiler/core/pandagen.cpp index 7cf1bb96f5..972c8b710b 100644 --- a/es2panda/compiler/core/pandagen.cpp +++ b/es2panda/compiler/core/pandagen.cpp @@ -825,7 +825,25 @@ void PandaGen::EmitThrow(const ir::AstNode *node) void PandaGen::EmitRethrow(const ir::AstNode *node) { - // TODO: rethrow in try-catch + RegScope rs(this); + auto *skipThrow = AllocLabel(); + auto *doThrow = AllocLabel(); + + VReg exception = AllocReg(); + StoreAccumulator(node, exception); + + VReg hole = AllocReg(); + StoreConst(node, hole, Constant::JS_HOLE); + + LoadAccumulator(node, exception); + ra_.Emit(node, hole); + sa_.Emit(node, skipThrow); + + SetLabel(node, doThrow); + LoadAccumulator(node, exception); + sa_.Emit(node); + + SetLabel(node, skipThrow); } void PandaGen::EmitReturn(const ir::AstNode *node) -- Gitee