1174 // 3: allocate a block of new ObjectMonitors |
1174 // 3: allocate a block of new ObjectMonitors |
1175 // Both the local and global free lists are empty -- resort to malloc(). |
1175 // Both the local and global free lists are empty -- resort to malloc(). |
1176 // In the current implementation objectMonitors are TSM - immortal. |
1176 // In the current implementation objectMonitors are TSM - immortal. |
1177 // Ideally, we'd write "new ObjectMonitor[_BLOCKSIZE], but we want |
1177 // Ideally, we'd write "new ObjectMonitor[_BLOCKSIZE], but we want |
1178 // each ObjectMonitor to start at the beginning of a cache line, |
1178 // each ObjectMonitor to start at the beginning of a cache line, |
1179 // so we use align_size_up(). |
1179 // so we use align_up(). |
1180 // A better solution would be to use C++ placement-new. |
1180 // A better solution would be to use C++ placement-new. |
1181 // BEWARE: As it stands currently, we don't run the ctors! |
1181 // BEWARE: As it stands currently, we don't run the ctors! |
1182 assert(_BLOCKSIZE > 1, "invariant"); |
1182 assert(_BLOCKSIZE > 1, "invariant"); |
1183 size_t neededsize = sizeof(PaddedEnd<ObjectMonitor>) * _BLOCKSIZE; |
1183 size_t neededsize = sizeof(PaddedEnd<ObjectMonitor>) * _BLOCKSIZE; |
1184 PaddedEnd<ObjectMonitor> * temp; |
1184 PaddedEnd<ObjectMonitor> * temp; |
1185 size_t aligned_size = neededsize + (DEFAULT_CACHE_LINE_SIZE - 1); |
1185 size_t aligned_size = neededsize + (DEFAULT_CACHE_LINE_SIZE - 1); |
1186 void* real_malloc_addr = (void *)NEW_C_HEAP_ARRAY(char, aligned_size, |
1186 void* real_malloc_addr = (void *)NEW_C_HEAP_ARRAY(char, aligned_size, |
1187 mtInternal); |
1187 mtInternal); |
1188 temp = (PaddedEnd<ObjectMonitor> *) |
1188 temp = (PaddedEnd<ObjectMonitor> *) |
1189 align_ptr_up(real_malloc_addr, |
1189 align_up(real_malloc_addr, DEFAULT_CACHE_LINE_SIZE); |
1190 DEFAULT_CACHE_LINE_SIZE); |
|
1191 |
1190 |
1192 // NOTE: (almost) no way to recover if allocation failed. |
1191 // NOTE: (almost) no way to recover if allocation failed. |
1193 // We might be able to induce a STW safepoint and scavenge enough |
1192 // We might be able to induce a STW safepoint and scavenge enough |
1194 // objectMonitors to permit progress. |
1193 // objectMonitors to permit progress. |
1195 if (temp == NULL) { |
1194 if (temp == NULL) { |