src/share/vm/classfile/verifier.hpp
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File bug_8050485_4 Sdiff src/share/vm/classfile

src/share/vm/classfile/verifier.hpp

Print this page




  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 #ifndef SHARE_VM_CLASSFILE_VERIFIER_HPP
  26 #define SHARE_VM_CLASSFILE_VERIFIER_HPP
  27 
  28 #include "classfile/verificationType.hpp"
  29 #include "memory/gcLocker.hpp"
  30 #include "oops/klass.hpp"
  31 #include "oops/method.hpp"
  32 #include "runtime/handles.hpp"

  33 #include "utilities/exceptions.hpp"
  34 
  35 // The verifier class
  36 class Verifier : AllStatic {
  37  public:
  38   enum {
  39     STRICTER_ACCESS_CTRL_CHECK_VERSION  = 49,
  40     STACKMAP_ATTRIBUTE_MAJOR_VERSION    = 50,
  41     INVOKEDYNAMIC_MAJOR_VERSION         = 51,
  42     NO_RELAX_ACCESS_CTRL_CHECK_VERSION  = 52
  43   };
  44   typedef enum { ThrowException, NoException } Mode;
  45 
  46   /**
  47    * Verify the bytecodes for a class.  If 'throw_exception' is true
  48    * then the appropriate VerifyError or ClassFormatError will be thrown.
  49    * Otherwise, no exception is thrown and the return indicates the
  50    * error.
  51    */
  52   static bool verify(instanceKlassHandle klass, Mode mode, bool should_verify_class, TRAPS);


 286     u2 bci, bool this_uninit, StackMapFrame* current_frame,
 287     StackMapTable* stackmap_table, TRAPS);
 288 
 289   void verify_ldc(
 290     int opcode, u2 index, StackMapFrame *current_frame,
 291     constantPoolHandle cp, u2 bci, TRAPS);
 292 
 293   void verify_switch(
 294     RawBytecodeStream* bcs, u4 code_length, char* code_data,
 295     StackMapFrame* current_frame, StackMapTable* stackmap_table, TRAPS);
 296 
 297   void verify_field_instructions(
 298     RawBytecodeStream* bcs, StackMapFrame* current_frame,
 299     constantPoolHandle cp, TRAPS);
 300 
 301   void verify_invoke_init(
 302     RawBytecodeStream* bcs, u2 ref_index, VerificationType ref_class_type,
 303     StackMapFrame* current_frame, u4 code_length, bool* this_uninit,
 304     constantPoolHandle cp, TRAPS);
 305 
































 306   void verify_invoke_instructions(
 307     RawBytecodeStream* bcs, u4 code_length, StackMapFrame* current_frame,
 308     bool* this_uninit, VerificationType return_type,
 309     constantPoolHandle cp, TRAPS);
 310 
 311   VerificationType get_newarray_type(u2 index, u2 bci, TRAPS);
 312   void verify_anewarray(u2 bci, u2 index, constantPoolHandle cp,
 313       StackMapFrame* current_frame, TRAPS);
 314   void verify_return_value(
 315       VerificationType return_type, VerificationType type, u2 offset,
 316       StackMapFrame* current_frame, TRAPS);
 317 
 318   void verify_iload (u2 index, StackMapFrame* current_frame, TRAPS);
 319   void verify_lload (u2 index, StackMapFrame* current_frame, TRAPS);
 320   void verify_fload (u2 index, StackMapFrame* current_frame, TRAPS);
 321   void verify_dload (u2 index, StackMapFrame* current_frame, TRAPS);
 322   void verify_aload (u2 index, StackMapFrame* current_frame, TRAPS);
 323   void verify_istore(u2 index, StackMapFrame* current_frame, TRAPS);
 324   void verify_lstore(u2 index, StackMapFrame* current_frame, TRAPS);
 325   void verify_fstore(u2 index, StackMapFrame* current_frame, TRAPS);




  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 #ifndef SHARE_VM_CLASSFILE_VERIFIER_HPP
  26 #define SHARE_VM_CLASSFILE_VERIFIER_HPP
  27 
  28 #include "classfile/verificationType.hpp"
  29 #include "memory/gcLocker.hpp"
  30 #include "oops/klass.hpp"
  31 #include "oops/method.hpp"
  32 #include "runtime/handles.hpp"
  33 #include "utilities/growableArray.hpp"
  34 #include "utilities/exceptions.hpp"
  35 
  36 // The verifier class
  37 class Verifier : AllStatic {
  38  public:
  39   enum {
  40     STRICTER_ACCESS_CTRL_CHECK_VERSION  = 49,
  41     STACKMAP_ATTRIBUTE_MAJOR_VERSION    = 50,
  42     INVOKEDYNAMIC_MAJOR_VERSION         = 51,
  43     NO_RELAX_ACCESS_CTRL_CHECK_VERSION  = 52
  44   };
  45   typedef enum { ThrowException, NoException } Mode;
  46 
  47   /**
  48    * Verify the bytecodes for a class.  If 'throw_exception' is true
  49    * then the appropriate VerifyError or ClassFormatError will be thrown.
  50    * Otherwise, no exception is thrown and the return indicates the
  51    * error.
  52    */
  53   static bool verify(instanceKlassHandle klass, Mode mode, bool should_verify_class, TRAPS);


 287     u2 bci, bool this_uninit, StackMapFrame* current_frame,
 288     StackMapTable* stackmap_table, TRAPS);
 289 
 290   void verify_ldc(
 291     int opcode, u2 index, StackMapFrame *current_frame,
 292     constantPoolHandle cp, u2 bci, TRAPS);
 293 
 294   void verify_switch(
 295     RawBytecodeStream* bcs, u4 code_length, char* code_data,
 296     StackMapFrame* current_frame, StackMapTable* stackmap_table, TRAPS);
 297 
 298   void verify_field_instructions(
 299     RawBytecodeStream* bcs, StackMapFrame* current_frame,
 300     constantPoolHandle cp, TRAPS);
 301 
 302   void verify_invoke_init(
 303     RawBytecodeStream* bcs, u2 ref_index, VerificationType ref_class_type,
 304     StackMapFrame* current_frame, u4 code_length, bool* this_uninit,
 305     constantPoolHandle cp, TRAPS);
 306 
 307   // Used by ends_in_athrow() to save bytecode intervals.
 308   void push_bci_offsets(GrowableArray<u4> *bci_stack_ptr,
 309     u4 start_offset, u4 end_offset) {
 310     bci_stack_ptr->push(start_offset);
 311     bci_stack_ptr->push(end_offset);
 312   }
 313 
 314   // Used by ends_in_athrow() to retrieve start of saved bytecode interval.
 315   u4 pop_bci_start_offset(GrowableArray<u4> *bci_stack_ptr) {
 316     assert(!bci_stack_ptr->is_empty(), "Stack should not be empty");
 317     assert(bci_stack_ptr->length() % 2 == 1, 
 318            "Stack should have odd number of entries");
 319     return bci_stack_ptr->pop();
 320   }
 321 
 322   // Used by ends_in_athrow() to retrieve end of saved bytecode interval.
 323   u4 pop_bci_end_offset(GrowableArray<u4> *bci_stack_ptr) {
 324     assert(!bci_stack_ptr->is_empty(), "Stack should not be empty");
 325     assert(bci_stack_ptr->length() % 2 == 0,
 326            "Stack should have even number of entries");
 327     return bci_stack_ptr->pop();
 328   }
 329 
 330   // Used by ends_in_athrow() to push all handlers that contain bci onto the
 331   // handler_stack, if the handler is not already on the stack.
 332   void push_handlers(ExceptionTable* exhandlers,
 333                      GrowableArray<u4>* handler_stack,
 334                      u4 bci);
 335 
 336   // Returns true if all paths starting with start_bc_offset end in athrow.
 337   bool ends_in_athrow(u4 start_bc_offset);
 338 
 339   void verify_invoke_instructions(
 340     RawBytecodeStream* bcs, u4 code_length, StackMapFrame* current_frame,
 341     bool* this_uninit, VerificationType return_type,
 342     constantPoolHandle cp, TRAPS);
 343 
 344   VerificationType get_newarray_type(u2 index, u2 bci, TRAPS);
 345   void verify_anewarray(u2 bci, u2 index, constantPoolHandle cp,
 346       StackMapFrame* current_frame, TRAPS);
 347   void verify_return_value(
 348       VerificationType return_type, VerificationType type, u2 offset,
 349       StackMapFrame* current_frame, TRAPS);
 350 
 351   void verify_iload (u2 index, StackMapFrame* current_frame, TRAPS);
 352   void verify_lload (u2 index, StackMapFrame* current_frame, TRAPS);
 353   void verify_fload (u2 index, StackMapFrame* current_frame, TRAPS);
 354   void verify_dload (u2 index, StackMapFrame* current_frame, TRAPS);
 355   void verify_aload (u2 index, StackMapFrame* current_frame, TRAPS);
 356   void verify_istore(u2 index, StackMapFrame* current_frame, TRAPS);
 357   void verify_lstore(u2 index, StackMapFrame* current_frame, TRAPS);
 358   void verify_fstore(u2 index, StackMapFrame* current_frame, TRAPS);


src/share/vm/classfile/verifier.hpp
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File