Merge "Revert "Revert "Implement long negate instruction in the optimizing compiler."""
diff --git a/compiler/optimizing/builder.cc b/compiler/optimizing/builder.cc
index 0ab7782..e4dee46 100644
--- a/compiler/optimizing/builder.cc
+++ b/compiler/optimizing/builder.cc
@@ -550,7 +550,7 @@
}
void HGraphBuilder::BuildFillWideArrayData(HInstruction* object,
- const uint64_t* data,
+ const int64_t* data,
uint32_t element_count,
uint32_t dex_offset) {
for (uint32_t i = 0; i < element_count; ++i) {
@@ -964,25 +964,29 @@
switch (payload->element_width) {
case 1:
- BuildFillArrayData(null_check, data, element_count, Primitive::kPrimByte, dex_offset);
+ BuildFillArrayData(null_check,
+ reinterpret_cast<const int8_t*>(data),
+ element_count,
+ Primitive::kPrimByte,
+ dex_offset);
break;
case 2:
BuildFillArrayData(null_check,
- reinterpret_cast<const uint16_t*>(data),
+ reinterpret_cast<const int16_t*>(data),
element_count,
Primitive::kPrimShort,
dex_offset);
break;
case 4:
BuildFillArrayData(null_check,
- reinterpret_cast<const uint32_t*>(data),
+ reinterpret_cast<const int32_t*>(data),
element_count,
Primitive::kPrimInt,
dex_offset);
break;
case 8:
BuildFillWideArrayData(null_check,
- reinterpret_cast<const uint64_t*>(data),
+ reinterpret_cast<const int64_t*>(data),
element_count,
dex_offset);
break;
diff --git a/compiler/optimizing/builder.h b/compiler/optimizing/builder.h
index c5e02db..b55ef07 100644
--- a/compiler/optimizing/builder.h
+++ b/compiler/optimizing/builder.h
@@ -154,7 +154,7 @@
// Fills the given object with data as specified in the fill-array-data
// instruction. The data must be for long and double arrays.
void BuildFillWideArrayData(HInstruction* object,
- const uint64_t* data,
+ const int64_t* data,
uint32_t element_count,
uint32_t dex_offset);
diff --git a/test/412-new-array/src/Main.java b/test/412-new-array/src/Main.java
index 3c74275..168420c 100644
--- a/test/412-new-array/src/Main.java
+++ b/test/412-new-array/src/Main.java
@@ -24,6 +24,8 @@
public static void main(String[] args) throws Exception {
$opt$TestAllocations();
$opt$TestWithInitializations();
+ $opt$TestNegativeValueNewByteArray();
+ $opt$TestNegativeValueNewCharArray();
testSmaliFilledNewArray();
testSmaliFillArrayData();
testSmaliVerifyError();
@@ -109,6 +111,24 @@
assertEquals(obj2, i[1]);
}
+ static void $opt$TestNegativeValueNewByteArray() {
+ // Use an array initializer to hint the use of filled-new-array.
+ byte[] a = { (byte)0xa0, (byte)0xa1, (byte)0xa2, (byte)0xa3,
+ (byte)0xa4, (byte)0xa5, (byte)0xa6, (byte)0xa7 };
+ for (int i = 0; i < a.length; i++) {
+ assertEquals((byte)0xa0 + i, a[i]);
+ }
+ }
+
+ static void $opt$TestNegativeValueNewCharArray() {
+ // Use an array initializer to hint the use of filled-new-array.
+ char[] a = { (char)0xa000, (char)0xa001, (char)0xa002, (char)0xa003,
+ (char)0xa004, (char)0xa005, (char)0xa006, (char)0xa007 };
+ for (int i = 0; i < a.length; i++) {
+ assertEquals((char)0xa000 + i, a[i]);
+ }
+ }
+
public static void testSmaliFilledNewArray() throws Exception {
Class<?> c = Class.forName("FilledNewArray");
diff --git a/test/etc/default-build b/test/etc/default-build
index 009736b..3369dc6 100755
--- a/test/etc/default-build
+++ b/test/etc/default-build
@@ -20,7 +20,7 @@
mkdir classes
${JAVAC} -d classes `find src -name '*.java'`
-if [ -r src2 ]; then
+if [ -d src2 ]; then
${JAVAC} -d classes `find src2 -name '*.java'`
fi
@@ -28,13 +28,13 @@
${DX} -JXmx256m --debug --dex --dump-to=classes.lst --output=classes.dex --dump-width=1000 classes
fi
-if [ -r smali ]; then
+if [ -d smali ]; then
# Compile Smali classes
${SMALI} -JXmx256m --output smali_classes.dex `find smali -name '*.smali'`
${DXMERGER} classes.dex classes.dex smali_classes.dex
fi
-if [ -r src-ex ]; then
+if [ -d src-ex ]; then
mkdir classes-ex
${JAVAC} -d classes-ex -cp classes `find src-ex -name '*.java'`
if [ ${NEED_DEX} = "true" ]; then