forked from facebook/hermes
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Show source location in stacktrace after bound function call.
Summary: In order to handle the clobbering of the stacktraces of bound functions, we look up the register stack to the caller's frame, and use the caller's "callee code block" instead of using the `savedCodeBlock` in the callee. We must also store the saved IP in the callee frame, but because we have a `null` `SavedCodeBlock`, we can use that as an indicator to still return as if we were executing a native function call. Reviewed By: tmikov, motiz88 Differential Revision: D17665340 fbshipit-source-id: 5e8ee86bffd8e3539230eb2321f3675d7ebc5ac3
- Loading branch information
1 parent
f5d717a
commit 037f8c4
Showing
11 changed files
with
107 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
backtrace | ||
continue | ||
backtrace | ||
continue |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// Copyright (c) Facebook, Inc. and its affiliates. | ||
// | ||
// This source code is licensed under the MIT license found in the LICENSE | ||
// file in the root directory of this source tree. | ||
// | ||
// RUN: %hermes -O -fno-inline %s | %FileCheck --match-full-lines %s | ||
|
||
function foo() { | ||
throw new Error("qwerty"); | ||
} | ||
|
||
try { foo() } catch (e) { print(e.stack) } | ||
// CHECK: Error: qwerty | ||
// CHECK-NEXT: at foo ({{.*}}/stacktrace-bound.js:9:18) | ||
// CHECK-NEXT: at global ({{.*}}/stacktrace-bound.js:12:10) | ||
|
||
try { foo.bind(null)() } catch (e) { print(e.stack) } | ||
// CHECK: Error: qwerty | ||
// CHECK-NEXT: at foo ({{.*}}/stacktrace-bound.js:9:18) | ||
// CHECK-NEXT: at global ({{.*}}/stacktrace-bound.js:17:21) | ||
|
||
try { foo.bind(null).bind(null)() } catch (e) { print(e.stack) } | ||
// CHECK: Error: qwerty | ||
// CHECK-NEXT: at foo ({{.*}}/stacktrace-bound.js:9:18) | ||
// CHECK-NEXT: at global ({{.*}}/stacktrace-bound.js:22:32) | ||
|
||
function chain1() { | ||
chain2bound(); | ||
} | ||
|
||
function chain2() { | ||
throw new Error("asdf"); | ||
} | ||
|
||
var chain2bound = chain2.bind(null); | ||
|
||
try { chain1.bind(null)() } catch (e) { print(e.stack) } | ||
// CHECK: Error: asdf | ||
// CHECK-NEXT: at chain2 ({{.*}}/stacktrace-bound.js:32:18) | ||
// CHECK-NEXT: at chain1 ({{.*}}/stacktrace-bound.js:28:14) | ||
// CHECK-NEXT: at global ({{.*}}/stacktrace-bound.js:37:24) |