-
Notifications
You must be signed in to change notification settings - Fork 645
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix simplifyGetConstructedObjectInst
Summary: We need to make sure that when replacing `GetConstructedObjectInst`, the value we are replacing it with is also an object type. It may not have been inferred yet. Reviewed By: avp Differential Revision: D66516220 fbshipit-source-id: 4046d0d0147fdbdb15a169b70ef4f4c5abb0078b
- Loading branch information
1 parent
24a3444
commit b275bde
Showing
8 changed files
with
87 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
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,68 @@ | ||
/** | ||
* 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 %s -dump-ir | %FileCheckOrRegen --match-full-lines %s | ||
|
||
// Check that we don't replace GetConstructedObjectInst with a | ||
// value which does not also have an object type. | ||
// | ||
// IRVerifier error: StoreFrameInst: Value type mismatch in function | ||
|
||
function main() { | ||
var x = null; | ||
function y() {} | ||
return function value() { | ||
return x || (x = new y()); | ||
}; | ||
} | ||
|
||
// 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 "main": string | ||
// CHECK-NEXT: %2 = CreateFunctionInst (:object) %0: environment, %main(): functionCode | ||
// CHECK-NEXT: StorePropertyLooseInst %2: object, globalObject: object, "main": string | ||
// CHECK-NEXT: ReturnInst undefined: undefined | ||
// CHECK-NEXT:function_end | ||
|
||
// CHECK:scope %VS1 [x: null|object, y: object] | ||
|
||
// CHECK:function main(): object | ||
// CHECK-NEXT:%BB0: | ||
// CHECK-NEXT: %0 = GetParentScopeInst (:environment) %VS0: any, %parentScope: environment | ||
// CHECK-NEXT: %1 = CreateScopeInst (:environment) %VS1: any, %0: environment | ||
// CHECK-NEXT: %2 = CreateFunctionInst (:object) %1: environment, %y(): functionCode | ||
// CHECK-NEXT: StoreFrameInst %1: environment, %2: object, [%VS1.y]: object | ||
// CHECK-NEXT: StoreFrameInst %1: environment, null: null, [%VS1.x]: null|object | ||
// CHECK-NEXT: %5 = CreateFunctionInst (:object) %1: environment, %value(): functionCode | ||
// CHECK-NEXT: ReturnInst %5: object | ||
// CHECK-NEXT:function_end | ||
|
||
// CHECK:function y(): undefined [allCallsitesKnownInStrictMode,unreachable] | ||
// CHECK-NEXT:%BB0: | ||
// CHECK-NEXT: UnreachableInst | ||
// CHECK-NEXT:function_end | ||
|
||
// CHECK:function value(): null|object | ||
// CHECK-NEXT:%BB0: | ||
// CHECK-NEXT: %0 = GetParentScopeInst (:environment) %VS1: any, %parentScope: environment | ||
// CHECK-NEXT: %1 = LoadFrameInst (:null|object) %0: environment, [%VS1.x]: null|object | ||
// CHECK-NEXT: CondBranchInst %1: null|object, %BB2, %BB1 | ||
// CHECK-NEXT:%BB1: | ||
// CHECK-NEXT: %3 = LoadFrameInst (:object) %0: environment, [%VS1.y]: object | ||
// CHECK-NEXT: %4 = CreateThisInst (:undefined|object) %3: object, empty: any | ||
// CHECK-NEXT: %5 = GetConstructedObjectInst (:object) %4: undefined|object, undefined: undefined | ||
// CHECK-NEXT: StoreFrameInst %0: environment, %5: object, [%VS1.x]: null|object | ||
// CHECK-NEXT: BranchInst %BB2 | ||
// CHECK-NEXT:%BB2: | ||
// CHECK-NEXT: %8 = PhiInst (:null|object) %1: null|object, %BB0, %5: object, %BB1 | ||
// CHECK-NEXT: ReturnInst %8: null|object | ||
// CHECK-NEXT:function_end |