History

Rewritten Thread native module to fit the modern Inferno

Dmitry Kabak (userdima committed 13 years ago

Commit c0b82061 parent ab9ed8e2 files · +51 −32Browse files

Showing the changes to java (2 of 2 files). Show all

Unified · Split

2 files
  1. java/pkg/java/lang/Thread_L.b +44 −29
  2. java/pkg/java/lang/Thread_L.m +7 −3
java/pkg/java/lang/Thread_L.b+44−29
@@ -71,8 +71,6 @@ init( jni_p : JNI ) · 70 unmodified lines
7171
7272 currentThread_rThread( ) : JThread
7373 {#>>
74− e := ref Sys->Exception;
75− if ( sys->rescue("*",e) == Sys->HANDLER )
7674 {
7775 # get the java thread object assocciated
7876 # with this thread. it is stored in the
@@ -80,10 +78,12 @@ currentThread_rThread( ) : JThread · 1 unmodified line
8078 thd_obj := jldr->getthreaddata().this;
8179 if ( thd_obj != nil )
8280 return( cast->JObjToJThd(thd_obj) );
83− sys->unrescue();
8481 }
85− else
86− sys->rescued(Sys->ONCE, nil);
82+ exception e
83+ {
84+ "*" =>
85+ ; # ignore
86+ }
8787
8888
8989 # either we could not find the thread data
@@ -118,7 +118,7 @@ sleep_J_V( p0 : big) · 28 unmodified lines
118118 jldr->sleep( millis );
119119 }#<<
120120
121−start_V( this : JThread)
121+start0_V( this : JThread)
122122 {#>>
123123 thdobj := cast->JThdToJObj(this);
124124
@@ -249,10 +249,7 @@ lowinit_rThread_V( p0 : JThread) · 124 unmodified lines
249249 # java.lang.Thread object. 'p0' is the "root thread" object
250250 # which must be associated witht the Dis thread which is
251251 # calling this fuction -- i.e. associate the 'p0' java thread
252− # object with the current Dis thread. 'p1' is the same thread
253− # object, just with the type JObject which allows us to store
254− # it off in the JavaClassLoader->ThreadData structure associated
255− # with the calling Dis thread.
252+ # object with the current Dis thread.
256253
257254 # since this is the root thread make a root thread group by
258255 # creating an instance of ThreadGroup and calling its private
@@ -273,6 +270,32 @@ lowinit_rThread_V( p0 : JThread) · 14 unmodified lines
273270
274271 }#<<
275272
273+holdsLock_rObject_Z( p0 : JObject) : int
274+{#>>
275+ if (p0 == nil)
276+ jni->ThrowException( "java.lang.NullPointerException", "obj arg is null" );
277+
278+ # TODO: implement
279+ return 0;
280+}#<<
281+
282+dumpThreads_aThread_aaStackTraceElement( p0 : JArrayJObject) : JArray
283+{#>>
284+ # TODO: implement
285+ return nil;
286+}#<<
287+
288+getThreads_aThread( ) : JArrayJObject
289+{#>>
290+ # TODO: implement
291+ return nil;
292+}#<<
293+
294+registerNatives_V( )
295+{#>>
296+ # currently empty...
297+}#<<
298+
276299
277300
278301
@@ -324,8 +347,6 @@ javathreadinit( jthd : JNI->JThread, ok : chan of int ) · 45 unmodified lines
324347
325348 # we need to catch any exceptions in order
326349 # to clean up the thread object's state
327− ee := ref Sys->Exception;
328− if ( sys->rescue( "*", ee ) == Sys->HANDLER )
329350 {
330351
331352 # call Thread.run() or Runnable.run()
@@ -334,17 +355,14 @@ javathreadinit( jthd : JNI->JThread, ok : chan of int ) · 2 unmodified lines
334355 # call Thread.exit()
335356 (mod,idx) := jni->FindMethod( threadclass, "exit", "()V", JNI->METH_PRIVATE );
336357 jni->jassist->mcall1( mod, idx, thdobj );
337− sys->unrescue();
338358 }
339− else
359+ exception e
340360 {
341− # clear exception
342− sys->rescued( Sys->ONCE, nil );
343−
344− # thread threw an unhandled exception so
345− # call the ThreadGroup.uncaughtException()
346− # method.
347− UncaughtException( jthd, thdobj, ee );
361+ "*" =>
362+ # thread threw an unhandled exception so
363+ # call the ThreadGroup.uncaughtException()
364+ # method.
365+ UncaughtException( jthd, thdobj, e );
348366 }
349367
350368 # java thread clean up
@@ -408,7 +426,7 @@ Run( jthd : JNI->JThread, thdobj : JObject ) · 57 unmodified lines
408426 # The method is passed an instance of the Thread along with the
409427 # "throwable" (i.e. exception).
410428 #
411−UncaughtException( jthd : JThread, thdobj : JObject, ee : ref Sys->Exception )
429+UncaughtException( jthd : JThread, thdobj : JObject, ee : string )
412430 {
413431 tgrp_cl := jni->GetObjectClassData( jthd.group );
414432
@@ -421,8 +439,6 @@ UncaughtException( jthd : JThread, thdobj : JObject, ee : ref Sys->Exception ) · 6 unmodified lines
421439 {
422440 # call method, protected against exceptions
423441 # since we must still clean-up the thread
424− eee := ref Sys->Exception;
425− if ( sys->rescue( "*", eee ) == Sys->HANDLER )
426442 {
427443 # find the uncaughtException method for the thd-grp
428444 (mod,idx) := jni->FindMethod( tgrp_cl, "uncaughtException",
@@ -441,13 +457,12 @@ UncaughtException( jthd : JThread, thdobj : JObject, ee : ref Sys->Exception ) · 12 unmodified lines
441457 # do the call
442458 ##LATER nil := jni->LowCall( mod, idx, jthd.group, args );
443459 }
444− sys->unrescue();
445460 }
446− else
461+ exception e
447462 {
448− # if we get an exception here just return
449− # and let the thread finish cleanup.
450− sys->rescued( Sys->ONCE, nil );
463+ "*" =>
464+ # if we get an exception here just return
465+ # and let the thread finish cleanup.
451466 }
452467 }
453468
java/pkg/java/lang/Thread_L.m+7−3
@@ -1,16 +1,20 @@
1−# javal v1.3 generated file: edit with care
1+# generated file edit with care
22
33 Thread_L : module
44 {
55
66 init : fn( jni_p : JNI );
7+ isInterrupted_Z_Z : fn( this : JThread, p0 : int) : int;
78 currentThread_rThread : fn( ) : JThread;
9+ registerNatives_V : fn( );
10+ holdsLock_rObject_Z : fn( p0 : JObject) : int;
811 yield_V : fn( );
912 sleep_J_V : fn( p0 : big);
10− start_V : fn( this : JThread);
11− isInterrupted_Z_Z : fn( this : JThread, p0 : int) : int;
13+ start0_V : fn( this : JThread);
1214 isAlive_Z : fn( this : JThread) : int;
1315 countStackFrames_I : fn( this : JThread) : int;
16+ dumpThreads_aThread_aaStackTraceElement : fn( p0 : JArrayJObject) : JArray;
17+ getThreads_aThread : fn( ) : JArrayJObject;
1418 setPriority0_I_V : fn( this : JThread, p0 : int);
1519 stop0_rObject_V : fn( this : JThread, p0 : JObject);
1620 suspend0_V : fn( this : JThread);