hotspot/src/share/vm/classfile/verifier.hpp
author jrose
Mon, 13 Sep 2010 23:24:30 -0700
changeset 6463 f4362c8da849
parent 5882 6b2aecc4f7d8
child 7380 041cf7f1cce6
permissions -rw-r--r--
6939224: MethodHandle.invokeGeneric needs to perform the correct set of conversions Reviewed-by: never
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
5547
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 3820
diff changeset
     2
 * Copyright (c) 1998, 2006, Oracle and/or its affiliates. All rights reserved.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     4
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
489c9b5090e2 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
489c9b5090e2 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     8
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
489c9b5090e2 Initial load
duke
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
489c9b5090e2 Initial load
duke
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
489c9b5090e2 Initial load
duke
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
489c9b5090e2 Initial load
duke
parents:
diff changeset
    13
 * accompanied this code).
489c9b5090e2 Initial load
duke
parents:
diff changeset
    14
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
489c9b5090e2 Initial load
duke
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    18
 *
5547
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 3820
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 3820
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 3820
diff changeset
    21
 * questions.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    22
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    23
 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    24
489c9b5090e2 Initial load
duke
parents:
diff changeset
    25
// The verifier class
489c9b5090e2 Initial load
duke
parents:
diff changeset
    26
class Verifier : AllStatic {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    27
 public:
5882
6b2aecc4f7d8 6939203: JSR 292 needs method handle constants
jrose
parents: 5702
diff changeset
    28
  enum {
6b2aecc4f7d8 6939203: JSR 292 needs method handle constants
jrose
parents: 5702
diff changeset
    29
    STACKMAP_ATTRIBUTE_MAJOR_VERSION    = 50,
6b2aecc4f7d8 6939203: JSR 292 needs method handle constants
jrose
parents: 5702
diff changeset
    30
    INVOKEDYNAMIC_MAJOR_VERSION         = 51
6b2aecc4f7d8 6939203: JSR 292 needs method handle constants
jrose
parents: 5702
diff changeset
    31
  };
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    32
  typedef enum { ThrowException, NoException } Mode;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    33
489c9b5090e2 Initial load
duke
parents:
diff changeset
    34
  /**
489c9b5090e2 Initial load
duke
parents:
diff changeset
    35
   * Verify the bytecodes for a class.  If 'throw_exception' is true
489c9b5090e2 Initial load
duke
parents:
diff changeset
    36
   * then the appropriate VerifyError or ClassFormatError will be thrown.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    37
   * Otherwise, no exception is thrown and the return indicates the
489c9b5090e2 Initial load
duke
parents:
diff changeset
    38
   * error.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
   */
3820
0a8fbbe180db 6830542: Performance: JVM_DefineClass already verified.
acorn
parents: 1
diff changeset
    40
  static bool verify(instanceKlassHandle klass, Mode mode, bool should_verify_class, TRAPS);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
3820
0a8fbbe180db 6830542: Performance: JVM_DefineClass already verified.
acorn
parents: 1
diff changeset
    42
  // Return false if the class is loaded by the bootstrap loader,
0a8fbbe180db 6830542: Performance: JVM_DefineClass already verified.
acorn
parents: 1
diff changeset
    43
  // or if defineClass was called requesting skipping verification
0a8fbbe180db 6830542: Performance: JVM_DefineClass already verified.
acorn
parents: 1
diff changeset
    44
  // -Xverify:all/none override this value
0a8fbbe180db 6830542: Performance: JVM_DefineClass already verified.
acorn
parents: 1
diff changeset
    45
  static bool should_verify_for(oop class_loader, bool should_verify_class);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
  // Relax certain verifier checks to enable some broken 1.1 apps to run on 1.2.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
  static bool relax_verify_for(oop class_loader);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
 private:
3820
0a8fbbe180db 6830542: Performance: JVM_DefineClass already verified.
acorn
parents: 1
diff changeset
    51
  static bool is_eligible_for_verification(instanceKlassHandle klass, bool should_verify_class);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
  static symbolHandle inference_verify(
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
    instanceKlassHandle klass, char* msg, size_t msg_len, TRAPS);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
class RawBytecodeStream;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
class StackMapFrame;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
class StackMapTable;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
// Summary of verifier's memory usage:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
// StackMapTable is stack allocated.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
// StackMapFrame are resource allocated. There is one ResourceMark
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
// for each method.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
// There is one mutable StackMapFrame (current_frame) which is updated
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
// by abstract bytecode interpretation. frame_in_exception_handler() returns
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
// a frame that has a mutable one-item stack (ready for pushing the
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
// catch type exception object). All the other StackMapFrame's
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
// are immutable (including their locals and stack arrays) after
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
// their constructions.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
// locals/stack arrays in StackMapFrame are resource allocated.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
// locals/stack arrays can be shared between StackMapFrame's, except
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
// the mutable StackMapFrame (current_frame).
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
// Care needs to be taken to make sure resource objects don't outlive
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
// the lifetime of their ResourceMark.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
// These macros are used similarly to CHECK macros but also check
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
// the status of the verifier and return if that has an error.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
#define CHECK_VERIFY(verifier) \
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
  CHECK); if ((verifier)->has_error()) return; (0
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
#define CHECK_VERIFY_(verifier, result) \
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
  CHECK_(result)); if ((verifier)->has_error()) return (result); (0
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
// A new instance of this class is created for each class being verified
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
class ClassVerifier : public StackObj {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
  Thread* _thread;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
  symbolHandle _exception_type;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
  char* _message;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
  size_t _message_buffer_len;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
  void verify_method(methodHandle method, TRAPS);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
  char* generate_code_data(methodHandle m, u4 code_length, TRAPS);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
  void verify_exception_handler_table(u4 code_length, char* code_data, int& min, int& max, TRAPS);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
  void verify_local_variable_table(u4 code_length, char* code_data, TRAPS);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
  VerificationType cp_ref_index_to_type(
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
      int index, constantPoolHandle cp, TRAPS) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
    return cp_index_to_type(cp->klass_ref_index_at(index), cp, THREAD);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
  bool is_protected_access(
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
    instanceKlassHandle this_class, klassOop target_class,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
    symbolOop field_name, symbolOop field_sig, bool is_method);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
  void verify_cp_index(constantPoolHandle cp, int index, TRAPS);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
  void verify_cp_type(
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
    int index, constantPoolHandle cp, unsigned int types, TRAPS);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
  void verify_cp_class_type(int index, constantPoolHandle cp, TRAPS);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
  u2 verify_stackmap_table(
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
    u2 stackmap_index, u2 bci, StackMapFrame* current_frame,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
    StackMapTable* stackmap_table, bool no_control_flow, TRAPS);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
  void verify_exception_handler_targets(
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
    u2 bci, bool this_uninit, StackMapFrame* current_frame,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
    StackMapTable* stackmap_table, TRAPS);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
  void verify_ldc(
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
    int opcode, u2 index, StackMapFrame *current_frame,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   120
    constantPoolHandle cp, u2 bci, TRAPS);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   121
489c9b5090e2 Initial load
duke
parents:
diff changeset
   122
  void verify_switch(
489c9b5090e2 Initial load
duke
parents:
diff changeset
   123
    RawBytecodeStream* bcs, u4 code_length, char* code_data,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   124
    StackMapFrame* current_frame, StackMapTable* stackmap_table, TRAPS);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   125
489c9b5090e2 Initial load
duke
parents:
diff changeset
   126
  void verify_field_instructions(
489c9b5090e2 Initial load
duke
parents:
diff changeset
   127
    RawBytecodeStream* bcs, StackMapFrame* current_frame,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   128
    constantPoolHandle cp, TRAPS);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   129
489c9b5090e2 Initial load
duke
parents:
diff changeset
   130
  void verify_invoke_init(
489c9b5090e2 Initial load
duke
parents:
diff changeset
   131
    RawBytecodeStream* bcs, VerificationType ref_class_type,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   132
    StackMapFrame* current_frame, u4 code_length, bool* this_uninit,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   133
    constantPoolHandle cp, TRAPS);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   134
489c9b5090e2 Initial load
duke
parents:
diff changeset
   135
  void verify_invoke_instructions(
489c9b5090e2 Initial load
duke
parents:
diff changeset
   136
    RawBytecodeStream* bcs, u4 code_length, StackMapFrame* current_frame,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   137
    bool* this_uninit, VerificationType return_type,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   138
    constantPoolHandle cp, TRAPS);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   139
489c9b5090e2 Initial load
duke
parents:
diff changeset
   140
  VerificationType get_newarray_type(u2 index, u2 bci, TRAPS);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   141
  void verify_anewarray(
489c9b5090e2 Initial load
duke
parents:
diff changeset
   142
    u2 index, constantPoolHandle cp, StackMapFrame* current_frame, TRAPS);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   143
  void verify_return_value(
489c9b5090e2 Initial load
duke
parents:
diff changeset
   144
    VerificationType return_type, VerificationType type, u2 offset, TRAPS);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   145
489c9b5090e2 Initial load
duke
parents:
diff changeset
   146
  void verify_iload (u2 index, StackMapFrame* current_frame, TRAPS);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   147
  void verify_lload (u2 index, StackMapFrame* current_frame, TRAPS);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   148
  void verify_fload (u2 index, StackMapFrame* current_frame, TRAPS);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   149
  void verify_dload (u2 index, StackMapFrame* current_frame, TRAPS);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   150
  void verify_aload (u2 index, StackMapFrame* current_frame, TRAPS);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   151
  void verify_istore(u2 index, StackMapFrame* current_frame, TRAPS);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   152
  void verify_lstore(u2 index, StackMapFrame* current_frame, TRAPS);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   153
  void verify_fstore(u2 index, StackMapFrame* current_frame, TRAPS);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   154
  void verify_dstore(u2 index, StackMapFrame* current_frame, TRAPS);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   155
  void verify_astore(u2 index, StackMapFrame* current_frame, TRAPS);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   156
  void verify_iinc  (u2 index, StackMapFrame* current_frame, TRAPS);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   157
489c9b5090e2 Initial load
duke
parents:
diff changeset
   158
  bool name_in_supers(symbolOop ref_name, instanceKlassHandle current);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   159
489c9b5090e2 Initial load
duke
parents:
diff changeset
   160
  instanceKlassHandle _klass;  // the class being verified
489c9b5090e2 Initial load
duke
parents:
diff changeset
   161
  methodHandle        _method; // current method being verified
489c9b5090e2 Initial load
duke
parents:
diff changeset
   162
  VerificationType    _this_type; // the verification type of the current class
489c9b5090e2 Initial load
duke
parents:
diff changeset
   163
5693
3015c564fcbc 6956164: nightly regressions from 6939207
jrose
parents: 3820
diff changeset
   164
  // Some recursive calls from the verifier to the name resolver
3015c564fcbc 6956164: nightly regressions from 6939207
jrose
parents: 3820
diff changeset
   165
  // can cause the current class to be re-verified and rewritten.
3015c564fcbc 6956164: nightly regressions from 6939207
jrose
parents: 3820
diff changeset
   166
  // If this happens, the original verification should not continue,
3015c564fcbc 6956164: nightly regressions from 6939207
jrose
parents: 3820
diff changeset
   167
  // because constant pool indexes will have changed.
3015c564fcbc 6956164: nightly regressions from 6939207
jrose
parents: 3820
diff changeset
   168
  // The rewriter is preceded by the verifier.  If the verifier throws
3015c564fcbc 6956164: nightly regressions from 6939207
jrose
parents: 3820
diff changeset
   169
  // an error, rewriting is prevented.  Also, rewriting always precedes
3015c564fcbc 6956164: nightly regressions from 6939207
jrose
parents: 3820
diff changeset
   170
  // bytecode execution or compilation.  Thus, is_rewritten implies
3015c564fcbc 6956164: nightly regressions from 6939207
jrose
parents: 3820
diff changeset
   171
  // that a class has been verified and prepared for execution.
3015c564fcbc 6956164: nightly regressions from 6939207
jrose
parents: 3820
diff changeset
   172
  bool was_recursively_verified() { return _klass->is_rewritten(); }
3015c564fcbc 6956164: nightly regressions from 6939207
jrose
parents: 3820
diff changeset
   173
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   174
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   175
  enum {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   176
    BYTECODE_OFFSET = 1,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   177
    NEW_OFFSET = 2
489c9b5090e2 Initial load
duke
parents:
diff changeset
   178
  };
489c9b5090e2 Initial load
duke
parents:
diff changeset
   179
489c9b5090e2 Initial load
duke
parents:
diff changeset
   180
  // constructor
489c9b5090e2 Initial load
duke
parents:
diff changeset
   181
  ClassVerifier(instanceKlassHandle klass, char* msg, size_t msg_len, TRAPS);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   182
489c9b5090e2 Initial load
duke
parents:
diff changeset
   183
  // destructor
489c9b5090e2 Initial load
duke
parents:
diff changeset
   184
  ~ClassVerifier();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   185
489c9b5090e2 Initial load
duke
parents:
diff changeset
   186
  Thread* thread()             { return _thread; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   187
  methodHandle method()        { return _method; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   188
  instanceKlassHandle current_class() const { return _klass; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   189
  VerificationType current_type() const { return _this_type; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   190
489c9b5090e2 Initial load
duke
parents:
diff changeset
   191
  // Verifies the class.  If a verify or class file format error occurs,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   192
  // the '_exception_name' symbols will set to the exception name and
489c9b5090e2 Initial load
duke
parents:
diff changeset
   193
  // the message_buffer will be filled in with the exception message.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   194
  void verify_class(TRAPS);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   195
489c9b5090e2 Initial load
duke
parents:
diff changeset
   196
  // Return status modes
489c9b5090e2 Initial load
duke
parents:
diff changeset
   197
  symbolHandle result() const { return _exception_type; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   198
  bool has_error() const { return !(result().is_null()); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   199
489c9b5090e2 Initial load
duke
parents:
diff changeset
   200
  // Called when verify or class format errors are encountered.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   201
  // May throw an exception based upon the mode.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   202
  void verify_error(u2 offset, const char* fmt, ...);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   203
  void verify_error(const char* fmt, ...);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   204
  void class_format_error(const char* fmt, ...);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   205
  void format_error_message(const char* fmt, int offset, va_list args);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   206
489c9b5090e2 Initial load
duke
parents:
diff changeset
   207
  klassOop load_class(symbolHandle name, TRAPS);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   208
489c9b5090e2 Initial load
duke
parents:
diff changeset
   209
  int change_sig_to_verificationType(
489c9b5090e2 Initial load
duke
parents:
diff changeset
   210
    SignatureStream* sig_type, VerificationType* inference_type, TRAPS);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   211
489c9b5090e2 Initial load
duke
parents:
diff changeset
   212
  VerificationType cp_index_to_type(int index, constantPoolHandle cp, TRAPS) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   213
    return VerificationType::reference_type(
489c9b5090e2 Initial load
duke
parents:
diff changeset
   214
      symbolHandle(THREAD, cp->klass_name_at(index)));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   215
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   216
489c9b5090e2 Initial load
duke
parents:
diff changeset
   217
  static bool _verify_verbose;  // for debugging
489c9b5090e2 Initial load
duke
parents:
diff changeset
   218
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   219
489c9b5090e2 Initial load
duke
parents:
diff changeset
   220
inline int ClassVerifier::change_sig_to_verificationType(
489c9b5090e2 Initial load
duke
parents:
diff changeset
   221
    SignatureStream* sig_type, VerificationType* inference_type, TRAPS) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   222
  BasicType bt = sig_type->type();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   223
  switch (bt) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   224
    case T_OBJECT:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   225
    case T_ARRAY:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   226
      {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   227
        symbolOop name = sig_type->as_symbol(CHECK_0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   228
        *inference_type =
489c9b5090e2 Initial load
duke
parents:
diff changeset
   229
          VerificationType::reference_type(symbolHandle(THREAD, name));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   230
        return 1;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   231
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   232
    case T_LONG:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   233
      *inference_type = VerificationType::long_type();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   234
      *++inference_type = VerificationType::long2_type();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   235
      return 2;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   236
    case T_DOUBLE:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   237
      *inference_type = VerificationType::double_type();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   238
      *++inference_type = VerificationType::double2_type();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   239
      return 2;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   240
    case T_INT:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   241
    case T_BOOLEAN:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   242
    case T_BYTE:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   243
    case T_CHAR:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   244
    case T_SHORT:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   245
      *inference_type = VerificationType::integer_type();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   246
      return 1;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   247
    case T_FLOAT:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   248
      *inference_type = VerificationType::float_type();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   249
      return 1;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   250
    default:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   251
      ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   252
      return 1;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   253
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   254
}