1 /* |
1 /* |
2 * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 1997, 2015, 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. |
177 |
177 |
178 class Bytecode_member_ref: public Bytecode { |
178 class Bytecode_member_ref: public Bytecode { |
179 protected: |
179 protected: |
180 const methodHandle _method; // method containing the bytecode |
180 const methodHandle _method; // method containing the bytecode |
181 |
181 |
182 Bytecode_member_ref(methodHandle method, int bci) : Bytecode(method(), method()->bcp_from(bci)), _method(method) {} |
182 Bytecode_member_ref(const methodHandle& method, int bci) : Bytecode(method(), method()->bcp_from(bci)), _method(method) {} |
183 |
183 |
184 methodHandle method() const { return _method; } |
184 methodHandle method() const { return _method; } |
185 ConstantPool* constants() const { return _method->constants(); } |
185 ConstantPool* constants() const { return _method->constants(); } |
186 ConstantPoolCache* cpcache() const { return _method->constants()->cache(); } |
186 ConstantPoolCache* cpcache() const { return _method->constants()->cache(); } |
187 ConstantPoolCacheEntry* cpcache_entry() const; |
187 ConstantPoolCacheEntry* cpcache_entry() const; |
199 // Abstraction for invoke_{virtual, static, interface, special} |
199 // Abstraction for invoke_{virtual, static, interface, special} |
200 |
200 |
201 class Bytecode_invoke: public Bytecode_member_ref { |
201 class Bytecode_invoke: public Bytecode_member_ref { |
202 protected: |
202 protected: |
203 // Constructor that skips verification |
203 // Constructor that skips verification |
204 Bytecode_invoke(methodHandle method, int bci, bool unused) : Bytecode_member_ref(method, bci) {} |
204 Bytecode_invoke(const methodHandle& method, int bci, bool unused) : Bytecode_member_ref(method, bci) {} |
205 |
205 |
206 public: |
206 public: |
207 Bytecode_invoke(methodHandle method, int bci) : Bytecode_member_ref(method, bci) { verify(); } |
207 Bytecode_invoke(const methodHandle& method, int bci) : Bytecode_member_ref(method, bci) { verify(); } |
208 void verify() const; |
208 void verify() const; |
209 |
209 |
210 // Attributes |
210 // Attributes |
211 methodHandle static_target(TRAPS); // "specified" method (from constant pool) |
211 methodHandle static_target(TRAPS); // "specified" method (from constant pool) |
212 Handle appendix(TRAPS); // if CPCE::has_appendix (from constant pool) |
212 Handle appendix(TRAPS); // if CPCE::has_appendix (from constant pool) |
230 |
230 |
231 bool has_appendix() { return cpcache_entry()->has_appendix(); } |
231 bool has_appendix() { return cpcache_entry()->has_appendix(); } |
232 |
232 |
233 private: |
233 private: |
234 // Helper to skip verification. Used is_valid() to check if the result is really an invoke |
234 // Helper to skip verification. Used is_valid() to check if the result is really an invoke |
235 inline friend Bytecode_invoke Bytecode_invoke_check(methodHandle method, int bci); |
235 inline friend Bytecode_invoke Bytecode_invoke_check(const methodHandle& method, int bci); |
236 }; |
236 }; |
237 |
237 |
238 inline Bytecode_invoke Bytecode_invoke_check(methodHandle method, int bci) { |
238 inline Bytecode_invoke Bytecode_invoke_check(const methodHandle& method, int bci) { |
239 return Bytecode_invoke(method, bci, false); |
239 return Bytecode_invoke(method, bci, false); |
240 } |
240 } |
241 |
241 |
242 |
242 |
243 // Abstraction for all field accesses (put/get field/static) |
243 // Abstraction for all field accesses (put/get field/static) |
244 class Bytecode_field: public Bytecode_member_ref { |
244 class Bytecode_field: public Bytecode_member_ref { |
245 public: |
245 public: |
246 Bytecode_field(methodHandle method, int bci) : Bytecode_member_ref(method, bci) { verify(); } |
246 Bytecode_field(const methodHandle& method, int bci) : Bytecode_member_ref(method, bci) { verify(); } |
247 |
247 |
248 // Testers |
248 // Testers |
249 bool is_getfield() const { return java_code() == Bytecodes::_getfield; } |
249 bool is_getfield() const { return java_code() == Bytecodes::_getfield; } |
250 bool is_putfield() const { return java_code() == Bytecodes::_putfield; } |
250 bool is_putfield() const { return java_code() == Bytecodes::_putfield; } |
251 bool is_getstatic() const { return java_code() == Bytecodes::_getstatic; } |
251 bool is_getstatic() const { return java_code() == Bytecodes::_getstatic; } |
314 const methodHandle _method; |
314 const methodHandle _method; |
315 |
315 |
316 int raw_index() const; |
316 int raw_index() const; |
317 |
317 |
318 public: |
318 public: |
319 Bytecode_loadconstant(methodHandle method, int bci): Bytecode(method(), method->bcp_from(bci)), _method(method) { verify(); } |
319 Bytecode_loadconstant(const methodHandle& method, int bci): Bytecode(method(), method->bcp_from(bci)), _method(method) { verify(); } |
320 |
320 |
321 void verify() const { |
321 void verify() const { |
322 assert(_method.not_null(), "must supply method"); |
322 assert(_method.not_null(), "must supply method"); |
323 Bytecodes::Code stdc = Bytecodes::java_code(code()); |
323 Bytecodes::Code stdc = Bytecodes::java_code(code()); |
324 assert(stdc == Bytecodes::_ldc || |
324 assert(stdc == Bytecodes::_ldc || |