int main(int argc, const char *argv[]) { /* generate a array with 30 elements, and do hex dump */ unsigned char t_arr_t[295] = {0}; get_random_bytes(t_arr_t, sizeof(t_arr_t)); //lamont_hdump((char*)t_arr_t, sizeof(t_arr_t)); //print_buf((char*)t_arr_t, sizeof(t_arr_t)); print_buf2((char*)t_arr_t, sizeof(t_arr_t)); /* check interval time */ #if 0 static int work_time = 0; #define WORK_INTERVAL_TIME 5 if (1 == check_work_time(&work_time, WORK_INTERVAL_TIME)) { printf("time to do job.\n"); } else { printf("free time.\n"); } sleep(3); if (1 == check_work_time(&work_time, WORK_INTERVAL_TIME)) { printf("time to do job.\n"); } else { printf("free time.\n"); } sleep(3); if (1 == check_work_time(&work_time, WORK_INTERVAL_TIME)) { printf("time to do job.\n"); } else { printf("free time.\n"); } sleep(2); if (1 == check_work_time(&work_time, WORK_INTERVAL_TIME)) { printf("time to do job.\n"); } else { printf("free time.\n"); } #endif #if 0 #define PRINT(a) printf(#a"=%d\n", a) int a = 5; int b = 3; PRINT(a); PRINT(b); SWAP(a,b); PRINT(a); PRINT(b); #endif /* splits string to array */ int i=0; char results[50][MAX_STR_LEN] = {}; /* char *test = ""; char *test = " "; char *test = "abc 123 55 66 a12cc"; */ char *test = " abc 123 55 66 a12cc "; int count = get_buffer_all(test, ' ', results, sizeof(results)); for (i=0; i<count; i++) printf("results[%d] = %s\n", i, results[i]); TIME_START(); system("ls"); TIME_END(); return 0; }
void ForkJoinNursery::pjsCollection(int op) { JS_ASSERT((op & Collect) != (op & Evacuate)); bool evacuate = op & Evacuate; bool recreate = op & Recreate; JS_ASSERT(!isEvacuating_); JS_ASSERT(!evacuationZone_); JS_ASSERT(!head_); JS_ASSERT(tail_ == &head_); JSRuntime *const rt = shared_->runtime(); const unsigned currentNumActiveChunks_ = numActiveChunks_; const char *msg = ""; JS_ASSERT(!rt->needsBarrier()); TIME_START(pjsCollection); rt->incFJMinorCollecting(); if (evacuate) { isEvacuating_ = true; evacuationZone_ = shared_->zone(); } flip(); if (recreate) { initNewspace(); // newspace must be at least as large as fromSpace numActiveChunks_ = currentNumActiveChunks_; } ForkJoinNurseryCollectionTracer trc(rt, this); forwardFromRoots(&trc); collectToFixedPoint(&trc); #ifdef JS_ION jit::UpdateJitActivationsForMinorGC(TlsPerThreadData.get(), &trc); #endif freeFromspace(); size_t live = movedSize_; computeNurserySizeAfterGC(live, &msg); sweepHugeSlots(); JS_ASSERT(hugeSlots[hugeSlotsFrom].empty()); JS_ASSERT_IF(isEvacuating_, hugeSlots[hugeSlotsNew].empty()); isEvacuating_ = false; evacuationZone_ = nullptr; head_ = nullptr; tail_ = &head_; movedSize_ = 0; rt->decFJMinorCollecting(); TIME_END(pjsCollection); // Note, the spew is awk-friendly, non-underlined words serve as markers: // FJGC _tag_ us _value_ copied _value_ size _value_ _message-word_ ... shared_->spewGC("FJGC %s us %5" PRId64 " copied %7" PRIu64 " size %" PRIu64 " %s", (evacuate ? "evacuate " : "collect "), TIME_TOTAL(pjsCollection), (uint64_t)live, (uint64_t)numActiveChunks_*1024*1024, msg); }