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