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.
Add source visibility support for lazy and S/D
Summary: The tricky case was to support `toString` on lazy function that haven't been invoked once (hence not parsed/compiled yet). Luckily, previous diffs had already set up everything. Before this diff, we already recorded directives from the preParse pass and restore the directive nodes for lazy function in lazyParse, and SemanticValidator will compute sourceVisibility for lazy functions no different with any other non-lazy functions. That means, lazy function with non-normal sources have already been reserved ahead of time in the "root" bytecode module. So the only thing this diff is doing is to make the `toString` implementation looking for lazy root bc module instead. To make sure source visibility works for S/D, we also need to specialize `getLazyRootModule` return the root RM under S/D. Note that lazy and S/D are not intended to work together. Reviewed By: avp Differential Revision: D26796465 fbshipit-source-id: e847422ba5a177124d763b00690176d10350b2fb
- Loading branch information
1 parent
d7c7752
commit 6a4b95a
Showing
10 changed files
with
46 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/** | ||
* 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 -non-strict -O0 %s 2>&1 | %FileCheck --match-full-lines %s | ||
// RUN: %hermes -lazy -non-strict -O0 %s 2>&1 | %FileCheck --match-full-lines %s | ||
// UNSUPPORTED: serializer | ||
|
||
// foo is never called, but its source needs to be reserved ahead of time. | ||
function foo(x) { "show source"; } | ||
|
||
(function bar() { | ||
print(foo.toString()); | ||
// CHECK: function foo(x) { "show source"; } | ||
})() |
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