< prev index next >

src/hotspot/cpu/x86/macroAssembler_x86.hpp

Print this page


   1 /*
   2  * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   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  *


  80 
  81  public:
  82   MacroAssembler(CodeBuffer* code) : Assembler(code) {}
  83 
  84  // These routines should emit JVMTI PopFrame and ForceEarlyReturn handling code.
  85  // The implementation is only non-empty for the InterpreterMacroAssembler,
  86  // as only the interpreter handles PopFrame and ForceEarlyReturn requests.
  87  virtual void check_and_handle_popframe(Register java_thread);
  88  virtual void check_and_handle_earlyret(Register java_thread);
  89 
  90   // Support for NULL-checks
  91   //
  92   // Generates code that causes a NULL OS exception if the content of reg is NULL.
  93   // If the accessed location is M[reg + offset] and the offset is known, provide the
  94   // offset. No explicit code generation is needed if the offset is within a certain
  95   // range (0 <= offset <= page_size).
  96 
  97   void null_check(Register reg, int offset = -1);
  98   static bool needs_explicit_null_check(intptr_t offset);
  99 


 100   void test_field_is_flattenable(Register flags, Register temp_reg, Label& is_flattenable);
 101   void test_field_is_not_flattenable(Register flags, Register temp_reg, Label& notFlattenable);
 102   void test_field_is_flattened(Register flags, Register temp_reg, Label& is_flattened);
 103   void test_value_is_not_buffered(Register value, Register temp_reg, Label& not_buffered);




 104 
 105   // Required platform-specific helpers for Label::patch_instructions.
 106   // They _shadow_ the declarations in AbstractAssembler, which are undefined.
 107   void pd_patch_instruction(address branch, address target) {
 108     unsigned char op = branch[0];
 109     assert(op == 0xE8 /* call */ ||
 110         op == 0xE9 /* jmp */ ||
 111         op == 0xEB /* short jmp */ ||
 112         (op & 0xF0) == 0x70 /* short jcc */ ||
 113         op == 0x0F && (branch[1] & 0xF0) == 0x80 /* jcc */ ||
 114         op == 0xC7 && branch[1] == 0xF8 /* xbegin */,
 115         "Invalid opcode at patch point");
 116 
 117     if (op == 0xEB || (op & 0xF0) == 0x70) {
 118       // short offset operators (jmp and jcc)
 119       char* disp = (char*) &branch[1];
 120       int imm8 = target - (address) &disp[1];
 121       guarantee(this->is8bit(imm8), "Short forward jump exceeds 8-bit offset");
 122       *disp = imm8;
 123     } else {


   1 /*
   2  * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   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  *


  80 
  81  public:
  82   MacroAssembler(CodeBuffer* code) : Assembler(code) {}
  83 
  84  // These routines should emit JVMTI PopFrame and ForceEarlyReturn handling code.
  85  // The implementation is only non-empty for the InterpreterMacroAssembler,
  86  // as only the interpreter handles PopFrame and ForceEarlyReturn requests.
  87  virtual void check_and_handle_popframe(Register java_thread);
  88  virtual void check_and_handle_earlyret(Register java_thread);
  89 
  90   // Support for NULL-checks
  91   //
  92   // Generates code that causes a NULL OS exception if the content of reg is NULL.
  93   // If the accessed location is M[reg + offset] and the offset is known, provide the
  94   // offset. No explicit code generation is needed if the offset is within a certain
  95   // range (0 <= offset <= page_size).
  96 
  97   void null_check(Register reg, int offset = -1);
  98   static bool needs_explicit_null_check(intptr_t offset);
  99 
 100   void test_klass_is_value(Register klass, Register temp_reg, Label& is_value);
 101 
 102   void test_field_is_flattenable(Register flags, Register temp_reg, Label& is_flattenable);
 103   void test_field_is_not_flattenable(Register flags, Register temp_reg, Label& notFlattenable);
 104   void test_field_is_flattened(Register flags, Register temp_reg, Label& is_flattened);
 105   void test_value_is_not_buffered(Register value, Register temp_reg, Label& not_buffered);
 106 
 107   // Check klass/oops is flat value type array (oop->_klass->_layout_helper & vt_bit)
 108   void test_flat_array_klass(Register klass, Register temp_reg, Label& is_flat_array);
 109   void test_flat_array_oop(Register oop, Register temp_reg, Label& is_flat_array);
 110 
 111   // Required platform-specific helpers for Label::patch_instructions.
 112   // They _shadow_ the declarations in AbstractAssembler, which are undefined.
 113   void pd_patch_instruction(address branch, address target) {
 114     unsigned char op = branch[0];
 115     assert(op == 0xE8 /* call */ ||
 116         op == 0xE9 /* jmp */ ||
 117         op == 0xEB /* short jmp */ ||
 118         (op & 0xF0) == 0x70 /* short jcc */ ||
 119         op == 0x0F && (branch[1] & 0xF0) == 0x80 /* jcc */ ||
 120         op == 0xC7 && branch[1] == 0xF8 /* xbegin */,
 121         "Invalid opcode at patch point");
 122 
 123     if (op == 0xEB || (op & 0xF0) == 0x70) {
 124       // short offset operators (jmp and jcc)
 125       char* disp = (char*) &branch[1];
 126       int imm8 = target - (address) &disp[1];
 127       guarantee(this->is8bit(imm8), "Short forward jump exceeds 8-bit offset");
 128       *disp = imm8;
 129     } else {


< prev index next >