mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-20 11:04:34 +02:00
Merge
This commit is contained in:
commit
d6a9b93b5a
133 changed files with 1889 additions and 1307 deletions
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 1997, 2009, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -26,92 +26,100 @@
|
|||
// relative to an objects 'this' pointer.
|
||||
|
||||
class ThisRelativeObj VALUE_OBJ_CLASS_SPEC {
|
||||
private:
|
||||
int sign_extend (int x, int size) const { const int s = (BytesPerInt - size)*BitsPerByte; return (x << s) >> s; }
|
||||
|
||||
public:
|
||||
// Address computation
|
||||
address addr_at (int offset) const { return (address)this + offset; }
|
||||
int byte_at (int offset) const { return *(addr_at(offset)); }
|
||||
address aligned_addr_at (int offset) const { return (address)round_to((intptr_t)addr_at(offset), jintSize); }
|
||||
int aligned_offset (int offset) const { return aligned_addr_at(offset) - addr_at(0); }
|
||||
|
||||
// Java unsigned accessors (using Java spec byte ordering)
|
||||
int java_byte_at (int offset) const { return *(jubyte*)addr_at(offset); }
|
||||
int java_hwrd_at (int offset) const { return java_byte_at(offset) << (1 * BitsPerByte) | java_byte_at(offset + 1); }
|
||||
int java_word_at (int offset) const { return java_hwrd_at(offset) << (2 * BitsPerByte) | java_hwrd_at(offset + 2); }
|
||||
|
||||
// Java signed accessors (using Java spec byte ordering)
|
||||
int java_signed_byte_at(int offset) const { return sign_extend(java_byte_at(offset), 1); }
|
||||
int java_signed_hwrd_at(int offset) const { return sign_extend(java_hwrd_at(offset), 2); }
|
||||
int java_signed_word_at(int offset) const { return java_word_at(offset) ; }
|
||||
|
||||
// Fast accessors (using the machine's natural byte ordering)
|
||||
int fast_byte_at (int offset) const { return *(jubyte *)addr_at(offset); }
|
||||
int fast_hwrd_at (int offset) const { return *(jushort*)addr_at(offset); }
|
||||
int fast_word_at (int offset) const { return *(juint *)addr_at(offset); }
|
||||
|
||||
// Fast signed accessors (using the machine's natural byte ordering)
|
||||
int fast_signed_byte_at(int offset) const { return *(jbyte *)addr_at(offset); }
|
||||
int fast_signed_hwrd_at(int offset) const { return *(jshort*)addr_at(offset); }
|
||||
int fast_signed_word_at(int offset) const { return *(jint *)addr_at(offset); }
|
||||
|
||||
// Fast manipulators (using the machine's natural byte ordering)
|
||||
void set_fast_byte_at (int offset, int x) const { *(jbyte *)addr_at(offset) = (jbyte )x; }
|
||||
void set_fast_hwrd_at (int offset, int x) const { *(jshort*)addr_at(offset) = (jshort)x; }
|
||||
void set_fast_word_at (int offset, int x) const { *(jint *)addr_at(offset) = (jint )x; }
|
||||
// Word access:
|
||||
int get_Java_u2_at (int offset) const { return Bytes::get_Java_u2(addr_at(offset)); }
|
||||
int get_Java_u4_at (int offset) const { return Bytes::get_Java_u4(addr_at(offset)); }
|
||||
int get_native_u2_at (int offset) const { return Bytes::get_native_u2(addr_at(offset)); }
|
||||
int get_native_u4_at (int offset) const { return Bytes::get_native_u4(addr_at(offset)); }
|
||||
};
|
||||
|
||||
|
||||
// The base class for different kinds of bytecode abstractions.
|
||||
// Provides the primitive operations to manipulate code relative
|
||||
// to an objects 'this' pointer.
|
||||
// FIXME: Make this a ResourceObj, include the enclosing methodOop, and cache the opcode.
|
||||
|
||||
class Bytecode: public ThisRelativeObj {
|
||||
protected:
|
||||
u_char byte_at(int offset) const { return *addr_at(offset); }
|
||||
bool check_must_rewrite() const;
|
||||
bool check_must_rewrite(Bytecodes::Code bc) const;
|
||||
|
||||
public:
|
||||
// Attributes
|
||||
address bcp() const { return addr_at(0); }
|
||||
address next_bcp() const { return addr_at(0) + Bytecodes::length_at(bcp()); }
|
||||
int instruction_size() const { return Bytecodes::length_at(bcp()); }
|
||||
|
||||
// Warning: Use code() with caution on live bytecode streams. 4926272
|
||||
Bytecodes::Code code() const { return Bytecodes::code_at(addr_at(0)); }
|
||||
Bytecodes::Code java_code() const { return Bytecodes::java_code(code()); }
|
||||
bool must_rewrite() const { return Bytecodes::can_rewrite(code()) && check_must_rewrite(); }
|
||||
bool is_active_breakpoint() const { return Bytecodes::is_active_breakpoint_at(bcp()); }
|
||||
|
||||
int one_byte_index() const { assert_index_size(1); return byte_at(1); }
|
||||
int two_byte_index() const { assert_index_size(2); return (byte_at(1) << 8) + byte_at(2); }
|
||||
|
||||
int offset() const { return (two_byte_index() << 16) >> 16; }
|
||||
address destination() const { return bcp() + offset(); }
|
||||
|
||||
// Attribute modification
|
||||
void set_code(Bytecodes::Code code);
|
||||
bool must_rewrite(Bytecodes::Code code) const { return Bytecodes::can_rewrite(code) && check_must_rewrite(code); }
|
||||
|
||||
// Creation
|
||||
inline friend Bytecode* Bytecode_at(address bcp);
|
||||
|
||||
private:
|
||||
void assert_index_size(int required_size) const {
|
||||
#ifdef ASSERT
|
||||
int isize = instruction_size() - 1;
|
||||
if (isize == 2 && code() == Bytecodes::_iinc)
|
||||
isize = 1;
|
||||
else if (isize <= 2)
|
||||
; // no change
|
||||
else if (code() == Bytecodes::_invokedynamic)
|
||||
isize = 4;
|
||||
else
|
||||
isize = 2;
|
||||
assert(isize = required_size, "wrong index size");
|
||||
#endif
|
||||
// Static functions for parsing bytecodes in place.
|
||||
int get_index_u1(Bytecodes::Code bc) const {
|
||||
assert_same_format_as(bc); assert_index_size(1, bc);
|
||||
return *(jubyte*)addr_at(1);
|
||||
}
|
||||
int get_index_u2(Bytecodes::Code bc, bool is_wide = false) const {
|
||||
assert_same_format_as(bc, is_wide); assert_index_size(2, bc, is_wide);
|
||||
address p = addr_at(is_wide ? 2 : 1);
|
||||
if (can_use_native_byte_order(bc, is_wide))
|
||||
return Bytes::get_native_u2(p);
|
||||
else return Bytes::get_Java_u2(p);
|
||||
}
|
||||
int get_index_u2_cpcache(Bytecodes::Code bc) const {
|
||||
assert_same_format_as(bc); assert_index_size(2, bc); assert_native_index(bc);
|
||||
return Bytes::get_native_u2(addr_at(1)) DEBUG_ONLY(+ constantPoolOopDesc::CPCACHE_INDEX_TAG);
|
||||
}
|
||||
int get_index_u4(Bytecodes::Code bc) const {
|
||||
assert_same_format_as(bc); assert_index_size(4, bc);
|
||||
assert(can_use_native_byte_order(bc), "");
|
||||
return Bytes::get_native_u4(addr_at(1));
|
||||
}
|
||||
bool has_index_u4(Bytecodes::Code bc) const {
|
||||
return bc == Bytecodes::_invokedynamic;
|
||||
}
|
||||
|
||||
int get_offset_s2(Bytecodes::Code bc) const {
|
||||
assert_same_format_as(bc); assert_offset_size(2, bc);
|
||||
return (jshort) Bytes::get_Java_u2(addr_at(1));
|
||||
}
|
||||
int get_offset_s4(Bytecodes::Code bc) const {
|
||||
assert_same_format_as(bc); assert_offset_size(4, bc);
|
||||
return (jint) Bytes::get_Java_u4(addr_at(1));
|
||||
}
|
||||
|
||||
int get_constant_u1(int offset, Bytecodes::Code bc) const {
|
||||
assert_same_format_as(bc); assert_constant_size(1, offset, bc);
|
||||
return *(jbyte*)addr_at(offset);
|
||||
}
|
||||
int get_constant_u2(int offset, Bytecodes::Code bc, bool is_wide = false) const {
|
||||
assert_same_format_as(bc, is_wide); assert_constant_size(2, offset, bc, is_wide);
|
||||
return (jshort) Bytes::get_Java_u2(addr_at(offset));
|
||||
}
|
||||
|
||||
// These are used locally and also from bytecode streams.
|
||||
void assert_same_format_as(Bytecodes::Code testbc, bool is_wide = false) const NOT_DEBUG_RETURN;
|
||||
static void assert_index_size(int required_size, Bytecodes::Code bc, bool is_wide = false) NOT_DEBUG_RETURN;
|
||||
static void assert_offset_size(int required_size, Bytecodes::Code bc, bool is_wide = false) NOT_DEBUG_RETURN;
|
||||
static void assert_constant_size(int required_size, int where, Bytecodes::Code bc, bool is_wide = false) NOT_DEBUG_RETURN;
|
||||
static void assert_native_index(Bytecodes::Code bc, bool is_wide = false) NOT_DEBUG_RETURN;
|
||||
static bool can_use_native_byte_order(Bytecodes::Code bc, bool is_wide = false) {
|
||||
return (!Bytes::is_Java_byte_ordering_different() || Bytecodes::native_byte_order(bc /*, is_wide*/));
|
||||
}
|
||||
};
|
||||
|
||||
inline Bytecode* Bytecode_at(address bcp) {
|
||||
// Warning: Use with caution on live bytecode streams. 4926272
|
||||
return (Bytecode*)bcp;
|
||||
}
|
||||
|
||||
|
@ -124,8 +132,8 @@ class LookupswitchPair: ThisRelativeObj {
|
|||
int _offset;
|
||||
|
||||
public:
|
||||
int match() const { return java_signed_word_at(0 * jintSize); }
|
||||
int offset() const { return java_signed_word_at(1 * jintSize); }
|
||||
int match() const { return get_Java_u4_at(0 * jintSize); }
|
||||
int offset() const { return get_Java_u4_at(1 * jintSize); }
|
||||
};
|
||||
|
||||
|
||||
|
@ -134,8 +142,8 @@ class Bytecode_lookupswitch: public Bytecode {
|
|||
void verify() const PRODUCT_RETURN;
|
||||
|
||||
// Attributes
|
||||
int default_offset() const { return java_signed_word_at(aligned_offset(1 + 0*jintSize)); }
|
||||
int number_of_pairs() const { return java_signed_word_at(aligned_offset(1 + 1*jintSize)); }
|
||||
int default_offset() const { return get_Java_u4_at(aligned_offset(1 + 0*jintSize)); }
|
||||
int number_of_pairs() const { return get_Java_u4_at(aligned_offset(1 + 1*jintSize)); }
|
||||
LookupswitchPair* pair_at(int i) const { assert(0 <= i && i < number_of_pairs(), "pair index out of bounds");
|
||||
return (LookupswitchPair*)aligned_addr_at(1 + (1 + i)*2*jintSize); }
|
||||
// Creation
|
||||
|
@ -154,9 +162,9 @@ class Bytecode_tableswitch: public Bytecode {
|
|||
void verify() const PRODUCT_RETURN;
|
||||
|
||||
// Attributes
|
||||
int default_offset() const { return java_signed_word_at(aligned_offset(1 + 0*jintSize)); }
|
||||
int low_key() const { return java_signed_word_at(aligned_offset(1 + 1*jintSize)); }
|
||||
int high_key() const { return java_signed_word_at(aligned_offset(1 + 2*jintSize)); }
|
||||
int default_offset() const { return get_Java_u4_at(aligned_offset(1 + 0*jintSize)); }
|
||||
int low_key() const { return get_Java_u4_at(aligned_offset(1 + 1*jintSize)); }
|
||||
int high_key() const { return get_Java_u4_at(aligned_offset(1 + 2*jintSize)); }
|
||||
int dest_offset_at(int i) const;
|
||||
int length() { return high_key()-low_key()+1; }
|
||||
|
||||
|
@ -206,7 +214,6 @@ class Bytecode_invoke: public ResourceObj {
|
|||
bool is_invokedynamic() const { return adjusted_invoke_code() == Bytecodes::_invokedynamic; }
|
||||
|
||||
bool has_receiver() const { return !is_invokestatic() && !is_invokedynamic(); }
|
||||
bool has_giant_index() const { return is_invokedynamic(); }
|
||||
|
||||
bool is_valid() const { return is_invokeinterface() ||
|
||||
is_invokevirtual() ||
|
||||
|
@ -252,26 +259,6 @@ inline Bytecode_field* Bytecode_field_at(const methodOop method, address bcp) {
|
|||
}
|
||||
|
||||
|
||||
// Abstraction for {get,put}static
|
||||
|
||||
class Bytecode_static: public Bytecode {
|
||||
public:
|
||||
void verify() const;
|
||||
|
||||
// Returns the result type of the send by inspecting the field ref
|
||||
BasicType result_type(methodOop method) const;
|
||||
|
||||
// Creation
|
||||
inline friend Bytecode_static* Bytecode_static_at(const methodOop method, address bcp);
|
||||
};
|
||||
|
||||
inline Bytecode_static* Bytecode_static_at(const methodOop method, address bcp) {
|
||||
Bytecode_static* b = (Bytecode_static*)bcp;
|
||||
debug_only(b->verify());
|
||||
return b;
|
||||
}
|
||||
|
||||
|
||||
// Abstraction for checkcast
|
||||
|
||||
class Bytecode_checkcast: public Bytecode {
|
||||
|
@ -279,7 +266,7 @@ class Bytecode_checkcast: public Bytecode {
|
|||
void verify() const { assert(Bytecodes::java_code(code()) == Bytecodes::_checkcast, "check checkcast"); }
|
||||
|
||||
// Returns index
|
||||
long index() const { return java_hwrd_at(1); };
|
||||
long index() const { return get_index_u2(Bytecodes::_checkcast); };
|
||||
|
||||
// Creation
|
||||
inline friend Bytecode_checkcast* Bytecode_checkcast_at(address bcp);
|
||||
|
@ -299,7 +286,7 @@ class Bytecode_instanceof: public Bytecode {
|
|||
void verify() const { assert(code() == Bytecodes::_instanceof, "check instanceof"); }
|
||||
|
||||
// Returns index
|
||||
long index() const { return java_hwrd_at(1); };
|
||||
long index() const { return get_index_u2(Bytecodes::_instanceof); };
|
||||
|
||||
// Creation
|
||||
inline friend Bytecode_instanceof* Bytecode_instanceof_at(address bcp);
|
||||
|
@ -317,7 +304,7 @@ class Bytecode_new: public Bytecode {
|
|||
void verify() const { assert(java_code() == Bytecodes::_new, "check new"); }
|
||||
|
||||
// Returns index
|
||||
long index() const { return java_hwrd_at(1); };
|
||||
long index() const { return get_index_u2(Bytecodes::_new); };
|
||||
|
||||
// Creation
|
||||
inline friend Bytecode_new* Bytecode_new_at(address bcp);
|
||||
|
@ -335,7 +322,7 @@ class Bytecode_multianewarray: public Bytecode {
|
|||
void verify() const { assert(java_code() == Bytecodes::_multianewarray, "check new"); }
|
||||
|
||||
// Returns index
|
||||
long index() const { return java_hwrd_at(1); };
|
||||
long index() const { return get_index_u2(Bytecodes::_multianewarray); };
|
||||
|
||||
// Creation
|
||||
inline friend Bytecode_multianewarray* Bytecode_multianewarray_at(address bcp);
|
||||
|
@ -353,7 +340,7 @@ class Bytecode_anewarray: public Bytecode {
|
|||
void verify() const { assert(java_code() == Bytecodes::_anewarray, "check anewarray"); }
|
||||
|
||||
// Returns index
|
||||
long index() const { return java_hwrd_at(1); };
|
||||
long index() const { return get_index_u2(Bytecodes::_anewarray); };
|
||||
|
||||
// Creation
|
||||
inline friend Bytecode_anewarray* Bytecode_anewarray_at(address bcp);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue