Merge "Revert "Remove GCC atomic workarounds.""
diff --git a/runtime/arch/x86/fault_handler_x86.cc b/runtime/arch/x86/fault_handler_x86.cc
index 8b6c9b1..89baded 100644
--- a/runtime/arch/x86/fault_handler_x86.cc
+++ b/runtime/arch/x86/fault_handler_x86.cc
@@ -28,16 +28,29 @@
#if defined(__APPLE__)
#define ucontext __darwin_ucontext
+
+#if defined(__x86_64__)
+// 64 bit mac build.
+#define CTX_ESP uc_mcontext->__ss.__rsp
+#define CTX_EIP uc_mcontext->__ss.__rip
+#define CTX_EAX uc_mcontext->__ss.__rax
+#define CTX_METHOD uc_mcontext->__ss.__rax
+#else
+// 32 bit mac build.
#define CTX_ESP uc_mcontext->__ss.__esp
#define CTX_EIP uc_mcontext->__ss.__eip
#define CTX_EAX uc_mcontext->__ss.__eax
#define CTX_METHOD uc_mcontext->__ss.__eax
+#endif
+
#elif defined(__x86_64__)
+// 64 bit linux build.
#define CTX_ESP uc_mcontext.gregs[REG_RSP]
#define CTX_EIP uc_mcontext.gregs[REG_RIP]
#define CTX_EAX uc_mcontext.gregs[REG_RAX]
#define CTX_METHOD uc_mcontext.gregs[REG_RDI]
#else
+// 32 bit linux build.
#define CTX_ESP uc_mcontext.gregs[REG_ESP]
#define CTX_EIP uc_mcontext.gregs[REG_EIP]
#define CTX_EAX uc_mcontext.gregs[REG_EAX]
@@ -50,9 +63,18 @@
namespace art {
+#if defined(__APPLE__) && defined(__x86_64__)
+// mac symbols have a prefix of _ on x86_64
+extern "C" void _art_quick_throw_null_pointer_exception();
+extern "C" void _art_quick_throw_stack_overflow_from_signal();
+extern "C" void _art_quick_test_suspend();
+#define EXT_SYM(sym) _ ## sym
+#else
extern "C" void art_quick_throw_null_pointer_exception();
extern "C" void art_quick_throw_stack_overflow_from_signal();
extern "C" void art_quick_test_suspend();
+#define EXT_SYM(sym) sym
+#endif
// Get the size of an instruction in bytes.
// Return 0 if the instruction is not handled.
@@ -253,7 +275,7 @@
*next_sp = retaddr;
uc->CTX_ESP = reinterpret_cast<uintptr_t>(next_sp);
- uc->CTX_EIP = reinterpret_cast<uintptr_t>(art_quick_throw_null_pointer_exception);
+ uc->CTX_EIP = reinterpret_cast<uintptr_t>(EXT_SYM(art_quick_throw_null_pointer_exception));
VLOG(signals) << "Generating null pointer exception";
return true;
}
@@ -327,7 +349,7 @@
*next_sp = retaddr;
uc->CTX_ESP = reinterpret_cast<uintptr_t>(next_sp);
- uc->CTX_EIP = reinterpret_cast<uintptr_t>(art_quick_test_suspend);
+ uc->CTX_EIP = reinterpret_cast<uintptr_t>(EXT_SYM(art_quick_test_suspend));
// Now remove the suspend trigger that caused this fault.
Thread::Current()->RemoveSuspendTrigger();
@@ -383,7 +405,7 @@
uc->CTX_EAX = pregion;
// Now arrange for the signal handler to return to art_quick_throw_stack_overflow_from_signal.
- uc->CTX_EIP = reinterpret_cast<uintptr_t>(art_quick_throw_stack_overflow_from_signal);
+ uc->CTX_EIP = reinterpret_cast<uintptr_t>(EXT_SYM(art_quick_throw_stack_overflow_from_signal));
return true;
}
diff --git a/runtime/arch/x86_64/asm_support_x86_64.S b/runtime/arch/x86_64/asm_support_x86_64.S
index 70c71c2..682ba43 100644
--- a/runtime/arch/x86_64/asm_support_x86_64.S
+++ b/runtime/arch/x86_64/asm_support_x86_64.S
@@ -112,6 +112,8 @@
.balign 16
END_MACRO
+// TODO: we might need to use SYMBOL() here to add the underscore prefix
+// for mac builds.
MACRO1(DEFINE_FUNCTION, c_name)
FUNCTION_TYPE(\c_name, 0)
.globl VAR(c_name, 0)
diff --git a/runtime/arch/x86_64/quick_entrypoints_x86_64.S b/runtime/arch/x86_64/quick_entrypoints_x86_64.S
index f021ada..cbf0f38 100644
--- a/runtime/arch/x86_64/quick_entrypoints_x86_64.S
+++ b/runtime/arch/x86_64/quick_entrypoints_x86_64.S
@@ -285,7 +285,7 @@
NO_ARG_RUNTIME_EXCEPTION art_quick_throw_stack_overflow, artThrowStackOverflowFromCode
// On entry to this function, RAX contains the ESP value for the overflow region.
-DEFINE_FUNCTION art_quick_throw_stack_overflow_from_signal
+DEFINE_FUNCTION SYMBOL(art_quick_throw_stack_overflow_from_signal)
// Here, the RSP is above the protected region. We need to create a
// callee save frame and then move RSP down to the overflow region.
SETUP_SAVE_ALL_CALLEE_SAVE_FRAME // save all registers as basis for long jump context
@@ -294,7 +294,7 @@
mov %gs:THREAD_SELF_OFFSET, %rdi // pass Thread::Current() as first arg
call PLT_SYMBOL(artThrowStackOverflowFromCode) // artThrowStackOverflowFromCode(Thread*, SP)
int3 // unreached
-END_FUNCTION art_quick_throw_stack_overflow_from_signal
+END_FUNCTION SYMBOL(art_quick_throw_stack_overflow_from_signal)
/*
* Called by managed code, saves callee saves and then calls artThrowException
diff --git a/test/046-reflect/src/Main.java b/test/046-reflect/src/Main.java
index 11eb773..3fe3881 100644
--- a/test/046-reflect/src/Main.java
+++ b/test/046-reflect/src/Main.java
@@ -693,10 +693,35 @@
}
}
+ private static void checkGetDeclaredConstructor() {
+ try {
+ Method.class.getDeclaredConstructor().setAccessible(true);
+ System.out.print("Didn't get an exception from method getDeclaredConstructor");
+ } catch (NoSuchMethodException e) {
+ } catch (Exception e) {
+ System.out.print(e);
+ }
+ try {
+ Field.class.getDeclaredConstructor().setAccessible(true);
+ System.out.print("Didn't get an exception from field getDeclaredConstructor");
+ } catch (NoSuchMethodException e) {
+ } catch (Exception e) {
+ System.out.print(e);
+ }
+ try {
+ Class.class.getDeclaredConstructor().setAccessible(true);
+ System.out.print("Didn't get an exception from class getDeclaredConstructor()");
+ } catch (SecurityException e) {
+ } catch (Exception e) {
+ System.out.print(e);
+ }
+ }
+
public static void main(String[] args) throws Exception {
Main test = new Main();
test.run();
+ checkGetDeclaredConstructor();
checkAccess();
checkType();
checkClinitForFields();
diff --git a/test/Android.run-test.mk b/test/Android.run-test.mk
index d7ee383..47111c5 100644
--- a/test/Android.run-test.mk
+++ b/test/Android.run-test.mk
@@ -168,6 +168,7 @@
########################################################################
ART_TEST_TARGET_RUN_TEST_ALL_RULES :=
+ART_TEST_TARGET_RUN_TEST_GCSTRESS_RULES :=
ART_TEST_TARGET_RUN_TEST_DEFAULT_RULES :=
ART_TEST_TARGET_RUN_TEST_INTERPRETER_RULES :=
ART_TEST_TARGET_RUN_TEST_OPTIMIZING_RULES :=
@@ -188,6 +189,7 @@
ART_TEST_TARGET_RUN_TEST_OPTIMIZING_NO_PREBUILD_RULES :=
ART_TEST_TARGET_RUN_TEST_OPTIMIZING_PREBUILD_RULES :=
ART_TEST_TARGET_RUN_TEST_ALL$(ART_PHONY_TEST_TARGET_SUFFIX)_RULES :=
+ART_TEST_TARGET_RUN_TEST_GCSTRESS$(ART_PHONY_TEST_TARGET_SUFFIX)_RULES :=
ART_TEST_TARGET_RUN_TEST_DEFAULT$(ART_PHONY_TEST_TARGET_SUFFIX)_RULES :=
ART_TEST_TARGET_RUN_TEST_INTERPRETER$(ART_PHONY_TEST_TARGET_SUFFIX)_RULES :=
ART_TEST_TARGET_RUN_TEST_OPTIMIZING$(ART_PHONY_TEST_TARGET_SUFFIX)_RULES :=
@@ -226,6 +228,7 @@
ART_TEST_TARGET_RUN_TEST_OPTIMIZING_NO_PREBUILD$(2ND_ART_PHONY_TEST_TARGET_SUFFIX)_RULES :=
ART_TEST_TARGET_RUN_TEST_OPTIMIZING_PREBUILD$(2ND_ART_PHONY_TEST_TARGET_SUFFIX)_RULES :=
ART_TEST_HOST_RUN_TEST_ALL_RULES :=
+ART_TEST_HOST_RUN_TEST_GCSTRESS_RULES :=
ART_TEST_HOST_RUN_TEST_DEFAULT_RULES :=
ART_TEST_HOST_RUN_TEST_INTERPRETER_RULES :=
ART_TEST_HOST_RUN_TEST_OPTIMIZING_RULES :=
@@ -246,6 +249,7 @@
ART_TEST_HOST_RUN_TEST_OPTIMIZING_NO_PREBUILD_RULES :=
ART_TEST_HOST_RUN_TEST_OPTIMIZING_PREBUILD_RULES :=
ART_TEST_HOST_RUN_TEST_ALL$(ART_PHONY_TEST_HOST_SUFFIX)_RULES :=
+ART_TEST_HOST_RUN_TEST_GCSTRESS$(ART_PHONY_TEST_HOST_SUFFIX)_RULES :=
ART_TEST_HOST_RUN_TEST_DEFAULT$(ART_PHONY_TEST_HOST_SUFFIX)_RULES :=
ART_TEST_HOST_RUN_TEST_INTERPRETER$(ART_PHONY_TEST_HOST_SUFFIX)_RULES :=
ART_TEST_HOST_RUN_TEST_OPTIMIZING$(ART_PHONY_TEST_HOST_SUFFIX)_RULES :=
@@ -330,6 +334,7 @@
prereq_rule :=
skip_test := false
uc_reloc_type :=
+ uc_run_type :=
ifeq ($(ART_TEST_RUN_TEST_ALWAYS_CLEAN),true)
run_test_options += --always-clean
endif
@@ -401,6 +406,7 @@
endif
endif
ifeq ($(5),trace)
+ uc_run_type := TRACE
run_test_options += --trace
run_test_rule_name := test-art-$(2)-run-test-trace-$(3)-$(6)-$(1)$(4)
ifneq ($$(ART_TEST_TRACE),true)
@@ -408,6 +414,7 @@
endif
else
ifeq ($(5),gcverify)
+ uc_run_type := GCVERIFY
run_test_options += --runtime-option -Xgc:preverify --runtime-option -Xgc:postverify \
--runtime-option -Xgc:preverify_rosalloc --runtime-option -Xgc:postverify_rosalloc
run_test_rule_name := test-art-$(2)-run-test-gcverify-$(3)-$(6)-$(1)$(4)
@@ -416,6 +423,7 @@
endif
else
ifeq ($(5),gcstress)
+ uc_run_type := GCSTRESS
run_test_options += --runtime-option -Xgc:SS --runtime-option -Xms2m \
--runtime-option -Xmx2m --runtime-option -Xgc:preverify --runtime-option -Xgc:postverify
run_test_rule_name := test-art-$(2)-run-test-gcstress-$(3)-$(6)-$(1)$(4)
@@ -457,6 +465,7 @@
ART_TEST_$$(uc_host_or_target)_RUN_TEST_ALL_RULES += $$(run_test_rule_name)
ART_TEST_$$(uc_host_or_target)_RUN_TEST_$$(uc_reloc_type)_RULES += $$(run_test_rule_name)
ART_TEST_$$(uc_host_or_target)_RUN_TEST_ALL$(4)_RULES += $$(run_test_rule_name)
+ ART_TEST_$$(uc_host_or_target)_RUN_TEST_$$(uc_run_type)_RULES += $$(run_test_rule_name)
# Clear locally defined variables.
skip_test :=
@@ -609,6 +618,8 @@
$(ART_TEST_TARGET_RUN_TEST_RELOCATE_RULES)))
$(eval $(call define-test-art-run-test-group-rule,test-art-target-run-test, \
$(ART_TEST_TARGET_RUN_TEST_ALL_RULES)))
+$(eval $(call define-test-art-run-test-group-rule,test-art-target-run-test-gcstress, \
+ $(ART_TEST_TARGET_RUN_TEST_GCSTRESS_RULES)))
$(eval $(call define-test-art-run-test-group-rule,test-art-target-run-test-default, \
$(ART_TEST_TARGET_RUN_TEST_DEFAULT_RULES)))
$(eval $(call define-test-art-run-test-group-rule,test-art-target-run-test-interpreter, \
@@ -682,6 +693,8 @@
ifdef TARGET_2ND_ARCH
$(eval $(call define-test-art-run-test-group-rule,test-art-target-run-test$(2ND_ART_PHONY_TEST_TARGET_SUFFIX), \
$(ART_TEST_TARGET_RUN_TEST_ALL$(2ND_ART_PHONY_TEST_TARGET_SUFFIX)_RULES)))
+ $(eval $(call define-test-art-run-test-group-rule,test-art-target-run-test-gcstress$(2ND_ART_PHONY_TEST_TARGET_SUFFIX), \
+ $(ART_TEST_TARGET_RUN_TEST_GCSTRESS$(2ND_ART_PHONY_TEST_TARGET_SUFFIX)_RULES)))
$(eval $(call define-test-art-run-test-group-rule,test-art-target-run-test-default$(2ND_ART_PHONY_TEST_TARGET_SUFFIX), \
$(ART_TEST_TARGET_RUN_TEST_DEFAULT$(2ND_ART_PHONY_TEST_TARGET_SUFFIX)_RULES)))
$(eval $(call define-test-art-run-test-group-rule,test-art-target-run-test-interpreter$(2ND_ART_PHONY_TEST_TARGET_SUFFIX), \
@@ -732,6 +745,8 @@
$(ART_TEST_HOST_RUN_TEST_RELOCATE_RULES)))
$(eval $(call define-test-art-run-test-group-rule,test-art-host-run-test, \
$(ART_TEST_HOST_RUN_TEST_ALL_RULES)))
+$(eval $(call define-test-art-run-test-group-rule,test-art-host-run-test-gcstress, \
+ $(ART_TEST_HOST_RUN_TEST_GCSTRESS_RULES)))
$(eval $(call define-test-art-run-test-group-rule,test-art-host-run-test-default, \
$(ART_TEST_HOST_RUN_TEST_DEFAULT_RULES)))
$(eval $(call define-test-art-run-test-group-rule,test-art-host-run-test-interpreter, \
@@ -805,6 +820,8 @@
ifneq ($(HOST_PREFER_32_BIT),true)
$(eval $(call define-test-art-run-test-group-rule,test-art-host-run-test$(2ND_ART_PHONY_TEST_HOST_SUFFIX), \
$(ART_TEST_HOST_RUN_TEST_ALL$(2ND_ART_PHONY_TEST_HOST_SUFFIX)_RULES)))
+ $(eval $(call define-test-art-run-test-group-rule,test-art-host-run-test-gcstress$(2ND_ART_PHONY_TEST_HOST_SUFFIX), \
+ $(ART_TEST_HOST_RUN_TEST_GCSTRESS$(2ND_ART_PHONY_TEST_HOST_SUFFIX)_RULES)))
$(eval $(call define-test-art-run-test-group-rule,test-art-host-run-test-default$(2ND_ART_PHONY_TEST_HOST_SUFFIX), \
$(ART_TEST_HOST_RUN_TEST_DEFAULT$(2ND_ART_PHONY_TEST_HOST_SUFFIX)_RULES)))
$(eval $(call define-test-art-run-test-group-rule,test-art-host-run-test-interpreter$(2ND_ART_PHONY_TEST_HOST_SUFFIX), \