Commit 855dd2bc by Tom Tromey Committed by Tom Tromey

re PR java/22578 (should inline floatToIntBits et al)

gcc/java
	PR java/22578:
	* check-init.c (check_init): Handle VIEW_CONVERT_EXPR.
	* builtins.c (convert_real): New function.
	(java_builtins): Handle Float.intBitsToFloat,
	Float.floatToRawIntBits, Double.longBitsToDouble,
	Double.doubleToRawLongBits.
libjava
	PR java/22578:
	* gcj/javaprims.h: Updated.
	* sources.am, Makefile.in: Rebuilt.
	* java/lang/natDouble.cc (doubleToLongBits): Moved to VMDouble.
	(doubleToRawLongBits): Likewise.
	(longBitsToDouble): Likewise.
	(toString): Likewise.
	(parseDouble): Likewise.
	* java/lang/natFloat.cc (floatToIntBits): Moved to VMFloat.
	(floatToRawIntBits): Likewise.
	(intBitsToFloat): Likewise.
	* java/lang/VMDouble.java: New file.
	* java/lang/VMFloat.java: New file.
	* java/lang/Float.java, java/lang/Double.java: Removed.

From-SVN: r110759
parent 59c02d8a
2006-02-08 Tom Tromey <tromey@redhat.com>
PR java/22578:
* check-init.c (check_init): Handle VIEW_CONVERT_EXPR.
* builtins.c (convert_real): New function.
(java_builtins): Handle Float.intBitsToFloat,
Float.floatToRawIntBits, Double.longBitsToDouble,
Double.doubleToRawLongBits.
2006-02-07 Andrew Haley <aph@redhat.com>
* expr.c (expand_invoke): (BC mode.) If we find a method in a
......
......@@ -39,6 +39,7 @@ The Free Software Foundation is independent of Sun Microsystems, Inc. */
static tree max_builtin (tree, tree);
static tree min_builtin (tree, tree);
static tree abs_builtin (tree, tree);
static tree convert_real (tree, tree);
static tree java_build_function_call_expr (tree, tree);
......@@ -85,6 +86,10 @@ static GTY(()) struct builtin_record java_builtins[] =
{ { "java.lang.Math" }, { "sin" }, NULL, BUILT_IN_SIN },
{ { "java.lang.Math" }, { "sqrt" }, NULL, BUILT_IN_SQRT },
{ { "java.lang.Math" }, { "tan" }, NULL, BUILT_IN_TAN },
{ { "java.lang.Float" }, { "intBitsToFloat" }, convert_real, 0 },
{ { "java.lang.Double" }, { "longBitsToDouble" }, convert_real, 0 },
{ { "java.lang.Float" }, { "floatToRawIntBits" }, convert_real, 0 },
{ { "java.lang.Double" }, { "doubleToRawLongBits" }, convert_real, 0 },
{ { NULL }, { NULL }, NULL, END_BUILTINS }
};
......@@ -131,6 +136,13 @@ java_build_function_call_expr (tree fn, tree arglist)
call_expr, arglist, NULL_TREE);
}
static tree
convert_real (tree method_return_type, tree method_arguments)
{
return build1 (VIEW_CONVERT_EXPR, method_return_type,
TREE_VALUE (method_arguments));
}
#define BUILTIN_NOTHROW 1
......
/* Code to test for "definitive [un]assignment".
Copyright (C) 1999, 2000, 2001, 2003, 2004, 2005 Free Software Foundation,
Copyright (C) 1999, 2000, 2001, 2003, 2004, 2005, 2006 Free Software Foundation,
Inc.
This file is part of GCC.
......@@ -806,6 +806,7 @@ check_init (tree exp, words before)
case TRUTH_NOT_EXPR:
case BIT_NOT_EXPR:
case CONVERT_EXPR:
case VIEW_CONVERT_EXPR:
case BIT_FIELD_REF:
case FLOAT_EXPR:
case FIX_TRUNC_EXPR:
......
2006-02-08 Tom Tromey <tromey@redhat.com>
PR java/22578:
* gcj/javaprims.h: Updated.
* sources.am, Makefile.in: Rebuilt.
* java/lang/natDouble.cc (doubleToLongBits): Moved to VMDouble.
(doubleToRawLongBits): Likewise.
(longBitsToDouble): Likewise.
(toString): Likewise.
(parseDouble): Likewise.
* java/lang/natFloat.cc (floatToIntBits): Moved to VMFloat.
(floatToRawIntBits): Likewise.
(intBitsToFloat): Likewise.
* java/lang/VMDouble.java: New file.
* java/lang/VMFloat.java: New file.
* java/lang/Float.java, java/lang/Double.java: Removed.
2006-02-06 Tom Tromey <tromey@redhat.com>
* gij.cc (version): Use 2006.
......
......@@ -2884,12 +2884,12 @@ classpath/java/lang/Cloneable.java \
classpath/java/lang/Comparable.java \
classpath/java/lang/Compiler.java \
java/lang/ConcreteProcess.java \
java/lang/Double.java \
classpath/java/lang/Double.java \
classpath/java/lang/EnumConstantNotPresentException.java \
classpath/java/lang/Error.java \
classpath/java/lang/Exception.java \
classpath/java/lang/ExceptionInInitializerError.java \
java/lang/Float.java \
classpath/java/lang/Float.java \
classpath/java/lang/IllegalAccessError.java \
classpath/java/lang/IllegalAccessException.java \
classpath/java/lang/IllegalArgumentException.java \
......@@ -2947,6 +2947,8 @@ classpath/java/lang/UnsupportedClassVersionError.java \
classpath/java/lang/UnsupportedOperationException.java \
java/lang/VMClassLoader.java \
java/lang/VMCompiler.java \
java/lang/VMDouble.java \
java/lang/VMFloat.java \
java/lang/VMSecurityManager.java \
java/lang/VMThrowable.java \
classpath/java/lang/VerifyError.java \
......
// javaprims.h - Main external header file for libgcj. -*- c++ -*-
/* Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
/* Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006
Free Software Foundation
This file is part of libgcj.
......@@ -218,6 +218,8 @@ extern "Java"
class UnsupportedOperationException;
class VMClassLoader;
class VMCompiler;
class VMDouble;
class VMFloat;
class VMSecurityManager;
class VMThrowable;
class VerifyError;
......
/* VMDouble.java -- VM Specific Double methods
Copyright (C) 2003, 2005, 2006 Free Software Foundation
This file is part of GNU Classpath.
GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.
As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module. An independent module is a module which is not derived from
or based on this library. If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
package java.lang;
import gnu.classpath.Configuration;
/*
* This class is a reference version, mainly for compiling a class library
* jar. It is likely that VM implementers replace this with their own
* version that can communicate effectively with the VM.
*/
/**
* Code relocated from java.lang.Double by
* @author Dave Grove (groved@us.ibm.com)
*/
final class VMDouble
{
/**
* Convert the double to the IEEE 754 floating-point "double format" bit
* layout. Bit 63 (the most significant) is the sign bit, bits 62-52
* (masked by 0x7ff0000000000000L) represent the exponent, and bits 51-0
* (masked by 0x000fffffffffffffL) are the mantissa. This function
* collapses all versions of NaN to 0x7ff8000000000000L. The result of this
* function can be used as the argument to
* <code>Double.longBitsToDouble(long)</code> to obtain the original
* <code>double</code> value.
*
* @param value the <code>double</code> to convert
* @return the bits of the <code>double</code>
* @see #longBitsToDouble(long)
*/
public static native long doubleToLongBits(double value);
/**
* Convert the double to the IEEE 754 floating-point "double format" bit
* layout. Bit 63 (the most significant) is the sign bit, bits 62-52
* (masked by 0x7ff0000000000000L) represent the exponent, and bits 51-0
* (masked by 0x000fffffffffffffL) are the mantissa. This function
* leaves NaN alone, rather than collapsing to a canonical value. The
* result of this function can be used as the argument to
* <code>Double.longBitsToDouble(long)</code> to obtain the original
* <code>double</code> value.
*
* @param value the <code>double</code> to convert
* @return the bits of the <code>double</code>
* @see #longBitsToDouble(long)
*/
public static native long doubleToRawLongBits(double value);
/**
* Convert the argument in IEEE 754 floating-point "double format" bit
* layout to the corresponding float. Bit 63 (the most significant) is the
* sign bit, bits 62-52 (masked by 0x7ff0000000000000L) represent the
* exponent, and bits 51-0 (masked by 0x000fffffffffffffL) are the mantissa.
* This function leaves NaN alone, so that you can recover the bit pattern
* with <code>Double.doubleToRawLongBits(double)</code>.
*
* @param bits the bits to convert
* @return the <code>double</code> represented by the bits
* @see #doubleToLongBits(double)
* @see #doubleToRawLongBits(double)
*/
public static native double longBitsToDouble(long bits);
/**
* Helper method to convert to string.
*
* @param d the double to convert
* @param isFloat true if the conversion is requested by Float (results in
* fewer digits)
*/
public static native String toString(double d, boolean isFloat);
public static native double parseDouble(String str);
}
/* VMFloat.java -- VM Specific Float methods
Copyright (C) 2003, 2006 Free Software Foundation
This file is part of GNU Classpath.
GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.
As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module. An independent module is a module which is not derived from
or based on this library. If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
package java.lang;
import gnu.classpath.Configuration;
/*
* This class is a reference version, mainly for compiling a class library
* jar. It is likely that VM implementers replace this with their own
* version that can communicate effectively with the VM.
*/
/**
* Code relocated from java.lang.Float by
* @author Dave Grove <groved@us.ibm.com>
*/
final class VMFloat
{
/**
* Convert the float to the IEEE 754 floating-point "single format" bit
* layout. Bit 31 (the most significant) is the sign bit, bits 30-23
* (masked by 0x7f800000) represent the exponent, and bits 22-0
* (masked by 0x007fffff) are the mantissa. This function collapses all
* versions of NaN to 0x7fc00000. The result of this function can be used
* as the argument to <code>Float.intBitsToFloat(int)</code> to obtain the
* original <code>float</code> value.
*
* @param value the <code>float</code> to convert
* @return the bits of the <code>float</code>
* @see #intBitsToFloat(int)
*/
static native int floatToIntBits(float value);
/**
* Convert the float to the IEEE 754 floating-point "single format" bit
* layout. Bit 31 (the most significant) is the sign bit, bits 30-23
* (masked by 0x7f800000) represent the exponent, and bits 22-0
* (masked by 0x007fffff) are the mantissa. This function leaves NaN alone,
* rather than collapsing to a canonical value. The result of this function
* can be used as the argument to <code>Float.intBitsToFloat(int)</code> to
* obtain the original <code>float</code> value.
*
* @param value the <code>float</code> to convert
* @return the bits of the <code>float</code>
* @see #intBitsToFloat(int)
*/
static native int floatToRawIntBits(float value);
/**
* Convert the argument in IEEE 754 floating-point "single format" bit
* layout to the corresponding float. Bit 31 (the most significant) is the
* sign bit, bits 30-23 (masked by 0x7f800000) represent the exponent, and
* bits 22-0 (masked by 0x007fffff) are the mantissa. This function leaves
* NaN alone, so that you can recover the bit pattern with
* <code>Float.floatToRawIntBits(float)</code>.
*
* @param bits the bits to convert
* @return the <code>float</code> represented by the bits
* @see #floatToIntBits(float)
* @see #floatToRawIntBits(float)
*/
static native float intBitsToFloat(int bits);
} // class VMFloat
// natDouble.cc - Implementation of java.lang.Double native methods.
// natDouble.cc - Implementation of java.lang.VMDouble native methods.
/* Copyright (C) 1998, 1999, 2000, 2001, 2003, 2005, 2006 Free Software Foundation
......@@ -15,6 +15,7 @@ details. */
#include <gcj/cni.h>
#include <java/lang/String.h>
#include <java/lang/Double.h>
#include <java/lang/VMDouble.h>
#include <java/lang/Character.h>
#include <java/lang/NumberFormatException.h>
#include <jvm.h>
......@@ -31,7 +32,7 @@ union u
};
jlong
java::lang::Double::doubleToLongBits(jdouble value)
java::lang::VMDouble::doubleToLongBits(jdouble value)
{
union u u;
u.d = value;
......@@ -46,7 +47,7 @@ java::lang::Double::doubleToLongBits(jdouble value)
}
jlong
java::lang::Double::doubleToRawLongBits(jdouble value)
java::lang::VMDouble::doubleToRawLongBits(jdouble value)
{
union u u;
u.d = value;
......@@ -54,7 +55,7 @@ java::lang::Double::doubleToRawLongBits(jdouble value)
}
jdouble
java::lang::Double::longBitsToDouble(jlong bits)
java::lang::VMDouble::longBitsToDouble(jlong bits)
{
union u u;
u.l = bits;
......@@ -62,15 +63,15 @@ java::lang::Double::longBitsToDouble(jlong bits)
}
jstring
java::lang::Double::toString(jdouble value, jboolean isFloat)
java::lang::VMDouble::toString(jdouble value, jboolean isFloat)
{
if (isNaN (value))
if (Double::isNaN (value))
return JvNewStringLatin1 ("NaN", sizeof ("NaN") - 1);
if (value == POSITIVE_INFINITY)
if (value == Double::POSITIVE_INFINITY)
return JvNewStringLatin1 ("Infinity", sizeof ("Infinity") - 1);
if (value == NEGATIVE_INFINITY)
if (value == Double::NEGATIVE_INFINITY)
return JvNewStringLatin1 ("-Infinity", sizeof ("-Infinity") - 1);
char buffer[50], result[50];
......@@ -158,7 +159,7 @@ java::lang::Double::toString(jdouble value, jboolean isFloat)
}
jdouble
java::lang::Double::parseDouble(jstring str)
java::lang::VMDouble::parseDouble(jstring str)
{
int length = str->length();
......@@ -194,11 +195,11 @@ java::lang::Double::parseDouble(jstring str)
{
if (! strcmp (data, "NaN") || ! strcmp (data, "+NaN")
|| ! strcmp (data, "-NaN"))
return NaN;
return Double::NaN;
else if (! strcmp (data, "Infinity") || ! strcmp (data, "+Infinity"))
return POSITIVE_INFINITY;
return Double::POSITIVE_INFINITY;
else if (! strcmp (data, "-Infinity"))
return NEGATIVE_INFINITY;
return Double::NEGATIVE_INFINITY;
}
struct _Jv_reent reent;
......
// natFloat.cc - Implementation of java.lang.Float native methods.
// natFloat.cc - Implementation of java.lang.VMFloat native methods.
/* Copyright (C) 1998, 1999, 2001 Free Software Foundation
/* Copyright (C) 1998, 1999, 2001, 2006 Free Software Foundation
This file is part of libgcj.
......@@ -11,6 +11,7 @@ details. */
#include <config.h>
#include <java/lang/Float.h>
#include <java/lang/VMFloat.h>
#include <jvm.h>
union u
......@@ -20,7 +21,7 @@ union u
};
jint
java::lang::Float::floatToIntBits(jfloat value)
java::lang::VMFloat::floatToIntBits(jfloat value)
{
union u u;
u.d = value;
......@@ -34,7 +35,7 @@ java::lang::Float::floatToIntBits(jfloat value)
}
jint
java::lang::Float::floatToRawIntBits(jfloat value)
java::lang::VMFloat::floatToRawIntBits(jfloat value)
{
union u u;
u.d = value;
......@@ -42,7 +43,7 @@ java::lang::Float::floatToRawIntBits(jfloat value)
}
jfloat
java::lang::Float::intBitsToFloat(jint bits)
java::lang::VMFloat::intBitsToFloat(jint bits)
{
union u u;
u.l = bits;
......
......@@ -3043,12 +3043,12 @@ classpath/java/lang/Cloneable.java \
classpath/java/lang/Comparable.java \
classpath/java/lang/Compiler.java \
java/lang/ConcreteProcess.java \
java/lang/Double.java \
classpath/java/lang/Double.java \
classpath/java/lang/EnumConstantNotPresentException.java \
classpath/java/lang/Error.java \
classpath/java/lang/Exception.java \
classpath/java/lang/ExceptionInInitializerError.java \
java/lang/Float.java \
classpath/java/lang/Float.java \
classpath/java/lang/IllegalAccessError.java \
classpath/java/lang/IllegalAccessException.java \
classpath/java/lang/IllegalArgumentException.java \
......@@ -3106,6 +3106,8 @@ classpath/java/lang/UnsupportedClassVersionError.java \
classpath/java/lang/UnsupportedOperationException.java \
java/lang/VMClassLoader.java \
java/lang/VMCompiler.java \
java/lang/VMDouble.java \
java/lang/VMFloat.java \
java/lang/VMSecurityManager.java \
java/lang/VMThrowable.java \
classpath/java/lang/VerifyError.java \
......
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