• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright (C) 2017 The Android Open Source Project
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7#      http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
15.class public LSmaliTests;
16.super Ljava/lang/Object;
17
18## CHECK-START: void SmaliTests.bar() load_store_elimination (after)
19## CHECK-DAG: <<Null:l\d+>>       NullConstant
20## CHECK-DAG: <<BoundType:l\d+>>  BoundType [<<Null>>]
21## CHECK-DAG: <<CheckL:l\d+>>     NullCheck [<<BoundType>>]
22## CHECK-DAG: <<GetL0:l\d+>>      ArrayGet [<<CheckL>>,{{i\d+}}]
23## CHECK-DAG: <<GetL1:l\d+>>      ArrayGet [<<CheckL>>,{{i\d+}}]
24## CHECK-DAG: <<GetL2:l\d+>>      ArrayGet [<<CheckL>>,{{i\d+}}]
25## CHECK-DAG: <<GetL3:l\d+>>      ArrayGet [<<CheckL>>,{{i\d+}}]
26## CHECK-DAG: <<CheckJ:l\d+>>     NullCheck [<<Null>>]
27## CHECK-DAG: <<GetJ0:j\d+>>      ArrayGet [<<CheckJ>>,{{i\d+}}]
28## CHECK-DAG: <<GetJ1:j\d+>>      ArrayGet [<<CheckJ>>,{{i\d+}}]
29## CHECK-DAG: <<GetJ2:j\d+>>      ArrayGet [<<CheckJ>>,{{i\d+}}]
30## CHECK-DAG: <<GetJ3:j\d+>>      ArrayGet [<<CheckJ>>,{{i\d+}}]
31.method public static bar()V
32    .registers 7
33
34    .prologue
35    const/4 v6, 0x3
36    const/4 v5, 0x2
37    const/4 v4, 0x1
38    const/4 v3, 0x0
39
40    # We create multiple accesses that will lead the bounds check
41    # elimination pass to add a HDeoptimize. Not having the bounds check helped
42    # the load store elimination think it could merge two ArrayGet with different
43    # types.
44
45    # String[] array = (String[])getNull();
46    invoke-static {}, LMain;->getNull()Ljava/lang/Object;
47    move-result-object v0
48    check-cast v0, [Ljava/lang/String;
49
50    # objectField = array[0];
51    aget-object v2, v0, v3
52    sput-object v2, LMain;->objectField:Ljava/lang/Object;
53    # objectField = array[1];
54    aget-object v2, v0, v4
55    sput-object v2, LMain;->objectField:Ljava/lang/Object;
56    # objectField = array[2];
57    aget-object v2, v0, v5
58    sput-object v2, LMain;->objectField:Ljava/lang/Object;
59    # objectField = array[3];
60    aget-object v2, v0, v6
61    sput-object v2, LMain;->objectField:Ljava/lang/Object;
62
63    # long[] longArray = getLongArray();
64    invoke-static {}, LMain;->getLongArray()[J
65    move-result-object v1
66
67    # longField = longArray[0];
68    aget-wide v2, v1, v3
69    sput-wide v2, LMain;->longField:J
70    # longField = longArray[1];
71    aget-wide v2, v1, v4
72    sput-wide v2, LMain;->longField:J
73    # longField = longArray[2];
74    aget-wide v2, v1, v5
75    sput-wide v2, LMain;->longField:J
76    # longField = longArray[3];
77    aget-wide v2, v1, v6
78    sput-wide v2, LMain;->longField:J
79
80    return-void
81.end method
82
83
84# static fields
85.field static doThrow:Z # boolean
86
87# direct methods
88.method static constructor <clinit>()V
89    .registers 1
90
91    .prologue
92    # doThrow = false
93    const/4 v0, 0x0
94    sput-boolean v0, LSmaliTests;->doThrow:Z
95    return-void
96.end method
97