forked from facebook/hermes
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathglobal_props.js
57 lines (51 loc) · 2.96 KB
/
global_props.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/**
* 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 -hermes-parser -strict -dump-ir -O0 -include-globals=%s.d %s | %FileCheck %s --match-full-lines
// RUN: %hermes -hermes-parser -strict -dump-ir -O -include-globals=%s.d %s | %FileCheck %s --match-full-lines --check-prefix=OPT-CHECK
// RUN: %hermes -hermes-parser -non-strict -dump-ir -O -include-globals=%s.d %s | %FileCheck %s --match-full-lines --check-prefix=OPT-NONSTRICT
// Ensure that global properties are not promoted.
var a = 10;
print(a, process);
process = null;
//CHECK-LABEL:function global()
//CHECK-NEXT:frame = [], globals = [a]
//CHECK-NEXT:%BB0:
//CHECK-NEXT: %0 = AllocStackInst $?anon_0_ret
//CHECK-NEXT: %1 = StoreStackInst undefined : undefined, %0
//CHECK-NEXT: %2 = StorePropertyInst 10 : number, globalObject : object, "a" : string
//CHECK-NEXT: %3 = TryLoadGlobalPropertyInst globalObject : object, "print" : string
//CHECK-NEXT: %4 = LoadPropertyInst globalObject : object, "a" : string
//CHECK-NEXT: %5 = TryLoadGlobalPropertyInst globalObject : object, "process" : string
//CHECK-NEXT: %6 = CallInst %3, undefined : undefined, %4, %5
//CHECK-NEXT: %7 = StoreStackInst %6, %0
//CHECK-NEXT: %8 = TryStoreGlobalPropertyInst null : null, globalObject : object, "process" : string
//CHECK-NEXT: %9 = StoreStackInst null : null, %0
//CHECK-NEXT: %10 = LoadStackInst %0
//CHECK-NEXT: %11 = ReturnInst %10
//CHECK-NEXT:function_end
//OPT-CHECK-LABEL:function global() : null
//OPT-CHECK-NEXT:frame = [], globals = [a]
//OPT-CHECK-NEXT:%BB0:
//OPT-CHECK-NEXT: %0 = StorePropertyInst 10 : number, globalObject : object, "a" : string
//OPT-CHECK-NEXT: %1 = TryLoadGlobalPropertyInst globalObject : object, "print" : string
//OPT-CHECK-NEXT: %2 = LoadPropertyInst globalObject : object, "a" : string
//OPT-CHECK-NEXT: %3 = TryLoadGlobalPropertyInst globalObject : object, "process" : string
//OPT-CHECK-NEXT: %4 = CallInst %1, undefined : undefined, %2, %3
//OPT-CHECK-NEXT: %5 = TryStoreGlobalPropertyInst null : null, globalObject : object, "process" : string
//OPT-CHECK-NEXT: %6 = ReturnInst null : null
//OPT-CHECK-NEXT:function_end
//OPT-NONSTRICT-LABEL:function global() : null
//OPT-NONSTRICT-NEXT:frame = [], globals = [a]
//OPT-NONSTRICT-NEXT:%BB0:
//OPT-NONSTRICT-NEXT: %0 = StorePropertyInst 10 : number, globalObject : object, "a" : string
//OPT-NONSTRICT-NEXT: %1 = TryLoadGlobalPropertyInst globalObject : object, "print" : string
//OPT-NONSTRICT-NEXT: %2 = LoadPropertyInst globalObject : object, "a" : string
//OPT-NONSTRICT-NEXT: %3 = TryLoadGlobalPropertyInst globalObject : object, "process" : string
//OPT-NONSTRICT-NEXT: %4 = CallInst %1, undefined : undefined, %2, %3
//OPT-NONSTRICT-NEXT: %5 = StorePropertyInst null : null, globalObject : object, "process" : string
//OPT-NONSTRICT-NEXT: %6 = ReturnInst null : null
//OPT-NONSTRICT-NEXT:function_end