hotspot/src/cpu/x86/vm/templateInterpreterGenerator_x86.cpp
changeset 35479 62c12ca7a45e
parent 35214 d86005e0b4c2
child 36301 cb578d8c6cba
equal deleted inserted replaced
35474:8333d76c7fee 35479:62c12ca7a45e
     1 /*
     1 /*
     2  * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     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
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     7  * published by the Free Software Foundation.
    47 #include "utilities/debug.hpp"
    47 #include "utilities/debug.hpp"
    48 #include "utilities/macros.hpp"
    48 #include "utilities/macros.hpp"
    49 
    49 
    50 #define __ _masm->
    50 #define __ _masm->
    51 
    51 
       
    52 // Size of interpreter code.  Increase if too small.  Interpreter will
       
    53 // fail with a guarantee ("not enough space for interpreter generation");
       
    54 // if too small.
       
    55 // Run with +PrintInterpreter to get the VM to print out the size.
       
    56 // Max size with JVMTI
       
    57 #ifdef AMD64
       
    58 int TemplateInterpreter::InterpreterCodeSize = 256 * 1024;
       
    59 #else
       
    60 int TemplateInterpreter::InterpreterCodeSize = 224 * 1024;
       
    61 #endif // AMD64
       
    62 
    52 // Global Register Names
    63 // Global Register Names
    53 static const Register rbcp     = LP64_ONLY(r13) NOT_LP64(rsi);
    64 static const Register rbcp     = LP64_ONLY(r13) NOT_LP64(rsi);
    54 static const Register rlocals  = LP64_ONLY(r14) NOT_LP64(rdi);
    65 static const Register rlocals  = LP64_ONLY(r14) NOT_LP64(rdi);
    55 
    66 
    56 const int method_offset = frame::interpreter_frame_method_offset * wordSize;
    67 const int method_offset = frame::interpreter_frame_method_offset * wordSize;
    57 const int bcp_offset    = frame::interpreter_frame_bcp_offset    * wordSize;
    68 const int bcp_offset    = frame::interpreter_frame_bcp_offset    * wordSize;
    58 const int locals_offset = frame::interpreter_frame_locals_offset * wordSize;
    69 const int locals_offset = frame::interpreter_frame_locals_offset * wordSize;
       
    70 
    59 
    71 
    60 //-----------------------------------------------------------------------------
    72 //-----------------------------------------------------------------------------
    61 
    73 
    62 address TemplateInterpreterGenerator::generate_StackOverflowError_handler() {
    74 address TemplateInterpreterGenerator::generate_StackOverflowError_handler() {
    63   address entry = __ pc();
    75   address entry = __ pc();
   776   // If G1 is not enabled then attempt to go through the accessor entry point
   788   // If G1 is not enabled then attempt to go through the accessor entry point
   777   // Reference.get is an accessor
   789   // Reference.get is an accessor
   778   return NULL;
   790   return NULL;
   779 }
   791 }
   780 
   792 
       
   793 // TODO: rather than touching all pages, check against stack_overflow_limit and bang yellow page to
       
   794 // generate exception.  Windows might need this to map the shadow pages though.
       
   795 void TemplateInterpreterGenerator::bang_stack_shadow_pages(bool native_call) {
       
   796   // Quick & dirty stack overflow checking: bang the stack & handle trap.
       
   797   // Note that we do the banging after the frame is setup, since the exception
       
   798   // handling code expects to find a valid interpreter frame on the stack.
       
   799   // Doing the banging earlier fails if the caller frame is not an interpreter
       
   800   // frame.
       
   801   // (Also, the exception throwing code expects to unlock any synchronized
       
   802   // method receiever, so do the banging after locking the receiver.)
       
   803 
       
   804   // Bang each page in the shadow zone. We can't assume it's been done for
       
   805   // an interpreter frame with greater than a page of locals, so each page
       
   806   // needs to be checked.  Only true for non-native.
       
   807   if (UseStackBanging) {
       
   808     const int page_size = os::vm_page_size();
       
   809     const int n_shadow_pages = ((int)JavaThread::stack_shadow_zone_size()) / page_size;
       
   810     const int start_page = native_call ? n_shadow_pages : 1;
       
   811     for (int pages = start_page; pages <= n_shadow_pages; pages++) {
       
   812       __ bang_stack_with_offset(pages*page_size);
       
   813     }
       
   814   }
       
   815 }
       
   816 
   781 // Interpreter stub for calling a native method. (asm interpreter)
   817 // Interpreter stub for calling a native method. (asm interpreter)
   782 // This sets up a somewhat different looking stack for calling the
   818 // This sets up a somewhat different looking stack for calling the
   783 // native method than the typical interpreter frame setup.
   819 // native method than the typical interpreter frame setup.
   784 address TemplateInterpreterGenerator::generate_native_entry(bool synchronized) {
   820 address TemplateInterpreterGenerator::generate_native_entry(bool synchronized) {
   785   // determine code generation flags
   821   // determine code generation flags
  1298   if (inc_counter) {
  1334   if (inc_counter) {
  1299     // Handle overflow of counter and compile method
  1335     // Handle overflow of counter and compile method
  1300     __ bind(invocation_counter_overflow);
  1336     __ bind(invocation_counter_overflow);
  1301     generate_counter_overflow(continue_after_compile);
  1337     generate_counter_overflow(continue_after_compile);
  1302   }
  1338   }
       
  1339 
       
  1340   return entry_point;
       
  1341 }
       
  1342 
       
  1343 // Abstract method entry
       
  1344 // Attempt to execute abstract method. Throw exception
       
  1345 address TemplateInterpreterGenerator::generate_abstract_entry(void) {
       
  1346 
       
  1347   address entry_point = __ pc();
       
  1348 
       
  1349   // abstract method entry
       
  1350 
       
  1351   //  pop return address, reset last_sp to NULL
       
  1352   __ empty_expression_stack();
       
  1353   __ restore_bcp();      // rsi must be correct for exception handler   (was destroyed)
       
  1354   __ restore_locals();   // make sure locals pointer is correct as well (was destroyed)
       
  1355 
       
  1356   // throw exception
       
  1357   __ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::throw_AbstractMethodError));
       
  1358   // the call_VM checks for exception, so we should never return here.
       
  1359   __ should_not_reach_here();
  1303 
  1360 
  1304   return entry_point;
  1361   return entry_point;
  1305 }
  1362 }
  1306 
  1363 
  1307 //
  1364 //