< prev index next >

src/hotspot/share/interpreter/oopMapCache.cpp

Print this page

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

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

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

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