Merge "Fix a MOV instruction in Optimizing's x86-64 code generator."
diff --git a/compiler/dex/quick/gen_loadstore.cc b/compiler/dex/quick/gen_loadstore.cc
index aa95e77..3f89001 100644
--- a/compiler/dex/quick/gen_loadstore.cc
+++ b/compiler/dex/quick/gen_loadstore.cc
@@ -107,7 +107,9 @@
}
RegLocation Mir2Lir::LoadValue(RegLocation rl_src, RegisterClass op_kind) {
- DCHECK(!rl_src.ref || op_kind == kRefReg);
+ // If op_kind isn't a reference, rl_src should not be marked as a reference either
+ // unless we've seen type conflicts (i.e. register promotion is disabled).
+ DCHECK(op_kind == kRefReg || (!rl_src.ref || (cu_->disable_opt & (1u << kPromoteRegs)) != 0u));
rl_src = UpdateLoc(rl_src);
if (rl_src.location == kLocPhysReg) {
if (!RegClassMatches(op_kind, rl_src.reg)) {
diff --git a/compiler/optimizing/code_generator_arm.cc b/compiler/optimizing/code_generator_arm.cc
index ff9373a..39c316f 100644
--- a/compiler/optimizing/code_generator_arm.cc
+++ b/compiler/optimizing/code_generator_arm.cc
@@ -1030,9 +1030,8 @@
if (!cond->IsCondition() || cond->AsCondition()->NeedsMaterialization()) {
// Condition has been materialized, compare the output to 0
DCHECK(instruction->GetLocations()->InAt(0).IsRegister());
- __ cmp(instruction->GetLocations()->InAt(0).AsRegister<Register>(),
- ShifterOperand(0));
- __ b(true_target, NE);
+ __ CompareAndBranchIfNonZero(instruction->GetLocations()->InAt(0).AsRegister<Register>(),
+ true_target);
} else {
// Condition has not been materialized, use its inputs as the
// comparison and its condition as the branch condition.
@@ -2591,8 +2590,7 @@
switch (instruction->GetType()) {
case Primitive::kPrimInt: {
if (value.IsRegister()) {
- __ cmp(value.AsRegister<Register>(), ShifterOperand(0));
- __ b(slow_path->GetEntryLabel(), EQ);
+ __ CompareAndBranchIfZero(value.AsRegister<Register>(), slow_path->GetEntryLabel());
} else {
DCHECK(value.IsConstant()) << value;
if (value.GetConstant()->AsIntConstant()->GetValue() == 0) {
@@ -3011,8 +3009,7 @@
__ ldrexd(temp1, temp2, addr);
codegen_->MaybeRecordImplicitNullCheck(instruction);
__ strexd(temp1, value_lo, value_hi, addr);
- __ cmp(temp1, ShifterOperand(0));
- __ b(&fail, NE);
+ __ CompareAndBranchIfNonZero(temp1, &fail);
}
void LocationsBuilderARM::HandleFieldSet(HInstruction* instruction, const FieldInfo& field_info) {
@@ -3328,8 +3325,7 @@
LocationSummary* locations = instruction->GetLocations();
Location obj = locations->InAt(0);
- __ cmp(obj.AsRegister<Register>(), ShifterOperand(0));
- __ b(slow_path->GetEntryLabel(), EQ);
+ __ CompareAndBranchIfZero(obj.AsRegister<Register>(), slow_path->GetEntryLabel());
}
void InstructionCodeGeneratorARM::VisitNullCheck(HNullCheck* instruction) {
@@ -3746,13 +3742,11 @@
__ LoadFromOffset(
kLoadUnsignedHalfword, IP, TR, Thread::ThreadFlagsOffset<kArmWordSize>().Int32Value());
- __ cmp(IP, ShifterOperand(0));
- // TODO: Figure out the branch offsets and use cbz/cbnz.
if (successor == nullptr) {
- __ b(slow_path->GetEntryLabel(), NE);
+ __ CompareAndBranchIfNonZero(IP, slow_path->GetEntryLabel());
__ Bind(slow_path->GetReturnLabel());
} else {
- __ b(codegen_->GetLabelOf(successor), EQ);
+ __ CompareAndBranchIfZero(IP, codegen_->GetLabelOf(successor));
__ b(slow_path->GetEntryLabel());
}
}
@@ -4004,8 +3998,7 @@
SlowPathCodeARM* slow_path = new (GetGraph()->GetArena()) LoadClassSlowPathARM(
cls, cls, cls->GetDexPc(), cls->MustGenerateClinitCheck());
codegen_->AddSlowPath(slow_path);
- __ cmp(out, ShifterOperand(0));
- __ b(slow_path->GetEntryLabel(), EQ);
+ __ CompareAndBranchIfZero(out, slow_path->GetEntryLabel());
if (cls->MustGenerateClinitCheck()) {
GenerateClassInitializationCheck(slow_path, out);
} else {
@@ -4061,8 +4054,7 @@
kLoadWord, out, current_method, ArtMethod::DeclaringClassOffset().Int32Value());
__ LoadFromOffset(kLoadWord, out, out, mirror::Class::DexCacheStringsOffset().Int32Value());
__ LoadFromOffset(kLoadWord, out, out, CodeGenerator::GetCacheOffset(load->GetStringIndex()));
- __ cmp(out, ShifterOperand(0));
- __ b(slow_path->GetEntryLabel(), EQ);
+ __ CompareAndBranchIfZero(out, slow_path->GetEntryLabel());
__ Bind(slow_path->GetExitLabel());
}
diff --git a/compiler/utils/arm/assembler_thumb2.cc b/compiler/utils/arm/assembler_thumb2.cc
index f9e1ac6..2dde014 100644
--- a/compiler/utils/arm/assembler_thumb2.cc
+++ b/compiler/utils/arm/assembler_thumb2.cc
@@ -3341,7 +3341,7 @@
void Thumb2Assembler::CompareAndBranchIfZero(Register r, Label* label) {
- if (CanRelocateBranches() && IsLowRegister(r)) {
+ if (CanRelocateBranches() && IsLowRegister(r) && !label->IsBound()) {
cbz(r, label);
} else {
cmp(r, ShifterOperand(0));
@@ -3351,7 +3351,7 @@
void Thumb2Assembler::CompareAndBranchIfNonZero(Register r, Label* label) {
- if (CanRelocateBranches() && IsLowRegister(r)) {
+ if (CanRelocateBranches() && IsLowRegister(r) && !label->IsBound()) {
cbnz(r, label);
} else {
cmp(r, ShifterOperand(0));
diff --git a/dex2oat/dex2oat.cc b/dex2oat/dex2oat.cc
index 7a23746..74d5c0c 100644
--- a/dex2oat/dex2oat.cc
+++ b/dex2oat/dex2oat.cc
@@ -1038,6 +1038,10 @@
bool OpenFile() {
bool create_file = !oat_unstripped_.empty(); // as opposed to using open file descriptor
if (create_file) {
+ // We're supposed to create this file. If the file already exists, it may be in use currently.
+ // We must not change the content of that file, then. So unlink it first.
+ unlink(oat_unstripped_.c_str());
+
oat_file_.reset(OS::CreateEmptyFile(oat_unstripped_.c_str()));
if (oat_location_.empty()) {
oat_location_ = oat_filename_;
diff --git a/runtime/Android.mk b/runtime/Android.mk
index 5ed6955..19079cb 100644
--- a/runtime/Android.mk
+++ b/runtime/Android.mk
@@ -478,7 +478,7 @@
# For liblog, atrace, properties, ashmem, set_sched_policy and socket_peer_is_trusted.
LOCAL_SHARED_LIBRARIES += libcutils
else # host
- LOCAL_SHARED_LIBRARIES += libziparchive-host
+ LOCAL_SHARED_LIBRARIES += libziparchive-host libz-host
# For ashmem_create_region.
LOCAL_SHARED_LIBRARIES += libcutils
endif
diff --git a/runtime/java_vm_ext.cc b/runtime/java_vm_ext.cc
index eb9c32d..f1deacf 100644
--- a/runtime/java_vm_ext.cc
+++ b/runtime/java_vm_ext.cc
@@ -132,6 +132,8 @@
}
void* FindSymbol(const std::string& symbol_name) {
+ CHECK(!NeedsNativeBridge());
+
return dlsym(handle_, symbol_name.c_str());
}
@@ -234,9 +236,6 @@
fn = library->FindSymbol(jni_long_name);
}
}
- if (fn == nullptr) {
- fn = library->FindSymbol(jni_long_name);
- }
if (fn != nullptr) {
VLOG(jni) << "[Found native code for " << PrettyMethod(m)
<< " in \"" << library->GetPath() << "\"]";
diff --git a/test/036-finalizer/src/Main.java b/test/036-finalizer/src/Main.java
index e3cf4ee..8c7c27d 100644
--- a/test/036-finalizer/src/Main.java
+++ b/test/036-finalizer/src/Main.java
@@ -34,31 +34,10 @@
}
public static WeakReference<FinalizerTest> makeRef() {
- /*
- * Make ft in another thread, so there is no danger of
- * a conservative reference leaking onto the main thread's
- * stack.
- */
-
- final List<WeakReference<FinalizerTest>> wimp =
- new ArrayList<WeakReference<FinalizerTest>>();
- Thread t = new Thread() {
- public void run() {
- FinalizerTest ft = new FinalizerTest("wahoo");
- wimp.add(new WeakReference<FinalizerTest>(ft));
- ft = null;
- }
- };
-
- t.start();
-
- try {
- t.join();
- } catch (InterruptedException ie) {
- throw new RuntimeException(ie);
- }
-
- return wimp.get(0);
+ FinalizerTest ft = new FinalizerTest("wahoo");
+ WeakReference<FinalizerTest> ref = new WeakReference<FinalizerTest>(ft);
+ ft = null;
+ return ref;
}
public static String wimpString(final WeakReference<FinalizerTest> wimp) {
@@ -91,10 +70,12 @@
public static void main(String[] args) {
WeakReference<FinalizerTest> wimp = makeRef();
+ FinalizerTest keepLive = wimp.get();
System.out.println("wimp: " + wimpString(wimp));
/* this will try to collect and finalize ft */
+ keepLive = null;
System.out.println("gc");
Runtime.getRuntime().gc();
diff --git a/test/Android.run-test.mk b/test/Android.run-test.mk
index 6c2ce62..5b5c368 100644
--- a/test/Android.run-test.mk
+++ b/test/Android.run-test.mk
@@ -233,7 +233,10 @@
TEST_ART_BROKEN_NO_RELOCATE_TESTS :=
# Tests that are broken with GC stress.
-TEST_ART_BROKEN_GCSTRESS_RUN_TESTS :=
+# 137-cfi needs to unwind a second forked process. We're using a primitive sleep to wait till we
+# hope the second process got into the expected state. The slowness of gcstress makes this bad.
+TEST_ART_BROKEN_GCSTRESS_RUN_TESTS := \
+ 137-cfi
ifneq (,$(filter gcstress,$(GC_TYPES)))
ART_TEST_KNOWN_BROKEN += $(call all-run-test-names,$(TARGET_TYPES),$(RUN_TYPES),$(PREBUILD_TYPES), \
diff --git a/test/run-test b/test/run-test
index 995d30f..ffa25eb 100755
--- a/test/run-test
+++ b/test/run-test
@@ -308,7 +308,7 @@
run_args="${run_args} --runtime-option -Xgc:preverify_rosalloc --runtime-option -Xgc:postverify_rosalloc"
fi
if [ "$gc_stress" = "true" ]; then
- run_args="${run_args} --runtime-option -Xgc:SS --runtime-option -Xms2m --runtime-option -Xmx2m"
+ run_args="${run_args} --runtime-option -Xgc:SS,gcstress --runtime-option -Xms2m --runtime-option -Xmx16m"
fi
if [ "$trace" = "true" ]; then
run_args="${run_args} --runtime-option -Xmethod-trace --runtime-option -Xmethod-trace-file-size:2000000"
diff --git a/tools/symbolize.sh b/tools/symbolize.sh
index 0168e7d..7365a9b 100755
--- a/tools/symbolize.sh
+++ b/tools/symbolize.sh
@@ -37,30 +37,23 @@
exit 0
fi
fi
- adb pull /data/dalvik-cache/$1/$2 /tmp || exit 1
- mkdir -p $OUT/symbols/data/dalvik-cache/$1
- oatdump --symbolize=/tmp/$2 --output=$OUT/symbols/data/dalvik-cache/$1/$2
+ adb pull $1/$2 /tmp || exit 1
+ mkdir -p $OUT/symbols/$1
+ oatdump --symbolize=/tmp/$2 --output=$OUT/symbols/$1/$2
}
-# adb shell ls seems to output in DOS format (CRLF), which messes up scripting
-function adbls() {
- adb shell ls $@ | sed 's/\r$//'
+# adb shell find seems to output in DOS format (CRLF), which messes up scripting
+function adbshellstrip() {
+ adb shell $@ | sed 's/\r$//'
}
-# Check for all ISA directories on device.
+# Search in all of /data on device.
function all() {
- DIRS=$(adbls /data/dalvik-cache/)
- for DIR in $DIRS ; do
- case $DIR in
- arm|arm64|mips|mips64|x86|x86_64)
- FILES=$(adbls /data/dalvik-cache/$DIR/*.oat /data/dalvik-cache/$DIR/*.dex)
- for FILE in $FILES ; do
- # Cannot use basename as the file doesn't exist.
- NAME=$(echo $FILE | sed -e 's/.*\///')
- one $DIR $NAME
- done
- ;;
- esac
+ FILES=$(adbshellstrip find /data -name "'*.oat'" -o -name "'*.dex'" -o -name "'*.odex'")
+ for FILE in $FILES ; do
+ DIR=$(dirname $FILE)
+ NAME=$(basename $FILE)
+ one $DIR $NAME
done
}