hotspot/src/share/vm/interpreter/templateInterpreterGenerator.cpp
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File jdk9-opensource-openjdk Sdiff hotspot/src/share/vm/interpreter

hotspot/src/share/vm/interpreter/templateInterpreterGenerator.cpp

Print this page




   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  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "code/codeCacheExtensions.hpp"
  27 #include "interpreter/interpreter.hpp"
  28 #include "interpreter/interpreterRuntime.hpp"
  29 #include "interpreter/interp_masm.hpp"
  30 #include "interpreter/templateInterpreter.hpp"
  31 #include "interpreter/templateInterpreterGenerator.hpp"
  32 #include "interpreter/templateTable.hpp"
  33 
  34 #ifndef CC_INTERP
  35 
  36 # define __ _masm->
  37 
  38 TemplateInterpreterGenerator::TemplateInterpreterGenerator(StubQueue* _code): AbstractInterpreterGenerator(_code) {
  39   _unimplemented_bytecode    = NULL;
  40   _illegal_bytecode_sequence = NULL;
  41   generate_all();
  42 }
  43 
  44 static const BasicType types[Interpreter::number_of_result_handlers] = {
  45   T_BOOLEAN,
  46   T_CHAR   ,
  47   T_BYTE   ,
  48   T_SHORT  ,
  49   T_INT    ,
  50   T_LONG   ,
  51   T_VOID   ,
  52   T_FLOAT  ,
  53   T_DOUBLE ,
  54   T_OBJECT
  55 };
  56 
  57 void TemplateInterpreterGenerator::generate_all() {
  58   // Loop, in case we need several variants of the interpreter entries
  59   do {
  60     if (!CodeCacheExtensions::skip_code_generation()) {
  61       // bypass code generation when useless
  62       { CodeletMark cm(_masm, "slow signature handler");
  63         AbstractInterpreter::_slow_signature_handler = generate_slow_signature_handler();
  64       }
  65 
  66       { CodeletMark cm(_masm, "error exits");
  67         _unimplemented_bytecode    = generate_error_exit("unimplemented bytecode");
  68         _illegal_bytecode_sequence = generate_error_exit("illegal bytecode sequence - method not verified");
  69       }
  70 
  71 #ifndef PRODUCT
  72       if (TraceBytecodes) {
  73         CodeletMark cm(_masm, "bytecode tracing support");
  74         Interpreter::_trace_code =
  75           EntryPoint(
  76                      generate_trace_code(btos),
  77                      generate_trace_code(ztos),
  78                      generate_trace_code(ctos),
  79                      generate_trace_code(stos),
  80                      generate_trace_code(atos),
  81                      generate_trace_code(itos),


 249       Interpreter::_native_entry_begin = Interpreter::code()->code_end();
 250       method_entry(native)
 251       method_entry(native_synchronized)
 252       Interpreter::_native_entry_end = Interpreter::code()->code_end();
 253 
 254       method_entry(java_util_zip_CRC32_update)
 255       method_entry(java_util_zip_CRC32_updateBytes)
 256       method_entry(java_util_zip_CRC32_updateByteBuffer)
 257       method_entry(java_util_zip_CRC32C_updateBytes)
 258       method_entry(java_util_zip_CRC32C_updateDirectByteBuffer)
 259 
 260       method_entry(java_lang_Float_intBitsToFloat);
 261       method_entry(java_lang_Float_floatToRawIntBits);
 262       method_entry(java_lang_Double_longBitsToDouble);
 263       method_entry(java_lang_Double_doubleToRawLongBits);
 264 
 265 #undef method_entry
 266 
 267       // Bytecodes
 268       set_entry_points_for_all_bytes();
 269     }
 270   } while (CodeCacheExtensions::needs_other_interpreter_variant());
 271 
 272   // installation of code in other places in the runtime
 273   // (ExcutableCodeManager calls not needed to copy the entries)
 274   set_safepoints_for_all_bytes();
 275 }
 276 
 277 //------------------------------------------------------------------------------------------------------------------------
 278 
 279 address TemplateInterpreterGenerator::generate_error_exit(const char* msg) {
 280   address entry = __ pc();
 281   __ stop(msg);
 282   return entry;
 283 }
 284 
 285 
 286 //------------------------------------------------------------------------------------------------------------------------
 287 
 288 void TemplateInterpreterGenerator::set_entry_points_for_all_bytes() {
 289   for (int i = 0; i < DispatchTable::length; i++) {
 290     Bytecodes::Code code = (Bytecodes::Code)i;


 297 }
 298 
 299 
 300 void TemplateInterpreterGenerator::set_safepoints_for_all_bytes() {
 301   for (int i = 0; i < DispatchTable::length; i++) {
 302     Bytecodes::Code code = (Bytecodes::Code)i;
 303     if (Bytecodes::is_defined(code)) Interpreter::_safept_table.set_entry(code, Interpreter::_safept_entry);
 304   }
 305 }
 306 
 307 
 308 void TemplateInterpreterGenerator::set_unimplemented(int i) {
 309   address e = _unimplemented_bytecode;
 310   EntryPoint entry(e, e, e, e, e, e, e, e, e, e);
 311   Interpreter::_normal_table.set_entry(i, entry);
 312   Interpreter::_wentry_point[i] = _unimplemented_bytecode;
 313 }
 314 
 315 
 316 void TemplateInterpreterGenerator::set_entry_points(Bytecodes::Code code) {
 317   if (CodeCacheExtensions::skip_template_interpreter_entries(code)) {
 318     return;
 319   }
 320   CodeletMark cm(_masm, Bytecodes::name(code), code);
 321   // initialize entry points
 322   assert(_unimplemented_bytecode    != NULL, "should have been generated before");
 323   assert(_illegal_bytecode_sequence != NULL, "should have been generated before");
 324   address bep = _illegal_bytecode_sequence;
 325   address zep = _illegal_bytecode_sequence;
 326   address cep = _illegal_bytecode_sequence;
 327   address sep = _illegal_bytecode_sequence;
 328   address aep = _illegal_bytecode_sequence;
 329   address iep = _illegal_bytecode_sequence;
 330   address lep = _illegal_bytecode_sequence;
 331   address fep = _illegal_bytecode_sequence;
 332   address dep = _illegal_bytecode_sequence;
 333   address vep = _unimplemented_bytecode;
 334   address wep = _unimplemented_bytecode;
 335   // code for short & wide version of bytecode
 336   if (Bytecodes::is_defined(code)) {
 337     Template* t = TemplateTable::template_for(code);
 338     assert(t->is_valid(), "just checking");
 339     set_short_entry_points(t, bep, cep, sep, aep, iep, lep, fep, dep, vep);
 340   }
 341   if (Bytecodes::wide_is_defined(code)) {
 342     Template* t = TemplateTable::template_for_wide(code);
 343     assert(t->is_valid(), "just checking");
 344     set_wide_entry_point(t, wep);
 345   }
 346   // set entry points
 347   EntryPoint entry(bep, zep, cep, sep, aep, iep, lep, fep, dep, vep);
 348   Interpreter::_normal_table.set_entry(code, entry);
 349   Interpreter::_wentry_point[code] = wep;
 350   CodeCacheExtensions::completed_template_interpreter_entries(_masm, code);
 351 }
 352 
 353 
 354 void TemplateInterpreterGenerator::set_wide_entry_point(Template* t, address& wep) {
 355   assert(t->is_valid(), "template must exist");
 356   assert(t->tos_in() == vtos, "only vtos tos_in supported for wide instructions");
 357   wep = __ pc(); generate_and_dispatch(t);
 358 }
 359 
 360 
 361 void TemplateInterpreterGenerator::set_short_entry_points(Template* t, address& bep, address& cep, address& sep, address& aep, address& iep, address& lep, address& fep, address& dep, address& vep) {
 362   assert(t->is_valid(), "template must exist");
 363   switch (t->tos_in()) {
 364     case btos:
 365     case ztos:
 366     case ctos:
 367     case stos:
 368       ShouldNotReachHere();  // btos/ctos/stos should use itos.
 369       break;
 370     case atos: vep = __ pc(); __ pop(atos); aep = __ pc(); generate_and_dispatch(t); break;




   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  *
  23  */
  24 
  25 #include "precompiled.hpp"

  26 #include "interpreter/interpreter.hpp"
  27 #include "interpreter/interpreterRuntime.hpp"
  28 #include "interpreter/interp_masm.hpp"
  29 #include "interpreter/templateInterpreter.hpp"
  30 #include "interpreter/templateInterpreterGenerator.hpp"
  31 #include "interpreter/templateTable.hpp"
  32 
  33 #ifndef CC_INTERP
  34 
  35 # define __ _masm->
  36 
  37 TemplateInterpreterGenerator::TemplateInterpreterGenerator(StubQueue* _code): AbstractInterpreterGenerator(_code) {
  38   _unimplemented_bytecode    = NULL;
  39   _illegal_bytecode_sequence = NULL;
  40   generate_all();
  41 }
  42 
  43 static const BasicType types[Interpreter::number_of_result_handlers] = {
  44   T_BOOLEAN,
  45   T_CHAR   ,
  46   T_BYTE   ,
  47   T_SHORT  ,
  48   T_INT    ,
  49   T_LONG   ,
  50   T_VOID   ,
  51   T_FLOAT  ,
  52   T_DOUBLE ,
  53   T_OBJECT
  54 };
  55 
  56 void TemplateInterpreterGenerator::generate_all() {




  57   { CodeletMark cm(_masm, "slow signature handler");
  58     AbstractInterpreter::_slow_signature_handler = generate_slow_signature_handler();
  59   }
  60 
  61   { CodeletMark cm(_masm, "error exits");
  62     _unimplemented_bytecode    = generate_error_exit("unimplemented bytecode");
  63     _illegal_bytecode_sequence = generate_error_exit("illegal bytecode sequence - method not verified");
  64   }
  65 
  66 #ifndef PRODUCT
  67   if (TraceBytecodes) {
  68     CodeletMark cm(_masm, "bytecode tracing support");
  69     Interpreter::_trace_code =
  70       EntryPoint(
  71                  generate_trace_code(btos),
  72                  generate_trace_code(ztos),
  73                  generate_trace_code(ctos),
  74                  generate_trace_code(stos),
  75                  generate_trace_code(atos),
  76                  generate_trace_code(itos),


 244   Interpreter::_native_entry_begin = Interpreter::code()->code_end();
 245   method_entry(native)
 246   method_entry(native_synchronized)
 247   Interpreter::_native_entry_end = Interpreter::code()->code_end();
 248 
 249   method_entry(java_util_zip_CRC32_update)
 250   method_entry(java_util_zip_CRC32_updateBytes)
 251   method_entry(java_util_zip_CRC32_updateByteBuffer)
 252   method_entry(java_util_zip_CRC32C_updateBytes)
 253   method_entry(java_util_zip_CRC32C_updateDirectByteBuffer)
 254 
 255   method_entry(java_lang_Float_intBitsToFloat);
 256   method_entry(java_lang_Float_floatToRawIntBits);
 257   method_entry(java_lang_Double_longBitsToDouble);
 258   method_entry(java_lang_Double_doubleToRawLongBits);
 259 
 260 #undef method_entry
 261 
 262   // Bytecodes
 263   set_entry_points_for_all_bytes();


 264 
 265   // installation of code in other places in the runtime
 266   // (ExcutableCodeManager calls not needed to copy the entries)
 267   set_safepoints_for_all_bytes();
 268 }
 269 
 270 //------------------------------------------------------------------------------------------------------------------------
 271 
 272 address TemplateInterpreterGenerator::generate_error_exit(const char* msg) {
 273   address entry = __ pc();
 274   __ stop(msg);
 275   return entry;
 276 }
 277 
 278 
 279 //------------------------------------------------------------------------------------------------------------------------
 280 
 281 void TemplateInterpreterGenerator::set_entry_points_for_all_bytes() {
 282   for (int i = 0; i < DispatchTable::length; i++) {
 283     Bytecodes::Code code = (Bytecodes::Code)i;


 290 }
 291 
 292 
 293 void TemplateInterpreterGenerator::set_safepoints_for_all_bytes() {
 294   for (int i = 0; i < DispatchTable::length; i++) {
 295     Bytecodes::Code code = (Bytecodes::Code)i;
 296     if (Bytecodes::is_defined(code)) Interpreter::_safept_table.set_entry(code, Interpreter::_safept_entry);
 297   }
 298 }
 299 
 300 
 301 void TemplateInterpreterGenerator::set_unimplemented(int i) {
 302   address e = _unimplemented_bytecode;
 303   EntryPoint entry(e, e, e, e, e, e, e, e, e, e);
 304   Interpreter::_normal_table.set_entry(i, entry);
 305   Interpreter::_wentry_point[i] = _unimplemented_bytecode;
 306 }
 307 
 308 
 309 void TemplateInterpreterGenerator::set_entry_points(Bytecodes::Code code) {



 310   CodeletMark cm(_masm, Bytecodes::name(code), code);
 311   // initialize entry points
 312   assert(_unimplemented_bytecode    != NULL, "should have been generated before");
 313   assert(_illegal_bytecode_sequence != NULL, "should have been generated before");
 314   address bep = _illegal_bytecode_sequence;
 315   address zep = _illegal_bytecode_sequence;
 316   address cep = _illegal_bytecode_sequence;
 317   address sep = _illegal_bytecode_sequence;
 318   address aep = _illegal_bytecode_sequence;
 319   address iep = _illegal_bytecode_sequence;
 320   address lep = _illegal_bytecode_sequence;
 321   address fep = _illegal_bytecode_sequence;
 322   address dep = _illegal_bytecode_sequence;
 323   address vep = _unimplemented_bytecode;
 324   address wep = _unimplemented_bytecode;
 325   // code for short & wide version of bytecode
 326   if (Bytecodes::is_defined(code)) {
 327     Template* t = TemplateTable::template_for(code);
 328     assert(t->is_valid(), "just checking");
 329     set_short_entry_points(t, bep, cep, sep, aep, iep, lep, fep, dep, vep);
 330   }
 331   if (Bytecodes::wide_is_defined(code)) {
 332     Template* t = TemplateTable::template_for_wide(code);
 333     assert(t->is_valid(), "just checking");
 334     set_wide_entry_point(t, wep);
 335   }
 336   // set entry points
 337   EntryPoint entry(bep, zep, cep, sep, aep, iep, lep, fep, dep, vep);
 338   Interpreter::_normal_table.set_entry(code, entry);
 339   Interpreter::_wentry_point[code] = wep;

 340 }
 341 
 342 
 343 void TemplateInterpreterGenerator::set_wide_entry_point(Template* t, address& wep) {
 344   assert(t->is_valid(), "template must exist");
 345   assert(t->tos_in() == vtos, "only vtos tos_in supported for wide instructions");
 346   wep = __ pc(); generate_and_dispatch(t);
 347 }
 348 
 349 
 350 void TemplateInterpreterGenerator::set_short_entry_points(Template* t, address& bep, address& cep, address& sep, address& aep, address& iep, address& lep, address& fep, address& dep, address& vep) {
 351   assert(t->is_valid(), "template must exist");
 352   switch (t->tos_in()) {
 353     case btos:
 354     case ztos:
 355     case ctos:
 356     case stos:
 357       ShouldNotReachHere();  // btos/ctos/stos should use itos.
 358       break;
 359     case atos: vep = __ pc(); __ pop(atos); aep = __ pc(); generate_and_dispatch(t); break;


hotspot/src/share/vm/interpreter/templateInterpreterGenerator.cpp
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File