< prev index next >

src/share/vm/oops/generateOopMap.cpp

Print this page


   1 /*
   2  * Copyright (c) 1997, 2013, 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  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "interpreter/bytecodeStream.hpp"
  27 #include "oops/generateOopMap.hpp"
  28 #include "oops/oop.inline.hpp"
  29 #include "oops/symbol.hpp"
  30 #include "runtime/handles.inline.hpp"
  31 #include "runtime/java.hpp"

  32 #include "runtime/relocator.hpp"
  33 #include "utilities/bitMap.inline.hpp"
  34 #include "prims/methodHandles.hpp"
  35 
  36 //
  37 //
  38 // Compute stack layouts for each instruction in method.
  39 //
  40 //  Problems:
  41 //  - What to do about jsr with different types of local vars?
  42 //  Need maps that are conditional on jsr path?
  43 //  - Jsr and exceptions should be done more efficiently (the retAddr stuff)
  44 //
  45 //  Alternative:
  46 //  - Could extend verifier to provide this information.
  47 //    For: one fewer abstract interpreter to maintain. Against: the verifier
  48 //    solves a bigger problem so slower (undesirable to force verification of
  49 //    everything?).
  50 //
  51 //  Algorithm:


2116   // Step 4:Return results
2117   if (!_got_error && report_results())
2118      report_result();
2119 
2120   if (_got_error) {
2121     THROW_HANDLE(_exception);
2122   }
2123 }
2124 
2125 // Error handling methods
2126 // These methods create an exception for the current thread which is thrown
2127 // at the bottom of the call stack, when it returns to compute_map().  The
2128 // _got_error flag controls execution.  NOT TODO: The VM exception propagation
2129 // mechanism using TRAPS/CHECKs could be used here instead but it would need
2130 // to be added as a parameter to every function and checked for every call.
2131 // The tons of extra code it would generate didn't seem worth the change.
2132 //
2133 void GenerateOopMap::error_work(const char *format, va_list ap) {
2134   _got_error = true;
2135   char msg_buffer[512];
2136   vsnprintf(msg_buffer, sizeof(msg_buffer), format, ap);
2137   // Append method name
2138   char msg_buffer2[512];
2139   jio_snprintf(msg_buffer2, sizeof(msg_buffer2), "%s in method %s", msg_buffer, method()->name()->as_C_string());
2140   _exception = Exceptions::new_exception(Thread::current(),
2141                 vmSymbols::java_lang_LinkageError(), msg_buffer2);
2142 }
2143 
2144 void GenerateOopMap::report_error(const char *format, ...) {
2145   va_list ap;
2146   va_start(ap, format);
2147   error_work(format, ap);
2148 }
2149 
2150 void GenerateOopMap::verify_error(const char *format, ...) {
2151   // We do not distinguish between different types of errors for verification
2152   // errors.  Let the verifier give a better message.
2153   const char *msg = "Illegal class file encountered. Try running with -Xverify:all";
2154   _got_error = true;
2155   // Append method name
2156   char msg_buffer2[512];
2157   jio_snprintf(msg_buffer2, sizeof(msg_buffer2), "%s in method %s", msg,
2158                method()->name()->as_C_string());
2159   _exception = Exceptions::new_exception(Thread::current(),
2160                 vmSymbols::java_lang_LinkageError(), msg_buffer2);
2161 }
2162 
2163 //
2164 // Report result opcodes
2165 //
2166 void GenerateOopMap::report_result() {
2167 
2168   if (TraceNewOopMapGeneration) tty->print_cr("Report result pass");
2169 
2170   // We now want to report the result of the parse
2171   _report_result = true;
2172 
2173   // Prolog code
2174   fill_stackmap_prolog(_gc_points);
2175 
2176    // Mark everything changed, then do one interpretation pass.
2177   for (int i = 0; i<_bb_count; i++) {


   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  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "interpreter/bytecodeStream.hpp"
  27 #include "oops/generateOopMap.hpp"
  28 #include "oops/oop.inline.hpp"
  29 #include "oops/symbol.hpp"
  30 #include "runtime/handles.inline.hpp"
  31 #include "runtime/java.hpp"
  32 #include "runtime/os.hpp"
  33 #include "runtime/relocator.hpp"
  34 #include "utilities/bitMap.inline.hpp"
  35 #include "prims/methodHandles.hpp"
  36 
  37 //
  38 //
  39 // Compute stack layouts for each instruction in method.
  40 //
  41 //  Problems:
  42 //  - What to do about jsr with different types of local vars?
  43 //  Need maps that are conditional on jsr path?
  44 //  - Jsr and exceptions should be done more efficiently (the retAddr stuff)
  45 //
  46 //  Alternative:
  47 //  - Could extend verifier to provide this information.
  48 //    For: one fewer abstract interpreter to maintain. Against: the verifier
  49 //    solves a bigger problem so slower (undesirable to force verification of
  50 //    everything?).
  51 //
  52 //  Algorithm:


2117   // Step 4:Return results
2118   if (!_got_error && report_results())
2119      report_result();
2120 
2121   if (_got_error) {
2122     THROW_HANDLE(_exception);
2123   }
2124 }
2125 
2126 // Error handling methods
2127 // These methods create an exception for the current thread which is thrown
2128 // at the bottom of the call stack, when it returns to compute_map().  The
2129 // _got_error flag controls execution.  NOT TODO: The VM exception propagation
2130 // mechanism using TRAPS/CHECKs could be used here instead but it would need
2131 // to be added as a parameter to every function and checked for every call.
2132 // The tons of extra code it would generate didn't seem worth the change.
2133 //
2134 void GenerateOopMap::error_work(const char *format, va_list ap) {
2135   _got_error = true;
2136   char msg_buffer[512];
2137   os::vsnprintf(msg_buffer, sizeof(msg_buffer), format, ap);
2138   // Append method name
2139   char msg_buffer2[512];
2140   os::snprintf(msg_buffer2, sizeof(msg_buffer2), "%s in method %s", msg_buffer, method()->name()->as_C_string());
2141   _exception = Exceptions::new_exception(Thread::current(),
2142                 vmSymbols::java_lang_LinkageError(), msg_buffer2);
2143 }
2144 
2145 void GenerateOopMap::report_error(const char *format, ...) {
2146   va_list ap;
2147   va_start(ap, format);
2148   error_work(format, ap);
2149 }
2150 
2151 void GenerateOopMap::verify_error(const char *format, ...) {
2152   // We do not distinguish between different types of errors for verification
2153   // errors.  Let the verifier give a better message.
2154   const char *msg = "Illegal class file encountered. Try running with -Xverify:all";
2155   _got_error = true;
2156   // Append method name
2157   char msg_buffer2[512];
2158   os::snprintf(msg_buffer2, sizeof(msg_buffer2), "%s in method %s", msg,
2159                method()->name()->as_C_string());
2160   _exception = Exceptions::new_exception(Thread::current(),
2161                 vmSymbols::java_lang_LinkageError(), msg_buffer2);
2162 }
2163 
2164 //
2165 // Report result opcodes
2166 //
2167 void GenerateOopMap::report_result() {
2168 
2169   if (TraceNewOopMapGeneration) tty->print_cr("Report result pass");
2170 
2171   // We now want to report the result of the parse
2172   _report_result = true;
2173 
2174   // Prolog code
2175   fill_stackmap_prolog(_gc_points);
2176 
2177    // Mark everything changed, then do one interpretation pass.
2178   for (int i = 0; i<_bb_count; i++) {


< prev index next >