remove unnecessary framePtr code (#19645)

This commit is contained in:
flywind 2022-03-25 17:46:42 +08:00 • committed by GitHub
commit afbcba909b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 4 deletions

View file

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

View file

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