summaryrefslogtreecommitdiff
path: root/src/native/java_lang_System.cc
diff options
context:
space:
mode:
author Ian Rogers <irogers@google.com> 2013-02-27 08:32:07 -0800
committer Ian Rogers <irogers@google.com> 2013-04-08 14:24:13 -0700
commit62d6c772205b8859f0ebf7ad105402ec4c3e2e01 (patch)
treee2f2ba6d71ed5a39c9f6909e3f7c08e998053315 /src/native/java_lang_System.cc
parentc9b17c7ee96cd04fac9048aab624ed554fe260bf (diff)
Interpreter entries and instrumentation as a listener.
Make the instrumentation responsible for whether we want method entry/exit stubs, and allow it to use interpreter entry stubs when instruction by instruction instrumentation is required. Improve deoptimization so more JDWP test cases are passing. Refactor exception debug posting, in particular improve reporting in the interpreter. Improve class linker exception throwing so that broken dex files are more likely to be reported. Fixes the performance issue Bug: 8410519. Fix some error reporting lock level errors for the large object space. Make fast object verification faster. Add some debug mode robustness to finding dex PCs in GC maps. Add printf attributes to JniAbortF and fix errors. Expand run-test 044 to test return behaviors and fix issues with not throwing appropriate exceptions for proxies. Ensure causes are reported with a class linker NoClassDefFoundError and JNI NoSuchFieldError. Remove unused debugMe and updateDebuggerFromCode. There's a minor sizing tweak to the arg array builder, and an extra reference array check in the interpreter. Some clean-up of trace code. Fix reg type cache destructor if it is called after the reg type cache is shutdown (as is the case in oatdump). Change-Id: I6519c7b35df77f978d011999354c864f4918e8ce
Diffstat (limited to 'src/native/java_lang_System.cc')
-rw-r--r--src/native/java_lang_System.cc45
1 files changed, 26 insertions, 19 deletions
diff --git a/src/native/java_lang_System.cc b/src/native/java_lang_System.cc
index 5572623a0c..d8df9d9dae 100644
--- a/src/native/java_lang_System.cc
+++ b/src/native/java_lang_System.cc
@@ -14,6 +14,7 @@
* limitations under the License.
*/
+#include "common_throws.h"
#include "gc/card_table-inl.h"
#include "jni_internal.h"
#include "mirror/array.h"
@@ -171,31 +172,33 @@ namespace art {
static void ThrowArrayStoreException_NotAnArray(const char* identifier, mirror::Object* array)
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
std::string actualType(PrettyTypeOf(array));
- Thread::Current()->ThrowNewExceptionF("Ljava/lang/ArrayStoreException;",
- "%s of type %s is not an array", identifier, actualType.c_str());
+ Thread* self = Thread::Current();
+ ThrowLocation throw_location = self->GetCurrentLocationForThrow();
+ self->ThrowNewExceptionF(throw_location, "Ljava/lang/ArrayStoreException;",
+ "%s of type %s is not an array", identifier, actualType.c_str());
}
static void System_arraycopy(JNIEnv* env, jclass, jobject javaSrc, jint srcPos, jobject javaDst, jint dstPos, jint length) {
ScopedObjectAccess soa(env);
// Null pointer checks.
- if (javaSrc == NULL) {
- soa.Self()->ThrowNewException("Ljava/lang/NullPointerException;", "src == null");
+ if (UNLIKELY(javaSrc == NULL)) {
+ ThrowNullPointerException(NULL, "src == null");
return;
}
- if (javaDst == NULL) {
- soa.Self()->ThrowNewException("Ljava/lang/NullPointerException;", "dst == null");
+ if (UNLIKELY(javaDst == NULL)) {
+ ThrowNullPointerException(NULL, "dst == null");
return;
}
// Make sure source and destination are both arrays.
mirror::Object* srcObject = soa.Decode<mirror::Object*>(javaSrc);
mirror::Object* dstObject = soa.Decode<mirror::Object*>(javaDst);
- if (!srcObject->IsArrayInstance()) {
+ if (UNLIKELY(!srcObject->IsArrayInstance())) {
ThrowArrayStoreException_NotAnArray("source", srcObject);
return;
}
- if (!dstObject->IsArrayInstance()) {
+ if (UNLIKELY(!dstObject->IsArrayInstance())) {
ThrowArrayStoreException_NotAnArray("destination", dstObject);
return;
}
@@ -205,21 +208,24 @@ static void System_arraycopy(JNIEnv* env, jclass, jobject javaSrc, jint srcPos,
mirror::Class* dstComponentType = dstArray->GetClass()->GetComponentType();
// Bounds checking.
- if (srcPos < 0 || dstPos < 0 || length < 0 || srcPos > srcArray->GetLength() - length || dstPos > dstArray->GetLength() - length) {
- soa.Self()->ThrowNewExceptionF("Ljava/lang/ArrayIndexOutOfBoundsException;",
- "src.length=%d srcPos=%d dst.length=%d dstPos=%d length=%d",
- srcArray->GetLength(), srcPos, dstArray->GetLength(), dstPos, length);
+ if (UNLIKELY(srcPos < 0 || dstPos < 0 || length < 0 || srcPos > srcArray->GetLength() - length || dstPos > dstArray->GetLength() - length)) {
+ ThrowLocation throw_location = soa.Self()->GetCurrentLocationForThrow();
+ soa.Self()->ThrowNewExceptionF(throw_location, "Ljava/lang/ArrayIndexOutOfBoundsException;",
+ "src.length=%d srcPos=%d dst.length=%d dstPos=%d length=%d",
+ srcArray->GetLength(), srcPos, dstArray->GetLength(), dstPos, length);
return;
}
// Handle primitive arrays.
if (srcComponentType->IsPrimitive() || dstComponentType->IsPrimitive()) {
// If one of the arrays holds a primitive type the other array must hold the exact same type.
- if (srcComponentType->IsPrimitive() != dstComponentType->IsPrimitive() || srcComponentType != dstComponentType) {
+ if (UNLIKELY(srcComponentType != dstComponentType)) {
std::string srcType(PrettyTypeOf(srcArray));
std::string dstType(PrettyTypeOf(dstArray));
- soa.Self()->ThrowNewExceptionF("Ljava/lang/ArrayStoreException;",
- "Incompatible types: src=%s, dst=%s", srcType.c_str(), dstType.c_str());
+ ThrowLocation throw_location = soa.Self()->GetCurrentLocationForThrow();
+ soa.Self()->ThrowNewExceptionF(throw_location, "Ljava/lang/ArrayStoreException;",
+ "Incompatible types: src=%s, dst=%s",
+ srcType.c_str(), dstType.c_str());
return;
}
@@ -299,12 +305,13 @@ static void System_arraycopy(JNIEnv* env, jclass, jobject javaSrc, jint srcPos,
}
Runtime::Current()->GetHeap()->WriteBarrierArray(dstArray, dstPos, length);
- if (i != length) {
+ if (UNLIKELY(i != length)) {
std::string actualSrcType(PrettyTypeOf(o));
std::string dstType(PrettyTypeOf(dstArray));
- soa.Self()->ThrowNewExceptionF("Ljava/lang/ArrayStoreException;",
- "source[%d] of type %s cannot be stored in destination array of type %s",
- srcPos + i, actualSrcType.c_str(), dstType.c_str());
+ ThrowLocation throw_location = soa.Self()->GetCurrentLocationForThrow();
+ soa.Self()->ThrowNewExceptionF(throw_location, "Ljava/lang/ArrayStoreException;",
+ "source[%d] of type %s cannot be stored in destination array of type %s",
+ srcPos + i, actualSrcType.c_str(), dstType.c_str());
return;
}
}