-
Notifications
You must be signed in to change notification settings - Fork 647
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use loop depth to decide whether to JIT functions
Summary: Avoid JIT for functions that don't have loops if they're not called much. This is configured using `-Xjit-threshold`, which will be `1 << 5` by default. Reviewed By: tmikov Differential Revision: D65497432 fbshipit-source-id: f5763871a9a19f1b5dfd92e0ce0f43b4b180f07f
- Loading branch information
1 parent
659e39c
commit e6921e0
Showing
7 changed files
with
150 additions
and
7 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
/** | ||
* Copyright (c) Meta Platforms, Inc. and 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 -Xforce-jit=0 -fno-inline -Xjit -Xjit-crash-on-error -Xdump-jitcode=2 %s | %FileCheckOrRegen --match-full-lines %s | ||
// REQUIRES: jit | ||
|
||
// Demonstrate the various JIT levels. | ||
// Update if JIT heuristics are updated to illustrate that they still work. | ||
|
||
function loop0(arr) { | ||
var sum = 0; | ||
return sum; | ||
} | ||
|
||
function loop1(arr) { | ||
var sum = 0; | ||
for (var i = 0; i < arr.length; ++i) | ||
sum += arr[i]; | ||
return sum; | ||
} | ||
|
||
function loop2(arr) { | ||
var sum = 0; | ||
for (var i = 0; i < arr.length; ++i) | ||
for (var j = 0; j < arr.length; ++j) | ||
sum += arr[i] + arr[j]; | ||
return sum; | ||
} | ||
|
||
var arr = Array(10); | ||
arr.fill(0, 0, 10) | ||
for (var i = 0; i < 50; ++i) { | ||
print(i); | ||
loop0(arr); | ||
loop1(arr); | ||
loop2(arr); | ||
} | ||
|
||
// Auto-generated content below. Please do not modify manually. | ||
|
||
// CHECK:0 | ||
// CHECK-NEXT:1 | ||
// CHECK-NEXT:2 | ||
|
||
// CHECK:JIT compilation of FunctionID 3, 'loop2' | ||
|
||
// CHECK:JIT successfully compiled FunctionID 3, 'loop2' | ||
// CHECK-NEXT:3 | ||
// CHECK-NEXT:4 | ||
// CHECK-NEXT:5 | ||
// CHECK-NEXT:6 | ||
// CHECK-NEXT:7 | ||
// CHECK-NEXT:8 | ||
|
||
// CHECK:JIT compilation of FunctionID 2, 'loop1' | ||
|
||
// CHECK:JIT successfully compiled FunctionID 2, 'loop1' | ||
// CHECK-NEXT:9 | ||
// CHECK-NEXT:10 | ||
// CHECK-NEXT:11 | ||
// CHECK-NEXT:12 | ||
// CHECK-NEXT:13 | ||
// CHECK-NEXT:14 | ||
// CHECK-NEXT:15 | ||
// CHECK-NEXT:16 | ||
// CHECK-NEXT:17 | ||
// CHECK-NEXT:18 | ||
// CHECK-NEXT:19 | ||
// CHECK-NEXT:20 | ||
// CHECK-NEXT:21 | ||
// CHECK-NEXT:22 | ||
// CHECK-NEXT:23 | ||
// CHECK-NEXT:24 | ||
// CHECK-NEXT:25 | ||
// CHECK-NEXT:26 | ||
// CHECK-NEXT:27 | ||
// CHECK-NEXT:28 | ||
// CHECK-NEXT:29 | ||
// CHECK-NEXT:30 | ||
// CHECK-NEXT:31 | ||
// CHECK-NEXT:32 | ||
|
||
// CHECK:JIT compilation of FunctionID 1, 'loop0' | ||
|
||
// CHECK:JIT successfully compiled FunctionID 1, 'loop0' | ||
// CHECK-NEXT:33 | ||
// CHECK-NEXT:34 | ||
// CHECK-NEXT:35 | ||
// CHECK-NEXT:36 | ||
// CHECK-NEXT:37 | ||
// CHECK-NEXT:38 | ||
// CHECK-NEXT:39 | ||
// CHECK-NEXT:40 | ||
// CHECK-NEXT:41 | ||
// CHECK-NEXT:42 | ||
// CHECK-NEXT:43 | ||
// CHECK-NEXT:44 | ||
// CHECK-NEXT:45 | ||
// CHECK-NEXT:46 | ||
// CHECK-NEXT:47 | ||
// CHECK-NEXT:48 | ||
// CHECK-NEXT:49 |
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