260
261 void generate() {
262 iterate();
263 }
264 };
265
266 bool OopMapCacheEntry::verify_mask(CellTypeState* vars, CellTypeState* stack, int max_locals, int stack_top) {
267 // Check mask includes map
268 VerifyClosure blk(this);
269 iterate_oop(&blk);
270 if (blk.failed()) return false;
271
272 // Check if map is generated correctly
273 // (Use ?: operator to make sure all 'true' & 'false' are represented exactly the same so we can use == afterwards)
274 const bool log = log_is_enabled(Trace, interpreter, oopmap);
275 LogStream st(Log(interpreter, oopmap)::trace());
276
277 if (log) st.print("Locals (%d): ", max_locals);
278 for(int i = 0; i < max_locals; i++) {
279 bool v1 = is_oop(i) ? true : false;
280 bool v2 = vars[i].is_reference() ? true : false;
281 assert(v1 == v2, "locals oop mask generation error");
282 if (log) st.print("%d", v1 ? 1 : 0);
283 }
284 if (log) st.cr();
285
286 if (log) st.print("Stack (%d): ", stack_top);
287 for(int j = 0; j < stack_top; j++) {
288 bool v1 = is_oop(max_locals + j) ? true : false;
289 bool v2 = stack[j].is_reference() ? true : false;
290 assert(v1 == v2, "stack oop mask generation error");
291 if (log) st.print("%d", v1 ? 1 : 0);
292 }
293 if (log) st.cr();
294 return true;
295 }
296
297 void OopMapCacheEntry::allocate_bit_mask() {
298 if (mask_size() > small_mask_limit) {
299 assert(_bit_mask[0] == 0, "bit mask should be new or just flushed");
300 _bit_mask[0] = (intptr_t)
301 NEW_C_HEAP_ARRAY(uintptr_t, mask_word_size(), mtClass);
302 }
303 }
304
305 void OopMapCacheEntry::deallocate_bit_mask() {
306 if (mask_size() > small_mask_limit && _bit_mask[0] != 0) {
307 assert(!Thread::current()->resource_area()->contains((void*)_bit_mask[0]),
308 "This bit mask should not be in the resource area");
309 FREE_C_HEAP_ARRAY(uintptr_t, _bit_mask[0]);
352 int word_index = 0;
353 uintptr_t value = 0;
354 uintptr_t mask = 1;
355
356 _num_oops = 0;
357 CellTypeState* cell = vars;
358 for (int entry_index = 0; entry_index < n_entries; entry_index++, mask <<= bits_per_entry, cell++) {
359 // store last word
360 if (mask == 0) {
361 bit_mask()[word_index++] = value;
362 value = 0;
363 mask = 1;
364 }
365
366 // switch to stack when done with locals
367 if (entry_index == max_locals) {
368 cell = stack;
369 }
370
371 // set oop bit
372 if ( cell->is_reference()) {
373 value |= (mask << oop_bit_number );
374 _num_oops++;
375 }
376
377 // set dead bit
378 if (!cell->is_live()) {
379 value |= (mask << dead_bit_number);
380 assert(!cell->is_reference(), "dead value marked as oop");
381 }
382 }
383
384 // make sure last word is stored
385 bit_mask()[word_index] = value;
386
387 // verify bit mask
388 assert(verify_mask(vars, stack, max_locals, stack_top), "mask could not be verified");
389 }
390
391 void OopMapCacheEntry::flush() {
392 deallocate_bit_mask();
|
260
261 void generate() {
262 iterate();
263 }
264 };
265
266 bool OopMapCacheEntry::verify_mask(CellTypeState* vars, CellTypeState* stack, int max_locals, int stack_top) {
267 // Check mask includes map
268 VerifyClosure blk(this);
269 iterate_oop(&blk);
270 if (blk.failed()) return false;
271
272 // Check if map is generated correctly
273 // (Use ?: operator to make sure all 'true' & 'false' are represented exactly the same so we can use == afterwards)
274 const bool log = log_is_enabled(Trace, interpreter, oopmap);
275 LogStream st(Log(interpreter, oopmap)::trace());
276
277 if (log) st.print("Locals (%d): ", max_locals);
278 for(int i = 0; i < max_locals; i++) {
279 bool v1 = is_oop(i) ? true : false;
280 bool v2 = vars[i].is_reference();
281 assert(v1 == v2, "locals oop mask generation error");
282 if (log) st.print("%d", v1 ? 1 : 0);
283 }
284 if (log) st.cr();
285
286 if (log) st.print("Stack (%d): ", stack_top);
287 for(int j = 0; j < stack_top; j++) {
288 bool v1 = is_oop(max_locals + j) ? true : false;
289 bool v2 = stack[j].is_reference();
290 assert(v1 == v2, "stack oop mask generation error");
291 if (log) st.print("%d", v1 ? 1 : 0);
292 }
293 if (log) st.cr();
294 return true;
295 }
296
297 void OopMapCacheEntry::allocate_bit_mask() {
298 if (mask_size() > small_mask_limit) {
299 assert(_bit_mask[0] == 0, "bit mask should be new or just flushed");
300 _bit_mask[0] = (intptr_t)
301 NEW_C_HEAP_ARRAY(uintptr_t, mask_word_size(), mtClass);
302 }
303 }
304
305 void OopMapCacheEntry::deallocate_bit_mask() {
306 if (mask_size() > small_mask_limit && _bit_mask[0] != 0) {
307 assert(!Thread::current()->resource_area()->contains((void*)_bit_mask[0]),
308 "This bit mask should not be in the resource area");
309 FREE_C_HEAP_ARRAY(uintptr_t, _bit_mask[0]);
352 int word_index = 0;
353 uintptr_t value = 0;
354 uintptr_t mask = 1;
355
356 _num_oops = 0;
357 CellTypeState* cell = vars;
358 for (int entry_index = 0; entry_index < n_entries; entry_index++, mask <<= bits_per_entry, cell++) {
359 // store last word
360 if (mask == 0) {
361 bit_mask()[word_index++] = value;
362 value = 0;
363 mask = 1;
364 }
365
366 // switch to stack when done with locals
367 if (entry_index == max_locals) {
368 cell = stack;
369 }
370
371 // set oop bit
372 if (cell->is_reference()) {
373 value |= (mask << oop_bit_number );
374 _num_oops++;
375 }
376
377 // set dead bit
378 if (!cell->is_live()) {
379 value |= (mask << dead_bit_number);
380 assert(!cell->is_reference(), "dead value marked as oop");
381 }
382 }
383
384 // make sure last word is stored
385 bit_mask()[word_index] = value;
386
387 // verify bit mask
388 assert(verify_mask(vars, stack, max_locals, stack_top), "mask could not be verified");
389 }
390
391 void OopMapCacheEntry::flush() {
392 deallocate_bit_mask();
|