forked from eclipse-openj9/openj9
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvmthread.cpp
2483 lines (2134 loc) · 82.6 KB
/
vmthread.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*******************************************************************************
* Copyright IBM Corp. and others 1991
*
* This program and the accompanying materials are made available under
* the terms of the Eclipse Public License 2.0 which accompanies this
* distribution and is available at https://www.eclipse.org/legal/epl-2.0/
* or the Apache License, Version 2.0 which accompanies this distribution and
* is available at https://www.apache.org/licenses/LICENSE-2.0.
*
* This Source Code may also be made available under the following
* Secondary Licenses when the conditions for such availability set
* forth in the Eclipse Public License, v. 2.0 are satisfied: GNU
* General Public License, version 2 with the GNU Classpath
* Exception [1] and GNU General Public License, version 2 with the
* OpenJDK Assembly Exception [2].
*
* [1] https://www.gnu.org/software/classpath/license.html
* [2] https://openjdk.org/legal/assembly-exception.html
*
* SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0 OR GPL-2.0-only WITH OpenJDK-assembly-exception-1.0
*******************************************************************************/
/* #define J9VM_DBG */
#include <string.h>
#include "omrcfg.h"
#include "j9.h"
#include "j9cfg.h"
#include "j9consts.h"
#include "j9cp.h"
#include "omrgcconsts.h"
#include "omrlinkedlist.h"
#include "j9port.h"
#include "j9protos.h"
#include "omrthread.h"
#include "j9vmnls.h"
#include "jni.h"
#include "monhelp.h"
#include "objhelp.h"
#include "omr.h"
#include "rommeth.h"
#include "stackwalk.h"
#include "ut_j9vm.h"
#include "vm_internal.h"
#include "vmaccess.h"
#include "vmhook_internal.h"
#include "HeapIteratorAPI.h"
#include "j2sever.h"
#if defined(J9VM_OPT_CRIU_SUPPORT)
#include "CRIUHelpers.hpp"
#include "VMHelpers.hpp"
#endif /* defined(J9VM_OPT_CRIU_SUPPORT) */
extern "C" {
#define SIGQUIT_FILE_NAME "sigquit"
#define SIGQUIT_FILE_EXT ".trc"
/* Generic rounding macro - result is a UDATA */
#define ROUND_TO(granularity, number) (((UDATA)(number) + (granularity) - 1) & ~((UDATA)(granularity) - 1))
#define LEADING_SPACE " "
#define LEADING_SPACE_EXTRA " "
static char *getJ9ThreadStatus(J9VMThread *vmThread);
static void printJ9ThreadStatusMonitorInfo (J9VMThread *vmStruct, IDATA tracefd);
static void trace_printf (struct J9PortLibrary *portLib, IDATA tracefd, char * format, ...);
static UDATA printMethodInfo (J9VMThread *currentThread , J9StackWalkState *stackWalkState);
#if defined(J9ZOS390)
static IDATA setFailedToForkThreadException(J9VMThread *currentThread, IDATA retVal, omrthread_os_errno_t os_errno, omrthread_os_errno_t os_errno2);
#else /* !J9ZOS390 */
static IDATA setFailedToForkThreadException(J9VMThread *currentThread, IDATA retVal, omrthread_os_errno_t os_errno);
#endif /* !J9ZOS390 */
static UDATA javaProtectedThreadProc (J9PortLibrary* portLibrary, void * entryarg);
static UDATA startJavaThreadInternal(J9VMThread * currentThread, UDATA privateFlags, UDATA osStackSize, UDATA priority, omrthread_entrypoint_t entryPoint, void * entryArg, UDATA setException);
#if (defined(J9VM_DBG))
static void badness (char *description);
#endif /* J9VM_DBG */
static void dumpThreadingInfo(J9JavaVM *vm);
static void initMinCPUSpinCounts(J9JavaVM *vm);
#if defined(J9VM_INTERP_CUSTOM_SPIN_OPTIONS)
static void printCustomSpinOptions(void *element, void *userData);
#endif /* J9VM_INTERP_CUSTOM_SPIN_OPTIONS */
J9VMThread *
allocateVMThread(J9JavaVM *vm, omrthread_t osThread, UDATA privateFlags, void *memorySpace, J9Object *threadObject)
{
PORT_ACCESS_FROM_PORT(vm->portLibrary);
J9JavaStack *stack = NULL;
J9VMThread *newThread = NULL;
BOOLEAN threadIsRecycled = FALSE;
J9MemoryManagerFunctions* gcFuncs = vm->memoryManagerFunctions;
#ifdef J9VM_INTERP_GROWABLE_STACKS
#define VMTHR_INITIAL_STACK_SIZE ((vm->initialStackSize > (UDATA) vm->stackSize) ? vm->stackSize : vm->initialStackSize)
#else
#define VMTHR_INITIAL_STACK_SIZE vm->stackSize
#endif
omrthread_monitor_enter(vm->vmThreadListMutex);
/* Allocate the stack */
if ((stack = allocateJavaStack(vm, VMTHR_INITIAL_STACK_SIZE, NULL)) == NULL) {
goto fail;
}
#undef VMTHR_INITIAL_STACK_SIZE
/* Try to reuse a dead thread; otherwise allocate a new one */
if (J9_LINKED_LIST_IS_EMPTY(vm->deadThreadList)) {
/* Create the vmThread */
void *startOfMemoryBlock = NULL;
UDATA vmThreadAllocationSize = J9VMTHREAD_ALIGNMENT + ROUND_TO(sizeof(UDATA), vm->vmThreadSize);
if (J9JAVAVM_COMPRESS_OBJECT_REFERENCES(vm)) {
startOfMemoryBlock = (void *)j9mem_allocate_memory32(vmThreadAllocationSize, OMRMEM_CATEGORY_THREADS);
} else {
startOfMemoryBlock = (void *)j9mem_allocate_memory(vmThreadAllocationSize, OMRMEM_CATEGORY_THREADS);
}
if (NULL == startOfMemoryBlock) {
goto fail;
}
/* Align thread address to J9VMTHREAD_ALIGNMENT (~ 256 bytes) to prevent VM ACCESS errors */
newThread = (J9VMThread *)ROUND_TO(J9VMTHREAD_ALIGNMENT, (UDATA)startOfMemoryBlock);
/* Clean allocated memory and store alignment offset to retrieve original pointer for freeing memory */
memset(newThread, 0, vm->vmThreadSize);
newThread->startOfMemoryBlock = startOfMemoryBlock;
#if defined(J9VM_PORT_RUNTIME_INSTRUMENTATION)
/* Allocate J9RIParameters. */
newThread->riParameters = (J9RIParameters*)j9mem_allocate_memory(sizeof(J9RIParameters), OMRMEM_CATEGORY_THREADS);
if (NULL == newThread->riParameters) {
goto fail;
}
memset(newThread->riParameters, 0, sizeof(J9RIParameters));
#endif /* defined(J9VM_PORT_RUNTIME_INSTRUMENTATION) */
/* Initialize the vmThread */
/* Link the thread in the linked list - early, but done under mutex so we're safe*/
J9_LINKED_LIST_ADD_LAST(vm->mainThread, newThread);
omrthread_monitor_init_with_name(&newThread->publicFlagsMutex, J9THREAD_MONITOR_JLM_TIME_STAMP_INVALIDATOR, "Thread public flags mutex");
if (newThread->publicFlagsMutex == NULL) {
goto fail;
}
initOMRVMThread(vm, newThread);
} else {
/* Reuse a dead vmThread */
threadIsRecycled = TRUE;
/* Grab the first dead thread (already reinitialized) */
J9_LINKED_LIST_REMOVE_FIRST(vm->deadThreadList, newThread);
/* Link the thread in the linked list - early, but done under mutex so we're safe*/
J9_LINKED_LIST_ADD_LAST(vm->mainThread, newThread);
/* dead threads are stored in "halted for inspection" state. Resume the thread before we recycle it */
omrthread_monitor_enter(newThread->publicFlagsMutex);
if (newThread->inspectionSuspendCount != 0) {
if (--newThread->inspectionSuspendCount == 0) {
clearHaltFlag(newThread, J9_PUBLIC_FLAGS_HALT_THREAD_INSPECTION);
}
}
omrthread_monitor_exit(newThread->publicFlagsMutex);
}
if (0 != vm->segregatedAllocationCacheSize) {
newThread->segregatedAllocationCache = (J9VMGCSegregatedAllocationCacheEntry *)(((UDATA)newThread) + J9_VMTHREAD_SEGREGATED_ALLOCATION_CACHE_OFFSET);
}
#if defined(OMR_GC_COMPRESSED_POINTERS) && defined(OMR_GC_FULL_POINTERS)
newThread->compressObjectReferences = J9JAVAVM_COMPRESS_OBJECT_REFERENCES(vm);
#endif /* defined(OMR_GC_COMPRESSED_POINTERS) && defined(OMR_GC_FULL_POINTERS) */
#ifdef J9VM_OPT_JAVA_OFFLOAD_SUPPORT
newThread->invokedCalldisp = FALSE;
#endif
newThread->threadObject = threadObject;
newThread->stackWalkState = &(newThread->inlineStackWalkState);
newThread->javaVM = vm;
newThread->contiguousIndexableHeaderSize = vm->contiguousIndexableHeaderSize;
newThread->discontiguousIndexableHeaderSize = vm->discontiguousIndexableHeaderSize;
newThread->unsafeIndexableHeaderSize = vm->unsafeIndexableHeaderSize;
#if defined(J9VM_ENV_DATA64)
newThread->indexableObjectLayout = vm->indexableObjectLayout;
#endif /* defined(J9VM_ENV_DATA64) */
newThread->privateFlags = privateFlags;
if (vm->extendedRuntimeFlags & J9_EXTENDED_RUNTIME_DEBUG_VM_ACCESS) {
setEventFlag(newThread, J9_PUBLIC_FLAGS_DEBUG_VM_ACCESS);
}
newThread->stackObject = stack;
newThread->stackOverflowMark = newThread->stackOverflowMark2 = J9JAVASTACK_STACKOVERFLOWMARK(stack);
newThread->osThread = osThread;
#if defined(J9VM_OPT_CRIU_SUPPORT)
/* JDWP threads need to remain live while checkpoint/restore hooks run, so add
* J9_PRIVATE_FLAGS2_DELAY_HALT_FOR_CHECKPOINT to the new J9VMThread created from a
* JDWP java thread object.
*/
if (J9_ARE_ANY_BITS_SET(vm->checkpointState.flags, J9VM_CRIU_IS_JDWP_ENABLED)) {
for (UDATA i = 0; i < vm->checkpointState.javaDebugThreadCount; i++) {
j9object_t jdwpThreadObject = J9_JNI_UNWRAP_REFERENCE(vm->checkpointState.javaDebugThreads[i]);
if (jdwpThreadObject == threadObject) {
Trc_VM_criu_allocateVMThread_set_delayflag(i);
newThread->privateFlags2 |= J9_PRIVATE_FLAGS2_DELAY_HALT_FOR_CHECKPOINT;
break;
}
}
}
#endif /* defined(J9VM_OPT_CRIU_SUPPORT) */
#ifdef J9VM_OPT_JAVA_OFFLOAD_SUPPORT
newThread->javaOffloadState = 0;
#endif
#ifdef J9VM_JIT_FREE_SYSTEM_STACK_POINTER
newThread->systemStackPointer = 0;
#endif
/* Initialize stack and bytecode execution stuff (this flushes the method cache) */
initializeExecutionModel(newThread);
#ifdef J9VM_OPT_SIDECAR
/* Initialize fields used by java.lang.management */
newThread->mgmtBlockedCount = 0;
newThread->mgmtWaitedCount = 0;
newThread->mgmtBlockedStart = JNI_FALSE;
newThread->mgmtWaitedStart = JNI_FALSE;
#endif
#ifdef OMR_GC_CONCURRENT_SCAVENGER
/* Initialize fields used by Concurrent Scavenger */
newThread->readBarrierRangeCheckBase = UDATA_MAX;
newThread->readBarrierRangeCheckTop = 0;
#ifdef OMR_GC_COMPRESSED_POINTERS
/* No need for a runtime check here - it would just waste cycles */
newThread->readBarrierRangeCheckBaseCompressed = U_32_MAX;
newThread->readBarrierRangeCheckTopCompressed = 0;
#endif /* OMR_GC_COMPRESSED_POINTERS */
#endif /* OMR_GC_CONCURRENT_SCAVENGER */
/* Attach the thread to OMR */
if (JNI_OK != attachVMThreadToOMR(vm, newThread, osThread)) {
goto fail;
}
newThread->monitorEnterRecordPool = pool_new(sizeof(J9MonitorEnterRecord), 0, 0, 0, J9_GET_CALLSITE(), OMRMEM_CATEGORY_VM, POOL_FOR_PORT(PORTLIB));
if (NULL == newThread->monitorEnterRecordPool) {
goto fail;
}
newThread->omrVMThread->memorySpace = memorySpace;
/* Initialize the thread for memory management purposes (vm->memoryManagerFunctions will be NULL if we failed to load the gc dll) */
if ( (NULL == gcFuncs) || (0 != gcFuncs->initializeMutatorModelJava(newThread)) ) {
goto fail;
}
#if defined(J9VM_INTERP_NATIVE_SUPPORT)
newThread->jitCountDelta = 2;
newThread->maxProfilingCount = (3000 * 2) + 1;
#if defined(J9VM_ENV_SHARED_LIBS_USE_GLOBAL_TABLE)
/* Propagate TOC/GOT register into threads as they are created */
newThread->jitTOC = vm->jitTOC;
#endif
#endif
#if JAVA_SPEC_VERSION >= 16
newThread->ffiArgs = NULL;
newThread->ffiArgCount = 0;
newThread->jmpBufEnvPtr = NULL;
#endif /* JAVA_SPEC_VERSION >= 16 */
#if JAVA_SPEC_VERSION >= 21
newThread->isInCriticalDownCall = FALSE;
#endif /* JAVA_SPEC_VERSION >= 21 */
#if JAVA_SPEC_VERSION >= 19
newThread->currentContinuation = NULL;
newThread->continuationPinCount = 0;
newThread->ownedMonitorCount = 0;
newThread->callOutCount = 0;
newThread->carrierThreadObject = threadObject;
newThread->scopedValueCache = NULL;
#endif /* JAVA_SPEC_VERSION >= 19 */
#if defined(J9VM_OPT_JFR)
newThread->threadJfrState.prevTimestamp = -1;
#endif /* defined(J9VM_OPT_JFR) */
/* If an exclusive access request is in progress, mark this thread */
omrthread_monitor_enter(vm->exclusiveAccessMutex);
/* The new thread does not have VM access, so there's no need to set any not_counted
* bits, as the thread will block attempting to acquire VM access, and will not release
* VM access for the duration of the exclusive.
*/
if (J9_XACCESS_NONE != vm->exclusiveAccessState) {
setHaltFlag(newThread, J9_PUBLIC_FLAGS_HALT_THREAD_EXCLUSIVE);
}
if (J9_XACCESS_NONE != vm->safePointState) {
setHaltFlag(newThread, J9_PUBLIC_FLAGS_HALTED_AT_SAFE_POINT);
}
#if defined(J9VM_OPT_CRIU_SUPPORT)
if (VM_CRIUHelpers::isJVMInSingleThreadMode(vm) && VM_VMHelpers::threadCanRunJavaCode(newThread)) {
/* New threads with the delay halt flag should not be halted here. */
Trc_VM_criu_allocateVMThread_check_delayflag(newThread);
if (J9_ARE_NO_BITS_SET(newThread->privateFlags2, J9_PRIVATE_FLAGS2_DELAY_HALT_FOR_CHECKPOINT)) {
Trc_VM_criu_allocateVMThread_set_haltflag(newThread);
setHaltFlag(newThread, J9_PUBLIC_FLAGS_HALT_THREAD_FOR_CHECKPOINT);
}
}
#endif /* defined(J9VM_OPT_CRIU_SUPPORT) */
omrthread_monitor_exit(vm->exclusiveAccessMutex);
/* Set the thread's method enter notification bits */
newThread->eventFlags = vm->globalEventFlags;
if (J9_EVENT_IS_HOOKED(vm->hookInterface, J9HOOK_VM_THREAD_CREATED)) {
UDATA continueInitialization = TRUE;
ALWAYS_TRIGGER_J9HOOK_VM_THREAD_CREATED(vm->hookInterface, newThread, continueInitialization);
if (!continueInitialization) {
/* Make sure the memory manager does anything needed before shutting down */
/* Holding the vmThreadListMutex ensures that no heap walking will occur, ergo heap manipulation is safe */
gcFuncs->cleanupMutatorModelJava(newThread);
TRIGGER_J9HOOK_VM_THREAD_DESTROY(vm->hookInterface, newThread);
goto fail;
}
}
/* Update counters for total # of threads and daemon threads and notify anyone waiting */
++(vm->totalThreadCount);
if (privateFlags & J9_PRIVATE_FLAGS_DAEMON_THREAD) {
++(vm->daemonThreadCount);
}
omrthread_monitor_notify_all(vm->vmThreadListMutex);
omrthread_monitor_exit(vm->vmThreadListMutex);
return newThread;
fail:
if (stack) {
freeJavaStack(vm, stack);
}
if (newThread) {
J9Pool *pool = newThread->monitorEnterRecordPool;
if (NULL != pool) {
newThread->monitorEnterRecordPool = NULL;
pool_kill(pool);
}
/* Remove the TLS entry for this thread to prevent currentVMThread(vm) from finding freed memory */
omrthread_tls_set(osThread, vm->omrVM->_vmThreadKey, NULL);
/* Remove the thread from the live thread list */
J9_LINKED_LIST_REMOVE(vm->mainThread, newThread);
/* Return the new thread to the deadThreadList if it came from there */
if (threadIsRecycled) {
J9_LINKED_LIST_ADD_LAST(vm->deadThreadList, newThread);
} else {
if (newThread->publicFlagsMutex) {
omrthread_monitor_destroy(newThread->publicFlagsMutex);
}
freeVMThread(vm, newThread);
}
newThread->threadObject = NULL;
#if JAVA_SPEC_VERSION >= 19
newThread->carrierThreadObject = NULL;
#endif /* JAVA_SPEC_VERSION >= 19 */
/* Detach the thread from OMR */
detachVMThreadFromOMR(vm, newThread);
if (!threadIsRecycled) {
destroyOMRVMThread(vm, newThread);
}
}
omrthread_monitor_exit(vm->vmThreadListMutex);
return NULL;
}
IDATA J9THREAD_PROC javaThreadProc(void *entryarg)
{
J9JavaVM * vm = (J9JavaVM*)entryarg;
J9VMThread* vmThread = currentVMThread(vm);
PORT_ACCESS_FROM_JAVAVM(vm);
UDATA result;
vmThread->gpProtected = 1;
j9sig_protect(javaProtectedThreadProc, vmThread,
structuredSignalHandler, vmThread,
J9PORT_SIG_FLAG_SIGALLSYNC | J9PORT_SIG_FLAG_MAY_CONTINUE_EXECUTION,
&result);
exitJavaThread(vm);
/* Execution never reaches this point */
return 0;
}
#if (defined(J9VM_DBG))
static void badness(char *description)
{
printf("\n<badness: %s>\n", description);
}
#endif /* J9VM_DBG */
void OMRNORETURN
exitJavaThread(J9JavaVM * vm)
{
omrthread_monitor_enter(vm->vmThreadListMutex);
--(vm->zombieThreadCount);
omrthread_monitor_notify_all(vm->vmThreadListMutex);
omrthread_exit(vm->vmThreadListMutex);
/* Execution never reaches this point */
}
J9VMThread *
currentVMThread(J9JavaVM *vm)
{
return getVMThreadFromOMRThread(vm, omrthread_self());
}
void threadCleanup(J9VMThread * vmThread, UDATA forkedByVM)
{
J9JavaVM * vm = vmThread->javaVM;
enterVMFromJNI(vmThread);
/* Inform ThreadGroup about any uncaught exception. Tiny VMs do not have ThreadGroup, so they just dump the exception. */
if (vmThread->currentException) {
handleUncaughtException(vmThread);
/* Safe to call this whether handleUncaughtException clears the exception or not */
internalExceptionDescribe(vmThread);
}
releaseVMAccess(vmThread);
/* Mark this thread as dead */
setEventFlag(vmThread, J9_PUBLIC_FLAGS_STOPPED);
/* We are dead at this point. Clear the suspend bit prior to triggering the thread end hook */
clearHaltFlag(vmThread, J9_PUBLIC_FLAGS_HALT_THREAD_JAVA_SUSPEND);
TRIGGER_J9HOOK_VM_THREAD_END(vmThread->javaVM->hookInterface, vmThread, 0);
#ifdef J9VM_OPT_DEPRECATED_METHODS
/* Prevent this thread from processing further stop requests */
omrthread_monitor_enter(vmThread->publicFlagsMutex);
clearEventFlag(vmThread, J9_PUBLIC_FLAGS_STOP);
vmThread->stopThrowable = NULL;
omrthread_monitor_exit(vmThread->publicFlagsMutex);
#endif
/* Increment zombie thread counter - indicates threads which have notified java of their death, but have not deallocated their vmThread and exited their thread proc */
omrthread_monitor_enter(vm->vmThreadListMutex);
++(vm->zombieThreadCount);
omrthread_monitor_exit(vm->vmThreadListMutex);
/* Do the java dance to indicate thread death */
acquireVMAccess(vmThread);
cleanUpAttachedThread(vmThread);
releaseVMAccess(vmThread);
#if defined(OMR_GC_CONCURRENT_SCAVENGER) && defined(J9VM_ARCH_S390)
/* Concurrent scavenge enabled and JIT loaded implies running on supported h/w.
* As such, per-thread deinitialization must occur
*/
if (vm->memoryManagerFunctions->j9gc_concurrent_scavenger_enabled(vm)
&& (NULL != vm->jitConfig)
) {
if (0 == j9gs_deinitializeThread(vmThread)) {
fatalError((JNIEnv *)vmThread, "Failed to deinitialize thread; please disable Concurrent Scavenge.\n");
}
}
#endif
/* Deallocate the vmThread - if this thread was not forked by the VM, decrement the zombie counter now as the VM is not in control of the native thread */
deallocateVMThread(vmThread, !forkedByVM, TRUE);
}
#if defined(J9VM_INTERP_CUSTOM_SPIN_OPTIONS)
static void
printCustomSpinOptions(void *element, void *userData)
{
J9JavaVM *vm = (J9JavaVM *)userData;
PORT_ACCESS_FROM_JAVAVM(vm);
J9VMCustomSpinOptions *options = (J9VMCustomSpinOptions *)element;
const J9ObjectMonitorCustomSpinOptions *const j9monitorOptions = &options->j9monitorOptions;
const J9ThreadCustomSpinOptions *const j9threadOptions = &options->j9threadOptions;
j9tty_printf(PORTLIB, ",\n" LEADING_SPACE "className=%s", options->className);
j9tty_printf(PORTLIB, ",\n" LEADING_SPACE_EXTRA "customSpin1=%zu", j9monitorOptions->thrMaxSpins1BeforeBlocking);
j9tty_printf(PORTLIB, ",\n" LEADING_SPACE_EXTRA "customSpin2=%zu", j9monitorOptions->thrMaxSpins2BeforeBlocking);
j9tty_printf(PORTLIB, ",\n" LEADING_SPACE_EXTRA "customYield=%zu", j9monitorOptions->thrMaxYieldsBeforeBlocking);
j9tty_printf(PORTLIB, ",\n" LEADING_SPACE_EXTRA "customTryEnterSpin1=%zu", j9monitorOptions->thrMaxTryEnterSpins1BeforeBlocking);
j9tty_printf(PORTLIB, ",\n" LEADING_SPACE_EXTRA "customTryEnterSpin2=%zu", j9monitorOptions->thrMaxTryEnterSpins2BeforeBlocking);
j9tty_printf(PORTLIB, ",\n" LEADING_SPACE_EXTRA "customTryEnterYield=%zu", j9monitorOptions->thrMaxTryEnterYieldsBeforeBlocking);
#if defined(OMR_THR_CUSTOM_SPIN_OPTIONS)
#if defined(OMR_THR_THREE_TIER_LOCKING)
j9tty_printf(PORTLIB, ",\n" LEADING_SPACE_EXTRA "customThreeTierSpinCount1=%zu", j9threadOptions->customThreeTierSpinCount1);
j9tty_printf(PORTLIB, ",\n" LEADING_SPACE_EXTRA "customThreeTierSpinCount2=%zu", j9threadOptions->customThreeTierSpinCount2);
j9tty_printf(PORTLIB, ",\n" LEADING_SPACE_EXTRA "customThreeTierSpinCount3=%zu", j9threadOptions->customThreeTierSpinCount3);
#endif /* OMR_THR_THREE_TIER_LOCKING */
#if defined(OMR_THR_ADAPTIVE_SPIN)
j9tty_printf(PORTLIB, ",\n" LEADING_SPACE_EXTRA "customAdaptSpin=%zu", j9threadOptions->customAdaptSpin);
#endif /* OMR_THR_ADAPTIVE_SPIN */
#endif /* OMR_THR_CUSTOM_SPIN_OPTIONS */
}
#endif /* J9VM_INTERP_CUSTOM_SPIN_OPTIONS */
/**
* Initializes VM thread options and parses suboptions of -Xthr:
*
* Note that omrthread defaults are set at omrthread_init(), and not in
* this function.
*
* @param[in] vm JavaVM.
* @param[in] optArg Suboption string of format subopt[=val][,[subopt[=val]]...
* @returns JNI error code
* @retval JNI_OK success
* @retval JNI_EINVAL unrecognized option
*/
jint
threadParseArguments(J9JavaVM *vm, char *optArg)
{
char *scan_start;
char *scan_limit;
int dumpInfo = 0;
UDATA cpus = 0;
#if defined(J9VM_INTERP_CUSTOM_SPIN_OPTIONS)
BOOLEAN customSpinOptionsParsed = FALSE;
#if defined(OMR_THR_CUSTOM_SPIN_OPTIONS)
#if defined(OMR_THR_ADAPTIVE_SPIN)
BOOLEAN customAdaptSpinEnabled = FALSE;
#endif /* OMR_THR_ADAPTIVE_SPIN */
#endif /* OMR_THR_CUSTOM_SPIN_OPTIONS */
#endif /* J9VM_INTERP_CUSTOM_SPIN_OPTIONS */
PORT_ACCESS_FROM_JAVAVM(vm);
cpus = j9sysinfo_get_number_CPUs_by_type(J9PORT_CPU_TARGET);
/* initialize defaults, first */
vm->thrMaxYieldsBeforeBlocking = 45;
vm->thrMaxTryEnterYieldsBeforeBlocking = 45;
vm->thrNestedSpinning = 1;
vm->thrTryEnterNestedSpinning = 1;
vm->thrDeflationPolicy = J9VM_DEFLATION_POLICY_ASAP;
if (cpus > 1) {
#if (defined(LINUXPPC)) && !defined(J9VM_ENV_LITTLE_ENDIAN)
vm->thrMaxSpins1BeforeBlocking = 151;
#elif defined(AIXPPC) || defined(LINUXPPC)
vm->thrMaxSpins1BeforeBlocking = 96;
#else /* defined(AIXPPC) || defined(LINUXPPC) */
vm->thrMaxSpins1BeforeBlocking = 256;
#endif /* defined(AIXPPC) || defined(LINUXPPC) */
vm->thrMaxSpins2BeforeBlocking = 32;
vm->thrMaxTryEnterSpins1BeforeBlocking = 256;
vm->thrMaxTryEnterSpins2BeforeBlocking = 32;
} else {
/* In ObjectMonitor.cpp:objectMonitorEnterNonBlocking, we converted
* "goto statements" into "three nested for loops". Due to this change,
* we can no longer let spin counts to be 0. With spin counts set to
* zero, there will be no attempts to acquire a lock. To allow atleast
* one attempt to acquire a lock, minimum value of spin counts is set to 1.
*/
vm->thrMaxSpins1BeforeBlocking = 1;
vm->thrMaxSpins2BeforeBlocking = 1;
vm->thrMaxTryEnterSpins1BeforeBlocking = 1;
vm->thrMaxTryEnterSpins2BeforeBlocking = 1;
}
#if defined(J9ZOS390)
{
UDATA *gtw;
/* Supply default thread weight, may be overridden below. */
gtw = omrthread_global((char*)"thread_weight");
*gtw = (UDATA)"medium";
/* different defaults for z/OS */
vm->thrNestedSpinning = 0;
vm->thrTryEnterNestedSpinning = 0;
vm->thrMaxYieldsBeforeBlocking = 128;
vm->thrMaxTryEnterYieldsBeforeBlocking = 128;
vm->thrMaxSpins2BeforeBlocking = 8;
vm->thrMaxTryEnterSpins2BeforeBlocking = 8;
/* In ObjectMonitor.cpp:objectMonitorEnterNonBlocking, we converted
* "goto statements" into "three nested for loops". Due to this change,
* we can no longer let spin counts to be 0. With spin counts set to
* zero, there will be no attempts to acquire a lock. To allow atleast
* one attempt to acquire a lock, minimum value of spin counts is set to 1.
*/
vm->thrMaxSpins1BeforeBlocking = 1;
vm->thrMaxTryEnterSpins1BeforeBlocking = 1;
}
#endif
#if defined(OMR_THR_YIELD_ALG)
**(UDATA**)omrthread_global((char*)"yieldAlgorithm") = J9THREAD_LIB_YIELD_ALGORITHM_SCHED_YIELD;
**(UDATA**)omrthread_global((char*)"yieldUsleepMultiplier") = 1;
#endif /* defined(OMR_THR_YIELD_ALG) */
#if defined(LINUX)
/* Check the sched_compat_yield setting for the versions of the Completely Fair Scheduler (CFS) which
* have broken the thread_yield behavior. If running in CFS and sched_compat_yield=0, the CPU yielding
* behavior is moderated to act as though CFS is not enabled by increasing the yield count to 270 in
* the three-tier spinlock loops.
*
* sched_compat_yield=1 uses the aggressive CPU yielding behavior of some versions of the O(1)
* scheduler and uses the default yield counts (= 45).
*
* Newer Linux versions no longer support the sched_compat_yield flag since the thread_yield behavior
* is restored to something stable.
*/
if ('0' == j9util_sched_compat_yield_value(vm)) {
#if defined(OMR_THR_YIELD_ALG)
**(UDATA**)omrthread_global((char*)"yieldAlgorithm") = J9THREAD_LIB_YIELD_ALGORITHM_INCREASING_USLEEP;
#if defined(OMR_THR_THREE_TIER_LOCKING)
**(UDATA **)omrthread_global((char*)"defaultMonitorSpinCount3") = 270;
#endif /* defined(OMR_THR_THREE_TIER_LOCKING) */
vm->thrMaxYieldsBeforeBlocking = 270;
vm->thrMaxTryEnterYieldsBeforeBlocking = 270;
#endif /* defined(OMR_THR_YIELD_ALG) */
}
#endif /* defined(LINUX) */
/* experimental options to force stacks to be relatively misaligned */
vm->thrStaggerStep = 32;
vm->thrStaggerMax = 0;
vm->thrStagger = 0;
#if defined(J9VM_GC_REALTIME)
/* If we aren't realtime, we can still be vanilla metronome (formerly known as SoftRT) and that means we still need to set these values but they are different */
vm->priorityPosixSignalDispatch = PRIORITY_INDICATOR_VALUE(J9THREAD_PRIORITY_MAX) + PRIORITY_INDICATOR_ADJUSTED_TYPE(PRIORITY_INDICATOR_J9THREAD_PRIORITY);
vm->priorityPosixSignalDispatchNH = PRIORITY_INDICATOR_VALUE(J9THREAD_PRIORITY_MAX) + PRIORITY_INDICATOR_ADJUSTED_TYPE(PRIORITY_INDICATOR_J9THREAD_PRIORITY);
vm->priorityAsyncEventDispatch = PRIORITY_INDICATOR_VALUE(J9THREAD_PRIORITY_MAX) + PRIORITY_INDICATOR_ADJUSTED_TYPE(PRIORITY_INDICATOR_J9THREAD_PRIORITY);
vm->priorityAsyncEventDispatchNH = PRIORITY_INDICATOR_VALUE(J9THREAD_PRIORITY_MAX) + PRIORITY_INDICATOR_ADJUSTED_TYPE(PRIORITY_INDICATOR_J9THREAD_PRIORITY);
vm->priorityTimerDispatch = PRIORITY_INDICATOR_VALUE(J9THREAD_PRIORITY_MAX) + PRIORITY_INDICATOR_ADJUSTED_TYPE(PRIORITY_INDICATOR_J9THREAD_PRIORITY);
vm->priorityTimerDispatchNH = PRIORITY_INDICATOR_VALUE(J9THREAD_PRIORITY_MAX) + PRIORITY_INDICATOR_ADJUSTED_TYPE(PRIORITY_INDICATOR_J9THREAD_PRIORITY);
vm->priorityMetronomeAlarm = PRIORITY_INDICATOR_VALUE(J9THREAD_PRIORITY_MAX) + PRIORITY_INDICATOR_ADJUSTED_TYPE(PRIORITY_INDICATOR_J9THREAD_PRIORITY);
vm->priorityMetronomeTrace = PRIORITY_INDICATOR_VALUE(J9THREAD_PRIORITY_MIN) + PRIORITY_INDICATOR_ADJUSTED_TYPE(PRIORITY_INDICATOR_J9THREAD_PRIORITY);
vm->priorityJitSample = PRIORITY_INDICATOR_VALUE(J9THREAD_PRIORITY_MAX) + PRIORITY_INDICATOR_ADJUSTED_TYPE(PRIORITY_INDICATOR_J9THREAD_PRIORITY);
vm->priorityJitCompile = PRIORITY_INDICATOR_VALUE(J9THREAD_PRIORITY_MAX) + PRIORITY_INDICATOR_ADJUSTED_TYPE(PRIORITY_INDICATOR_J9THREAD_PRIORITY);
vm->priorityRealtimePriorityShift = 0;
#endif
#if defined(OMR_THR_ADAPTIVE_SPIN)
*(UDATA*)omrthread_global((char*)"adaptSpinHoldtimeEnable")=1;
*(UDATA*)omrthread_global((char*)"adaptSpinSlowPercentEnable")=1;
**(UDATA**)omrthread_global((char*)"adaptSpinHoldtime")=1000000;
**(UDATA**)omrthread_global((char*)"adaptSpinSlowPercent")=10;
**(UDATA**)omrthread_global((char*)"adaptSpinSampleThreshold")=1000;
**(UDATA**)omrthread_global((char*)"adaptSpinSampleStopCount")=10;
**(UDATA**)omrthread_global((char*)"adaptSpinSampleCountStopRatio")=150;
omrthread_lib_set_flags(J9THREAD_LIB_FLAG_ADAPTIVE_SPIN_KEEP_SAMPLING);
#if defined(J9VM_INTERP_CUSTOM_SPIN_OPTIONS)
#if defined(OMR_THR_CUSTOM_SPIN_OPTIONS)
/* Handle allocation and initialization of JLM tracing data structures for class-specific spin parameters */
*(UDATA*)omrthread_global((char*)"customAdaptSpinEnabled") = customAdaptSpinEnabled;
#endif /* OMR_THR_CUSTOM_SPIN_OPTIONS */
#endif /* J9VM_INTERP_CUSTOM_SPIN_OPTIONS */
#endif /* OMR_THR_ADAPTIVE_SPIN */
#if defined(OMR_THR_THREE_TIER_LOCKING)
omrthread_lib_clear_flags(J9THREAD_LIB_FLAG_SECONDARY_SPIN_OBJECT_MONITORS_ENABLED | J9THREAD_LIB_FLAG_FAST_NOTIFY);
#if defined(OMR_THR_SPIN_WAKE_CONTROL)
{
UDATA maxSpinThreadsLocal = 0;
if (cpus < OMRTHREAD_MINIMUM_SPIN_THREADS) {
maxSpinThreadsLocal = OMRTHREAD_MINIMUM_SPIN_THREADS;
} else if (cpus <= 4) {
maxSpinThreadsLocal = cpus;
} else if (cpus <= 16) {
maxSpinThreadsLocal = cpus/2;
} else if (cpus <= 64) {
maxSpinThreadsLocal = cpus/3;
} else {
maxSpinThreadsLocal = cpus/4;
}
**(UDATA**)omrthread_global((char*)"maxSpinThreads") = maxSpinThreadsLocal;
}
**(UDATA**)omrthread_global((char*)"maxWakeThreads") = OMRTHREAD_MINIMUM_WAKE_THREADS;
#endif /* defined(OMR_THR_SPIN_WAKE_CONTROL) */
#endif /* defined(OMR_THR_THREE_TIER_LOCKING) */
/* parse arguments */
if (optArg == NULL) {
return JNI_OK;
}
scan_start = optArg;
scan_limit = optArg + strlen(optArg);
while (scan_start < scan_limit) {
/* ignore separators */
try_scan(&scan_start, ",");
#if defined(J9VM_GC_REALTIME)
{
char *oldScanStart = scan_start;
/* priorities will be determined algorithmically */
if (try_scan(&scan_start, "spreadPrios")) {
if (omrthread_set_priority_spread()) {
scan_start = oldScanStart;
goto _error;
}
continue;
}
}
#endif /* defined(J9VM_GC_REALTIME) */
if (try_scan(&scan_start, "what")) {
dumpInfo = 1;
continue;
}
if (try_scan(&scan_start, "spin1=")) {
if (scan_udata(&scan_start, &vm->thrMaxSpins1BeforeBlocking)) {
goto _error;
}
continue;
}
if (try_scan(&scan_start, "spin2=")) {
if (scan_udata(&scan_start, &vm->thrMaxSpins2BeforeBlocking)) {
goto _error;
}
continue;
}
if (try_scan(&scan_start, "yield=")) {
if (scan_udata(&scan_start, &vm->thrMaxYieldsBeforeBlocking)) {
goto _error;
}
continue;
}
if (try_scan(&scan_start, "tryEnterSpin1=")) {
if (scan_udata(&scan_start, &vm->thrMaxTryEnterSpins1BeforeBlocking)) {
goto _error;
}
continue;
}
if (try_scan(&scan_start, "tryEnterSpin2=")) {
if (scan_udata(&scan_start, &vm->thrMaxTryEnterSpins2BeforeBlocking)) {
goto _error;
}
continue;
}
if (try_scan(&scan_start, "tryEnterYield=")) {
if (scan_udata(&scan_start, &vm->thrMaxTryEnterYieldsBeforeBlocking)) {
goto _error;
}
continue;
}
if (try_scan(&scan_start, "nestedSpinning")) {
vm->thrNestedSpinning = 1;
continue;
}
if (try_scan(&scan_start, "noNestedSpinning")) {
vm->thrNestedSpinning = 0;
continue;
}
if (try_scan(&scan_start, "tryEnterNestedSpinning")) {
vm->thrTryEnterNestedSpinning = 1;
continue;
}
if (try_scan(&scan_start, "noTryEnterNestedSpinning")) {
vm->thrTryEnterNestedSpinning = 0;
continue;
}
if (try_scan(&scan_start, "staggerStep=")) {
if (scan_udata(&scan_start, &vm->thrStaggerStep)) {
goto _error;
}
if (vm->thrStaggerStep & (sizeof(UDATA) - 1)) {
vm->thrStaggerStep += (sizeof(UDATA) - (vm->thrStaggerStep & (sizeof(UDATA) - 1)));
}
continue;
}
if (try_scan(&scan_start, "staggerMax=")) {
if (scan_udata(&scan_start, &vm->thrStaggerMax)) {
goto _error;
}
continue;
}
if (try_scan(&scan_start, "noPriorities")) {
vm->runtimeFlags |= J9_RUNTIME_NO_PRIORITIES;
continue;
}
#if !defined(WIN32) && defined(OMR_NOTIFY_POLICY_CONTROL)
if (try_scan(&scan_start, "notifyPolicy=")) {
char *oldScanStart = scan_start;
char *notifyPolicy = scan_to_delim(PORTLIB, &scan_start, ',');
if (NULL != notifyPolicy) {
if (0 == strcmp(notifyPolicy, "signal")) {
omrthread_lib_clear_flags(J9THREAD_LIB_FLAG_NOTIFY_POLICY_BROADCAST);
} else if (0 == strcmp(notifyPolicy, "broadcast")) {
omrthread_lib_set_flags(J9THREAD_LIB_FLAG_NOTIFY_POLICY_BROADCAST);
} else {
/* restore for better error message */
scan_start = oldScanStart;
j9mem_free_memory(notifyPolicy);
goto _error;
}
j9mem_free_memory(notifyPolicy);
} else {
goto _error;
}
continue;
}
#endif /* !defined(WIN32) && defined(OMR_NOTIFY_POLICY_CONTROL) */
#if defined(OMR_THR_THREE_TIER_LOCKING)
#if defined(OMR_THR_SPIN_WAKE_CONTROL)
if (try_scan(&scan_start, "maxSpinThreads=")) {
UDATA maxSpinThreads = 0;
if (scan_udata(&scan_start, &maxSpinThreads)) {
goto _error;
}
**(UDATA**)omrthread_global((char*)"maxSpinThreads") = maxSpinThreads;
continue;
}
if (try_scan(&scan_start, "maxWakeThreads=")) {
UDATA maxWakeThreads = 0;
if (scan_udata(&scan_start, &maxWakeThreads)) {
goto _error;
}
if (maxWakeThreads < OMRTHREAD_MINIMUM_WAKE_THREADS) {
goto _error;
}
**(UDATA**)omrthread_global((char*)"maxWakeThreads") = maxWakeThreads;
continue;
}
#endif /* defined(OMR_THR_SPIN_WAKE_CONTROL) */
if (try_scan(&scan_start, "threeTierSpinCount1=")) {
UDATA spinCount;
if (scan_udata(&scan_start, &spinCount)) {
goto _error;
}
if (0 == spinCount) {
goto _error;
}
**(UDATA**)omrthread_global((char*)"defaultMonitorSpinCount1") = spinCount;
continue;
}
if (try_scan(&scan_start, "threeTierSpinCount2=")) {
UDATA spinCount;
if (scan_udata(&scan_start, &spinCount)) {
goto _error;
}
if (0 == spinCount) {
goto _error;
}
**(UDATA**)omrthread_global((char*)"defaultMonitorSpinCount2") = spinCount;
continue;
}
if (try_scan(&scan_start, "threeTierSpinCount3=")) {
UDATA spinCount;
if (scan_udata(&scan_start, &spinCount)) {
goto _error;
}
if (0 == spinCount) {
goto _error;
}
**(UDATA**)omrthread_global((char*)"defaultMonitorSpinCount3") = spinCount;
continue;
}
#endif /* defined(OMR_THR_THREE_TIER_LOCKING) */
if (try_scan(&scan_start, "minimizeUserCPU")) {
initMinCPUSpinCounts(vm);
#ifdef OMR_THR_ADAPTIVE_SPIN
*(UDATA*)omrthread_global((char*)"adaptSpinHoldtimeEnable") = 0;
*(UDATA*)omrthread_global((char*)"adaptSpinSlowPercentEnable") = 0;
#endif
#if defined(OMR_THR_YIELD_ALG)
**(UDATA**)omrthread_global((char*)"yieldAlgorithm") = J9THREAD_LIB_YIELD_ALGORITHM_SCHED_YIELD;
#endif /* defined(OMR_THR_YIELD_ALG) */
continue;
}
#ifdef OMR_THR_JLM_HOLD_TIMES
if (try_scan(&scan_start, "clockSkewHi=")) {
/* upper 32 bits of 64 bit clock */
UDATA clockSkewHi;
if (scan_hex(&scan_start, &clockSkewHi)) {
goto _error;
}
*omrthread_global((char*)"clockSkewHi") = clockSkewHi;
continue;
}
#endif
if (try_scan(&scan_start, "deflationPolicy=")) {
char *oldScanStart = scan_start;
char *policy = scan_to_delim(PORTLIB, &scan_start, ',');
if (NULL != policy) {
if (0 == strcmp(policy, "never")) {
vm->thrDeflationPolicy = J9VM_DEFLATION_POLICY_NEVER;
} else if (0 == strcmp(policy, "asap")) {
vm->thrDeflationPolicy = J9VM_DEFLATION_POLICY_ASAP;
}
#ifdef J9VM_THR_SMART_DEFLATION
else if (0 == strcmp(policy,"smart")) {
vm->thrDeflationPolicy = J9VM_DEFLATION_POLICY_SMART;
}
#endif
else {
/* restore for better error message */
scan_start = oldScanStart;
j9mem_free_memory(policy);
goto _error;
}
j9mem_free_memory(policy);
} else {
goto _error;
}
continue;
}
#if defined(J9VM_INTERP_CUSTOM_SPIN_OPTIONS)
if (try_scan(&scan_start, "customSpinOptions=")) {
vm->customSpinOptions = pool_new(sizeof(J9VMCustomSpinOptions), 0, 0, 0, J9_GET_CALLSITE(), OMRMEM_CATEGORY_VM, POOL_FOR_PORT(vm->portLibrary));
if (NULL == vm->customSpinOptions) {
goto _error;
}
do {
J9VMCustomSpinOptions *option = (J9VMCustomSpinOptions*) pool_newElement(vm->customSpinOptions);
J9ObjectMonitorCustomSpinOptions *j9monitorOptions = &option->j9monitorOptions;
J9ThreadCustomSpinOptions *j9threadOptions = &option->j9threadOptions;
if (NULL == option) {
goto _error;
}
option->className = scan_to_delim(vm->portLibrary, &scan_start, ':');
if(NULL == option->className) {
goto _error;
}
if (scan_udata(&scan_start, &j9monitorOptions->thrMaxSpins1BeforeBlocking)) {
goto _error;
}
if (!try_scan(&scan_start, ":")) {
goto _error;
}
if (scan_udata(&scan_start, &j9monitorOptions->thrMaxSpins2BeforeBlocking)) {
goto _error;
}
if (!try_scan(&scan_start, ":")) {
goto _error;
}
if (scan_udata(&scan_start, &j9monitorOptions->thrMaxYieldsBeforeBlocking)) {
goto _error;