Commit 30d28794 by Tom Tromey Committed by Tom Tromey

interpret.cc (convert): New function.

	* interpret.cc (convert): New function.
	(continue1) [insn_d2i, insn_d2l, insn_f2i, insn_f2l]: Use
	convert.
	Include Long.h.

From-SVN: r49621
parent c50503ac
2002-02-08 Tom Tromey <tromey@redhat.com>
* interpret.cc (convert): New function.
(continue1) [insn_d2i, insn_d2l, insn_f2i, insn_f2l]: Use
convert.
Include Long.h.
2002-02-08 Anthony Green <green@redhat.com> 2002-02-08 Anthony Green <green@redhat.com>
* configure.host: Add support for xscale-elf embedded target. * configure.host: Add support for xscale-elf embedded target.
......
...@@ -21,6 +21,7 @@ details. */ ...@@ -21,6 +21,7 @@ details. */
#include <java/lang/System.h> #include <java/lang/System.h>
#include <java/lang/String.h> #include <java/lang/String.h>
#include <java/lang/Integer.h> #include <java/lang/Integer.h>
#include <java/lang/Long.h>
#include <java/lang/StringBuffer.h> #include <java/lang/StringBuffer.h>
#include <java/lang/Class.h> #include <java/lang/Class.h>
#include <java/lang/reflect/Modifier.h> #include <java/lang/reflect/Modifier.h>
...@@ -67,6 +68,22 @@ static inline void dupx (_Jv_word *sp, int n, int x) ...@@ -67,6 +68,22 @@ static inline void dupx (_Jv_word *sp, int n, int x)
}; };
// Used to convert from floating types to integral types.
template<typename TO, typename FROM>
static inline TO
convert (FROM val, TO min, TO max)
{
TO ret;
if (val >= (FROM) max)
ret = max;
else if (val <= (FROM) min)
ret = min;
else if (val != val)
ret = 0;
else
ret = (TO) val;
return ret;
}
#define PUSHA(V) (sp++)->o = (V) #define PUSHA(V) (sp++)->o = (V)
#define PUSHI(V) (sp++)->i = (V) #define PUSHI(V) (sp++)->i = (V)
...@@ -1534,11 +1551,19 @@ void _Jv_InterpMethod::continue1 (_Jv_InterpMethodInvocation *inv) ...@@ -1534,11 +1551,19 @@ void _Jv_InterpMethod::continue1 (_Jv_InterpMethodInvocation *inv)
NEXT_INSN; NEXT_INSN;
insn_f2i: insn_f2i:
{ jint value = (jint)POPF (); PUSHI(value); } {
using namespace java::lang;
jint value = convert (POPF (), Integer::MIN_VALUE, Integer::MAX_VALUE);
PUSHI(value);
}
NEXT_INSN; NEXT_INSN;
insn_f2l: insn_f2l:
{ jlong value = (jlong)POPF (); PUSHL(value); } {
using namespace java::lang;
jlong value = convert (POPF (), Long::MIN_VALUE, Long::MAX_VALUE);
PUSHI(value);
}
NEXT_INSN; NEXT_INSN;
insn_f2d: insn_f2d:
...@@ -1546,11 +1571,19 @@ void _Jv_InterpMethod::continue1 (_Jv_InterpMethodInvocation *inv) ...@@ -1546,11 +1571,19 @@ void _Jv_InterpMethod::continue1 (_Jv_InterpMethodInvocation *inv)
NEXT_INSN; NEXT_INSN;
insn_d2i: insn_d2i:
{ jint value = (jint)POPD (); PUSHI(value); } {
using namespace java::lang;
jint value = convert (POPD (), Integer::MIN_VALUE, Integer::MAX_VALUE);
PUSHI(value);
}
NEXT_INSN; NEXT_INSN;
insn_d2l: insn_d2l:
{ jlong value = (jlong)POPD (); PUSHL(value); } {
using namespace java::lang;
jlong value = convert (POPD (), Long::MIN_VALUE, Long::MAX_VALUE);
PUSHL(value);
}
NEXT_INSN; NEXT_INSN;
insn_d2f: insn_d2f:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment