Skip to content

Commit

Permalink
Treat TDZ checks as unsupported
Browse files Browse the repository at this point in the history
Summary:
TDZ checks are unsupported and not fully tested. They should not be
encouraged for production use.

Reviewed By: tmikov

Differential Revision: D31778780

fbshipit-source-id: 0448b2406828677e96e488b4888994b586aa2d25
  • Loading branch information
neildhar authored and facebook-github-bot committed Oct 20, 2021
1 parent 5be5dcd commit f811a0e
Show file tree
Hide file tree
Showing 9 changed files with 17 additions and 17 deletions.
12 changes: 6 additions & 6 deletions lib/CompilerDriver/CompilerDriver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -514,12 +514,12 @@ static CLFlag StripFunctionNames(
"Strip function names to reduce string table size",
CompilerCategory);

static CLFlag EnableTDZ(
'f',
"enable-tdz",
false,
"Enable TDZ checks for let/const",
CompilerCategory);
static opt<bool> EnableTDZ(
"Xenable-tdz",
init(false),
Hidden,
desc("UNSUPPORTED: Enable TDZ checks for let/const"),
cat(CompilerCategory));

#define WARNING_CATEGORY(name, specifier, description) \
static CLFlag name##Warning( \
Expand Down
2 changes: 1 addition & 1 deletion lib/InternalBytecode/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ add_custom_command(
# Compile the one source file to Hermes bytecode.
add_custom_command(
OUTPUT InternalBytecode.hbc
COMMAND ${hermesc_EXE} ${JS_COMPILER_FLAGS} -fno-enable-tdz -emit-binary -out=${CMAKE_CURRENT_BINARY_DIR}/InternalBytecode.hbc ${CMAKE_CURRENT_BINARY_DIR}/InternalBytecode.js
COMMAND ${hermesc_EXE} ${JS_COMPILER_FLAGS} -emit-binary -out=${CMAKE_CURRENT_BINARY_DIR}/InternalBytecode.hbc ${CMAKE_CURRENT_BINARY_DIR}/InternalBytecode.js
DEPENDS ${hermesc_EXE} InternalBytecode.js
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
VERBATIM
Expand Down
2 changes: 1 addition & 1 deletion test/BCGen/HBC/es6/tdz-check.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* LICENSE file in the root directory of this source tree.
*/

// RUN: %hermes -fenable-tdz -O0 -target=HBC -dump-bytecode %s | %FileCheck --match-full-lines %s
// RUN: %hermes -Xenable-tdz -O0 -target=HBC -dump-bytecode %s | %FileCheck --match-full-lines %s

function foo() {
return x;
Expand Down
2 changes: 1 addition & 1 deletion test/FlowParser/simple-let-const.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* LICENSE file in the root directory of this source tree.
*/

// RUN: %hermesc -fenable-tdz -Xflow-parser -dump-ir -O0 %s | %FileCheck --match-full-lines %s
// RUN: %hermesc -Xenable-tdz -Xflow-parser -dump-ir -O0 %s | %FileCheck --match-full-lines %s
// REQUIRES: flowparser

function foo() {
Expand Down
4 changes: 2 additions & 2 deletions test/IRGen/es6/disable-tdz.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
* LICENSE file in the root directory of this source tree.
*/

// RUN: %hermesc -O0 -fenable-tdz -dump-ir %s | %FileCheck --match-full-lines %s
// RUN: %hermesc -O0 -fno-enable-tdz -dump-ir %s | %FileCheck --match-full-lines --check-prefix=CHKDIS %s
// RUN: %hermesc -O0 -Xenable-tdz -dump-ir %s | %FileCheck --match-full-lines %s
// RUN: %hermesc -O0 -dump-ir %s | %FileCheck --match-full-lines --check-prefix=CHKDIS %s

function check1() {
return x + y;
Expand Down
2 changes: 1 addition & 1 deletion test/IRGen/es6/tdz-check.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* LICENSE file in the root directory of this source tree.
*/

// RUN: %hermesc -fenable-tdz -O0 -dump-ir %s | %FileCheck --match-full-lines %s
// RUN: %hermesc -Xenable-tdz -O0 -dump-ir %s | %FileCheck --match-full-lines %s

function check1() {
return x + y;
Expand Down
4 changes: 2 additions & 2 deletions test/Optimizer/es6/tdz-dedup.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
* LICENSE file in the root directory of this source tree.
*/

// RUN: %hermesc -fenable-tdz -O0 -dump-ir %s | %FileCheck --match-full-lines %s
// RUN: %hermesc -fenable-tdz -custom-opt=typeinference -custom-opt=tdzdedup -dump-ir %s | %FileCheck --match-full-lines --check-prefix=CHKOPT %s
// RUN: %hermesc -Xenable-tdz -O0 -dump-ir %s | %FileCheck --match-full-lines %s
// RUN: %hermesc -Xenable-tdz -custom-opt=typeinference -custom-opt=tdzdedup -dump-ir %s | %FileCheck --match-full-lines --check-prefix=CHKOPT %s

function check_after_store(p) {
let x = 10;
Expand Down
4 changes: 2 additions & 2 deletions test/hermes/tdz-check.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
* LICENSE file in the root directory of this source tree.
*/

// RUN: %hermes -fenable-tdz -O0 %s | %FileCheck --match-full-lines %s
// RUN: %hermes -fenable-tdz -O %s | %FileCheck --match-full-lines %s
// RUN: %hermes -Xenable-tdz -O0 %s | %FileCheck --match-full-lines %s
// RUN: %hermes -Xenable-tdz -O %s | %FileCheck --match-full-lines %s

function test(f) {
try {
Expand Down
2 changes: 1 addition & 1 deletion tools/node-hermes/nodelib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ add_custom_command(
# Compile the one source file to bytecode.
add_custom_command(
OUTPUT NodeBytecode.hbc
COMMAND ${hermesc_EXE} ${JS_COMPILER_FLAGS} -fno-enable-tdz -emit-binary -out=${CMAKE_CURRENT_BINARY_DIR}/NodeBytecode.hbc ${CMAKE_CURRENT_BINARY_DIR}/WrappedNode.js
COMMAND ${hermesc_EXE} ${JS_COMPILER_FLAGS} -emit-binary -out=${CMAKE_CURRENT_BINARY_DIR}/NodeBytecode.hbc ${CMAKE_CURRENT_BINARY_DIR}/WrappedNode.js
DEPENDS ${hermesc_EXE} WrappedNode.js
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
VERBATIM
Expand Down

0 comments on commit f811a0e

Please sign in to comment.