I downloaded the latest CVS with the interp.cc fix, but I still have this
problem on the host build. Here is the init.java file I use to show the
problem. The testVoidReturn function is what I was playing with to try and
narrow down the cause.
- Avery J. Regier
/*
* The contents of this file are subject to the JJOS Public License
* Version 0.0 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.jos.org/
*
* Software distributed under the License is distributed on an "AS IS"
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
* License for the specific language governing rights and limitations
* under the License.
*
* The Original Code is decaf's code, released October, 1998.
*
* The Initial Developer of the Original Code is Todd L. Miller.
* Portions created by Todd L. Miller are Copyright (C) 1998 & 1999.
* All Rights Reserved.
*
*/
/**
* init
*
* The first thread run and the last to die.
*/
import jos.system.interrupts;
import jos.system.keyboard;
import jos.system.consoled;
import java.util.Vector;
import java.util.Enumeration;
import java.io.*;
import jos.platform.driver.StandardVga;
public class init {
public static boolean testVM = true;
public static boolean testThreads = true;
public static boolean testExceptions = true;
public static boolean testConsoleDaemons = true;
public static boolean testVGADriver = false;
public static boolean exitWhenDone = true;
public static boolean testGC = true;
/* the jos logo -> just for testing */
final static int[] logo =
{0,0,0,0,0,14,15,15,15,15,14,0,0,0,0,0,
0,0,0,14,15,7,3,7,3,7,3,15,14,0,0,0,
0,0,14,15,7,3,7,3,7,3,7,3,15,14,0,0,
0,14,15,6,6,6,3,7,3,7,3,7,3,15,14,0,
0,15,6,1,1,1,6,3,7,3,7,3,7,3,15,0,
14,6,1,1,1,1,1,6,3,7,3,7,3,7,3,14,
15,1,1,1,1,1,1,6,7,3,7,3,7,3,7,15,
15,1,1,3,7,1,1,6,3,7,3,1,1,7,3,15,
15,1,1,7,3,1,1,1,6,3,7,1,1,3,7,15,
15,1,1,1,1,1,1,1,6,7,3,7,3,7,3,15,
14,1,1,1,1,1,1,1,6,3,7,3,7,3,6,14,
0,15,1,1,1,1,1,1,1,6,3,7,3,6,15,0,
0,14,1,1,1,1,1,1,1,1,6,6,6,1,14,0,
0,0,14,1,1,1,1,1,1,1,1,1,1,14,0,0,
0,0,0,14,15,1,1,1,1,1,1,15,14,0,0,0,
0,0,0,0,0,14,15,15,15,15,14,0,0,0,0,0};
public static void main( String[] argv ) {
System.out.println( "init for decaf, version 0.0.1" );
if (init.testVM)
testVM();
else
System.out.println( "skipping VM tests..." );
if (init.testThreads)
testThreads();
else
System.out.println( "skipping threading tests..." );
if (init.testExceptions)
testExceptions();
else
System.out.println( "skipping exception tests..." );
if (init.testConsoleDaemons)
testConsoleDaemons();
else
System.out.println( "init() skipping console daemon tests..." );
if (testVGADriver)
testVGADriver();
else
System.out.println( "init() skipping VGA tests..." );
if (testGC)
testGC();
else
System.out.println( "init() skipping GC tests..." );
if (exitWhenDone)
{
System.out.println( "init() for decaf v0.0.1, exiting..." );
}
else
{
System.out.println( "init() entering idle time..." );
while ( true ); /* or, j.s.system.isNotShuttingDown(), etc. */
}
}
public static void testCasting() {
System.out.println( "init() testing casting..." );
Object o = new Object();
Vector v = new Vector();
int[] array_i = new int[10];
String[] array_s = new String[10];
System.out.println( "o = (Object)Vector; (OK)" );
o = (Object)v;
System.out.println( "Vector = (Vector)o; (OK)" );
v = (Vector)o;
System.out.println( "o = Object; Vector = (Vector)o (NOT OK)" );
o = new Object();
v = (Vector)o;
System.out.println( "ser = new String(); (OK)" );
System.out.println( "o = (Object)int[]; (OK)" );
o = (Object)array_i;
System.out.println( "o = (Object)String[]; (OK)" );
o = (Object)array_s;
System.out.println( "o = (Object)int[]; int[] = (int[])o; (OK)" );
o = (Object)array_i;
array_i = (int[])o;
// Failed by compiler.
// System.out.println( "s = (String[])int[]; (NOT OK)" );
// array_s = (String[])array_i;
// Failed by compiler.
// System.out.println( "i = (int[])Vector; (NOT OK)" );
// array_i = (int[])v;
o = new Object();
v = new Vector();
Enumeration e = v.elements();
System.out.println( "e = (Enumeration)v; (NOT OK)" );
e = (Enumeration)v;
e = v.elements();
System.out.println( "v = (Vector)e; (NOT OK)" );
v = (Vector)e;
System.out.println( "ser = new String(); (OK)" );
Serializable ser = new String();
} /* end testCasting() */
public static boolean testFunctionCalls() {
// return true on error.
testVoidReturn();
System.out.println("Void return successful");
if ( testStaticDoubleReturn() != (double)5.77 ) {
System.out.println( "Static double return failed." );
return true;
}
if ( testDynamicDoubleReturn((double)5.77) != (double)5.77 ) {
System.out.println( "Dynamic double return failed." );
return true;
}
// float, int, reference(array), void(null) remain to test.
return false;
} // end testFunctionCalls()
public static double testStaticDoubleReturn() { return (double)5.77; }
public static double testDynamicDoubleReturn( double d ) { return d; }
public static int testVoidReturn() {
System.out.println("Having fun with testing");
int i=0;
for(; i<10; i++);
return i;
}
public static void testMathOps() {
System.out.print( "testing integer comparisons... " );
int k = 1;
int l = 10;
System.out.print( "ops failed: " );
if ( k == l ) { System.out.print( "== " ); }
if ( k != l ) { ; } else { System.out.print( "!= " ); }
if ( k > l ) { System.out.print( "> " ); }
if ( l < k ) { System.out.print( "< " ); }
if ( k >= l ) { System.out.print( ">= " ); }
if ( l <= k ) { System.out.print( "<=" ); }
System.out.print( "\n" );
System.out.print( "testing double comparisons... " );
double o = (double)55.3;
double p = (double)11.1;
System.out.print( "ops failed: " );
if ( o == p ) { System.out.print( "== " ); }
if ( o != p ) { ; } else { System.out.print( "!= "); }
if ( o < p ) { System.out.print( "< " ); }
if ( p > o ) { System.out.print( "> " ); }
if ( o <= p ) { System.out.print( "<= " ); }
if ( p >= o ) { System.out.print( ">=" ); }
System.out.print( "\n" );
System.out.print( "Testing float comparisons... " );
float q = (float)4.5;
float r = (float)4.5;
System.out.print( "ops failed: " );
if ( q == r ) { ; } else { System.out.print( "== "); }
if ( q != r ) { System.out.print( "!= " ); }
if ( q < r ) { System.out.print( "< " ); }
if ( r > q ) { System.out.print( "> " ); }
if ( r <= q ) { ; } else { System.out.print( "<= " ); }
if ( q >= r ) { ; } else { System.out.print( ">=" ); }
System.out.print( "\n" );
System.out.print( "Testing float ops... " );
System.out.print( "ops failed: " );
if ( q + r != (float)9.0 ) { System.out.print( "add " ); }
if ( q - r != (float)0.0 ) { System.out.print( "sub " ); }
if ( q / r != (float)1.0 ) { System.out.print( "div " ); }
if ( q % r != (float)0.0 ) { System.out.print( "mod " ); }
if ( -q != (float)-4.5 ) { System.out.print( "neg " ); }
if ( q * r != (float)20.25 ) { System.out.print( "mul" ); }
System.out.print( "\n" );
System.out.print( "Testing double ops... " );
double result;
System.out.print( "ops failed: " );
result = o + p;
if ( result < 66.0 || result > 67.0 ) { System.out.print("add "); }
result = o - p;
if ( result < 44.0 || result > 45.0 ) { System.out.print("sub "); }
result = -o;
if ( result > -55 || result < -56 ) { System.out.print("neg "); }
result = o * p;
if ( result < 613 || result > 614 ) { System.out.print( "mul" ); }
System.out.print( "\n" );
// need long ops & comparisons, integer ops;
// byte & char ops * comparisons.
System.out.print( "Math ops finished\n");
testArrayOps();
} // end testMathOps()
public static void testArrayOps() {
System.out.print( "testing array operations... " );
int[][][] array_three = new int [5][5][5];
array_three[4][4][4] = 3;
int[][] array_two = new int [4][4];
array_two[3][3] = 2;
int[] array_one = new int [3];
array_one[2] = 1;
int two = array_two[3][3];
int three = array_three[4][4][4];
int one = array_one[2];
if( one != 1 ) { System.out.print( "1-dim int array failed. " ); }
if( two != 2 ) { System.out.print( "2-dim int array failed. " ); }
if( three != 3 ) { System.out.print( "3-dim int array failed." ); }
System.out.print( "\n" );
String[] strings = new String[3];
strings[1] = "one";
System.out.print( "\"one\" should be printed: " );
System.out.println( strings[1] );
} // end testArrayOps()
public static void testVM() {
System.out.println( "testing the VM..." );
if ( testFunctionCalls() ) {
System.out.println( "testFunctionCalls() failed!" );
System.out.println( "the remaining tests are probably invalid." );
}
testMathOps();
System.out.print( "Now testing Arrays\n");
testArrayOps();
testCasting();
/* test print/println */
System.out.print( "does 56 = " );
System.out.print( 56 );
System.out.println( "?" );
System.out.print( "is true = " );
System.out.print( true );
System.out.println( "?" ) ;
System.out.print( "This sentence should end with a period" );
System.out.println( (char)'.' );
}
public static void testThreads() {
System.out.println( "init(): testing threading." );
System.out.println( "init() starting counter..." );
counter c = new counter();
c.start();
System.out.println( "init() starting decounter..." );
counter d = new counter( false );
d.start();
System.out.println( "init() entering .wait() loop..." );
int interrupt_count = 0;
while ( interrupt_count < 10 ) {
/* Bad Karma w/o this. */
synchronized( jos.system.interrupts.int000 ) {
/* because wait() calls release
locks, this doesn't actually
cause any blockage. */
try { jos.system.interrupts.int000.wait(); }
catch ( InterruptedException ie ) {
System.out.println( "init() interrupted waiting for notify" );
continue;
}
} /* end synchlock on interrupt. */
// System.out.println( "init() caught interrupt." );
interrupt_count++;
} /* end .wait() loop */
System.out.println( "init() has caught 10 interrupts." );
}
public static void testExceptions() {
/* run exception tests */
System.out.println( "init() testing exceptions()" );
/* throw/catch pair #1 -- basic mechanism */
try {
throw new Exception();
} /* end throw #1 */
catch ( Exception e ) {
System.out.println( "init(): caught exception #1!" );
} /* end catch #1 */
/* throw/catch pair #2 -- casting exceptions up */
try { throw new java.io.IOException(); }
catch ( Exception e ) {
System.out.println( "init(): caught exception #2!" );
} /* end catch #2 */
/* throw/catch pair #3 -- data preservation */
try { throw new Exception( "init(): caught exception #3!" ); }
catch ( Exception e ) {
System.out.println( e.getMessage() );
}
}
public static void testConsoleDaemons() {
System.out.println( "init() starting console daemons..." );
System.out.println( "init() starting jos.system.keyboard..." );
/* sets up the hardware driver */
keyboard k = new keyboard();
/* starts the KeyEvent dispatch loop */
k.start();
System.out.println( "init() starting consoled..." );
/* listens to the dispatching from j.s.k above */
consoled cd = new consoled();
}
public static void testVGADriver() {
System.out.println( "init() testing VGA driver..." );
StandardVga v = new StandardVga();
if(v.setVideoMode(640,480,4)==0)
{
v.startService();
v.bitblt(312,232,logo,16);
v.delay(0x100000);
v.stopService();
System.out.println("back to textmode");
}
/* end VGA test routine */
}
public static void testGC() {
int i=0;
while (i<1000000)
{
int size = i%1000;
int[] garbage = new int[size];
i = i+1;
testVM();
testThreads();
testExceptions();
testCasting();
}
}
} // end init.
_______________________________________________
Kernel maillist - [EMAIL PROTECTED]
http://jos.org/mailman/listinfo/kernel