< prev index next >

src/hotspot/share/prims/jvmtiClassFileReconstituter.cpp

Print this page

 979 }
 980 
 981 void JvmtiClassFileReconstituter::write_u1(u1 x) {
 982   *writeable_address(1) = x;
 983 }
 984 
 985 void JvmtiClassFileReconstituter::write_u2(u2 x) {
 986   Bytes::put_Java_u2(writeable_address(2), x);
 987 }
 988 
 989 void JvmtiClassFileReconstituter::write_u4(u4 x) {
 990   Bytes::put_Java_u4(writeable_address(4), x);
 991 }
 992 
 993 void JvmtiClassFileReconstituter::write_u8(u8 x) {
 994   Bytes::put_Java_u8(writeable_address(8), x);
 995 }
 996 
 997 void JvmtiClassFileReconstituter::copy_bytecodes(const methodHandle& mh,
 998                                                  unsigned char* bytecodes) {





 999   // use a BytecodeStream to iterate over the bytecodes. JVM/fast bytecodes
1000   // and the breakpoint bytecode are converted to their original bytecodes.
1001 
1002   BytecodeStream bs(mh);
1003 
1004   unsigned char* p = bytecodes;
1005   Bytecodes::Code code;
1006   bool is_rewritten = mh->method_holder()->is_rewritten();
1007 
1008   while ((code = bs.next()) >= 0) {
1009     assert(Bytecodes::is_java_code(code), "sanity check");
1010     assert(code != Bytecodes::_breakpoint, "sanity check");
1011 
1012     // length of bytecode (mnemonic + operands)
1013     address bcp = bs.bcp();
1014     int     len = bs.instruction_size();
1015     assert(len > 0, "length must be > 0");
1016 
1017     // copy the bytecodes
1018     *p = (unsigned char) (bs.is_wide()? Bytecodes::_wide : code);

 979 }
 980 
 981 void JvmtiClassFileReconstituter::write_u1(u1 x) {
 982   *writeable_address(1) = x;
 983 }
 984 
 985 void JvmtiClassFileReconstituter::write_u2(u2 x) {
 986   Bytes::put_Java_u2(writeable_address(2), x);
 987 }
 988 
 989 void JvmtiClassFileReconstituter::write_u4(u4 x) {
 990   Bytes::put_Java_u4(writeable_address(4), x);
 991 }
 992 
 993 void JvmtiClassFileReconstituter::write_u8(u8 x) {
 994   Bytes::put_Java_u8(writeable_address(8), x);
 995 }
 996 
 997 void JvmtiClassFileReconstituter::copy_bytecodes(const methodHandle& mh,
 998                                                  unsigned char* bytecodes) {
 999   // We must copy bytecodes only from linked classes.
1000   // Being linked guarantees we are not getting bytecodes at
1001   // the same time the linking process is rewriting them.
1002   guarantee(mh->method_holder()->is_linked(), "Bytecodes must be copied from a linked class");
1003 
1004   // use a BytecodeStream to iterate over the bytecodes. JVM/fast bytecodes
1005   // and the breakpoint bytecode are converted to their original bytecodes.
1006 
1007   BytecodeStream bs(mh);
1008 
1009   unsigned char* p = bytecodes;
1010   Bytecodes::Code code;
1011   bool is_rewritten = mh->method_holder()->is_rewritten();
1012 
1013   while ((code = bs.next()) >= 0) {
1014     assert(Bytecodes::is_java_code(code), "sanity check");
1015     assert(code != Bytecodes::_breakpoint, "sanity check");
1016 
1017     // length of bytecode (mnemonic + operands)
1018     address bcp = bs.bcp();
1019     int     len = bs.instruction_size();
1020     assert(len > 0, "length must be > 0");
1021 
1022     // copy the bytecodes
1023     *p = (unsigned char) (bs.is_wide()? Bytecodes::_wide : code);
< prev index next >