// Initialize the methodDataOop corresponding to a given method. void methodDataOopDesc::initialize(methodHandle method) { ResourceMark rm; // Set the method back-pointer. _method = method(); set_creation_mileage(mileage_of(method())); // Initialize flags and trap history. _nof_decompiles = 0; _nof_overflow_recompiles = 0; _nof_overflow_traps = 0; assert(sizeof(_trap_hist) % sizeof(HeapWord) == 0, "align"); Copy::zero_to_words((HeapWord*) &_trap_hist, sizeof(_trap_hist) / sizeof(HeapWord)); // Go through the bytecodes and allocate and initialize the // corresponding data cells. int data_size = 0; int empty_bc_count = 0; // number of bytecodes lacking data BytecodeStream stream(method); Bytecodes::Code c; while ((c = stream.next()) >= 0) { int size_in_bytes = initialize_data(&stream, data_size); data_size += size_in_bytes; if (size_in_bytes == 0) empty_bc_count += 1; } _data_size = data_size; int object_size = in_bytes(data_offset()) + data_size; // Add some extra DataLayout cells (at least one) to track stray traps. int extra_data_count = compute_extra_data_count(data_size, empty_bc_count); int extra_size = extra_data_count * DataLayout::compute_size_in_bytes(0); // Add a cell to record information about modified arguments. // Set up _args_modified array after traps cells so that // the code for traps cells works. DataLayout *dp = data_layout_at(data_size + extra_size); int arg_size = method->size_of_parameters(); dp->initialize(DataLayout::arg_info_data_tag, 0, arg_size+1); object_size += extra_size + DataLayout::compute_size_in_bytes(arg_size+1); // Set an initial hint. Don't use set_hint_di() because // first_di() may be out of bounds if data_size is 0. // In that situation, _hint_di is never used, but at // least well-defined. _hint_di = first_di(); post_initialize(&stream); set_object_is_parsable(object_size); }
void MethodData::initialize() { No_Safepoint_Verifier no_safepoint; // init function atomic wrt GC ResourceMark rm; init(); set_creation_mileage(mileage_of(method())); // Go through the bytecodes and allocate and initialize the // corresponding data cells. int data_size = 0; int empty_bc_count = 0; // number of bytecodes lacking data _data[0] = 0; // apparently not set below. BytecodeStream stream(method()); Bytecodes::Code c; while ((c = stream.next()) >= 0) { int size_in_bytes = initialize_data(&stream, data_size); data_size += size_in_bytes; if (is_empty_data(size_in_bytes, c)) empty_bc_count++; } _data_size = data_size; int object_size = in_bytes(data_offset()) + data_size; // Add some extra DataLayout cells (at least one) to track stray traps. int extra_data_count = compute_extra_data_count(data_size, empty_bc_count); int extra_size = extra_data_count * DataLayout::compute_size_in_bytes(0); object_size += extra_size; Copy::zero_to_bytes((HeapWord*) extra_data_base(), extra_size); #ifndef GRAALVM // Add a cell to record information about modified arguments. // Set up _args_modified array after traps cells so that // the code for traps cells works. DataLayout *dp = data_layout_at(data_size + extra_size); int arg_size = method()->size_of_parameters(); dp->initialize(DataLayout::arg_info_data_tag, 0, arg_size+1); object_size += DataLayout::compute_size_in_bytes(arg_size+1); #endif // Set an initial hint. Don't use set_hint_di() because // first_di() may be out of bounds if data_size is 0. // In that situation, _hint_di is never used, but at // least well-defined. _hint_di = first_di(); post_initialize(&stream); set_size(object_size); }
// Compute the size of the methodDataOop necessary to store // profiling information about a given method. Size is in bytes. int methodDataOopDesc::compute_allocation_size_in_bytes(methodOop method) { int data_size = 0; BytecodeStream stream(method); Bytecodes::Code c; int empty_bc_count = 0; // number of bytecodes lacking data while ((c = stream.next()) >= 0) { int size_in_bytes = compute_data_size(&stream); data_size += size_in_bytes; if (size_in_bytes == 0) empty_bc_count += 1; } int object_size = in_bytes(data_offset()) + data_size; // Add some extra DataLayout cells (at least one) to track stray traps. int extra_data_count = compute_extra_data_count(data_size, empty_bc_count); object_size += extra_data_count * DataLayout::compute_size_in_bytes(0); return object_size; }
// Compute the size of the methodDataOop necessary to store // profiling information about a given method. Size is in bytes. int methodDataOopDesc::compute_allocation_size_in_bytes(methodHandle method) { int data_size = 0; BytecodeStream stream(method); Bytecodes::Code c; int empty_bc_count = 0; // number of bytecodes lacking data while ((c = stream.next()) >= 0) { int size_in_bytes = compute_data_size(&stream); data_size += size_in_bytes; if (size_in_bytes == 0) empty_bc_count += 1; } int object_size = in_bytes(data_offset()) + data_size; // Add some extra DataLayout cells (at least one) to track stray traps. int extra_data_count = compute_extra_data_count(data_size, empty_bc_count); object_size += extra_data_count * DataLayout::compute_size_in_bytes(0); // Add a cell to record information about modified arguments. int arg_size = method->size_of_parameters(); object_size += DataLayout::compute_size_in_bytes(arg_size+1); return object_size; }
int mesg_write_rrset_list (G_List *rrls, u_char *msg, u_char *msg_tail, uint16_t *dnames, int dnames_len, u_char **wp, uint16_t *cnt) { char *fn = "mesg_write_rrset_list()"; u_char *wp_start, *wp_period; Mesg_Hdr *hdr; uint16_t us; uint32_t ul; RRset *rrsp; RR *rrp; int i, ret; if (T.debug > 4) syslog (LOG_DEBUG, "%s: start.", fn); if (!rrls) return 0; wp_start = *wp; hdr = (Mesg_Hdr *) msg; for (rrls = rrls->next; rrls->list_data; rrls = rrls->next) { if (T.debug > 4) syslog (LOG_DEBUG, "%s: write a record", fn); rrsp = (RRset *) rrls->list_data; for (i = 0; i < rrsp->data.d->data_cnt; i++) { wp_period = *wp; /* write the owner name */ ret = write_dname (msg, msg_tail, dnames, dnames_len, rrset_owner (rrsp), *wp); if (ret < 0) { syslog (LOG_DEBUG, "write ownername failed"); *wp = wp_period; return wp_period - wp_start; } *wp += ret; /* write RR field and data */ rrp = (RR *) (rrsp->data.p + data_offset (i, rrsp->data.p)); if (*wp + sizeof (uint16_t) * 3 + sizeof (uint32_t) + rrp->rd_len > msg_tail) { syslog (LOG_DEBUG, "write rdata failed"); *wp = wp_period; return wp_period - wp_start; } PUTSHORT (rrsp->key.info->r_type, *wp); PUTSHORT (rrsp->key.info->r_class, *wp); ul = rrp->ttl; PUTLONG (ul, *wp); /* XXX RDATA COMPRESSION NOT IMPLEMENTED */ PUTSHORT (rrp->rd_len, *wp); memcpy (*wp, rr_rdata (rrp), rrp->rd_len); *wp += rrp->rd_len; /* update header */ us = ntohs (*cnt) + 1; /* and caller's counter */ *cnt = htons (us); if (T.debug > 4) syslog (LOG_DEBUG, "%s: now counter = %d", fn, us); } } if (T.debug > 4) syslog (LOG_DEBUG, "%s: return %d", fn,(int)(*wp - wp_start)); return (*wp - wp_start); }
void set_data(Oop * p) {obj_field_put(data_offset(), p);}
ReturnOop data(){ return obj_field(data_offset());}
char* keymask() noexcept { return &vla[data_offset() - mask_length()]; }
char* data() noexcept { return &vla[data_offset()]; }
const char* data() const noexcept { return &vla[data_offset()]; }
uint16_t header_length() const noexcept { return sizeof(ws_header) + data_offset(); }
void getOffsetAndCount(const MultiTag &tag, const DataArray &array, size_t index, NDSize &offsets, NDSize &counts) { DataArray positions = tag.positions(); DataArray extents = tag.extents(); NDSize position_size, extent_size; size_t dimension_count = array.dimensionCount(); if (positions) { position_size = positions.dataExtent(); } if (extents) { extent_size = extents.dataExtent(); } if (!positions || index >= position_size[0]) { throw nix::OutOfBounds("Index out of bounds of positions!", 0); } if (extents && index >= extent_size[0]) { throw nix::OutOfBounds("Index out of bounds of positions or extents!", 0); } if (position_size.size() == 1 && dimension_count != 1) { throw nix::IncompatibleDimensions("Number of dimensions in positions does not match dimensionality of data", "util::getOffsetAndCount"); } if (position_size.size() > 1 && position_size[1] > dimension_count) { throw nix::IncompatibleDimensions("Number of dimensions in positions does not match dimensionality of data", "util::getOffsetAndCount"); } if (extents && extent_size.size() > 1 && extent_size[1] > dimension_count) { throw nix::IncompatibleDimensions("Number of dimensions in extents does not match dimensionality of data", "util::getOffsetAndCount"); } NDSize temp_offset = NDSize{static_cast<NDSize::value_type>(index), static_cast<NDSize::value_type>(0)}; NDSize temp_count{static_cast<NDSize::value_type>(1), static_cast<NDSize::value_type>(dimension_count)}; vector<double> offset; positions.getData(offset, temp_count, temp_offset); NDSize data_offset(dimension_count, static_cast<size_t>(0)); NDSize data_count(dimension_count, static_cast<size_t>(1)); vector<string> units = tag.units(); for (size_t i = 0; i < offset.size(); ++i) { Dimension dimension = array.getDimension(i+1); string unit = "none"; if (i <= units.size() && units.size() > 0) { unit = units[i]; } data_offset[i] = positionToIndex(offset[i], unit, dimension); } if (extents) { vector<double> extent; extents.getData(extent, temp_count, temp_offset); for (size_t i = 0; i < extent.size(); ++i) { Dimension dimension = array.getDimension(i+1); string unit = "none"; if (i <= units.size() && units.size() > 0) { unit = units[i]; } ndsize_t c = positionToIndex(offset[i] + extent[i], unit, dimension) - data_offset[i]; data_count[i] = (c > 1) ? c : 1; } } offsets = data_offset; counts = data_count; }