remove unnecessary framePtr code (#19645)

(cherry picked from commit afbcba909b)
This commit is contained in:
flywind
2022-03-25 17:46:42 +08:00
committed by narimiran
parent ea69f04cc7
commit 31f7b17dd0
2 changed files with 8 additions and 4 deletions

View File

@@ -773,7 +773,8 @@ proc genTry(p: PProc, n: PNode, r: var TCompRes) =
var tmpFramePtr = rope"F"
if optStackTrace notin p.options:
tmpFramePtr = p.getTemp(true)
line(p, tmpFramePtr & " = framePtr;\L")
if hasFrameInfo(p):
line(p, tmpFramePtr & " = framePtr;\L")
lineF(p, "try {$n", [])
var a: TCompRes
gen(p, n[0], a)
@@ -782,7 +783,8 @@ proc genTry(p: PProc, n: PNode, r: var TCompRes) =
if catchBranchesExist:
p.body.addf("--excHandler;$n} catch (EXCEPTION) {$n var prevJSError = lastJSError;$n" &
" lastJSError = EXCEPTION;$n --excHandler;$n", [])
line(p, "framePtr = $1;$n" % [tmpFramePtr])
if hasFrameInfo(p):
line(p, "framePtr = $1;$n" % [tmpFramePtr])
while i < n.len and n[i].kind == nkExceptBranch:
if n[i].len == 1:
# general except section:
@@ -841,7 +843,8 @@ proc genTry(p: PProc, n: PNode, r: var TCompRes) =
line(p, "}\L")
lineF(p, "lastJSError = prevJSError;$n")
line(p, "} finally {\L")
line(p, "framePtr = $1;$n" % [tmpFramePtr])
if hasFrameInfo(p):
line(p, "framePtr = $1;$n" % [tmpFramePtr])
if i < n.len and n[i].kind == nkFinally:
genStmt(p, n[i][0])
line(p, "}\L")

View File

@@ -130,7 +130,8 @@ proc unhandledException(e: ref Exception) {.
when NimStackTrace:
add(buf, rawWriteStackTrace())
let cbuf = cstring(buf)
framePtr = nil
when NimStackTrace:
framePtr = nil
{.emit: """
if (typeof(Error) !== "undefined") {
throw new Error(`cbuf`);