forked from facebook/hermes
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdead_code.js
60 lines (44 loc) · 1.21 KB
/
dead_code.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
58
59
/**
* Copyright (c) Facebook, Inc. and its 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 -dump-ir %s -O | %FileCheck %s --match-full-lines
// Make sure we can remove all trampolines from our code.
//CHECK-LABEL:function test_one(x, y, z) : string
//CHECK-NEXT:frame = []
//CHECK-NEXT: %BB0:
function test_one(x,y,z) {
//CHECK-NEXT: %0 = BinaryOperatorInst '+', %x, %y
x + y
//CHECK-NEXT: %1 = BinaryOperatorInst '+', %x, 5 : number
x + 5
//CHECK-NEXT: %2 = BinaryOperatorInst '+', false : boolean, %y
false + y
//DEAD!
8 + false
//DEAD!
9 + "9"
//DEAD!
8 + false
//DEAD!
"hi" + "bye"
//Alive - result is used.
//CHECK-NEXT: %3 = BinaryOperatorInst '+', "hi" : string, %z
var t = "hi" + z
//DEAD!
null + "hi"
//CHECK-NEXT: %4 = ReturnInst %3 : string
//CHECK-NEXT:function_end
return t
}
//CHECK-LABEL:function test_two(x, y, z) : undefined
//CHECK-NEXT:frame = []
//CHECK-NEXT: %BB0:
//CHECK-NEXT: %0 = ReturnInst undefined : undefined
//CHECK-NEXT:function_end
function test_two(x,y,z) {
function test00() {}
var test01 = function() {}
}