本文整理汇总了C++中p2i函数的典型用法代码示例。如果您正苦于以下问题:C++ p2i函数的具体用法?C++ p2i怎么用?C++ p2i使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了p2i函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: assert
void ThreadLocalAllocBuffer::resize() {
// Compute the next tlab size using expected allocation amount
assert(ResizeTLAB, "Should not call this otherwise");
size_t alloc = (size_t)(_allocation_fraction.average() *
(Universe::heap()->tlab_capacity(myThread()) / HeapWordSize));
size_t new_size = alloc / _target_refills;
new_size = MIN2(MAX2(new_size, min_size()), max_size());
size_t aligned_new_size = align_object_size(new_size);
if (PrintTLAB && Verbose) {
gclog_or_tty->print("TLAB new size: thread: " INTPTR_FORMAT " [id: %2d]"
" refills %d alloc: %8.6f desired_size: " SIZE_FORMAT " -> " SIZE_FORMAT "\n",
p2i(myThread()), myThread()->osthread()->thread_id(),
_target_refills, _allocation_fraction.average(), desired_size(), aligned_new_size);
}
set_desired_size(aligned_new_size);
set_refill_waste_limit(initial_refill_waste_limit());
}
示例2: compute_desired
// The rate estimate is in blocks per second.
void compute_desired(size_t count,
float inter_sweep_current,
float inter_sweep_estimate,
float intra_sweep_estimate) {
// If the latest inter-sweep time is below our granularity
// of measurement, we may call in here with
// inter_sweep_current == 0. However, even for suitably small
// but non-zero inter-sweep durations, we may not trust the accuracy
// of accumulated data, since it has not been "integrated"
// (read "low-pass-filtered") long enough, and would be
// vulnerable to noisy glitches. In such cases, we
// ignore the current sample and use currently available
// historical estimates.
assert(prev_sweep() + split_births() + coal_births() // "Total Production Stock"
>= split_deaths() + coal_deaths() + (ssize_t)count, // "Current stock + depletion"
"Conservation Principle");
if (inter_sweep_current > _threshold) {
ssize_t demand = prev_sweep() - (ssize_t)count + split_births() + coal_births()
- split_deaths() - coal_deaths();
assert(demand >= 0,
err_msg("Demand (" SSIZE_FORMAT ") should be non-negative for "
PTR_FORMAT " (size=" SIZE_FORMAT ")",
demand, p2i(this), count));
// Defensive: adjust for imprecision in event counting
if (demand < 0) {
demand = 0;
}
float old_rate = _demand_rate_estimate.padded_average();
float rate = ((float)demand)/inter_sweep_current;
_demand_rate_estimate.sample(rate);
float new_rate = _demand_rate_estimate.padded_average();
ssize_t old_desired = _desired;
float delta_ise = (CMSExtrapolateSweep ? intra_sweep_estimate : 0.0);
_desired = (ssize_t)(new_rate * (inter_sweep_estimate + delta_ise));
if (PrintFLSStatistics > 1) {
gclog_or_tty->print_cr("demand: " SSIZE_FORMAT ", old_rate: %f, current_rate: %f, "
"new_rate: %f, old_desired: " SSIZE_FORMAT ", new_desired: " SSIZE_FORMAT,
demand, old_rate, rate, new_rate, old_desired, _desired);
}
}
}
示例3: THROW_MSG_
// Walk the next batch of stack frames
//
// Parameters:
// stackStream StackStream object
// mode Stack walking mode.
// magic Must be valid value to continue the stack walk
// frame_count Number of frames to be decoded.
// start_index Start index to the user-supplied buffers.
// frames_array Buffer to store StackFrame in, starting at start_index.
//
// Returns the end index of frame filled in the buffer.
//
jint StackWalk::moreFrames(Handle stackStream, jlong mode, jlong magic,
int frame_count, int start_index,
objArrayHandle frames_array,
TRAPS)
{
JavaThread* jt = (JavaThread*)THREAD;
JavaFrameStream* existing_stream = JavaFrameStream::from_current(jt, magic, frames_array);
if (existing_stream == NULL) {
THROW_MSG_(vmSymbols::java_lang_InternalError(), "doStackWalk: corrupted buffers", 0L);
}
if (frames_array.is_null()) {
THROW_MSG_(vmSymbols::java_lang_NullPointerException(), "frames_array is NULL", 0L);
}
if (TraceStackWalk) {
tty->print_cr("StackWalk::moreFrames frame_count %d existing_stream " PTR_FORMAT " start %d frames %d",
frame_count, p2i(existing_stream), start_index, frames_array->length());
}
int end_index = start_index;
if (frame_count <= 0) {
return end_index; // No operation.
}
int count = frame_count + start_index;
assert (frames_array->length() >= count, "not enough space in buffers");
JavaFrameStream& stream = (*existing_stream);
if (!stream.at_end()) {
stream.next(); // advance past the last frame decoded in previous batch
if (!stream.at_end()) {
int n = fill_in_frames(mode, stream, frame_count, start_index,
frames_array, end_index, CHECK_0);
if (n < 1) {
THROW_MSG_(vmSymbols::java_lang_InternalError(), "doStackWalk: later decode failed", 0L);
}
return end_index;
}
}
return end_index;
}
示例4: assert
size_t ContiguousSpace::block_size(const HeapWord* p) const {
assert(MemRegion(bottom(), end()).contains(p),
"p (" PTR_FORMAT ") not in space [" PTR_FORMAT ", " PTR_FORMAT ")",
p2i(p), p2i(bottom()), p2i(end()));
HeapWord* current_top = top();
assert(p <= current_top,
"p > current top - p: " PTR_FORMAT ", current top: " PTR_FORMAT,
p2i(p), p2i(current_top));
assert(p == current_top || oop(p)->is_oop(),
"p (" PTR_FORMAT ") is not a block start - "
"current_top: " PTR_FORMAT ", is_oop: %s",
p2i(p), p2i(current_top), BOOL_TO_STR(oop(p)->is_oop()));
if (p < current_top) {
return oop(p)->size();
} else {
assert(p == current_top, "just checking");
return pointer_delta(end(), (HeapWord*) p);
}
}
示例5: guarantee
void HeapRegionManager::verify() {
guarantee(length() <= _allocated_heapregions_length,
"invariant: _length: %u _allocated_length: %u",
length(), _allocated_heapregions_length);
guarantee(_allocated_heapregions_length <= max_length(),
"invariant: _allocated_length: %u _max_length: %u",
_allocated_heapregions_length, max_length());
bool prev_committed = true;
uint num_committed = 0;
HeapWord* prev_end = heap_bottom();
for (uint i = 0; i < _allocated_heapregions_length; i++) {
if (!is_available(i)) {
prev_committed = false;
continue;
}
num_committed++;
HeapRegion* hr = _regions.get_by_index(i);
guarantee(hr != NULL, "invariant: i: %u", i);
guarantee(!prev_committed || hr->bottom() == prev_end,
"invariant i: %u " HR_FORMAT " prev_end: " PTR_FORMAT,
i, HR_FORMAT_PARAMS(hr), p2i(prev_end));
guarantee(hr->hrm_index() == i,
"invariant: i: %u hrm_index(): %u", i, hr->hrm_index());
// Asserts will fire if i is >= _length
HeapWord* addr = hr->bottom();
guarantee(addr_to_region(addr) == hr, "sanity");
// We cannot check whether the region is part of a particular set: at the time
// this method may be called, we have only completed allocation of the regions,
// but not put into a region set.
prev_committed = true;
prev_end = hr->end();
}
for (uint i = _allocated_heapregions_length; i < max_length(); i++) {
guarantee(_regions.get_by_index(i) == NULL, "invariant i: %u", i);
}
guarantee(num_committed == _num_committed, "Found %u committed regions, but should be %u", num_committed, _num_committed);
_free_list.verify();
}
示例6: fcloseTIMEOUT_FL
int fcloseTIMEOUT_FL(FL_PAR,FILE *fp)
{ int rcode;
if( fileno(fp) < 0 ){
porting_dbg("+++EPIPE[%d] fcloseTIMEOUT() for EOF",fileno(fp));
/*
return EOF;
9.8.2 should free the FILE structure.
*/
rcode = fcloseFILE(fp);
return rcode;
}
/*
* 9.8.2 this code is bad leaving FILE and descriptor unclosed.
* added in 2.4.8 maybe (?) intented to close disconnected stream
* without causing alarm signal for timeout (and buffer flushing ?).
if( feof(fp) )
return EOF;
*/
if( feof(fp) /*|| ferror(fp)*/ ){
if( ferror(fp) || LOG_VERBOSE )
sv1log("-- fcloseTIMEOUT(%X/%d/S%d) EOF=%d ERR=%d\n",
p2i(fp),fileno(fp),SocketOf(fileno(fp)),feof(fp),ferror(fp));
dupclosed_FL(FL_BAR,fileno(fp));
rcode = Xfclose(FL_BAR,fp);
return rcode;
}
{
fRETURN_ONTIMEOUTX(fp,-1,EOF,LIN_TIMEOUT+2);
/*
rcode = fclose(fp);
*/
rcode = Xfclose(FL_BAR,fp);
DONE_SUCCESSFULLY();
return rcode;
}
}
示例7: nm
inline void vframeStreamCommon::fill_from_compiled_frame(int decode_offset) {
_mode = compiled_mode;
// Range check to detect ridiculous offsets.
if (decode_offset == DebugInformationRecorder::serialized_null ||
decode_offset < 0 ||
decode_offset >= nm()->scopes_data_size()) {
// 6379830 AsyncGetCallTrace sometimes feeds us wild frames.
// If we read nmethod::scopes_data at serialized_null (== 0)
// or if read some at other invalid offset, invalid values will be decoded.
// Based on these values, invalid heap locations could be referenced
// that could lead to crashes in product mode.
// Therefore, do not use the decode offset if invalid, but fill the frame
// as it were a native compiled frame (no Java-level assumptions).
#ifdef ASSERT
if (WizardMode) {
tty->print_cr("Error in fill_from_frame: pc_desc for "
INTPTR_FORMAT " not found or invalid at %d",
p2i(_frame.pc()), decode_offset);
nm()->print();
nm()->method()->print_codes();
nm()->print_code();
nm()->print_pcs();
}
#endif
// Provide a cheap fallback in product mode. (See comment above.)
found_bad_method_frame();
fill_from_compiled_native_frame();
return;
}
// Decode first part of scopeDesc
DebugInfoReadStream buffer(nm(), decode_offset);
_sender_decode_offset = buffer.read_int();
_method = buffer.read_method();
_bci = buffer.read_bci();
assert(_method->is_method(), "checking type of decoded method");
}
示例8: myThread
void ThreadLocalAllocBuffer::print_stats(const char* tag) {
Thread* thrd = myThread();
size_t waste = _gc_waste + _slow_refill_waste + _fast_refill_waste;
size_t alloc = _number_of_refills * _desired_size;
double waste_percent = alloc == 0 ? 0.0 :
100.0 * waste / alloc;
size_t tlab_used = Universe::heap()->tlab_used(thrd);
gclog_or_tty->print("TLAB: %s thread: " INTPTR_FORMAT " [id: %2d]"
" desired_size: " SIZE_FORMAT "KB"
" slow allocs: %d refill waste: " SIZE_FORMAT "B"
" alloc:%8.5f %8.0fKB refills: %d waste %4.1f%% gc: %dB"
" slow: %dB fast: %dB\n",
tag, p2i(thrd), thrd->osthread()->thread_id(),
_desired_size / (K / HeapWordSize),
_slow_allocations, _refill_waste_limit * HeapWordSize,
_allocation_fraction.average(),
_allocation_fraction.average() * tlab_used / K,
_number_of_refills, waste_percent,
_gc_waste * HeapWordSize,
_slow_refill_waste * HeapWordSize,
_fast_refill_waste * HeapWordSize);
}
示例9: do_oop_work
template <class T> void do_oop_work(T* p) {
HeapWord* jp = (HeapWord*)p;
assert(jp >= _begin && jp < _end,
err_msg("Error: jp " PTR_FORMAT " should be within "
"[_begin, _end) = [" PTR_FORMAT "," PTR_FORMAT ")",
p2i(jp), p2i(_begin), p2i(_end)));
oop obj = oopDesc::load_decode_heap_oop(p);
if (!(obj == NULL || (HeapWord*)obj >= _boundary)) {
tty->print_cr("pointer " PTR_FORMAT " at " PTR_FORMAT " on "
"clean card crosses boundary" PTR_FORMAT,
p2i((HeapWord*)obj), p2i(jp), p2i(_boundary));
#ifndef PRODUCT
obj->print();
#endif
had_error = true;
}
}
示例10: assert_different_registers
inline void assert_different_registers(
AbstractRegister a,
AbstractRegister b,
AbstractRegister c,
AbstractRegister d,
AbstractRegister e,
AbstractRegister f,
AbstractRegister g,
AbstractRegister h
) {
assert(
a != b && a != c && a != d && a != e && a != f && a != g && a != h
&& b != c && b != d && b != e && b != f && b != g && b != h
&& c != d && c != e && c != f && c != g && c != h
&& d != e && d != f && d != g && d != h
&& e != f && e != g && e != h
&& f != g && f != h
&& g != h,
"registers must be different: a=" INTPTR_FORMAT ", b=" INTPTR_FORMAT
", c=" INTPTR_FORMAT ", d=" INTPTR_FORMAT ", e=" INTPTR_FORMAT
", f=" INTPTR_FORMAT ", g=" INTPTR_FORMAT ", h=" INTPTR_FORMAT "",
p2i(a), p2i(b), p2i(c), p2i(d), p2i(e), p2i(f), p2i(g), p2i(h)
);
}
示例11: assert
void CompiledIC::set_to_clean(bool in_use) {
assert(SafepointSynchronize::is_at_safepoint() || CompiledIC_lock->is_locked() , "MT-unsafe call");
if (TraceInlineCacheClearing || TraceICs) {
tty->print_cr("[email protected]" INTPTR_FORMAT ": set to clean", p2i(instruction_address()));
print();
}
address entry;
if (is_optimized()) {
entry = SharedRuntime::get_resolve_opt_virtual_call_stub();
} else {
entry = SharedRuntime::get_resolve_virtual_call_stub();
}
// A zombie transition will always be safe, since the metadata has already been set to NULL, so
// we only need to patch the destination
bool safe_transition = !in_use || is_optimized() || SafepointSynchronize::is_at_safepoint();
if (safe_transition) {
// Kill any leftover stub we might have too
clear_ic_stub();
if (is_optimized()) {
set_ic_destination(entry);
} else {
set_ic_destination_and_value(entry, (void*)NULL);
}
} else {
// Unsafe transition - create stub.
InlineCacheBuffer::create_transition_stub(this, NULL, entry);
}
// We can't check this anymore. With lazy deopt we could have already
// cleaned this IC entry before we even return. This is possible if
// we ran out of space in the inline cache buffer trying to do the
// set_next and we safepointed to free up space. This is a benign
// race because the IC entry was complete when we safepointed so
// cleaning it immediately is harmless.
// assert(is_clean(), "sanity check");
}
示例12: assert
void AdaptiveFreeList<Chunk>::verify_stats() const {
// The +1 of the LH comparand is to allow some "looseness" in
// checking: we usually call this interface when adding a block
// and we'll subsequently update the stats; we cannot update the
// stats beforehand because in the case of the large-block BT
// dictionary for example, this might be the first block and
// in that case there would be no place that we could record
// the stats (which are kept in the block itself).
assert((_allocation_stats.prev_sweep() + _allocation_stats.split_births()
+ _allocation_stats.coal_births() + 1) // Total Production Stock + 1
>= (_allocation_stats.split_deaths() + _allocation_stats.coal_deaths()
+ (ssize_t)count()), // Total Current Stock + depletion
err_msg("FreeList " PTR_FORMAT " of size " SIZE_FORMAT
" violates Conservation Principle: "
"prev_sweep(" SIZE_FORMAT ")"
" + split_births(" SIZE_FORMAT ")"
" + coal_births(" SIZE_FORMAT ") + 1 >= "
" split_deaths(" SIZE_FORMAT ")"
" coal_deaths(" SIZE_FORMAT ")"
" + count(" SSIZE_FORMAT ")",
p2i(this), size(), _allocation_stats.prev_sweep(), _allocation_stats.split_births(),
_allocation_stats.split_births(), _allocation_stats.split_deaths(),
_allocation_stats.coal_deaths(), count()));
}
示例13: DTRACE_CLASSLOAD_PROBE
void ClassLoadingService::notify_class_unloaded(InstanceKlass* k) {
DTRACE_CLASSLOAD_PROBE(unloaded, k, false);
// Classes that can be unloaded must be non-shared
_classes_unloaded_count->inc();
if (UsePerfData) {
// add the class size
size_t size = compute_class_size(k);
_classbytes_unloaded->inc(size);
// Compute method size & subtract from running total.
// We are called during phase 1 of mark sweep, so it's
// still ok to iterate through Method*s here.
Array<Method*>* methods = k->methods();
for (int i = 0; i < methods->length(); i++) {
_class_methods_size->inc(-methods->at(i)->size());
}
}
if (TraceClassUnloading) {
ResourceMark rm;
tty->print_cr("[Unloading class %s " INTPTR_FORMAT "]", k->external_name(), p2i(k));
}
}
示例14: assert_different_registers
inline void assert_different_registers(
AbstractRegister a,
AbstractRegister b,
AbstractRegister c,
AbstractRegister d,
AbstractRegister e,
AbstractRegister f
) {
assert(
a != b && a != c && a != d && a != e && a != f
&& b != c && b != d && b != e && b != f
&& c != d && c != e && c != f
&& d != e && d != f
&& e != f,
err_msg_res("registers must be different: a=" INTPTR_FORMAT ", b=" INTPTR_FORMAT
", c=" INTPTR_FORMAT ", d=" INTPTR_FORMAT ", e=" INTPTR_FORMAT
", f=" INTPTR_FORMAT "",
p2i(a), p2i(b), p2i(c), p2i(d), p2i(e), p2i(f))
);
}
示例15: assert
inline void CompactibleSpace::scan_and_adjust_pointers(SpaceType* space) {
// adjust all the interior pointers to point at the new locations of objects
// Used by MarkSweep::mark_sweep_phase3()
HeapWord* cur_obj = space->bottom();
HeapWord* const end_of_live = space->_end_of_live; // Established by "scan_and_forward".
HeapWord* const first_dead = space->_first_dead; // Established by "scan_and_forward".
assert(first_dead <= end_of_live, "Stands to reason, no?");
const intx interval = PrefetchScanIntervalInBytes;
debug_only(HeapWord* prev_obj = NULL);
while (cur_obj < end_of_live) {
Prefetch::write(cur_obj, interval);
if (cur_obj < first_dead || oop(cur_obj)->is_gc_marked()) {
// cur_obj is alive
// point all the oops to the new location
size_t size = MarkSweep::adjust_pointers(oop(cur_obj));
size = space->adjust_obj_size(size);
debug_only(prev_obj = cur_obj);
cur_obj += size;
} else {
debug_only(prev_obj = cur_obj);
// cur_obj is not a live object, instead it points at the next live object
cur_obj = *(HeapWord**)cur_obj;
assert(cur_obj > prev_obj, "we should be moving forward through memory, cur_obj: " PTR_FORMAT ", prev_obj: " PTR_FORMAT, p2i(cur_obj), p2i(prev_obj));
}
}
assert(cur_obj == end_of_live, "just checking");
}