Skip to content

Commit

Permalink
RUN_WASM is off by default
Browse files Browse the repository at this point in the history
Summary: This Diff disables `run_wasm` by default.

Reviewed By: tmikov

Differential Revision: D29764281

fbshipit-source-id: 5e96368579c9b5119a12b9f28bcdb1a65678da98
  • Loading branch information
Lin Cheng authored and facebook-github-bot committed Jul 24, 2021
1 parent a9b483a commit c4f2fc3
Show file tree
Hide file tree
Showing 14 changed files with 24 additions and 13 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ set(HERMESVM_EXCEPTION_ON_OOM OFF CACHE BOOL
set(HERMESVM_PLATFORM_LOGGING OFF CACHE BOOL
"hermesLog(...) is enabled, using the platform's logging mechanism")

set(HERMES_RUN_WASM ON CACHE BOOL
set(HERMES_RUN_WASM OFF CACHE BOOL
"Emit Asm.js/Wasm unsafe compiler intrinsics")

set(HERMES_USE_FLOWPARSER OFF CACHE BOOL
Expand Down
4 changes: 2 additions & 2 deletions include/hermes/BCGen/HBC/BytecodeVersion.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ namespace hermes {
namespace hbc {

// Bytecode version generated by this version of the compiler.
// Updated: Jul 16, 2021
const static uint32_t BYTECODE_VERSION = 85;
// Updated: Jul 23, 2021
const static uint32_t BYTECODE_VERSION = 86;

} // namespace hbc
} // namespace hermes
Expand Down
6 changes: 3 additions & 3 deletions include/hermes/Optimizer/Wasm/EmitWasmIntrinsics.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
*/

#ifdef HERMES_RUN_WASM
#ifndef HERMES_BCGEN_HBC_PASSES_WASMINTRINSICSPASS_H
#define HERMES_BCGEN_HBC_PASSES_WASMINTRINSICSPASS_H
#ifndef HERMES_OPTIMIZER_EMITWASMINTRINSICS_H
#define HERMES_OPTIMIZER_EMITWASMINTRINSICS_H

#include "hermes/Optimizer/PassManager/Pass.h"

Expand All @@ -24,5 +24,5 @@ class EmitWasmIntrinsics : public FunctionPass {

} // namespace hermes

#endif // HERMES_BCGEN_HBC_PASSES_WASMINTRINSICSPASS_H
#endif // HERMES_OPTIMIZER_EMITWASMINTRINSICS_H
#endif // HERMES_RUN_WASM
9 changes: 6 additions & 3 deletions lib/BCGen/HBC/Passes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -612,10 +612,13 @@ bool LowerCalls::runOnFunction(Function *F) {
// CallIntrinsicInst, emit ImplicitMov to encode that the "this"
// register is implicitly set to undefined.
Value *arg = call->getArgument(i);
if (llvh::isa<HBCCallNInst>(call) ||
(i == 0 && llvh::isa<CallBuiltinInst>(call))
#ifdef HERMES_RUN_WASM
|| (i == 0 && llvh::isa<CallIntrinsicInst>(call)))
if (llvh::isa<HBCCallNInst>(call) ||
(i == 0 && llvh::isa<CallBuiltinInst>(call)) ||
(i == 0 && llvh::isa<CallIntrinsicInst>(call)))
#else
if (llvh::isa<HBCCallNInst>(call) ||
(i == 0 && llvh::isa<CallBuiltinInst>(call)))
#endif
{
auto *imov = builder.createImplicitMovInst(arg);
Expand Down
2 changes: 0 additions & 2 deletions lib/Optimizer/Wasm/EmitWasmIntrinsics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,6 @@ EmitWasmIntrinsicsContext::findWasmIntrinsics(Identifier intrinsicsName) {
}

bool EmitWasmIntrinsics::runOnFunction(Function *F) {
NumWasmIntrinsics = 0;

IRBuilder builder{F};
bool changed = false;

Expand Down
1 change: 1 addition & 0 deletions test/Optimizer/wasm/unsafe-intrinsics-disable.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
*/

// RUN: %hermesc -dump-lir %s | %FileCheck --match-full-lines %s
// REQUIRES: run_wasm

// LowerIntrinsics pass is only enabled if -funsafe-intrinsics is set.
function undefinedIntrinsic(func) {
Expand Down
1 change: 1 addition & 0 deletions test/Optimizer/wasm/unsafe-intrinsics-mem.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

// RUN: %hermesc -funsafe-intrinsics -target=HBC -dump-postra %s | %FileCheck --match-full-lines --check-prefix=CHKRA %s
// RUN: %hermesc -funsafe-intrinsics -target=HBC -dump-bytecode %s | %FileCheck --match-full-lines --check-prefix=CHKBC %s
// REQUIRES: run_wasm

// Setup Asm.js/Wasm memory
var buffer = new ArrayBuffer(131072);
Expand Down
3 changes: 2 additions & 1 deletion test/Optimizer/wasm/unsafe-intrinsics-undefined.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@
*/

// RUN: ( ! %hermesc -funsafe-intrinsics -dump-lir -Werror %s 2>&1 ) | %FileCheck %s --match-full-lines
// REQUIRES: run_wasm

function undefinedIntrinsic(func) {
return __uasm.foo(42, 3);
}
//CHECK: {{.*}}unsafe-intrinsics-undefined.js:10:1: error: the intrinsic "foo" is undefined.
//CHECK: {{.*}}unsafe-intrinsics-undefined.js:11:1: error: the intrinsic "foo" is undefined.
//CHECK-NEXT: function undefinedIntrinsic(func) {
//CHECK-NEXT: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//CHECK-NEXT: Emitted 1 errors. exiting.
3 changes: 2 additions & 1 deletion test/Optimizer/wasm/unsafe-intrinsics-wrong-num-args.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@
*/

// RUN: ( ! %hermesc -funsafe-intrinsics -dump-lir -Werror %s 2>&1 ) | %FileCheck %s --match-full-lines
// REQUIRES: run_wasm

function wrongNumArgs(func) {
return __uasm.add32(1, 2, 3);
}
//CHECK: {{.*}}unsafe-intrinsics-wrong-num-args.js:10:1: error: the intrinsic "add32" is called with incorrect number of arguments. Expecting 2 but got 3.
//CHECK: {{.*}}unsafe-intrinsics-wrong-num-args.js:11:1: error: the intrinsic "add32" is called with incorrect number of arguments. Expecting 2 but got 3.
//CHECK-NEXT: function wrongNumArgs(func) {
//CHECK-NEXT: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//CHECK-NEXT: Emitted 1 errors. exiting.
1 change: 1 addition & 0 deletions test/Optimizer/wasm/unsafe-intrinsics.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

// RUN: %hermesc -funsafe-intrinsics -target=HBC -dump-postra %s | %FileCheck --match-full-lines --check-prefix=CHKRA %s
// RUN: %hermesc -funsafe-intrinsics -target=HBC -dump-bytecode %s | %FileCheck --match-full-lines --check-prefix=CHKBC %s
// REQUIRES: run_wasm

// Instrinsics that are defined should not cause any error. The call sequence is
// lowered to a CallIntrinsicInst.
Expand Down
1 change: 1 addition & 0 deletions test/hermes/rgb-to-grey.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
*/

// RUN: %hermes -funsafe-intrinsics -O %s | %FileCheck --match-full-lines %s
// REQUIRES: run_wasm

// Setup Asm.js/Wasm memory
var Math_imul = Math.imul;
Expand Down
1 change: 1 addition & 0 deletions test/hermes/unsafe-intrinsics-mem.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
// RUN: %hermes -funsafe-intrinsics -O %s | %FileCheck --match-full-lines %s
// RUN: %hermes -funsafe-intrinsics -O -emit-binary -out %t.hbc %s && %hermes %t.hbc | %FileCheck --match-full-lines %s
// RUN: %hermes -funsafe-intrinsics -O -dump-bytecode %s | %FileCheck --check-prefix=CHKBC %s
// REQUIRES: run_wasm

// Setup Asm.js/Wasm memory
var buffer = new ArrayBuffer(131072);
Expand Down
1 change: 1 addition & 0 deletions test/hermes/unsafe-intrinsics.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
// RUN: %hermes -funsafe-intrinsics -O %s | %FileCheck --match-full-lines %s
// RUN: %hermes -funsafe-intrinsics -O -emit-binary -out %t.hbc %s && %hermes %t.hbc | %FileCheck --match-full-lines %s
// RUN: %hermes -funsafe-intrinsics -O -dump-bytecode %s | %FileCheck --check-prefix=CHKBC %s
// REQUIRES: run_wasm

// Check regular case
print(__uasm.add32(19, 23) === (19 + 23));
Expand Down
2 changes: 2 additions & 0 deletions test/lit.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ if isTrue(lit_config.params.get("exception_on_oom_enabled")):
config.available_features.add("exception_on_oom")
if isTrue(lit_config.params.get('serialize_enabled')):
config.available_features.add("serializer")
if isTrue(lit_config.params.get('run_wasm_enabled')):
config.available_features.add("run_wasm")

if lit_config.params.get("profiler") == "BB":
config.available_features.add("basic_block_profiler")
Expand Down

0 comments on commit c4f2fc3

Please sign in to comment.