upload android base code part3
This commit is contained in:
parent
71b83c22f1
commit
b9e30e05b1
15122 changed files with 2089659 additions and 0 deletions
107
android/dalvik/dx/tests/111-use-null-as-array/Blort.java
Normal file
107
android/dalvik/dx/tests/111-use-null-as-array/Blort.java
Normal file
|
@ -0,0 +1,107 @@
|
|||
/*
|
||||
* Copyright (C) 2009 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
public class Blort {
|
||||
public static boolean test_getBooleanArray() {
|
||||
boolean[] arr = null;
|
||||
return arr[1];
|
||||
}
|
||||
|
||||
public static byte test_getByteArray() {
|
||||
byte[] arr = null;
|
||||
return arr[2];
|
||||
}
|
||||
|
||||
public static char test_getCharArray() {
|
||||
char[] arr = null;
|
||||
return arr[3];
|
||||
}
|
||||
|
||||
public static double test_getDoubleArray() {
|
||||
double[] arr = null;
|
||||
return arr[4];
|
||||
}
|
||||
|
||||
public static float test_getFloatArray() {
|
||||
float[] arr = null;
|
||||
return arr[5];
|
||||
}
|
||||
|
||||
public static int test_getIntArray() {
|
||||
int[] arr = null;
|
||||
return arr[6];
|
||||
}
|
||||
|
||||
public static long test_getLongArray() {
|
||||
long[] arr = null;
|
||||
return arr[7];
|
||||
}
|
||||
|
||||
public static Object test_getObjectArray() {
|
||||
Object[] arr = null;
|
||||
return arr[8];
|
||||
}
|
||||
|
||||
public static short test_getShortArray() {
|
||||
short[] arr = null;
|
||||
return arr[9];
|
||||
}
|
||||
|
||||
public static void test_setBooleanArray() {
|
||||
boolean[] arr = null;
|
||||
arr[1] = true;
|
||||
}
|
||||
|
||||
public static void test_setByteArray() {
|
||||
byte[] arr = null;
|
||||
arr[2] = (byte) 3;
|
||||
}
|
||||
|
||||
public static void test_setCharArray() {
|
||||
char[] arr = null;
|
||||
arr[4] = (char) 5;
|
||||
}
|
||||
|
||||
public static void test_setDoubleArray() {
|
||||
double[] arr = null;
|
||||
arr[6] = 7.0F;
|
||||
}
|
||||
|
||||
public static void test_setFloatArray() {
|
||||
float[] arr = null;
|
||||
arr[8] = 9.0F;
|
||||
}
|
||||
|
||||
public static void test_setIntArray() {
|
||||
int[] arr = null;
|
||||
arr[10] = 11;
|
||||
}
|
||||
|
||||
public static void test_setLongArray() {
|
||||
long[] arr = null;
|
||||
arr[12] = 13;
|
||||
}
|
||||
|
||||
public static void test_setObjectArray() {
|
||||
Object[] arr = null;
|
||||
arr[14] = "blort";
|
||||
}
|
||||
|
||||
public static void test_setShortArray() {
|
||||
short[] arr = null;
|
||||
arr[15] = (short) 16;
|
||||
}
|
||||
}
|
250
android/dalvik/dx/tests/111-use-null-as-array/expected.txt
Normal file
250
android/dalvik/dx/tests/111-use-null-as-array/expected.txt
Normal file
|
@ -0,0 +1,250 @@
|
|||
Blort.test_getBooleanArray:()Z:
|
||||
regs: 0002; ins: 0000; outs: 0000
|
||||
0000: const/4 v0, #null // #0
|
||||
0001: const/4 v1, #int 1 // #1
|
||||
0002: aget-byte v0, v0, v1
|
||||
0004: return v0
|
||||
Blort.test_getByteArray:()B:
|
||||
regs: 0002; ins: 0000; outs: 0000
|
||||
0000: const/4 v0, #null // #0
|
||||
0001: const/4 v1, #int 2 // #2
|
||||
0002: aget-byte v0, v0, v1
|
||||
0004: return v0
|
||||
Blort.test_getCharArray:()C:
|
||||
regs: 0002; ins: 0000; outs: 0000
|
||||
0000: const/4 v0, #null // #0
|
||||
0001: const/4 v1, #int 3 // #3
|
||||
0002: aget-char v0, v0, v1
|
||||
0004: return v0
|
||||
Blort.test_getDoubleArray:()D:
|
||||
regs: 0002; ins: 0000; outs: 0000
|
||||
0000: const/4 v0, #null // #0
|
||||
0001: const/4 v1, #int 4 // #4
|
||||
0002: aget-wide v0, v0, v1
|
||||
0004: return-wide v0
|
||||
Blort.test_getFloatArray:()F:
|
||||
regs: 0002; ins: 0000; outs: 0000
|
||||
0000: const/4 v0, #null // #0
|
||||
0001: const/4 v1, #int 5 // #5
|
||||
0002: aget v0, v0, v1
|
||||
0004: return v0
|
||||
Blort.test_getIntArray:()I:
|
||||
regs: 0002; ins: 0000; outs: 0000
|
||||
0000: const/4 v0, #null // #0
|
||||
0001: const/4 v1, #int 6 // #6
|
||||
0002: aget v0, v0, v1
|
||||
0004: return v0
|
||||
Blort.test_getLongArray:()J:
|
||||
regs: 0002; ins: 0000; outs: 0000
|
||||
0000: const/4 v0, #null // #0
|
||||
0001: const/4 v1, #int 7 // #7
|
||||
0002: aget-wide v0, v0, v1
|
||||
0004: return-wide v0
|
||||
Blort.test_getObjectArray:()Ljava/lang/Object;:
|
||||
regs: 0002; ins: 0000; outs: 0000
|
||||
0000: const/4 v0, #null // #0
|
||||
0001: const/16 v1, #int 8 // #0008
|
||||
0003: aget-object v0, v0, v1
|
||||
0005: return-object v0
|
||||
Blort.test_getShortArray:()S:
|
||||
regs: 0002; ins: 0000; outs: 0000
|
||||
0000: const/4 v0, #null // #0
|
||||
0001: const/16 v1, #int 9 // #0009
|
||||
0003: aget-short v0, v0, v1
|
||||
0005: return v0
|
||||
Blort.test_setBooleanArray:()V:
|
||||
regs: 0002; ins: 0000; outs: 0000
|
||||
0000: const/4 v1, #int 1 // #1
|
||||
0001: const/4 v0, #null // #0
|
||||
0002: aput v1, v0, v1
|
||||
0004: return-void
|
||||
Blort.test_setByteArray:()V:
|
||||
regs: 0003; ins: 0000; outs: 0000
|
||||
0000: const/4 v0, #null // #0
|
||||
0001: const/4 v1, #int 2 // #2
|
||||
0002: const/4 v2, #int 3 // #3
|
||||
0003: aput v2, v0, v1
|
||||
0005: return-void
|
||||
Blort.test_setCharArray:()V:
|
||||
regs: 0003; ins: 0000; outs: 0000
|
||||
0000: const/4 v0, #null // #0
|
||||
0001: const/4 v1, #int 4 // #4
|
||||
0002: const/4 v2, #int 5 // #5
|
||||
0003: aput v2, v0, v1
|
||||
0005: return-void
|
||||
Blort.test_setDoubleArray:()V:
|
||||
regs: 0004; ins: 0000; outs: 0000
|
||||
0000: const/4 v0, #null // #0
|
||||
0001: const/4 v1, #int 6 // #6
|
||||
0002: const-wide/high16 v2, #double 7.0 // #401c000000000000
|
||||
0004: aput-wide v2, v0, v1
|
||||
0006: return-void
|
||||
Blort.test_setFloatArray:()V:
|
||||
regs: 0003; ins: 0000; outs: 0000
|
||||
0000: const/4 v0, #null // #0
|
||||
0001: const/16 v1, #int 8 // #0008
|
||||
0003: const/high16 v2, #float 9.0 // #41100000
|
||||
0005: aput v2, v0, v1
|
||||
0007: return-void
|
||||
Blort.test_setIntArray:()V:
|
||||
regs: 0003; ins: 0000; outs: 0000
|
||||
0000: const/4 v0, #null // #0
|
||||
0001: const/16 v1, #int 10 // #000a
|
||||
0003: const/16 v2, #int 11 // #000b
|
||||
0005: aput v2, v0, v1
|
||||
0007: return-void
|
||||
Blort.test_setLongArray:()V:
|
||||
regs: 0004; ins: 0000; outs: 0000
|
||||
0000: const/4 v0, #null // #0
|
||||
0001: const/16 v1, #int 12 // #000c
|
||||
0003: const-wide/16 v2, #long 13 // #000d
|
||||
0005: aput-wide v2, v0, v1
|
||||
0007: return-void
|
||||
Blort.test_setObjectArray:()V:
|
||||
regs: 0003; ins: 0000; outs: 0000
|
||||
0000: const/4 v0, #null // #0
|
||||
0001: const/16 v1, #int 14 // #000e
|
||||
0003: const-string v2, "blort"
|
||||
0005: aput-object v2, v0, v1
|
||||
0007: return-void
|
||||
Blort.test_setShortArray:()V:
|
||||
regs: 0003; ins: 0000; outs: 0000
|
||||
0000: const/4 v0, #null // #0
|
||||
0001: const/16 v1, #int 15 // #000f
|
||||
0003: const/16 v2, #int 16 // #0010
|
||||
0005: aput v2, v0, v1
|
||||
0007: return-void
|
||||
multidimensional.test_getBooleanArray:()Z:
|
||||
regs: 0002; ins: 0000; outs: 0000
|
||||
0000: const/4 v1, #int 1 // #1
|
||||
0001: const/4 v0, #null // #0
|
||||
0002: aget-object v0, v0, v1
|
||||
0004: aget-byte v0, v0, v1
|
||||
0006: return v0
|
||||
multidimensional.test_getByteArray:()B:
|
||||
regs: 0002; ins: 0000; outs: 0000
|
||||
0000: const/4 v1, #int 1 // #1
|
||||
0001: const/4 v0, #null // #0
|
||||
0002: aget-object v0, v0, v1
|
||||
0004: aget-byte v0, v0, v1
|
||||
0006: return v0
|
||||
multidimensional.test_getCharArray:()C:
|
||||
regs: 0002; ins: 0000; outs: 0000
|
||||
0000: const/4 v1, #int 1 // #1
|
||||
0001: const/4 v0, #null // #0
|
||||
0002: aget-object v0, v0, v1
|
||||
0004: aget-char v0, v0, v1
|
||||
0006: return v0
|
||||
multidimensional.test_getDoubleArray:()D:
|
||||
regs: 0002; ins: 0000; outs: 0000
|
||||
0000: const/4 v1, #int 1 // #1
|
||||
0001: const/4 v0, #null // #0
|
||||
0002: aget-object v0, v0, v1
|
||||
0004: aget-wide v0, v0, v1
|
||||
0006: return-wide v0
|
||||
multidimensional.test_getFloatArray:()F:
|
||||
regs: 0002; ins: 0000; outs: 0000
|
||||
0000: const/4 v1, #int 1 // #1
|
||||
0001: const/4 v0, #null // #0
|
||||
0002: aget-object v0, v0, v1
|
||||
0004: aget v0, v0, v1
|
||||
0006: return v0
|
||||
multidimensional.test_getIntArray:()I:
|
||||
regs: 0002; ins: 0000; outs: 0000
|
||||
0000: const/4 v1, #int 1 // #1
|
||||
0001: const/4 v0, #null // #0
|
||||
0002: aget-object v0, v0, v1
|
||||
0004: aget v0, v0, v1
|
||||
0006: return v0
|
||||
multidimensional.test_getLongArray:()J:
|
||||
regs: 0002; ins: 0000; outs: 0000
|
||||
0000: const/4 v1, #int 1 // #1
|
||||
0001: const/4 v0, #null // #0
|
||||
0002: aget-object v0, v0, v1
|
||||
0004: aget-wide v0, v0, v1
|
||||
0006: return-wide v0
|
||||
multidimensional.test_getObjectArray:()Ljava/lang/Object;:
|
||||
regs: 0002; ins: 0000; outs: 0000
|
||||
0000: const/4 v1, #int 1 // #1
|
||||
0001: const/4 v0, #null // #0
|
||||
0002: aget-object v0, v0, v1
|
||||
0004: aget-object v0, v0, v1
|
||||
0006: return-object v0
|
||||
multidimensional.test_getShortArray:()S:
|
||||
regs: 0002; ins: 0000; outs: 0000
|
||||
0000: const/4 v1, #int 1 // #1
|
||||
0001: const/4 v0, #null // #0
|
||||
0002: aget-object v0, v0, v1
|
||||
0004: aget-short v0, v0, v1
|
||||
0006: return v0
|
||||
multidimensional.test_setBooleanArray:()V:
|
||||
regs: 0003; ins: 0000; outs: 0000
|
||||
0000: const/4 v2, #int 1 // #1
|
||||
0001: const/4 v0, #null // #0
|
||||
0002: aget-object v0, v0, v2
|
||||
0004: const/4 v1, #int 0 // #0
|
||||
0005: aput v1, v0, v2
|
||||
0007: return-void
|
||||
multidimensional.test_setByteArray:()V:
|
||||
regs: 0003; ins: 0000; outs: 0000
|
||||
0000: const/4 v2, #int 1 // #1
|
||||
0001: const/4 v0, #null // #0
|
||||
0002: aget-object v0, v0, v2
|
||||
0004: const/4 v1, #int 0 // #0
|
||||
0005: aput v1, v0, v2
|
||||
0007: return-void
|
||||
multidimensional.test_setCharArray:()V:
|
||||
regs: 0003; ins: 0000; outs: 0000
|
||||
0000: const/4 v2, #int 1 // #1
|
||||
0001: const/4 v0, #null // #0
|
||||
0002: aget-object v0, v0, v2
|
||||
0004: const/4 v1, #int 0 // #0
|
||||
0005: aput v1, v0, v2
|
||||
0007: return-void
|
||||
multidimensional.test_setDoubleArray:()V:
|
||||
regs: 0004; ins: 0000; outs: 0000
|
||||
0000: const/4 v1, #int 1 // #1
|
||||
0001: const/4 v0, #null // #0
|
||||
0002: aget-object v0, v0, v1
|
||||
0004: const-wide/16 v2, #double 0.0 // #0000
|
||||
0006: aput-wide v2, v0, v1
|
||||
0008: return-void
|
||||
multidimensional.test_setFloatArray:()V:
|
||||
regs: 0003; ins: 0000; outs: 0000
|
||||
0000: const/4 v2, #int 1 // #1
|
||||
0001: const/4 v0, #null // #0
|
||||
0002: aget-object v0, v0, v2
|
||||
0004: const/4 v1, #float 0.0 // #0
|
||||
0005: aput v1, v0, v2
|
||||
0007: return-void
|
||||
multidimensional.test_setIntArray:()V:
|
||||
regs: 0003; ins: 0000; outs: 0000
|
||||
0000: const/4 v2, #int 1 // #1
|
||||
0001: const/4 v0, #null // #0
|
||||
0002: aget-object v0, v0, v2
|
||||
0004: const/4 v1, #int 0 // #0
|
||||
0005: aput v1, v0, v2
|
||||
0007: return-void
|
||||
multidimensional.test_setLongArray:()V:
|
||||
regs: 0004; ins: 0000; outs: 0000
|
||||
0000: const/4 v1, #int 1 // #1
|
||||
0001: const/4 v0, #null // #0
|
||||
0002: aget-object v0, v0, v1
|
||||
0004: const-wide/16 v2, #long 0 // #0000
|
||||
0006: aput-wide v2, v0, v1
|
||||
0008: return-void
|
||||
multidimensional.test_setObjectArray:()V:
|
||||
regs: 0003; ins: 0000; outs: 0000
|
||||
0000: const/4 v2, #null // #0
|
||||
0001: const/4 v1, #int 1 // #1
|
||||
0002: aget-object v0, v2, v1
|
||||
0004: aput-object v2, v0, v1
|
||||
0006: return-void
|
||||
multidimensional.test_setShortArray:()V:
|
||||
regs: 0003; ins: 0000; outs: 0000
|
||||
0000: const/4 v2, #int 1 // #1
|
||||
0001: const/4 v0, #null // #0
|
||||
0002: aget-object v0, v0, v2
|
||||
0004: const/4 v1, #int 0 // #0
|
||||
0005: aput v1, v0, v2
|
||||
0007: return-void
|
18
android/dalvik/dx/tests/111-use-null-as-array/info.txt
Normal file
18
android/dalvik/dx/tests/111-use-null-as-array/info.txt
Normal file
|
@ -0,0 +1,18 @@
|
|||
This is a smoke test of dex conversion, which checks to see that uses
|
||||
of a known-null in contexts that require a specific type end up getting
|
||||
converted to the type in question. When executed, this sort of code
|
||||
will inevitably throw a NullPointerException, but if the opcode weren't
|
||||
correct, they would instead incorrectly fail verification.
|
||||
|
||||
If you inspect the expected output of this test, you will see that
|
||||
there are some surprising instructions in there, such as using
|
||||
aget-byte for what was a boolean[] in the source code. In these cases,
|
||||
the resulting output is still correct (passes verification and will
|
||||
throw a NullPointerException if ever executed). However, it happens
|
||||
that during translation there simply wasn't enough information to
|
||||
recover the "true" original meaning at the level of actual opcode
|
||||
selection.
|
||||
|
||||
This test compares emitted code against a known-good (via eyeballing)
|
||||
version, so it is possible for this test to spuriously fail if other
|
||||
aspects of conversion end up altering the output in innocuous ways.
|
|
@ -0,0 +1,80 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# Copyright (C) 2015 The Android Open Source Project
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
echo '
|
||||
.class multidimensional
|
||||
.super java/lang/Object
|
||||
'
|
||||
|
||||
function onetype() {
|
||||
local typename=$1
|
||||
local stacksize=$2
|
||||
local defaultvalue=$3
|
||||
local descriptor=$4
|
||||
local defaultload=$5
|
||||
local loadstoreprefix=$6
|
||||
local returnprefix=${7:-$loadstoreprefix}
|
||||
echo "
|
||||
; Output from some versions of javac on:
|
||||
; public static $typename test_get${typename^}Array() {
|
||||
; $typename[][] array = null;
|
||||
; return array[1][1];
|
||||
; }
|
||||
.method public static test_get${typename^}Array()$descriptor
|
||||
.limit locals 1
|
||||
.limit stack 2
|
||||
|
||||
aconst_null
|
||||
astore_0
|
||||
aload_0
|
||||
iconst_1
|
||||
aaload
|
||||
iconst_1
|
||||
${loadstoreprefix}aload
|
||||
${returnprefix}return
|
||||
.end method
|
||||
|
||||
; Output from some versions of javac on:
|
||||
; public static void test_set${typename^}Array() {
|
||||
; $typename[][] array = null;
|
||||
; array[1][1] = $defaultvalue;
|
||||
; }
|
||||
.method public static test_set${typename^}Array()V
|
||||
.limit locals 1
|
||||
.limit stack $((stacksize+2))
|
||||
|
||||
aconst_null
|
||||
astore_0
|
||||
aload_0
|
||||
iconst_1
|
||||
aaload
|
||||
iconst_1
|
||||
$defaultload
|
||||
${loadstoreprefix}astore
|
||||
return
|
||||
.end method
|
||||
"
|
||||
}
|
||||
|
||||
onetype Object 1 null 'Ljava/lang/Object;' aconst_null a
|
||||
onetype boolean 1 false Z iconst_0 b i
|
||||
onetype byte 1 0 B iconst_0 b i
|
||||
onetype char 1 0 C iconst_0 c i
|
||||
onetype short 1 0 S iconst_0 s i
|
||||
onetype int 1 0 I iconst_0 i
|
||||
onetype long 2 0 J lconst_0 l
|
||||
onetype float 1 0 F fconst_0 f
|
||||
onetype double 2 0 D dconst_0 d
|
24
android/dalvik/dx/tests/111-use-null-as-array/run
Normal file
24
android/dalvik/dx/tests/111-use-null-as-array/run
Normal file
|
@ -0,0 +1,24 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# Copyright (C) 2009 The Android Open Source Project
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
$JAVAC -Xlint:-options -source 1.7 -target 1.7 -g -d . Blort.java
|
||||
dx --debug --dex --positions=none --no-locals \
|
||||
--dump-to=- --dump-method="Blort.test*" Blort.class
|
||||
|
||||
bash multidimensional.sh > multidimensional.j
|
||||
jasmin -d . multidimensional.j >/dev/null
|
||||
dx --debug --dex --positions=none --no-locals \
|
||||
--dump-to=- --dump-method="multidimensional.*" multidimensional.class
|
Loading…
Add table
Add a link
Reference in a new issue