hotspot/src/share/vm/code/codeBlob.cpp
changeset 46620 750c6edff33b
parent 46560 388aa8d67c80
child 46625 edefffab74e2
equal deleted inserted replaced
46619:a3919f5e8d2b 46620:750c6edff33b
    58 
    58 
    59 
    59 
    60 // This must be consistent with the CodeBlob constructor's layout actions.
    60 // This must be consistent with the CodeBlob constructor's layout actions.
    61 unsigned int CodeBlob::allocation_size(CodeBuffer* cb, int header_size) {
    61 unsigned int CodeBlob::allocation_size(CodeBuffer* cb, int header_size) {
    62   unsigned int size = header_size;
    62   unsigned int size = header_size;
    63   size += round_to(cb->total_relocation_size(), oopSize);
    63   size += align_up(cb->total_relocation_size(), oopSize);
    64   // align the size to CodeEntryAlignment
    64   // align the size to CodeEntryAlignment
    65   size = align_code_offset(size);
    65   size = align_code_offset(size);
    66   size += round_to(cb->total_content_size(), oopSize);
    66   size += align_up(cb->total_content_size(), oopSize);
    67   size += round_to(cb->total_oop_size(), oopSize);
    67   size += align_up(cb->total_oop_size(), oopSize);
    68   size += round_to(cb->total_metadata_size(), oopSize);
    68   size += align_up(cb->total_metadata_size(), oopSize);
    69   return size;
    69   return size;
    70 }
    70 }
    71 
    71 
    72 CodeBlob::CodeBlob(const char* name, CompilerType type, const CodeBlobLayout& layout, int frame_complete_offset, int frame_size, ImmutableOopMapSet* oop_maps, bool caller_must_gc_arguments) :
    72 CodeBlob::CodeBlob(const char* name, CompilerType type, const CodeBlobLayout& layout, int frame_complete_offset, int frame_size, ImmutableOopMapSet* oop_maps, bool caller_must_gc_arguments) :
    73   _name(name),
    73   _name(name),
    85   _relocation_begin(layout.relocation_begin()),
    85   _relocation_begin(layout.relocation_begin()),
    86   _relocation_end(layout.relocation_end()),
    86   _relocation_end(layout.relocation_end()),
    87   _content_begin(layout.content_begin()),
    87   _content_begin(layout.content_begin()),
    88   _type(type)
    88   _type(type)
    89 {
    89 {
    90   assert(layout.size()        == round_to(layout.size(),        oopSize), "unaligned size");
    90   assert(is_aligned(layout.size(),            oopSize), "unaligned size");
    91   assert(layout.header_size() == round_to(layout.header_size(), oopSize), "unaligned size");
    91   assert(is_aligned(layout.header_size(),     oopSize), "unaligned size");
    92   assert(layout.relocation_size() == round_to(layout.relocation_size(), oopSize), "unaligned size");
    92   assert(is_aligned(layout.relocation_size(), oopSize), "unaligned size");
    93   assert(layout.code_end() == layout.content_end(), "must be the same - see code_end()");
    93   assert(layout.code_end() == layout.content_end(), "must be the same - see code_end()");
    94 #ifdef COMPILER1
    94 #ifdef COMPILER1
    95   // probably wrong for tiered
    95   // probably wrong for tiered
    96   assert(_frame_size >= -1, "must use frame size or -1 for runtime stubs");
    96   assert(_frame_size >= -1, "must use frame size or -1 for runtime stubs");
    97 #endif // COMPILER1
    97 #endif // COMPILER1
   112   _relocation_begin(layout.relocation_begin()),
   112   _relocation_begin(layout.relocation_begin()),
   113   _relocation_end(layout.relocation_end()),
   113   _relocation_end(layout.relocation_end()),
   114   _content_begin(layout.content_begin()),
   114   _content_begin(layout.content_begin()),
   115   _type(type)
   115   _type(type)
   116 {
   116 {
   117   assert(_size        == round_to(_size,        oopSize), "unaligned size");
   117   assert(is_aligned(_size,        oopSize), "unaligned size");
   118   assert(_header_size == round_to(_header_size, oopSize), "unaligned size");
   118   assert(is_aligned(_header_size, oopSize), "unaligned size");
   119   assert(_data_offset <= _size, "codeBlob is too small");
   119   assert(_data_offset <= _size, "codeBlob is too small");
   120   assert(layout.code_end() == layout.content_end(), "must be the same - see code_end()");
   120   assert(layout.code_end() == layout.content_end(), "must be the same - see code_end()");
   121 
   121 
   122   set_oop_maps(oop_maps);
   122   set_oop_maps(oop_maps);
   123 #ifdef COMPILER1
   123 #ifdef COMPILER1
   129 
   129 
   130 // Creates a simple CodeBlob. Sets up the size of the different regions.
   130 // Creates a simple CodeBlob. Sets up the size of the different regions.
   131 RuntimeBlob::RuntimeBlob(const char* name, int header_size, int size, int frame_complete, int locs_size)
   131 RuntimeBlob::RuntimeBlob(const char* name, int header_size, int size, int frame_complete, int locs_size)
   132   : CodeBlob(name, compiler_none, CodeBlobLayout((address) this, size, header_size, locs_size, size), frame_complete, 0, NULL, false /* caller_must_gc_arguments */)
   132   : CodeBlob(name, compiler_none, CodeBlobLayout((address) this, size, header_size, locs_size, size), frame_complete, 0, NULL, false /* caller_must_gc_arguments */)
   133 {
   133 {
   134   assert(locs_size   == round_to(locs_size,   oopSize), "unaligned size");
   134   assert(is_aligned(locs_size, oopSize), "unaligned size");
   135 }
   135 }
   136 
   136 
   137 
   137 
   138 // Creates a RuntimeBlob from a CodeBuffer
   138 // Creates a RuntimeBlob from a CodeBuffer
   139 // and copy code and relocation info.
   139 // and copy code and relocation info.
   219 
   219 
   220   BufferBlob* blob = NULL;
   220   BufferBlob* blob = NULL;
   221   unsigned int size = sizeof(BufferBlob);
   221   unsigned int size = sizeof(BufferBlob);
   222   // align the size to CodeEntryAlignment
   222   // align the size to CodeEntryAlignment
   223   size = CodeBlob::align_code_offset(size);
   223   size = CodeBlob::align_code_offset(size);
   224   size += round_to(buffer_size, oopSize);
   224   size += align_up(buffer_size, oopSize);
   225   assert(name != NULL, "must provide a name");
   225   assert(name != NULL, "must provide a name");
   226   {
   226   {
   227     MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
   227     MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
   228     blob = new (size) BufferBlob(name, size);
   228     blob = new (size) BufferBlob(name, size);
   229   }
   229   }
   302 
   302 
   303   MethodHandlesAdapterBlob* blob = NULL;
   303   MethodHandlesAdapterBlob* blob = NULL;
   304   unsigned int size = sizeof(MethodHandlesAdapterBlob);
   304   unsigned int size = sizeof(MethodHandlesAdapterBlob);
   305   // align the size to CodeEntryAlignment
   305   // align the size to CodeEntryAlignment
   306   size = CodeBlob::align_code_offset(size);
   306   size = CodeBlob::align_code_offset(size);
   307   size += round_to(buffer_size, oopSize);
   307   size += align_up(buffer_size, oopSize);
   308   {
   308   {
   309     MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
   309     MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
   310     blob = new (size) MethodHandlesAdapterBlob(size);
   310     blob = new (size) MethodHandlesAdapterBlob(size);
   311     if (blob == NULL) {
   311     if (blob == NULL) {
   312       vm_exit_out_of_memory(size, OOM_MALLOC_ERROR, "CodeCache: no room for method handle adapter blob");
   312       vm_exit_out_of_memory(size, OOM_MALLOC_ERROR, "CodeCache: no room for method handle adapter blob");