1001 const int mx = MonitorBound ;
1002 if (mx > 0 && (MonitorPopulation-MonitorFreeCount) > mx) {
1003 // We can't safely induce a STW safepoint from omAlloc() as our thread
1004 // state may not be appropriate for such activities and callers may hold
1005 // naked oops, so instead we defer the action.
1006 InduceScavenge (Self, "omAlloc") ;
1007 }
1008 continue;
1009 }
1010
1011 // 3: allocate a block of new ObjectMonitors
1012 // Both the local and global free lists are empty -- resort to malloc().
1013 // In the current implementation objectMonitors are TSM - immortal.
1014 assert (_BLOCKSIZE > 1, "invariant") ;
1015 ObjectMonitor * temp = new ObjectMonitor[_BLOCKSIZE];
1016
1017 // NOTE: (almost) no way to recover if allocation failed.
1018 // We might be able to induce a STW safepoint and scavenge enough
1019 // objectMonitors to permit progress.
1020 if (temp == NULL) {
1021 vm_exit_out_of_memory (sizeof (ObjectMonitor[_BLOCKSIZE]), "Allocate ObjectMonitors") ;
1022 }
1023
1024 // Format the block.
1025 // initialize the linked list, each monitor points to its next
1026 // forming the single linked free list, the very first monitor
1027 // will points to next block, which forms the block list.
1028 // The trick of using the 1st element in the block as gBlockList
1029 // linkage should be reconsidered. A better implementation would
1030 // look like: class Block { Block * next; int N; ObjectMonitor Body [N] ; }
1031
1032 for (int i = 1; i < _BLOCKSIZE ; i++) {
1033 temp[i].FreeNext = &temp[i+1];
1034 }
1035
1036 // terminate the last monitor as the end of list
1037 temp[_BLOCKSIZE - 1].FreeNext = NULL ;
1038
1039 // Element [0] is reserved for global list linkage
1040 temp[0].set_object(CHAINMARKER);
1041
|
1001 const int mx = MonitorBound ;
1002 if (mx > 0 && (MonitorPopulation-MonitorFreeCount) > mx) {
1003 // We can't safely induce a STW safepoint from omAlloc() as our thread
1004 // state may not be appropriate for such activities and callers may hold
1005 // naked oops, so instead we defer the action.
1006 InduceScavenge (Self, "omAlloc") ;
1007 }
1008 continue;
1009 }
1010
1011 // 3: allocate a block of new ObjectMonitors
1012 // Both the local and global free lists are empty -- resort to malloc().
1013 // In the current implementation objectMonitors are TSM - immortal.
1014 assert (_BLOCKSIZE > 1, "invariant") ;
1015 ObjectMonitor * temp = new ObjectMonitor[_BLOCKSIZE];
1016
1017 // NOTE: (almost) no way to recover if allocation failed.
1018 // We might be able to induce a STW safepoint and scavenge enough
1019 // objectMonitors to permit progress.
1020 if (temp == NULL) {
1021 vm_exit_out_of_memory (sizeof (ObjectMonitor[_BLOCKSIZE]), OOM_MALLOC_ERROR,
1022 "Allocate ObjectMonitors");
1023 }
1024
1025 // Format the block.
1026 // initialize the linked list, each monitor points to its next
1027 // forming the single linked free list, the very first monitor
1028 // will points to next block, which forms the block list.
1029 // The trick of using the 1st element in the block as gBlockList
1030 // linkage should be reconsidered. A better implementation would
1031 // look like: class Block { Block * next; int N; ObjectMonitor Body [N] ; }
1032
1033 for (int i = 1; i < _BLOCKSIZE ; i++) {
1034 temp[i].FreeNext = &temp[i+1];
1035 }
1036
1037 // terminate the last monitor as the end of list
1038 temp[_BLOCKSIZE - 1].FreeNext = NULL ;
1039
1040 // Element [0] is reserved for global list linkage
1041 temp[0].set_object(CHAINMARKER);
1042
|