1.1 --- a/src/share/vm/interpreter/bytecodes.hpp Wed Jan 12 13:59:18 2011 -0800 1.2 +++ b/src/share/vm/interpreter/bytecodes.hpp Thu Jan 13 22:15:41 2011 -0800 1.3 @@ -1,5 +1,5 @@ 1.4 /* 1.5 - * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. 1.6 + * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. 1.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 1.8 * 1.9 * This code is free software; you can redistribute it and/or modify it 1.10 @@ -342,6 +342,12 @@ 1.11 static void pd_initialize(); // platform specific initialization 1.12 static Code pd_base_code_for(Code code); // platform specific base_code_for implementation 1.13 1.14 + // Verify that bcp points into method 1.15 +#ifdef ASSERT 1.16 + static bool check_method(const methodOopDesc* method, address bcp); 1.17 +#endif 1.18 + static bool check_must_rewrite(Bytecodes::Code bc); 1.19 + 1.20 public: 1.21 // Conversion 1.22 static void check (Code code) { assert(is_defined(code), "illegal code"); } 1.23 @@ -349,22 +355,30 @@ 1.24 static Code cast (int code) { return (Code)code; } 1.25 1.26 1.27 - // Fetch a bytecode, hiding breakpoints as necessary: 1.28 - static Code code_at(address bcp, methodOop method = NULL) { 1.29 - Code code = cast(*bcp); return (code != _breakpoint) ? code : non_breakpoint_code_at(bcp, method); 1.30 - } 1.31 - static Code java_code_at(address bcp, methodOop method = NULL) { 1.32 - return java_code(code_at(bcp, method)); 1.33 - } 1.34 + // Fetch a bytecode, hiding breakpoints as necessary. The method 1.35 + // argument is used for conversion of breakpoints into the original 1.36 + // bytecode. The CI uses these methods but guarantees that 1.37 + // breakpoints are hidden so the method argument should be passed as 1.38 + // NULL since in that case the bcp and methodOop are unrelated 1.39 + // memory. 1.40 + static Code code_at(const methodOopDesc* method, address bcp) { 1.41 + assert(method == NULL || check_method(method, bcp), "bcp must point into method"); 1.42 + Code code = cast(*bcp); 1.43 + assert(code != _breakpoint || method != NULL, "need methodOop to decode breakpoint"); 1.44 + return (code != _breakpoint) ? code : non_breakpoint_code_at(method, bcp); 1.45 + } 1.46 + static Code java_code_at(const methodOopDesc* method, address bcp) { 1.47 + return java_code(code_at(method, bcp)); 1.48 + } 1.49 1.50 - // Fetch a bytecode or a breakpoint: 1.51 - static Code code_or_bp_at(address bcp) { return (Code)cast(*bcp); } 1.52 + // Fetch a bytecode or a breakpoint: 1.53 + static Code code_or_bp_at(address bcp) { return (Code)cast(*bcp); } 1.54 1.55 - static Code code_at(methodOop method, int bci); 1.56 - static bool is_active_breakpoint_at(address bcp) { return (Code)*bcp == _breakpoint; } 1.57 + static Code code_at(methodOop method, int bci); 1.58 + static bool is_active_breakpoint_at(address bcp) { return (Code)*bcp == _breakpoint; } 1.59 1.60 - // find a bytecode, behind a breakpoint if necessary: 1.61 - static Code non_breakpoint_code_at(address bcp, methodOop method = NULL); 1.62 + // find a bytecode, behind a breakpoint if necessary: 1.63 + static Code non_breakpoint_code_at(const methodOopDesc* method, address bcp); 1.64 1.65 // Bytecode attributes 1.66 static bool is_defined (int code) { return 0 <= code && code < number_of_codes && flags(code, false) != 0; } 1.67 @@ -379,14 +393,17 @@ 1.68 static bool can_trap (Code code) { check(code); return has_all_flags(code, _bc_can_trap, false); } 1.69 static Code java_code (Code code) { check(code); return _java_code [code]; } 1.70 static bool can_rewrite (Code code) { check(code); return has_all_flags(code, _bc_can_rewrite, false); } 1.71 + static bool must_rewrite(Bytecodes::Code code) { return can_rewrite(code) && check_must_rewrite(code); } 1.72 static bool native_byte_order(Code code) { check(code); return has_all_flags(code, _fmt_has_nbo, false); } 1.73 static bool uses_cp_cache (Code code) { check(code); return has_all_flags(code, _fmt_has_j, false); } 1.74 // if 'end' is provided, it indicates the end of the code buffer which 1.75 // should not be read past when parsing. 1.76 - static int special_length_at(address bcp, address end = NULL); 1.77 + static int special_length_at(Bytecodes::Code code, address bcp, address end = NULL); 1.78 + static int special_length_at(methodOop method, address bcp, address end = NULL) { return special_length_at(code_at(method, bcp), bcp, end); } 1.79 static int raw_special_length_at(address bcp, address end = NULL); 1.80 - static int length_at (address bcp) { int l = length_for(code_at(bcp)); return l > 0 ? l : special_length_at(bcp); } 1.81 - static int java_length_at (address bcp) { int l = length_for(java_code_at(bcp)); return l > 0 ? l : special_length_at(bcp); } 1.82 + static int length_for_code_at(Bytecodes::Code code, address bcp) { int l = length_for(code); return l > 0 ? l : special_length_at(code, bcp); } 1.83 + static int length_at (methodOop method, address bcp) { return length_for_code_at(code_at(method, bcp), bcp); } 1.84 + static int java_length_at (methodOop method, address bcp) { return length_for_code_at(java_code_at(method, bcp), bcp); } 1.85 static bool is_java_code (Code code) { return 0 <= code && code < number_of_java_codes; } 1.86 1.87 static bool is_aload (Code code) { return (code == _aload || code == _aload_0 || code == _aload_1