1 /* |
1 /* |
2 * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. |
7 * published by the Free Software Foundation. |
52 s_char Bytecodes::_depth [Bytecodes::number_of_codes]; |
52 s_char Bytecodes::_depth [Bytecodes::number_of_codes]; |
53 u_char Bytecodes::_lengths [Bytecodes::number_of_codes]; |
53 u_char Bytecodes::_lengths [Bytecodes::number_of_codes]; |
54 Bytecodes::Code Bytecodes::_java_code [Bytecodes::number_of_codes]; |
54 Bytecodes::Code Bytecodes::_java_code [Bytecodes::number_of_codes]; |
55 u_short Bytecodes::_flags [(1<<BitsPerByte)*2]; |
55 u_short Bytecodes::_flags [(1<<BitsPerByte)*2]; |
56 |
56 |
|
57 #ifdef ASSERT |
|
58 bool Bytecodes::check_method(const methodOopDesc* method, address bcp) { |
|
59 return method->contains(bcp); |
|
60 } |
|
61 #endif |
|
62 |
|
63 bool Bytecodes::check_must_rewrite(Bytecodes::Code code) { |
|
64 assert(can_rewrite(code), "post-check only"); |
|
65 |
|
66 // Some codes are conditionally rewriting. Look closely at them. |
|
67 switch (code) { |
|
68 case Bytecodes::_aload_0: |
|
69 // Even if RewriteFrequentPairs is turned on, |
|
70 // the _aload_0 code might delay its rewrite until |
|
71 // a following _getfield rewrites itself. |
|
72 return false; |
|
73 |
|
74 case Bytecodes::_lookupswitch: |
|
75 return false; // the rewrite is not done by the interpreter |
|
76 |
|
77 case Bytecodes::_new: |
|
78 // (Could actually look at the class here, but the profit would be small.) |
|
79 return false; // the rewrite is not always done |
|
80 } |
|
81 |
|
82 // No other special cases. |
|
83 return true; |
|
84 } |
57 |
85 |
58 Bytecodes::Code Bytecodes::code_at(methodOop method, int bci) { |
86 Bytecodes::Code Bytecodes::code_at(methodOop method, int bci) { |
59 return code_at(method->bcp_from(bci), method); |
87 return code_at(method, method->bcp_from(bci)); |
60 } |
88 } |
61 |
89 |
62 Bytecodes::Code Bytecodes::non_breakpoint_code_at(address bcp, methodOop method) { |
90 Bytecodes::Code Bytecodes::non_breakpoint_code_at(const methodOopDesc* method, address bcp) { |
63 if (method == NULL) method = methodOopDesc::method_from_bcp(bcp); |
91 assert(method != NULL, "must have the method for breakpoint conversion"); |
|
92 assert(method->contains(bcp), "must be valid bcp in method"); |
64 return method->orig_bytecode_at(method->bci_from(bcp)); |
93 return method->orig_bytecode_at(method->bci_from(bcp)); |
65 } |
94 } |
66 |
95 |
67 int Bytecodes::special_length_at(address bcp, address end) { |
96 int Bytecodes::special_length_at(Bytecodes::Code code, address bcp, address end) { |
68 Code code = code_at(bcp); |
|
69 switch (code) { |
97 switch (code) { |
70 case _wide: |
98 case _wide: |
71 if (end != NULL && bcp + 1 >= end) { |
99 if (end != NULL && bcp + 1 >= end) { |
72 return -1; // don't read past end of code buffer |
100 return -1; // don't read past end of code buffer |
73 } |
101 } |