< prev index next >
src/share/vm/classfile/verifier.hpp
Print this page
*** 31,48 ****
#include "oops/method.hpp"
#include "runtime/handles.hpp"
#include "utilities/exceptions.hpp"
#include "utilities/growableArray.hpp"
// The verifier class
class Verifier : AllStatic {
public:
enum {
STRICTER_ACCESS_CTRL_CHECK_VERSION = 49,
STACKMAP_ATTRIBUTE_MAJOR_VERSION = 50,
INVOKEDYNAMIC_MAJOR_VERSION = 51,
! NO_RELAX_ACCESS_CTRL_CHECK_VERSION = 52
};
typedef enum { ThrowException, NoException } Mode;
/**
* Verify the bytecodes for a class. If 'throw_exception' is true
--- 31,54 ----
#include "oops/method.hpp"
#include "runtime/handles.hpp"
#include "utilities/exceptions.hpp"
#include "utilities/growableArray.hpp"
+ // For bit tests involving JVM_CONSTANT_Value during verification,
+ // define a "safe" number to avoid integer overflow of types
+ #define SAFE_JVM_CONSTANT_Value JVM_CONSTANT_ExternalMax
+
// The verifier class
class Verifier : AllStatic {
public:
enum {
STRICTER_ACCESS_CTRL_CHECK_VERSION = 49,
STACKMAP_ATTRIBUTE_MAJOR_VERSION = 50,
INVOKEDYNAMIC_MAJOR_VERSION = 51,
! NO_RELAX_ACCESS_CTRL_CHECK_VERSION = 52,
! VALUETYPE_MAJOR_VERSION = 53,
! VALUETYPE_MINOR_VERSION = 1
};
typedef enum { ThrowException, NoException } Mode;
/**
* Verify the bytecodes for a class. If 'throw_exception' is true
*** 269,289 ****
int& min, int& max, TRAPS);
void verify_local_variable_table(u4 code_length, char* code_data, TRAPS);
VerificationType cp_ref_index_to_type(
int index, const constantPoolHandle& cp, TRAPS) {
! return cp_index_to_type(cp->klass_ref_index_at(index), cp, THREAD);
}
bool is_protected_access(
InstanceKlass* this_class, Klass* target_class,
Symbol* field_name, Symbol* field_sig, bool is_method);
void verify_cp_index(u2 bci, const constantPoolHandle& cp, int index, TRAPS);
void verify_cp_type(u2 bci, int index, const constantPoolHandle& cp,
unsigned int types, TRAPS);
void verify_cp_class_type(u2 bci, int index, const constantPoolHandle& cp, TRAPS);
u2 verify_stackmap_table(
u2 stackmap_index, u2 bci, StackMapFrame* current_frame,
StackMapTable* stackmap_table, bool no_control_flow, TRAPS);
--- 275,302 ----
int& min, int& max, TRAPS);
void verify_local_variable_table(u4 code_length, char* code_data, TRAPS);
VerificationType cp_ref_index_to_type(
int index, const constantPoolHandle& cp, TRAPS) {
! return cp_index_to_reference_type(cp->klass_ref_index_at(index), cp, THREAD);
! }
!
! VerificationType cp_value_index_to_type(
! int index, const constantPoolHandle& cp, TRAPS) {
! return cp_index_to_valuetype(cp->klass_ref_index_at(index), cp, THREAD);
}
bool is_protected_access(
InstanceKlass* this_class, Klass* target_class,
Symbol* field_name, Symbol* field_sig, bool is_method);
void verify_cp_index(u2 bci, const constantPoolHandle& cp, int index, TRAPS);
void verify_cp_type(u2 bci, int index, const constantPoolHandle& cp,
unsigned int types, TRAPS);
void verify_cp_class_type(u2 bci, int index, const constantPoolHandle& cp, TRAPS);
+ void verify_cp_value_type(u2 bci, int index, const constantPoolHandle& cp, TRAPS);
+ void verify_cp_class_or_value_type(u2 bci, int index, const constantPoolHandle& cp, TRAPS);
u2 verify_stackmap_table(
u2 stackmap_index, u2 bci, StackMapFrame* current_frame,
StackMapTable* stackmap_table, bool no_control_flow, TRAPS);
*** 301,310 ****
--- 314,327 ----
void verify_field_instructions(
RawBytecodeStream* bcs, StackMapFrame* current_frame,
const constantPoolHandle& cp, bool allow_arrays, TRAPS);
+ void verify_vwithfield(
+ RawBytecodeStream* bcs, StackMapFrame* current_frame,
+ const constantPoolHandle& cp, TRAPS);
+
void verify_invoke_init(
RawBytecodeStream* bcs, u2 ref_index, VerificationType ref_class_type,
StackMapFrame* current_frame, u4 code_length, bool in_try_block,
bool* this_uninit, const constantPoolHandle& cp, StackMapTable* stackmap_table,
TRAPS);
*** 335,354 ****
--- 352,374 ----
void verify_iload (u2 index, StackMapFrame* current_frame, TRAPS);
void verify_lload (u2 index, StackMapFrame* current_frame, TRAPS);
void verify_fload (u2 index, StackMapFrame* current_frame, TRAPS);
void verify_dload (u2 index, StackMapFrame* current_frame, TRAPS);
void verify_aload (u2 index, StackMapFrame* current_frame, TRAPS);
+ void verify_vload (u2 index, StackMapFrame* current_frame, TRAPS);
void verify_istore(u2 index, StackMapFrame* current_frame, TRAPS);
void verify_lstore(u2 index, StackMapFrame* current_frame, TRAPS);
void verify_fstore(u2 index, StackMapFrame* current_frame, TRAPS);
void verify_dstore(u2 index, StackMapFrame* current_frame, TRAPS);
void verify_astore(u2 index, StackMapFrame* current_frame, TRAPS);
+ void verify_vstore(u2 index, StackMapFrame* current_frame, TRAPS);
void verify_iinc (u2 index, StackMapFrame* current_frame, TRAPS);
bool name_in_supers(Symbol* ref_name, InstanceKlass* current);
VerificationType object_type() const;
+ VerificationType __value_type() const;
InstanceKlass* _klass; // the class being verified
methodHandle _method; // current method being verified
VerificationType _this_type; // the verification type of the current class
*** 405,418 ****
Klass* load_class(Symbol* name, TRAPS);
int change_sig_to_verificationType(
SignatureStream* sig_type, VerificationType* inference_type, TRAPS);
! VerificationType cp_index_to_type(int index, const constantPoolHandle& cp, TRAPS) {
return VerificationType::reference_type(cp->klass_name_at(index));
}
// Keep a list of temporary symbols created during verification because
// their reference counts need to be decremented when the verifier object
// goes out of scope. Since these symbols escape the scope in which they're
// created, we can't use a TempNewSymbol.
Symbol* create_temporary_symbol(const Symbol* s, int begin, int end, TRAPS);
--- 425,442 ----
Klass* load_class(Symbol* name, TRAPS);
int change_sig_to_verificationType(
SignatureStream* sig_type, VerificationType* inference_type, TRAPS);
! VerificationType cp_index_to_reference_type(int index, const constantPoolHandle& cp, TRAPS) {
return VerificationType::reference_type(cp->klass_name_at(index));
}
+ VerificationType cp_index_to_valuetype(int index, const constantPoolHandle& cp, TRAPS) {
+ return VerificationType::valuetype_type(cp->klass_name_at(index));
+ }
+
// Keep a list of temporary symbols created during verification because
// their reference counts need to be decremented when the verifier object
// goes out of scope. Since these symbols escape the scope in which they're
// created, we can't use a TempNewSymbol.
Symbol* create_temporary_symbol(const Symbol* s, int begin, int end, TRAPS);
*** 425,450 ****
_symbols->push(s);
return s;
}
TypeOrigin ref_ctx(const char* str, TRAPS);
};
inline int ClassVerifier::change_sig_to_verificationType(
SignatureStream* sig_type, VerificationType* inference_type, TRAPS) {
BasicType bt = sig_type->type();
switch (bt) {
case T_OBJECT:
case T_ARRAY:
{
Symbol* name = sig_type->as_symbol(CHECK_0);
// Create another symbol to save as signature stream unreferences this symbol.
Symbol* name_copy = create_temporary_symbol(name);
assert(name_copy == name, "symbols don't match");
! *inference_type =
! VerificationType::reference_type(name_copy);
return 1;
}
case T_LONG:
*inference_type = VerificationType::long_type();
*++inference_type = VerificationType::long2_type();
--- 449,476 ----
_symbols->push(s);
return s;
}
TypeOrigin ref_ctx(const char* str, TRAPS);
+ TypeOrigin valuetype_ctx(const char* str, TRAPS);
};
inline int ClassVerifier::change_sig_to_verificationType(
SignatureStream* sig_type, VerificationType* inference_type, TRAPS) {
BasicType bt = sig_type->type();
switch (bt) {
case T_OBJECT:
case T_ARRAY:
+ case T_VALUETYPE:
{
Symbol* name = sig_type->as_symbol(CHECK_0);
// Create another symbol to save as signature stream unreferences this symbol.
Symbol* name_copy = create_temporary_symbol(name);
assert(name_copy == name, "symbols don't match");
! *inference_type = ((bt == T_VALUETYPE) ? VerificationType::valuetype_type(name_copy) :
! VerificationType::reference_type(name_copy));
return 1;
}
case T_LONG:
*inference_type = VerificationType::long_type();
*++inference_type = VerificationType::long2_type();
< prev index next >