• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2016 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 
17 public class Main extends UnresolvedClass {
18 
19   /// CHECK-START: float Main.callAbs(float) register (before)
20   /// CHECK:       <<CurrentMethod:[ij]\d+>> CurrentMethod
21   /// CHECK:       <<ParamValue:f\d+>> ParameterValue
22   /// CHECK:       InvokeStaticOrDirect [<<ParamValue>>,<<CurrentMethod>>] method_name:java.lang.Math.abs
callAbs(float f)23   static public float callAbs(float f) {
24     // An intrinsic invoke in a method that has unresolved references will still
25     // have a CurrentMethod as an argument.  The X86 pc_relative_fixups_x86 pass
26     // must be able to handle Math.abs invokes that have a CurrentMethod, as both
27     // the CurrentMethod and the HX86LoadFromConstantTable (for the bitmask)
28     // expect to be in the 'SpecialInputIndex' input index.
29     return Math.abs(f);
30   }
31 
main(String[] args)32   static public void main(String[] args) {
33     expectEquals(callAbs(-6.5f), 6.5f);
34   }
35 
expectEquals(float expected, float result)36   public static void expectEquals(float expected, float result) {
37     if (expected != result) {
38       throw new Error("Expected: " + expected + ", found: " + result);
39     }
40   }
41 }
42