-
Notifications
You must be signed in to change notification settings - Fork 648
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Emit a fast path for Function.prototype.call
Summary: Time needed to execute attached microbenchmark: 280ms -> 170ms. Reviewed By: fbmal7 Differential Revision: D65348301 fbshipit-source-id: c21efcad04b7d15e93339dd1b093dbdd96dad1ba
- Loading branch information
1 parent
94a2419
commit 6d4da33
Showing
3 changed files
with
123 additions
and
2 deletions.
There are no files selected for viewing
20 changes: 20 additions & 0 deletions
20
benchmarks/bench-runner/resource/test-suites/micros/functionPrototypeCall.js
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,20 @@ | ||
/** | ||
* 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. | ||
* | ||
* @format | ||
*/ | ||
|
||
(function() { | ||
|
||
function foo() { 'noinline'; } | ||
|
||
var N = 10_000_000; | ||
var start = Date.now(); | ||
for (var i = 0; i < N; ++i) foo.call(); | ||
var end = Date.now(); | ||
print("Time: " + (end - start)); | ||
|
||
})(); |
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,52 @@ | ||
/** | ||
* 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: %hermesc -O -target=HBC -dump-ir %s | %FileCheckOrRegen --match-full-lines %s | ||
|
||
function foo(f, a, b) { | ||
f.call(a, b); | ||
f.call(b, a); | ||
} | ||
|
||
// Auto-generated content below. Please do not modify manually. | ||
|
||
// CHECK:scope %VS0 [] | ||
|
||
// CHECK:function global(): undefined | ||
// CHECK-NEXT:%BB0: | ||
// CHECK-NEXT: %0 = CreateScopeInst (:environment) %VS0: any, empty: any | ||
// CHECK-NEXT: DeclareGlobalVarInst "foo": string | ||
// CHECK-NEXT: %2 = CreateFunctionInst (:object) %0: environment, %foo(): functionCode | ||
// CHECK-NEXT: StorePropertyLooseInst %2: object, globalObject: object, "foo": string | ||
// CHECK-NEXT: ReturnInst undefined: undefined | ||
// CHECK-NEXT:function_end | ||
|
||
// CHECK:function foo(f: any, a: any, b: any): undefined | ||
// CHECK-NEXT:%BB0: | ||
// CHECK-NEXT: %0 = LoadParamInst (:any) %f: any | ||
// CHECK-NEXT: %1 = LoadParamInst (:any) %a: any | ||
// CHECK-NEXT: %2 = LoadParamInst (:any) %b: any | ||
// CHECK-NEXT: %3 = LoadPropertyInst (:any) %0: any, "call": string | ||
// CHECK-NEXT: BranchIfBuiltinInst [HermesBuiltin.functionPrototypeCall]: number, %3: any, %BB2, %BB3 | ||
// CHECK-NEXT:%BB1: | ||
// CHECK-NEXT: %5 = LoadPropertyInst (:any) %0: any, "call": string | ||
// CHECK-NEXT: BranchIfBuiltinInst [HermesBuiltin.functionPrototypeCall]: number, %5: any, %BB5, %BB6 | ||
// CHECK-NEXT:%BB2: | ||
// CHECK-NEXT: %7 = CallInst (:any) %0: any, empty: any, false: boolean, empty: any, undefined: undefined, %1: any, %2: any | ||
// CHECK-NEXT: BranchInst %BB1 | ||
// CHECK-NEXT:%BB3: | ||
// CHECK-NEXT: %9 = CallInst (:any) %3: any, empty: any, false: boolean, empty: any, undefined: undefined, %0: any, %1: any, %2: any | ||
// CHECK-NEXT: BranchInst %BB1 | ||
// CHECK-NEXT:%BB4: | ||
// CHECK-NEXT: ReturnInst undefined: undefined | ||
// CHECK-NEXT:%BB5: | ||
// CHECK-NEXT: %12 = CallInst (:any) %0: any, empty: any, false: boolean, empty: any, undefined: undefined, %2: any, %1: any | ||
// CHECK-NEXT: BranchInst %BB4 | ||
// CHECK-NEXT:%BB6: | ||
// CHECK-NEXT: %14 = CallInst (:any) %5: any, empty: any, false: boolean, empty: any, undefined: undefined, %0: any, %2: any, %1: any | ||
// CHECK-NEXT: BranchInst %BB4 | ||
// CHECK-NEXT:function_end |