aboutsummaryrefslogtreecommitdiff
path: root/libjava
diff options
context:
space:
mode:
authorChris Sears <cbsears_sf@yahoo.com>2002-01-08 19:07:46 +0000
committerTom Tromey <tromey@gcc.gnu.org>2002-01-08 19:07:46 +0000
commit00cc944db912f3b643c911f52af8a9b9ea2b1cd0 (patch)
tree491a228971a4e5b1a8b7c62dcdbef1379b66a7f9 /libjava
parent0d24f4d1314fbfc9a42fe7839179d20dc2e6b0dd (diff)
downloadgcc-00cc944db912f3b643c911f52af8a9b9ea2b1cd0.zip
gcc-00cc944db912f3b643c911f52af8a9b9ea2b1cd0.tar.gz
gcc-00cc944db912f3b643c911f52af8a9b9ea2b1cd0.tar.bz2
interpret.cc (ARRAYBOUNDSCHECK): New macro.
2002-01-08 Chris Sears <cbsears_sf@yahoo.com> * interpret.cc (ARRAYBOUNDSCHECK): New macro. (continue1) [insn_iaload, insn_laload, insn_faload, insn_daload, insn_aaload, insn_baload, insn_caload, insn_saload, insn_iastore, insn_lastore, insn_fastore, insn_dastore, insn_aastore, insn_bastore, insn_castore, insn_sastore]: Use it. (continue1) [insn_arraylength]: Check for null array. From-SVN: r48652
Diffstat (limited to 'libjava')
-rw-r--r--libjava/ChangeLog9
-rw-r--r--libjava/interpret.cc90
2 files changed, 34 insertions, 65 deletions
diff --git a/libjava/ChangeLog b/libjava/ChangeLog
index 97c3b0f..c8a957e 100644
--- a/libjava/ChangeLog
+++ b/libjava/ChangeLog
@@ -1,3 +1,12 @@
+2002-01-08 Chris Sears <cbsears_sf@yahoo.com>
+
+ * interpret.cc (ARRAYBOUNDSCHECK): New macro.
+ (continue1) [insn_iaload, insn_laload, insn_faload, insn_daload,
+ insn_aaload, insn_baload, insn_caload, insn_saload, insn_iastore,
+ insn_lastore, insn_fastore, insn_dastore, insn_aastore,
+ insn_bastore, insn_castore, insn_sastore]: Use it.
+ (continue1) [insn_arraylength]: Check for null array.
+
2002-01-06 Andreas Tobler <a.tobler@schweiz.ch>
* configure, include/config.h.in: Rebuilt.
diff --git a/libjava/interpret.cc b/libjava/interpret.cc
index 5bfe4e7..8075e5b 100644
--- a/libjava/interpret.cc
+++ b/libjava/interpret.cc
@@ -1,6 +1,6 @@
// interpret.cc - Code for the interpreter
-/* Copyright (C) 1999, 2000, 2001 Free Software Foundation
+/* Copyright (C) 1999, 2000, 2001 , 2002 Free Software Foundation
This file is part of libgcj.
@@ -187,6 +187,13 @@ static jint get4(unsigned char* loc) {
do { if ((X)==NULL) throw_null_pointer_exception (); } while (0)
#endif
+#define ARRAYBOUNDSCHECK(array, index) \
+ do \
+ { \
+ if (((unsigned) index) >= (unsigned) (array->length)) \
+ _Jv_ThrowBadArrayIndex (index); \
+ } \
+ while (0)
// this method starts the actual running of the method. It is inlined
// in three different variants in the static methods run_normal,
@@ -958,10 +965,7 @@ void _Jv_InterpMethod::continue1 (_Jv_InterpMethodInvocation *inv)
jint index = POPI();
jintArray arr = (jintArray) POPA();
NULLCHECK (arr);
- if (index < 0 || index >= arr->length)
- {
- _Jv_ThrowBadArrayIndex (index);
- }
+ ARRAYBOUNDSCHECK (arr, index);
PUSHI( elements(arr)[index] );
}
NEXT_INSN;
@@ -972,10 +976,7 @@ void _Jv_InterpMethod::continue1 (_Jv_InterpMethodInvocation *inv)
jint index = POPI();
jlongArray arr = (jlongArray) POPA();
NULLCHECK (arr);
- if (index < 0 || index >= arr->length)
- {
- _Jv_ThrowBadArrayIndex (index);
- }
+ ARRAYBOUNDSCHECK (arr, index);
PUSHL( elements(arr)[index] );
}
NEXT_INSN;
@@ -986,10 +987,7 @@ void _Jv_InterpMethod::continue1 (_Jv_InterpMethodInvocation *inv)
jint index = POPI();
jfloatArray arr = (jfloatArray) POPA();
NULLCHECK (arr);
- if (index < 0 || index >= arr->length)
- {
- _Jv_ThrowBadArrayIndex (index);
- }
+ ARRAYBOUNDSCHECK (arr, index);
PUSHF( elements(arr)[index] );
}
NEXT_INSN;
@@ -1000,10 +998,7 @@ void _Jv_InterpMethod::continue1 (_Jv_InterpMethodInvocation *inv)
jint index = POPI();
jdoubleArray arr = (jdoubleArray) POPA();
NULLCHECK (arr);
- if (index < 0 || index >= arr->length)
- {
- _Jv_ThrowBadArrayIndex (index);
- }
+ ARRAYBOUNDSCHECK (arr, index);
PUSHD( elements(arr)[index] );
}
NEXT_INSN;
@@ -1014,10 +1009,7 @@ void _Jv_InterpMethod::continue1 (_Jv_InterpMethodInvocation *inv)
jint index = POPI();
jobjectArray arr = (jobjectArray) POPA();
NULLCHECK (arr);
- if (index < 0 || index >= arr->length)
- {
- _Jv_ThrowBadArrayIndex (index);
- }
+ ARRAYBOUNDSCHECK (arr, index);
PUSHA( elements(arr)[index] );
}
NEXT_INSN;
@@ -1028,10 +1020,7 @@ void _Jv_InterpMethod::continue1 (_Jv_InterpMethodInvocation *inv)
jint index = POPI();
jbyteArray arr = (jbyteArray) POPA();
NULLCHECK (arr);
- if (index < 0 || index >= arr->length)
- {
- _Jv_ThrowBadArrayIndex (index);
- }
+ ARRAYBOUNDSCHECK (arr, index);
PUSHI( elements(arr)[index] );
}
NEXT_INSN;
@@ -1042,10 +1031,7 @@ void _Jv_InterpMethod::continue1 (_Jv_InterpMethodInvocation *inv)
jint index = POPI();
jcharArray arr = (jcharArray) POPA();
NULLCHECK (arr);
- if (index < 0 || index >= arr->length)
- {
- _Jv_ThrowBadArrayIndex (index);
- }
+ ARRAYBOUNDSCHECK (arr, index);
PUSHI( elements(arr)[index] );
}
NEXT_INSN;
@@ -1056,10 +1042,7 @@ void _Jv_InterpMethod::continue1 (_Jv_InterpMethodInvocation *inv)
jint index = POPI();
jshortArray arr = (jshortArray) POPA();
NULLCHECK (arr);
- if (index < 0 || index >= arr->length)
- {
- _Jv_ThrowBadArrayIndex (index);
- }
+ ARRAYBOUNDSCHECK (arr, index);
PUSHI( elements(arr)[index] );
}
NEXT_INSN;
@@ -1171,10 +1154,7 @@ void _Jv_InterpMethod::continue1 (_Jv_InterpMethodInvocation *inv)
jint index = POPI();
jintArray arr = (jintArray) POPA();
NULLCHECK (arr);
- if (index < 0 || index >= arr->length)
- {
- _Jv_ThrowBadArrayIndex (index);
- }
+ ARRAYBOUNDSCHECK (arr, index);
elements(arr)[index] = value;
}
NEXT_INSN;
@@ -1186,10 +1166,7 @@ void _Jv_InterpMethod::continue1 (_Jv_InterpMethodInvocation *inv)
jint index = POPI();
jlongArray arr = (jlongArray) POPA();
NULLCHECK (arr);
- if (index < 0 || index >= arr->length)
- {
- _Jv_ThrowBadArrayIndex (index);
- }
+ ARRAYBOUNDSCHECK (arr, index);
elements(arr)[index] = value;
}
NEXT_INSN;
@@ -1201,10 +1178,7 @@ void _Jv_InterpMethod::continue1 (_Jv_InterpMethodInvocation *inv)
jint index = POPI();
jfloatArray arr = (jfloatArray) POPA();
NULLCHECK (arr);
- if (index < 0 || index >= arr->length)
- {
- _Jv_ThrowBadArrayIndex (index);
- }
+ ARRAYBOUNDSCHECK (arr, index);
elements(arr)[index] = value;
}
NEXT_INSN;
@@ -1216,10 +1190,7 @@ void _Jv_InterpMethod::continue1 (_Jv_InterpMethodInvocation *inv)
jint index = POPI();
jdoubleArray arr = (jdoubleArray) POPA();
NULLCHECK (arr);
- if (index < 0 || index >= arr->length)
- {
- _Jv_ThrowBadArrayIndex (index);
- }
+ ARRAYBOUNDSCHECK (arr, index);
elements(arr)[index] = value;
}
NEXT_INSN;
@@ -1231,10 +1202,7 @@ void _Jv_InterpMethod::continue1 (_Jv_InterpMethodInvocation *inv)
jint index = POPI();
jobjectArray arr = (jobjectArray) POPA();
NULLCHECK (arr);
- if (index < 0 || index >= arr->length)
- {
- _Jv_ThrowBadArrayIndex (index);
- }
+ ARRAYBOUNDSCHECK (arr, index);
_Jv_CheckArrayStore (arr, value);
elements(arr)[index] = value;
}
@@ -1247,10 +1215,7 @@ void _Jv_InterpMethod::continue1 (_Jv_InterpMethodInvocation *inv)
jint index = POPI();
jbyteArray arr = (jbyteArray) POPA();
NULLCHECK (arr);
- if (index < 0 || index >= arr->length)
- {
- _Jv_ThrowBadArrayIndex (index);
- }
+ ARRAYBOUNDSCHECK (arr, index);
elements(arr)[index] = value;
}
NEXT_INSN;
@@ -1262,10 +1227,7 @@ void _Jv_InterpMethod::continue1 (_Jv_InterpMethodInvocation *inv)
jint index = POPI();
jcharArray arr = (jcharArray) POPA();
NULLCHECK (arr);
- if (index < 0 || index >= arr->length)
- {
- _Jv_ThrowBadArrayIndex (index);
- }
+ ARRAYBOUNDSCHECK (arr, index);
elements(arr)[index] = value;
}
NEXT_INSN;
@@ -1277,10 +1239,7 @@ void _Jv_InterpMethod::continue1 (_Jv_InterpMethodInvocation *inv)
jint index = POPI();
jshortArray arr = (jshortArray) POPA();
NULLCHECK (arr);
- if (index < 0 || index >= arr->length)
- {
- _Jv_ThrowBadArrayIndex (index);
- }
+ ARRAYBOUNDSCHECK (arr, index);
elements(arr)[index] = value;
}
NEXT_INSN;
@@ -2229,6 +2188,7 @@ void _Jv_InterpMethod::continue1 (_Jv_InterpMethodInvocation *inv)
SAVE_PC;
{
__JArray *arr = (__JArray*)POPA();
+ NULLCHECK (arr);
PUSHI (arr->length);
}
NEXT_INSN;