< prev index next >

src/hotspot/share/asm/assembler.cpp

Print this page




 296 void AbstractAssembler::update_delayed_values() {
 297   DelayedConstant::update_all();
 298 }
 299 
 300 void AbstractAssembler::block_comment(const char* comment) {
 301   if (sect() == CodeBuffer::SECT_INSTS) {
 302     code_section()->outer()->block_comment(offset(), comment);
 303   }
 304 }
 305 
 306 const char* AbstractAssembler::code_string(const char* str) {
 307   if (sect() == CodeBuffer::SECT_INSTS || sect() == CodeBuffer::SECT_STUBS) {
 308     return code_section()->outer()->code_string(str);
 309   }
 310   return NULL;
 311 }
 312 
 313 bool MacroAssembler::uses_implicit_null_check(void* address) {
 314   // Exception handler checks the nmethod's implicit null checks table
 315   // only when this method returns false.
 316   uintptr_t addr = reinterpret_cast<uintptr_t>(address);
 317   uintptr_t page_size = (uintptr_t)os::vm_page_size();

 318 #ifdef _LP64
 319   if (UseCompressedOops && CompressedOops::base() != NULL) {
 320     // A SEGV can legitimately happen in C2 code at address
 321     // (heap_base + offset) if  Matcher::narrow_oop_use_complex_address
 322     // is configured to allow narrow oops field loads to be implicitly
 323     // null checked
 324     uintptr_t start = (uintptr_t)CompressedOops::base();
 325     uintptr_t end = start + page_size;
 326     if (addr >= start && addr < end) {
 327       return true;
 328     }
 329   }
 330 #endif
 331   return addr < page_size;


 332 }
 333 
 334 bool MacroAssembler::needs_explicit_null_check(intptr_t offset) {
 335   // The offset -1 is used (hardcoded) in a number of places in C1 and MacroAssembler
 336   // to indicate an unknown offset. For example, TemplateTable::pop_and_check_object(Register r)
 337   // calls MacroAssembler::null_check(Register reg, int offset = -1) which gets here
 338   // with -1. Another example is GraphBuilder::access_field(...) which uses -1 as placeholder
 339   // for offsets to be patched in later. The -1 there means the offset is not yet known
 340   // and may lie outside of the zero-trapping page, and thus we need to ensure we're forcing
 341   // an explicit null check for -1.



 342 
 343   // Check if offset is outside of [0, os::vm_page_size()]
 344   return offset < 0 || offset >= os::vm_page_size();

 345 }


 296 void AbstractAssembler::update_delayed_values() {
 297   DelayedConstant::update_all();
 298 }
 299 
 300 void AbstractAssembler::block_comment(const char* comment) {
 301   if (sect() == CodeBuffer::SECT_INSTS) {
 302     code_section()->outer()->block_comment(offset(), comment);
 303   }
 304 }
 305 
 306 const char* AbstractAssembler::code_string(const char* str) {
 307   if (sect() == CodeBuffer::SECT_INSTS || sect() == CodeBuffer::SECT_STUBS) {
 308     return code_section()->outer()->code_string(str);
 309   }
 310   return NULL;
 311 }
 312 
 313 bool MacroAssembler::uses_implicit_null_check(void* address) {
 314   // Exception handler checks the nmethod's implicit null checks table
 315   // only when this method returns false.
 316   intptr_t int_address = reinterpret_cast<intptr_t>(address);
 317   intptr_t cell_header_size = Universe::heap()->cell_header_size();
 318   size_t region_size = os::vm_page_size() + cell_header_size;
 319 #ifdef _LP64
 320   if (UseCompressedOops && CompressedOops::base() != NULL) {
 321     // A SEGV can legitimately happen in C2 code at address
 322     // (heap_base + offset) if  Matcher::narrow_oop_use_complex_address
 323     // is configured to allow narrow oops field loads to be implicitly
 324     // null checked
 325     intptr_t start = ((intptr_t)CompressedOops::base()) - cell_header_size;
 326     intptr_t end = start + region_size;
 327     if (int_address >= start && int_address < end) {
 328       return true;
 329     }
 330   }
 331 #endif
 332   intptr_t start = -cell_header_size;
 333   intptr_t end = start + region_size;
 334   return int_address >= start && int_address < end;
 335 }
 336 
 337 bool MacroAssembler::needs_explicit_null_check(intptr_t offset) {
 338   // The offset -1 is used (hardcoded) in a number of places in C1 and MacroAssembler
 339   // to indicate an unknown offset. For example, TemplateTable::pop_and_check_object(Register r)
 340   // calls MacroAssembler::null_check(Register reg, int offset = -1) which gets here
 341   // with -1. Another example is GraphBuilder::access_field(...) which uses -1 as placeholder
 342   // for offsets to be patched in later. The -1 there means the offset is not yet known
 343   // and may lie outside of the zero-trapping page, and thus we need to ensure we're forcing
 344   // an explicit null check for -1, even if it may otherwise be in the range
 345   // [-cell_header_size, os::vm_page_size).
 346   // TODO: Find and replace all relevant uses of -1 with a reasonably named constant.
 347   if (offset == -1) return true;
 348 
 349   // Check if offset is outside of [-cell_header_size, os::vm_page_size)
 350   return offset < -Universe::heap()->cell_header_size() ||
 351          offset >= os::vm_page_size();
 352 }
< prev index next >