1 /* 2 * Copyright (C) 2020 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 public class Main { 17 Object field; 18 19 /// CHECK-START: java.lang.Object Main.testGetField() builder (after) 20 /// CHECK: <<This:l\d+>> ParameterValue 21 /// CHECK: InstanceFieldGet [<<This>>] field_name:Main.field 22 23 /// CHECK-START-ARM: java.lang.Object Main.testGetField() disassembly (after) 24 /// CHECK-IF: os.environ.get('ART_HEAP_POISONING') == 'true' 25 /// CHECK-IF: os.environ.get('ART_READ_BARRIER_TYPE') != 'TABLELOOKUP' 26 /// CHECK: <<This:l\d+>> ParameterValue 27 /// CHECK: <<Ref:l\d+>> InstanceFieldGet [<<This>>] field_name:Main.field 28 /// CHECK: ldr <<RefReg:r([0-8]|10|11)>>, [r1, #8] 29 /// CHECK: rsbs <<RefReg>>, #0 30 /// CHECK: Return [<<Ref>>] 31 /// CHECK-FI: 32 /// CHECK-ELSE: 33 /// CHECK-NOT: rsbs {{r\d+}}, #0 34 /// CHECK-FI: 35 36 /// CHECK-START-ARM64: java.lang.Object Main.testGetField() disassembly (after) 37 /// CHECK-IF: os.environ.get('ART_HEAP_POISONING') == 'true' 38 /// CHECK-IF: os.environ.get('ART_READ_BARRIER_TYPE') != 'TABLELOOKUP' 39 /// CHECK: <<This:l\d+>> ParameterValue 40 /// CHECK: <<Ref:l\d+>> InstanceFieldGet [<<This>>] field_name:Main.field 41 /// CHECK: ldr w0, [x1, #8] 42 /// CHECK: neg w0, w0 43 /// CHECK: Return [<<Ref>>] 44 /// CHECK: ret 45 /// CHECK-FI: 46 /// CHECK-ELSE: 47 /// CHECK-NOT: neg {{w\d+}}, {{w\d+}} 48 /// CHECK-FI: 49 50 /// CHECK-START-X86: java.lang.Object Main.testGetField() disassembly (after) 51 /// CHECK-IF: os.environ.get('ART_HEAP_POISONING') == 'true' 52 /// CHECK-IF: os.environ.get('ART_READ_BARRIER_TYPE') != 'TABLELOOKUP' 53 /// CHECK: <<This:l\d+>> ParameterValue 54 /// CHECK: <<Ref:l\d+>> InstanceFieldGet [<<This>>] field_name:Main.field 55 /// CHECK: mov eax, [ecx + 8] 56 /// CHECK: neg eax 57 /// CHECK: Return [<<Ref>>] 58 /// CHECK: ret 59 /// CHECK-FI: 60 /// CHECK-ELSE: 61 /// CHECK-NOT: neg {{[a-z]+}} 62 /// CHECK-FI: 63 64 /// CHECK-START-X86_64: java.lang.Object Main.testGetField() disassembly (after) 65 /// CHECK-IF: os.environ.get('ART_HEAP_POISONING') == 'true' 66 /// CHECK-IF: os.environ.get('ART_READ_BARRIER_TYPE') != 'TABLELOOKUP' 67 /// CHECK: <<This:l\d+>> ParameterValue 68 /// CHECK: <<Ref:l\d+>> InstanceFieldGet [<<This>>] field_name:Main.field 69 /// CHECK: mov eax, [rsi + 8] 70 /// CHECK: neg eax 71 /// CHECK: Return [<<Ref>>] 72 /// CHECK: ret 73 /// CHECK-FI: 74 /// CHECK-ELSE: 75 /// CHECK-NOT: neg {{[a-z]+}} 76 /// CHECK-FI: 77 testGetField()78 Object testGetField() { 79 return field; 80 } 81 82 /// CHECK-START: void Main.testSetField(java.lang.Object) builder (after) 83 /// CHECK: <<This:l\d+>> ParameterValue 84 /// CHECK: <<Arg:l\d+>> ParameterValue 85 /// CHECK: InstanceFieldSet [<<This>>,<<Arg>>] field_name:Main.field 86 87 /// CHECK-START-ARM: void Main.testSetField(java.lang.Object) disassembly (after) 88 /// CHECK-IF: os.environ.get('ART_HEAP_POISONING') == 'true' 89 /// CHECK-IF: os.environ.get('ART_READ_BARRIER_TYPE') != 'TABLELOOKUP' 90 /// CHECK: <<This:l\d+>> ParameterValue 91 /// CHECK: <<Arg:l\d+>> ParameterValue 92 /// CHECK: InstanceFieldSet [<<This>>,<<Arg>>] field_name:Main.field 93 /// CHECK-NEXT: mov <<Temp:r([0-8]|10|11)>>, r2 94 /// CHECK-NEXT: rsbs <<Temp>>, #0 95 /// CHECK-NEXT: str <<Temp>>, [r1, #8] 96 /// CHECK: ReturnVoid 97 /// CHECK-NEXT: bx lr 98 /// CHECK-FI: 99 /// CHECK-ELSE: 100 /// CHECK-NOT: rsbs {{r\d+}}, #0 101 /// CHECK-FI: 102 103 /// CHECK-START-ARM64: void Main.testSetField(java.lang.Object) disassembly (after) 104 /// CHECK-IF: os.environ.get('ART_HEAP_POISONING') == 'true' 105 /// CHECK-IF: os.environ.get('ART_READ_BARRIER_TYPE') != 'TABLELOOKUP' 106 /// CHECK: <<This:l\d+>> ParameterValue 107 /// CHECK: <<Arg:l\d+>> ParameterValue 108 /// CHECK: InstanceFieldSet [<<This>>,<<Arg>>] field_name:Main.field 109 /// CHECK-NEXT: mov <<Temp:w1[67]>>, w2 110 /// CHECK-NEXT: neg <<Temp>>, <<Temp>> 111 /// CHECK-NEXT: str <<Temp>>, [x1, #8] 112 /// CHECK: ReturnVoid 113 /// CHECK-NEXT: ret 114 /// CHECK-FI: 115 /// CHECK-ELSE: 116 /// CHECK-NOT: neg {{w\d+}}, {{w\d+}} 117 /// CHECK-FI: 118 119 /// CHECK-START-X86: void Main.testSetField(java.lang.Object) disassembly (after) 120 /// CHECK-IF: os.environ.get('ART_HEAP_POISONING') == 'true' 121 /// CHECK-IF: os.environ.get('ART_READ_BARRIER_TYPE') != 'TABLELOOKUP' 122 /// CHECK: <<This:l\d+>> ParameterValue 123 /// CHECK: <<Arg:l\d+>> ParameterValue 124 /// CHECK: ParallelMove 125 /// CHECK-NEXT: mov eax, ecx 126 /// CHECK: InstanceFieldSet [<<This>>,<<Arg>>] field_name:Main.field 127 /// CHECK-NEXT: mov <<Temp:e([acdb]x|bp|si|di)>>, edx 128 /// CHECK-NEXT: neg <<Temp>> 129 /// CHECK-NEXT: mov [eax + 8], <<Temp>> 130 /// CHECK: ReturnVoid 131 /// CHECK-NEXT: ret 132 /// CHECK-FI: 133 /// CHECK-ELSE: 134 /// CHECK-NOT: neg {{[a-z]+}} 135 /// CHECK-FI: 136 137 /// CHECK-START-X86_64: void Main.testSetField(java.lang.Object) disassembly (after) 138 /// CHECK-IF: os.environ.get('ART_HEAP_POISONING') == 'true' 139 /// CHECK-IF: os.environ.get('ART_READ_BARRIER_TYPE') != 'TABLELOOKUP' 140 /// CHECK: <<This:l\d+>> ParameterValue 141 /// CHECK: <<Arg:l\d+>> ParameterValue 142 /// CHECK: InstanceFieldSet [<<This>>,<<Arg>>] field_name:Main.field 143 /// CHECK-NEXT: mov <<Temp:e([acdb]x|bp|si|di)>>, edx 144 /// CHECK-NEXT: neg <<Temp>> 145 /// CHECK-NEXT: mov [rsi + 8], <<Temp>> 146 /// CHECK: ReturnVoid 147 /// CHECK-NEXT: ret 148 /// CHECK-FI: 149 /// CHECK-ELSE: 150 /// CHECK-NOT: neg {{[a-z]+}} 151 /// CHECK-FI: 152 testSetField(Object o)153 void testSetField(Object o) { 154 field = o; 155 } 156 main(String[] args)157 public static void main(String[] args) { 158 Main m = new Main(); 159 Object o = m.testGetField(); 160 m.testSetField(o); 161 System.out.println("passed"); 162 } 163 } 164