< prev index next >

src/hotspot/share/interpreter/oopMapCache.cpp

Print this page

270 
271   void generate() {
272     iterate();
273   }
274 };
275 
276 bool OopMapCacheEntry::verify_mask(CellTypeState* vars, CellTypeState* stack, int max_locals, int stack_top) {
277   // Check mask includes map
278   VerifyClosure blk(this);
279   iterate_oop(&blk);
280   if (blk.failed()) return false;
281 
282   // Check if map is generated correctly
283   // (Use ?: operator to make sure all 'true' & 'false' are represented exactly the same so we can use == afterwards)
284   const bool log = log_is_enabled(Trace, interpreter, oopmap);
285   LogStream st(Log(interpreter, oopmap)::trace());
286 
287   if (log) st.print("Locals (%d): ", max_locals);
288   for(int i = 0; i < max_locals; i++) {
289     bool v1 = is_oop(i)               ? true : false;
290     bool v2 = vars[i].is_reference()  ? true : false;
291     assert(v1 == v2, "locals oop mask generation error");
292     if (log) st.print("%d", v1 ? 1 : 0);
293   }
294   if (log) st.cr();
295 
296   if (log) st.print("Stack (%d): ", stack_top);
297   for(int j = 0; j < stack_top; j++) {
298     bool v1 = is_oop(max_locals + j)  ? true : false;
299     bool v2 = stack[j].is_reference() ? true : false;
300     assert(v1 == v2, "stack oop mask generation error");
301     if (log) st.print("%d", v1 ? 1 : 0);
302   }
303   if (log) st.cr();
304   return true;
305 }
306 
307 void OopMapCacheEntry::allocate_bit_mask() {
308   if (mask_size() > small_mask_limit) {
309     assert(_bit_mask[0] == 0, "bit mask should be new or just flushed");
310     _bit_mask[0] = (intptr_t)
311       NEW_C_HEAP_ARRAY(uintptr_t, mask_word_size(), mtClass);
312   }
313 }
314 
315 void OopMapCacheEntry::deallocate_bit_mask() {
316   if (mask_size() > small_mask_limit && _bit_mask[0] != 0) {
317     assert(!Thread::current()->resource_area()->contains((void*)_bit_mask[0]),
318       "This bit mask should not be in the resource area");
319     FREE_C_HEAP_ARRAY(uintptr_t, _bit_mask[0]);

362   int word_index = 0;
363   uintptr_t value = 0;
364   uintptr_t mask = 1;
365 
366   _num_oops = 0;
367   CellTypeState* cell = vars;
368   for (int entry_index = 0; entry_index < n_entries; entry_index++, mask <<= bits_per_entry, cell++) {
369     // store last word
370     if (mask == 0) {
371       bit_mask()[word_index++] = value;
372       value = 0;
373       mask = 1;
374     }
375 
376     // switch to stack when done with locals
377     if (entry_index == max_locals) {
378       cell = stack;
379     }
380 
381     // set oop bit
382     if ( cell->is_reference()) {
383       value |= (mask << oop_bit_number );
384       _num_oops++;
385     }
386 
387     // set dead bit
388     if (!cell->is_live()) {
389       value |= (mask << dead_bit_number);
390       assert(!cell->is_reference(), "dead value marked as oop");
391     }
392   }
393 
394   // make sure last word is stored
395   bit_mask()[word_index] = value;
396 
397   // verify bit mask
398   assert(verify_mask(vars, stack, max_locals, stack_top), "mask could not be verified");
399 }
400 
401 void OopMapCacheEntry::flush() {
402   deallocate_bit_mask();

270 
271   void generate() {
272     iterate();
273   }
274 };
275 
276 bool OopMapCacheEntry::verify_mask(CellTypeState* vars, CellTypeState* stack, int max_locals, int stack_top) {
277   // Check mask includes map
278   VerifyClosure blk(this);
279   iterate_oop(&blk);
280   if (blk.failed()) return false;
281 
282   // Check if map is generated correctly
283   // (Use ?: operator to make sure all 'true' & 'false' are represented exactly the same so we can use == afterwards)
284   const bool log = log_is_enabled(Trace, interpreter, oopmap);
285   LogStream st(Log(interpreter, oopmap)::trace());
286 
287   if (log) st.print("Locals (%d): ", max_locals);
288   for(int i = 0; i < max_locals; i++) {
289     bool v1 = is_oop(i)               ? true : false;
290     bool v2 = vars[i].is_reference();
291     assert(v1 == v2, "locals oop mask generation error");
292     if (log) st.print("%d", v1 ? 1 : 0);
293   }
294   if (log) st.cr();
295 
296   if (log) st.print("Stack (%d): ", stack_top);
297   for(int j = 0; j < stack_top; j++) {
298     bool v1 = is_oop(max_locals + j)  ? true : false;
299     bool v2 = stack[j].is_reference();
300     assert(v1 == v2, "stack oop mask generation error");
301     if (log) st.print("%d", v1 ? 1 : 0);
302   }
303   if (log) st.cr();
304   return true;
305 }
306 
307 void OopMapCacheEntry::allocate_bit_mask() {
308   if (mask_size() > small_mask_limit) {
309     assert(_bit_mask[0] == 0, "bit mask should be new or just flushed");
310     _bit_mask[0] = (intptr_t)
311       NEW_C_HEAP_ARRAY(uintptr_t, mask_word_size(), mtClass);
312   }
313 }
314 
315 void OopMapCacheEntry::deallocate_bit_mask() {
316   if (mask_size() > small_mask_limit && _bit_mask[0] != 0) {
317     assert(!Thread::current()->resource_area()->contains((void*)_bit_mask[0]),
318       "This bit mask should not be in the resource area");
319     FREE_C_HEAP_ARRAY(uintptr_t, _bit_mask[0]);

362   int word_index = 0;
363   uintptr_t value = 0;
364   uintptr_t mask = 1;
365 
366   _num_oops = 0;
367   CellTypeState* cell = vars;
368   for (int entry_index = 0; entry_index < n_entries; entry_index++, mask <<= bits_per_entry, cell++) {
369     // store last word
370     if (mask == 0) {
371       bit_mask()[word_index++] = value;
372       value = 0;
373       mask = 1;
374     }
375 
376     // switch to stack when done with locals
377     if (entry_index == max_locals) {
378       cell = stack;
379     }
380 
381     // set oop bit
382     if (cell->is_reference()) {
383       value |= (mask << oop_bit_number );
384       _num_oops++;
385     }
386 
387     // set dead bit
388     if (!cell->is_live()) {
389       value |= (mask << dead_bit_number);
390       assert(!cell->is_reference(), "dead value marked as oop");
391     }
392   }
393 
394   // make sure last word is stored
395   bit_mask()[word_index] = value;
396 
397   // verify bit mask
398   assert(verify_mask(vars, stack, max_locals, stack_top), "mask could not be verified");
399 }
400 
401 void OopMapCacheEntry::flush() {
402   deallocate_bit_mask();
< prev index next >