159 _data = NEW_RESOURCE_ARRAY(implicit_null_entry, (size*2)); 160 _len = 0; 161 } 162 163 void ImplicitExceptionTable::append( uint exec_off, uint cont_off ) { 164 assert( (sizeof(implicit_null_entry) >= 4) || (exec_off < 65535), "" ); 165 assert( (sizeof(implicit_null_entry) >= 4) || (cont_off < 65535), "" ); 166 uint l = len(); 167 if (l == _size) { 168 uint old_size_in_elements = _size*2; 169 if (_size == 0) _size = 4; 170 _size *= 2; 171 uint new_size_in_elements = _size*2; 172 _data = REALLOC_RESOURCE_ARRAY(uint, _data, old_size_in_elements, new_size_in_elements); 173 } 174 *(adr(l) ) = exec_off; 175 *(adr(l)+1) = cont_off; 176 _len = l+1; 177 }; 178 179 uint ImplicitExceptionTable::at( uint exec_off ) const { 180 uint l = len(); 181 for( uint i=0; i<l; i++ ) 182 if( *adr(i) == exec_off ) 183 return *(adr(i)+1); 184 return 0; // Failed to find any execption offset 185 } 186 187 void ImplicitExceptionTable::print(address base) const { 188 const uint n = len(); 189 if (n > 0) { 190 const uint items_per_line = 3; 191 uint i; 192 tty->print_cr("ImplicitExceptionTable (size = %d entries, %d bytes):", n, size_in_bytes()); 193 tty->print("{"); 194 for (i = 0; i < n; i++) { 195 if (i%items_per_line == 0) { 196 tty->cr(); 197 tty->fill_to(3); 198 } 199 tty->print("< " INTPTR_FORMAT ", " INTPTR_FORMAT " > ", p2i(base + *adr(i)), p2i(base + *(adr(i)+1))); 200 } 201 tty->bol(); 202 tty->print_cr("}"); 203 } else { 204 tty->print_cr("ImplicitExceptionTable is empty"); 205 } 206 } 207 208 ImplicitExceptionTable::ImplicitExceptionTable(const nmethod* nm) { 209 if (nm->nul_chk_table_size() == 0) { 210 _len = 0; 211 _data = NULL; 212 } else { 213 // the first word is the length if non-zero, so read it out and 214 // skip to the next word to get the table. 215 _data = (implicit_null_entry*)nm->nul_chk_table_begin(); 216 _len = _data[0]; 217 _data++; 218 } 219 _size = len(); 220 assert(size_in_bytes() <= nm->nul_chk_table_size(), "size of space allocated in nmethod incorrect"); 221 } 222 223 void ImplicitExceptionTable::copy_to( nmethod* nm ) { 224 assert(size_in_bytes() <= nm->nul_chk_table_size(), "size of space allocated in nmethod incorrect"); 225 if (len() != 0) { 226 implicit_null_entry* nmdata = (implicit_null_entry*)nm->nul_chk_table_begin(); 227 // store the length in the first uint 228 nmdata[0] = _len; 229 nmdata++; 230 // copy the table after the length 231 memmove( nmdata, _data, 2 * len() * sizeof(implicit_null_entry)); 232 } else { 233 // zero length table takes zero bytes 234 assert(size_in_bytes() == 0, "bad size"); 235 assert(nm->nul_chk_table_size() == 0, "bad size"); 236 } 237 } 238 239 void ImplicitExceptionTable::verify(nmethod *nm) const { 240 for (uint i = 0; i < len(); i++) { 241 if ((*adr(i) > (unsigned int)nm->insts_size()) || 242 (*(adr(i)+1) > (unsigned int)nm->insts_size())) 243 fatal("Invalid offset in ImplicitExceptionTable at " PTR_FORMAT, p2i(_data)); 244 } 245 } | 159 _data = NEW_RESOURCE_ARRAY(implicit_null_entry, (size*2)); 160 _len = 0; 161 } 162 163 void ImplicitExceptionTable::append( uint exec_off, uint cont_off ) { 164 assert( (sizeof(implicit_null_entry) >= 4) || (exec_off < 65535), "" ); 165 assert( (sizeof(implicit_null_entry) >= 4) || (cont_off < 65535), "" ); 166 uint l = len(); 167 if (l == _size) { 168 uint old_size_in_elements = _size*2; 169 if (_size == 0) _size = 4; 170 _size *= 2; 171 uint new_size_in_elements = _size*2; 172 _data = REALLOC_RESOURCE_ARRAY(uint, _data, old_size_in_elements, new_size_in_elements); 173 } 174 *(adr(l) ) = exec_off; 175 *(adr(l)+1) = cont_off; 176 _len = l+1; 177 }; 178 179 uint ImplicitExceptionTable::continuation_offset( uint exec_off ) const { 180 uint l = len(); 181 for( uint i=0; i<l; i++ ) 182 if( *adr(i) == exec_off ) 183 return *(adr(i)+1); 184 return 0; // Failed to find any execption offset 185 } 186 187 void ImplicitExceptionTable::print(address base) const { 188 const uint n = len(); 189 if (n > 0) { 190 const uint items_per_line = 3; 191 uint i; 192 tty->print_cr("ImplicitExceptionTable (size = %d entries, %d bytes):", n, size_in_bytes()); 193 tty->print("{"); 194 for (i = 0; i < n; i++) { 195 if (i%items_per_line == 0) { 196 tty->cr(); 197 tty->fill_to(3); 198 } 199 tty->print("< " INTPTR_FORMAT ", " INTPTR_FORMAT " > ", p2i(base + *adr(i)), p2i(base + *(adr(i)+1))); 200 } 201 tty->bol(); 202 tty->print_cr("}"); 203 } else { 204 tty->print_cr("ImplicitExceptionTable is empty"); 205 } 206 } 207 208 ImplicitExceptionTable::ImplicitExceptionTable(const CompiledMethod* nm) { 209 if (nm->nul_chk_table_size() == 0) { 210 _len = 0; 211 _data = NULL; 212 } else { 213 // the first word is the length if non-zero, so read it out and 214 // skip to the next word to get the table. 215 _data = (implicit_null_entry*)nm->nul_chk_table_begin(); 216 _len = _data[0]; 217 _data++; 218 } 219 _size = len(); 220 assert(size_in_bytes() <= nm->nul_chk_table_size(), "size of space allocated in nmethod incorrect"); 221 } 222 223 void ImplicitExceptionTable::copy_to( nmethod* nm ) { 224 copy_bytes_to(nm->nul_chk_table_begin(), nm->nul_chk_table_size()); 225 } 226 227 void ImplicitExceptionTable::copy_bytes_to(address addr, int size) { 228 assert(size_in_bytes() <= size, "size of space allocated in nmethod incorrect"); 229 if (len() != 0) { 230 implicit_null_entry* nmdata = (implicit_null_entry*)addr; 231 // store the length in the first uint 232 nmdata[0] = _len; 233 nmdata++; 234 // copy the table after the length 235 memmove( nmdata, _data, 2 * len() * sizeof(implicit_null_entry)); 236 } else { 237 // zero length table takes zero bytes 238 assert(size_in_bytes() == 0, "bad size"); 239 assert(size == 0, "bad size"); 240 } 241 } 242 243 void ImplicitExceptionTable::verify(nmethod *nm) const { 244 for (uint i = 0; i < len(); i++) { 245 if ((*adr(i) > (unsigned int)nm->insts_size()) || 246 (*(adr(i)+1) > (unsigned int)nm->insts_size())) 247 fatal("Invalid offset in ImplicitExceptionTable at " PTR_FORMAT, p2i(_data)); 248 } 249 } |