void __stdcall methodEntry(const char * methodName, U_32 argInfoCount, CallingConvention::OpndInfo * argInfos) { JitFrameContext context; #ifdef _EM64T_ context.rsp=(POINTER_SIZE_INT)(&methodName+sizeof(POINTER_SIZE_INT)); // must point to the beginning of incoming stack args #else context.esp=(POINTER_SIZE_INT)(&methodName+sizeof(POINTER_SIZE_INT)); // must point to the beginning of incoming stack args #endif ::std::ostream & os=Log::cat_rt()->out(); os<<"__METHOD_ENTRY__:"<<methodName<<::std::endl; os<<"\t("; printRuntimeArgs(os, argInfoCount, argInfos, &context); os<<")"<<::std::endl; if (tm == NULL) { tm = new (mm) TypeManager(mm); tm->init(); } for (U_32 i=0; i<argInfoCount; i++){ CallingConvention::OpndInfo & info=argInfos[i]; U_32 cb=0; U_8 arg[4*sizeof(U_32)]; for (U_32 j=0; j<info.slotCount; j++){ if (!info.isReg){ #ifdef _EM64T_ *(POINTER_SIZE_INT*)(arg+cb)=((POINTER_SIZE_INT*)context.rsp)[info.slots[j]]; #else *(U_32*)(arg+cb)=((U_32*)context.esp)[info.slots[j]]; #endif cb+=sizeof(U_32); }else{ m_assert(info.isReg); m_assert(0); } } if (Type::isObject((Type::Tag)info.typeTag)){ GCMap::checkObject(*tm, *(const void**)(const void*)arg); } } }
int main(int argc, char **argv) { for (int i = 1; i < argc; i += 1) { if (!strcmp(argv[i], "-help")) { printf("option: -help -list\n"); printf("selection: all || test_name || skip_test_name\n"); return 0; } } uint num_test_performed = 0; m_scope_exit(printf("Performed %d tests\n", num_test_performed)); m_test(math) { m_case(matrix) { mat4 m = mat4{} * mat4_identity(); m_assert(m == mat4{}); m = mat4_identity(); mat4 m_inv = mat4_inverse(m); m_assert(m == m_inv); } } }
void MemoryManager::_free_arenas(Arena *a) { while(a != NULL) { Arena* last = a; a = a->next_arena; #ifdef JIT_MEM_CHECK checkPointsMutex.lock(); _check_arena_paddings(last); CheckPointsByArena::iterator it = checkPointsByArena.find(last); m_assert(it!=checkPointsByArena.end()); std::vector<size_t>* v = it->second; checkPointsByArena.erase(it); delete v; checkPointsMutex.unlock(); #endif free_arena(last); } }
void worker(ThreadPool *tp) { for (; ;) { std::unique_lock<std::mutex> lock(tp->queue_mutex); if (tp->stop && tp->nr_active_thread == 0 && tp->tasks.empty()) return; while (tp->tasks.empty()) { Timer wttt; // fprintf(stderr, "waiting %lu\n", tp->tasks.size()); tp->condition.wait(lock); // fprintf(stderr, "after waiting\n"); if (tp->stop && tp->nr_active_thread == 0 && tp->tasks.empty()) return; print_debug("thread got a job after waiting for %.4lf secs\n", wttt.get_time()); } m_assert(tp->tasks.size()); std::function<void()> task(tp->tasks.top().second); tp->tasks.pop(); lock.unlock(); /* *{ // old one * std::lock_guard<std::mutex> lock(tp->nr_active_thread_mutex); * tp->nr_active_thread ++; * // fprintf(stderr, "++: %d, q:%d\n", tp->nr_active_thread, (int)tp->tasks.size()); *} */ __sync_fetch_and_add(&(tp->nr_active_thread), 1); task(); { // std::lock_guard<std::mutex> lock_queue(tp->queue_mutex); std::lock_guard<std::mutex> lock(tp->nr_active_thread_mutex); tp->nr_active_thread --; // fprintf(stderr, "--: %d, q:%d\n", tp->nr_active_thread, (int)tp->tasks.size()); if (tp->stop && tp->nr_active_thread == 0 && tp->tasks.empty()) { // fprintf(stderr, "notify\n"); tp->condition.notify_all(); return; } } } }