74
74
import com .oracle .truffle .espresso .substitutions .GenerateNativeEnv ;
75
75
import com .oracle .truffle .espresso .substitutions .Inject ;
76
76
import com .oracle .truffle .espresso .substitutions .JavaType ;
77
- import com .oracle .truffle .espresso .substitutions .SubstitutionProfiler ;
78
77
import com .oracle .truffle .espresso .substitutions .standard .Target_java_lang_Thread ;
79
78
import com .oracle .truffle .espresso .threads .EspressoThreadRegistry ;
80
79
import com .oracle .truffle .espresso .threads .State ;
@@ -289,18 +288,6 @@ public int GetOptionalSupport(@Pointer TruffleObject /* jmmOptionalSupport **/ s
289
288
return 0 ;
290
289
}
291
290
292
- private static void validateThreadIdArray (EspressoLanguage language , Meta meta , @ JavaType (long [].class ) StaticObject threadIds , SubstitutionProfiler profiler ) {
293
- assert threadIds .isArray ();
294
- int numThreads = threadIds .length (language );
295
- for (int i = 0 ; i < numThreads ; ++i ) {
296
- long tid = threadIds .<long []> unwrap (language )[i ];
297
- if (tid <= 0 ) {
298
- profiler .profile (3 );
299
- throw meta .throwExceptionWithMessage (meta .java_lang_IllegalArgumentException , "Invalid thread ID entry" );
300
- }
301
- }
302
- }
303
-
304
291
private static int validateThreadIdArray (EspressoLanguage language , Meta meta , @ JavaType (long [].class ) StaticObject threadIds ) {
305
292
assert threadIds .isArray ();
306
293
int numThreads = threadIds .length (language );
@@ -313,27 +300,24 @@ private static int validateThreadIdArray(EspressoLanguage language, Meta meta, @
313
300
return numThreads ;
314
301
}
315
302
316
- private static void validateThreadInfoArray (Meta meta , @ JavaType (internalName = "[Ljava/lang/management/ThreadInfo;" ) StaticObject infoArray , SubstitutionProfiler profiler ) {
303
+ private static void validateThreadInfoArray (Meta meta , @ JavaType (internalName = "[Ljava/lang/management/ThreadInfo;" ) StaticObject infoArray ) {
317
304
// check if the element of infoArray is of type ThreadInfo class
318
305
Klass infoArrayKlass = infoArray .getKlass ();
319
306
if (infoArray .isArray ()) {
320
307
Klass component = ((ArrayKlass ) infoArrayKlass ).getComponentType ();
321
308
if (!meta .java_lang_management_ThreadInfo .equals (component )) {
322
- profiler .profile (4 );
323
- throw meta .throwExceptionWithMessage (meta .java_lang_IllegalArgumentException , "infoArray element type is not ThreadInfo class" );
309
+ throw meta .throwIllegalArgumentExceptionBoundary ("infoArray element type is not ThreadInfo class" );
324
310
}
325
311
}
326
312
}
327
313
328
314
@ ManagementImpl
329
- public int GetThreadInfo (@ JavaType (long [].class ) StaticObject ids , int maxDepth , @ JavaType (Object [].class ) StaticObject infoArray , @ Inject EspressoLanguage language , @ Inject Meta meta ,
330
- @ Inject SubstitutionProfiler profiler ) {
315
+ public int GetThreadInfo (@ JavaType (long [].class ) StaticObject ids , int maxDepth , @ JavaType (Object [].class ) StaticObject infoArray , @ Inject EspressoLanguage language , @ Inject Meta meta ) {
331
316
if (StaticObject .isNull (ids )) {
332
- profiler .profile (0 );
333
- throw meta .throwNullPointerException ();
317
+ throw meta .throwNullPointerExceptionBoundary ();
334
318
}
335
- validateThreadIdArray (language , meta , ids , profiler );
336
- validateThreadInfoArray (meta , infoArray , profiler );
319
+ validateThreadIdArray (language , meta , ids );
320
+ validateThreadInfoArray (meta , infoArray );
337
321
338
322
int idsLength = ids .length (language );
339
323
StaticObject [] activeThreads = getContext ().getActiveThreads ();
@@ -343,7 +327,7 @@ public int GetThreadInfo(@JavaType(long[].class) StaticObject ids, int maxDepth,
343
327
threads [i ] = findThreadById (activeThreads , id );
344
328
}
345
329
346
- fillThreadInfos (threads , infoArray , maxDepth , language , meta , profiler , null );
330
+ fillThreadInfos (threads , infoArray , maxDepth , language , meta , null );
347
331
348
332
return JNI_OK ; // always 0
349
333
}
@@ -359,21 +343,18 @@ private StaticObject findThreadById(StaticObject[] activeThreads, long id) {
359
343
return thread ;
360
344
}
361
345
362
- private void fillThreadInfos (StaticObject [] threads , StaticObject infoArray , int maxDepth , EspressoLanguage language , Meta meta , SubstitutionProfiler profiler , Node node ) {
346
+ private void fillThreadInfos (StaticObject [] threads , StaticObject infoArray , int maxDepth , EspressoLanguage language , Meta meta , Node node ) {
363
347
if (StaticObject .isNull (infoArray )) {
364
- profiler .profile (0 );
365
- throw meta .throwNullPointerException ();
348
+ throw meta .throwNullPointerExceptionBoundary ();
366
349
}
367
350
if (maxDepth < -1 ) {
368
- profiler .profile (1 );
369
- throw meta .throwExceptionWithMessage (meta .java_lang_IllegalArgumentException , "Invalid maxDepth" );
351
+ throw meta .throwIllegalArgumentExceptionBoundary ("Invalid maxDepth" );
370
352
}
371
353
int actualMaxDepth = maxDepth < 0 ? InterpreterToVM .MAX_STACK_DEPTH : maxDepth ;
372
- validateThreadInfoArray (meta , infoArray , profiler );
354
+ validateThreadInfoArray (meta , infoArray );
373
355
374
356
if (threads .length != infoArray .length (language )) {
375
- profiler .profile (2 );
376
- throw meta .throwExceptionWithMessage (meta .java_lang_IllegalArgumentException , "The length of the given ThreadInfo array does not match the length of the given array of thread IDs" );
357
+ throw meta .throwIllegalArgumentExceptionBoundary ("The length of the given ThreadInfo array does not match the length of the given array of thread IDs" );
377
358
}
378
359
379
360
Method init = meta .java_lang_management_ThreadInfo .lookupDeclaredMethod (Names ._init_ , getSignatures ().makeRaw (
@@ -781,24 +762,19 @@ public boolean SetBoolAttribute(/* jmmBoolAttribute */ int att, boolean flag) {
781
762
782
763
@ ManagementImpl
783
764
public int GetVMGlobals (@ JavaType (Object [].class ) StaticObject names , /* jmmVMGlobal* */ @ Pointer TruffleObject globalsPtr , @ SuppressWarnings ("unused" ) int count ,
784
- @ Inject EspressoLanguage language ,
785
- @ Inject Meta meta ,
786
- @ Inject SubstitutionProfiler profiler ) {
765
+ @ Inject EspressoLanguage language , @ Inject Meta meta ) {
787
766
if (getUncached ().isNull (globalsPtr )) {
788
- profiler .profile (0 );
789
- throw meta .throwNullPointerException ();
767
+ throw meta .throwNullPointerExceptionBoundary ();
790
768
}
791
769
if (StaticObject .notNull (names )) {
792
770
if (!names .getKlass ().equals (meta .java_lang_String .array ())) {
793
- profiler .profile (1 );
794
- throw meta .throwExceptionWithMessage (meta .java_lang_IllegalArgumentException , "Array element type is not String class" );
771
+ throw meta .throwIllegalArgumentExceptionBoundary ("Array element type is not String class" );
795
772
}
796
773
797
774
StaticObject [] entries = names .unwrap (language );
798
775
for (StaticObject entry : entries ) {
799
776
if (StaticObject .isNull (entry )) {
800
- profiler .profile (2 );
801
- throw meta .throwNullPointerException ();
777
+ throw meta .throwNullPointerExceptionBoundary ();
802
778
}
803
779
getLogger ().fine (() -> "GetVMGlobals: " + meta .toHostString (entry ));
804
780
}
@@ -810,7 +786,7 @@ public int GetVMGlobals(@JavaType(Object[].class) StaticObject names, /* jmmVMGl
810
786
@ SuppressWarnings ("unused" )
811
787
public @ JavaType (internalName = "[Ljava/lang/management/ThreadInfo;" ) StaticObject DumpThreads (@ JavaType (long [].class ) StaticObject ids , boolean lockedMonitors , boolean lockedSynchronizers ,
812
788
int maybeMaxDepth ,
813
- @ Inject EspressoLanguage language , @ Inject Meta meta , @ Inject SubstitutionProfiler profiler ) {
789
+ @ Inject EspressoLanguage language , @ Inject Meta meta ) {
814
790
int maxDepth ;
815
791
if (managementVersion >= JMM_VERSION_2 ) {
816
792
maxDepth = maybeMaxDepth ;
@@ -820,11 +796,11 @@ public int GetVMGlobals(@JavaType(Object[].class) StaticObject names, /* jmmVMGl
820
796
if (StaticObject .isNull (ids )) {
821
797
StaticObject [] activeThreads = getContext ().getActiveThreads ();
822
798
StaticObject result = getMeta ().java_lang_management_ThreadInfo .allocateReferenceArray (activeThreads .length );
823
- fillThreadInfos (activeThreads , result , maxDepth , language , meta , profiler , null );
799
+ fillThreadInfos (activeThreads , result , maxDepth , language , meta , null );
824
800
return result ;
825
801
} else {
826
802
StaticObject result = getMeta ().java_lang_management_ThreadInfo .allocateReferenceArray (ids .length (language ));
827
- if (GetThreadInfo (ids , maxDepth , result , language , meta , profiler ) != JNI_OK ) {
803
+ if (GetThreadInfo (ids , maxDepth , result , language , meta ) != JNI_OK ) {
828
804
return StaticObject .NULL ;
829
805
}
830
806
return result ;
@@ -847,16 +823,13 @@ public void GetThreadAllocatedMemory(
847
823
@ JavaType (long [].class ) StaticObject ids ,
848
824
@ JavaType (long [].class ) StaticObject sizeArray ,
849
825
@ Inject EspressoLanguage language ,
850
- @ Inject Meta meta ,
851
- @ Inject SubstitutionProfiler profiler ) {
826
+ @ Inject Meta meta ) {
852
827
if (StaticObject .isNull (ids ) || StaticObject .isNull (sizeArray )) {
853
- profiler .profile (0 );
854
- throw meta .throwException (meta .java_lang_NullPointerException );
828
+ throw meta .throwNullPointerExceptionBoundary ();
855
829
}
856
- validateThreadIdArray (language , meta , ids , profiler );
830
+ validateThreadIdArray (language , meta , ids );
857
831
if (ids .length (language ) != sizeArray .length (language )) {
858
- profiler .profile (1 );
859
- throw meta .throwExceptionWithMessage (meta .java_lang_IllegalArgumentException , "The length of the given long array does not match the length of the given array of thread IDs" );
832
+ throw meta .throwIllegalArgumentExceptionBoundary ("The length of the given long array does not match the length of the given array of thread IDs" );
860
833
}
861
834
StaticObject [] activeThreads = getContext ().getActiveThreads ();
862
835
0 commit comments