1 /* |
1 /* |
2 * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 1997, 2017, 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. |
43 |
43 |
44 // Address computation |
44 // Address computation |
45 address addr_at (int offset) const { return (address)_bcp + offset; } |
45 address addr_at (int offset) const { return (address)_bcp + offset; } |
46 u_char byte_at(int offset) const { return *addr_at(offset); } |
46 u_char byte_at(int offset) const { return *addr_at(offset); } |
47 address aligned_addr_at (int offset) const { return (address)round_to((intptr_t)addr_at(offset), jintSize); } |
47 address aligned_addr_at (int offset) const { return (address)round_to((intptr_t)addr_at(offset), jintSize); } |
48 int aligned_offset (int offset) const { return aligned_addr_at(offset) - addr_at(0); } |
|
49 |
48 |
50 // Word access: |
49 // Word access: |
51 int get_Java_u2_at (int offset) const { return Bytes::get_Java_u2(addr_at(offset)); } |
50 int get_Java_u2_at (int offset) const { return Bytes::get_Java_u2(addr_at(offset)); } |
52 int get_Java_u4_at (int offset) const { return Bytes::get_Java_u4(addr_at(offset)); } |
51 int get_Java_u4_at (int offset) const { return Bytes::get_Java_u4(addr_at(offset)); } |
|
52 int get_aligned_Java_u4_at(int offset) const { return Bytes::get_Java_u4(aligned_addr_at(offset)); } |
53 int get_native_u2_at (int offset) const { return Bytes::get_native_u2(addr_at(offset)); } |
53 int get_native_u2_at (int offset) const { return Bytes::get_native_u2(addr_at(offset)); } |
54 int get_native_u4_at (int offset) const { return Bytes::get_native_u4(addr_at(offset)); } |
54 int get_native_u4_at (int offset) const { return Bytes::get_native_u4(addr_at(offset)); } |
55 |
55 |
56 public: |
56 public: |
57 Bytecode(Method* method, address bcp): _bcp(bcp), _code(Bytecodes::code_at(method, addr_at(0))) { |
57 Bytecode(Method* method, address bcp): _bcp(bcp), _code(Bytecodes::code_at(method, addr_at(0))) { |
148 // Defined in ciStreams.hpp |
148 // Defined in ciStreams.hpp |
149 inline Bytecode_lookupswitch(const ciBytecodeStream* stream); |
149 inline Bytecode_lookupswitch(const ciBytecodeStream* stream); |
150 void verify() const PRODUCT_RETURN; |
150 void verify() const PRODUCT_RETURN; |
151 |
151 |
152 // Attributes |
152 // Attributes |
153 int default_offset() const { return get_Java_u4_at(aligned_offset(1 + 0*jintSize)); } |
153 int default_offset() const { return get_aligned_Java_u4_at(1 + 0*jintSize); } |
154 int number_of_pairs() const { return get_Java_u4_at(aligned_offset(1 + 1*jintSize)); } |
154 int number_of_pairs() const { return get_aligned_Java_u4_at(1 + 1*jintSize); } |
155 LookupswitchPair pair_at(int i) const { |
155 LookupswitchPair pair_at(int i) const { |
156 assert(0 <= i && i < number_of_pairs(), "pair index out of bounds"); |
156 assert(0 <= i && i < number_of_pairs(), "pair index out of bounds"); |
157 return LookupswitchPair(aligned_addr_at(1 + (1 + i)*2*jintSize)); |
157 return LookupswitchPair(aligned_addr_at(1 + (1 + i)*2*jintSize)); |
158 } |
158 } |
159 }; |
159 }; |
164 // Defined in ciStreams.hpp |
164 // Defined in ciStreams.hpp |
165 inline Bytecode_tableswitch(const ciBytecodeStream* stream); |
165 inline Bytecode_tableswitch(const ciBytecodeStream* stream); |
166 void verify() const PRODUCT_RETURN; |
166 void verify() const PRODUCT_RETURN; |
167 |
167 |
168 // Attributes |
168 // Attributes |
169 int default_offset() const { return get_Java_u4_at(aligned_offset(1 + 0*jintSize)); } |
169 int default_offset() const { return get_aligned_Java_u4_at(1 + 0*jintSize); } |
170 int low_key() const { return get_Java_u4_at(aligned_offset(1 + 1*jintSize)); } |
170 int low_key() const { return get_aligned_Java_u4_at(1 + 1*jintSize); } |
171 int high_key() const { return get_Java_u4_at(aligned_offset(1 + 2*jintSize)); } |
171 int high_key() const { return get_aligned_Java_u4_at(1 + 2*jintSize); } |
172 int dest_offset_at(int i) const; |
172 int dest_offset_at(int i) const; |
173 int length() { return high_key()-low_key()+1; } |
173 int length() { return high_key()-low_key()+1; } |
174 }; |
174 }; |
175 |
175 |
176 // Common code for decoding invokes and field references. |
176 // Common code for decoding invokes and field references. |