1 /*
2  * Copyright (C) 2007 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 package org.apache.harmony.dalvik;
18 
19 import dalvik.annotation.optimization.CriticalNative;
20 import dalvik.annotation.optimization.FastNative;
21 
22 /**
23  * Methods used to test calling into native code. The methods in this
24  * class are all effectively no-ops and may be used to test the mechanisms
25  * and performance of calling native methods.
26  */
27 public final class NativeTestTarget {
NativeTestTarget()28     public NativeTestTarget() {
29     }
30 
31     /**
32      * This is used to benchmark dalvik's inline natives.
33      */
emptyInlineMethod()34     public static void emptyInlineMethod() {
35     }
36 
37     /**
38      * This is used to benchmark dalvik's inline natives.
39      */
emptyInternalStaticMethod()40     public static native void emptyInternalStaticMethod();
41 
42     // Synchronized methods. Test normal JNI only.
emptyJniStaticSynchronizedMethod0()43     public static native synchronized void emptyJniStaticSynchronizedMethod0();
emptyJniSynchronizedMethod0()44     public native synchronized void emptyJniSynchronizedMethod0();
45 
46     // Static methods without object parameters. Test all optimization combinations.
47 
48     // Normal native.
emptyJniStaticMethod0()49     public static native void emptyJniStaticMethod0();
50     // Normal native.
emptyJniStaticMethod6(int a, int b, int c, int d, int e, int f)51     public static native void emptyJniStaticMethod6(int a, int b, int c, int d, int e, int f);
52 
53     @FastNative
emptyJniStaticMethod0_Fast()54     public static native void emptyJniStaticMethod0_Fast();
55     @FastNative
emptyJniStaticMethod6_Fast(int a, int b, int c, int d, int e, int f)56     public static native void emptyJniStaticMethod6_Fast(int a, int b, int c, int d, int e, int f);
57 
58     @CriticalNative
emptyJniStaticMethod0_Critical()59     public static native void emptyJniStaticMethod0_Critical();
60     @CriticalNative
emptyJniStaticMethod6_Critical(int a, int b, int c, int d, int e, int f)61     public static native void emptyJniStaticMethod6_Critical(int a, int b, int c, int d, int e, int f);
62     // Instance methods or methods with object parameters. Test {Normal, @FastNative} combinations.
63 
64     // Normal native.
emptyJniMethod0()65     public native void emptyJniMethod0();
66     // Normal native.
emptyJniMethod6(int a, int b, int c, int d, int e, int f)67     public native void emptyJniMethod6(int a, int b, int c, int d, int e, int f);
68 
69     /**
70      * This is an empty native static method with six args, hooked up
71      * using JNI. These have more complex args to show the cost of
72      * parsing the signature. All six values should be null
73      * references.
74      */
75     // Normal native.
emptyJniStaticMethod6L(String a, String[] b, int[][] c, Object d, Object[] e, Object[][][][] f)76     public static native void emptyJniStaticMethod6L(String a, String[] b,
77         int[][] c, Object d, Object[] e, Object[][][][] f);
78 
79     // Normal native.
emptyJniMethod6L(String a, String[] b, int[][] c, Object d, Object[] e, Object[][][][] f)80     public native void emptyJniMethod6L(String a, String[] b,
81         int[][] c, Object d, Object[] e, Object[][][][] f);
82 
83     @FastNative
emptyJniMethod0_Fast()84     public native void emptyJniMethod0_Fast();
85     @FastNative
emptyJniMethod6_Fast(int a, int b, int c, int d, int e, int f)86     public native void emptyJniMethod6_Fast(int a, int b, int c, int d, int e, int f);
87 
88     /**
89      * This is an empty native static method with six args, hooked up
90      * using JNI. These have more complex args to show the cost of
91      * parsing the signature. All six values should be null
92      * references.
93      */
94     @FastNative
emptyJniStaticMethod6L_Fast(String a, String[] b, int[][] c, Object d, Object[] e, Object[][][][] f)95     public static native void emptyJniStaticMethod6L_Fast(String a, String[] b,
96         int[][] c, Object d, Object[] e, Object[][][][] f);
97 
98     @FastNative
emptyJniMethod6L_Fast(String a, String[] b, int[][] c, Object d, Object[] e, Object[][][][] f)99     public native void emptyJniMethod6L_Fast(String a, String[] b,
100         int[][] c, Object d, Object[] e, Object[][][][] f);
101 }
102