1.1 --- a/src/share/vm/interpreter/bytecodes.cpp Wed Jan 12 13:59:18 2011 -0800 1.2 +++ b/src/share/vm/interpreter/bytecodes.cpp 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 @@ -54,18 +54,46 @@ 1.11 Bytecodes::Code Bytecodes::_java_code [Bytecodes::number_of_codes]; 1.12 u_short Bytecodes::_flags [(1<<BitsPerByte)*2]; 1.13 1.14 +#ifdef ASSERT 1.15 +bool Bytecodes::check_method(const methodOopDesc* method, address bcp) { 1.16 + return method->contains(bcp); 1.17 +} 1.18 +#endif 1.19 + 1.20 +bool Bytecodes::check_must_rewrite(Bytecodes::Code code) { 1.21 + assert(can_rewrite(code), "post-check only"); 1.22 + 1.23 + // Some codes are conditionally rewriting. Look closely at them. 1.24 + switch (code) { 1.25 + case Bytecodes::_aload_0: 1.26 + // Even if RewriteFrequentPairs is turned on, 1.27 + // the _aload_0 code might delay its rewrite until 1.28 + // a following _getfield rewrites itself. 1.29 + return false; 1.30 + 1.31 + case Bytecodes::_lookupswitch: 1.32 + return false; // the rewrite is not done by the interpreter 1.33 + 1.34 + case Bytecodes::_new: 1.35 + // (Could actually look at the class here, but the profit would be small.) 1.36 + return false; // the rewrite is not always done 1.37 + } 1.38 + 1.39 + // No other special cases. 1.40 + return true; 1.41 +} 1.42 1.43 Bytecodes::Code Bytecodes::code_at(methodOop method, int bci) { 1.44 - return code_at(method->bcp_from(bci), method); 1.45 + return code_at(method, method->bcp_from(bci)); 1.46 } 1.47 1.48 -Bytecodes::Code Bytecodes::non_breakpoint_code_at(address bcp, methodOop method) { 1.49 - if (method == NULL) method = methodOopDesc::method_from_bcp(bcp); 1.50 +Bytecodes::Code Bytecodes::non_breakpoint_code_at(const methodOopDesc* method, address bcp) { 1.51 + assert(method != NULL, "must have the method for breakpoint conversion"); 1.52 + assert(method->contains(bcp), "must be valid bcp in method"); 1.53 return method->orig_bytecode_at(method->bci_from(bcp)); 1.54 } 1.55 1.56 -int Bytecodes::special_length_at(address bcp, address end) { 1.57 - Code code = code_at(bcp); 1.58 +int Bytecodes::special_length_at(Bytecodes::Code code, address bcp, address end) { 1.59 switch (code) { 1.60 case _wide: 1.61 if (end != NULL && bcp + 1 >= end) { 1.62 @@ -120,7 +148,7 @@ 1.63 if (code == _breakpoint) { 1.64 return 1; 1.65 } else { 1.66 - return special_length_at(bcp, end); 1.67 + return special_length_at(code, bcp, end); 1.68 } 1.69 } 1.70