< prev index next >

src/share/vm/asm/assembler.cpp

Print this page




   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "asm/macroAssembler.hpp"
  27 #include "asm/macroAssembler.inline.hpp"
  28 #include "asm/codeBuffer.hpp"

  29 #include "runtime/atomic.inline.hpp"
  30 #include "runtime/icache.hpp"
  31 #include "runtime/os.hpp"
  32 
  33 
  34 // Implementation of AbstractAssembler
  35 //
  36 // The AbstractAssembler is generating code into a CodeBuffer. To make code generation faster,
  37 // the assembler keeps a copy of the code buffers boundaries & modifies them when
  38 // emitting bytes rather than using the code buffers accessor functions all the time.
  39 // The code buffer is updated via set_code_end(...) after emitting a whole instruction.
  40 
  41 AbstractAssembler::AbstractAssembler(CodeBuffer* code) {
  42   if (code == NULL)  return;
  43   CodeSection* cs = code->insts();
  44   cs->clear_mark();   // new assembler kills old mark
  45   if (cs->start() == NULL)  {
  46     vm_exit_out_of_memory(0, OOM_MMAP_ERROR, err_msg("CodeCache: no room for %s",
  47                                      code->name()));
  48   }


 295   }
 296   return NULL;
 297 }
 298 
 299 bool MacroAssembler::needs_explicit_null_check(intptr_t offset) {
 300   // Exception handler checks the nmethod's implicit null checks table
 301   // only when this method returns false.
 302 #ifdef _LP64
 303   if (UseCompressedOops && Universe::narrow_oop_base() != NULL) {
 304     assert (Universe::heap() != NULL, "java heap should be initialized");
 305     // The first page after heap_base is unmapped and
 306     // the 'offset' is equal to [heap_base + offset] for
 307     // narrow oop implicit null checks.
 308     uintptr_t base = (uintptr_t)Universe::narrow_oop_base();
 309     if ((uintptr_t)offset >= base) {
 310       // Normalize offset for the next check.
 311       offset = (intptr_t)(pointer_delta((void*)offset, (void*)base, 1));
 312     }
 313   }
 314 #endif
 315   return offset < 0 || os::vm_page_size() <= offset;
 316 }


   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "asm/macroAssembler.hpp"
  27 #include "asm/macroAssembler.inline.hpp"
  28 #include "asm/codeBuffer.hpp"
  29 #include "gc/shenandoah/brooksPointer.hpp"
  30 #include "runtime/atomic.inline.hpp"
  31 #include "runtime/icache.hpp"
  32 #include "runtime/os.hpp"
  33 
  34 
  35 // Implementation of AbstractAssembler
  36 //
  37 // The AbstractAssembler is generating code into a CodeBuffer. To make code generation faster,
  38 // the assembler keeps a copy of the code buffers boundaries & modifies them when
  39 // emitting bytes rather than using the code buffers accessor functions all the time.
  40 // The code buffer is updated via set_code_end(...) after emitting a whole instruction.
  41 
  42 AbstractAssembler::AbstractAssembler(CodeBuffer* code) {
  43   if (code == NULL)  return;
  44   CodeSection* cs = code->insts();
  45   cs->clear_mark();   // new assembler kills old mark
  46   if (cs->start() == NULL)  {
  47     vm_exit_out_of_memory(0, OOM_MMAP_ERROR, err_msg("CodeCache: no room for %s",
  48                                      code->name()));
  49   }


 296   }
 297   return NULL;
 298 }
 299 
 300 bool MacroAssembler::needs_explicit_null_check(intptr_t offset) {
 301   // Exception handler checks the nmethod's implicit null checks table
 302   // only when this method returns false.
 303 #ifdef _LP64
 304   if (UseCompressedOops && Universe::narrow_oop_base() != NULL) {
 305     assert (Universe::heap() != NULL, "java heap should be initialized");
 306     // The first page after heap_base is unmapped and
 307     // the 'offset' is equal to [heap_base + offset] for
 308     // narrow oop implicit null checks.
 309     uintptr_t base = (uintptr_t)Universe::narrow_oop_base();
 310     if ((uintptr_t)offset >= base) {
 311       // Normalize offset for the next check.
 312       offset = (intptr_t)(pointer_delta((void*)offset, (void*)base, 1));
 313     }
 314   }
 315 #endif
 316   return (offset < 0 && ((!UseShenandoahGC) || offset != BrooksPointer::BYTE_OFFSET)) || os::vm_page_size() <= offset;
 317 }
< prev index next >