void LLVMState::compile_soon(STATE, CompiledMethod* cm, BlockEnvironment* block) { Object* placement; bool is_block = false; bool wait = config().jit_sync; // Ignore it! if(cm->backend_method()->call_count < 0) { if(config().jit_inline_debug) { log() << "JIT: ignoring candidate! " << symbol_cstr(cm->name()) << "\n"; } return; } if(config().jit_inline_debug) { log() << "JIT: queueing method: " << symbol_cstr(cm->name()) << "\n"; } cm->backend_method()->call_count = -1; if(block) { is_block = true; placement = block; } else { placement = Qnil; } BackgroundCompileRequest* req = new BackgroundCompileRequest(state, cm, placement, is_block); queued_methods_++; if(wait) { thread::Condition cond; req->set_waiter(&cond); thread::Mutex mux; mux.lock(); background_thread_->add(req); cond.wait(mux); mux.unlock(); if(config().jit_inline_debug) { log() << "JIT: compiled method: " << symbol_cstr(cm->name()) << "\n"; } } else { background_thread_->add(req); if(state->shared.config.jit_show_compiling) { llvm::outs() << "[[[ JIT Queued" << (block ? " block " : " method ") << queued_methods() << "/" << jitted_methods() << " ]]]\n"; } } }
void LLVMState::compile_soon(STATE, GCToken gct, CompiledCode* code, CallFrame* call_frame, Object* placement, bool is_block) { bool wait = config().jit_sync; if(code->machine_code()->call_count <= 1) { return; } if(code->machine_code()->compiling_p()) { return; } int hits = code->machine_code()->call_count; code->machine_code()->set_compiling(); BackgroundCompileRequest* req = new BackgroundCompileRequest(state, code, placement, hits, is_block); queued_methods_++; if(wait) { wait_mutex.lock(); req->set_waiter(&wait_cond); background_thread_->add(req); state->set_call_frame(call_frame); gc_independent(); wait_cond.wait(wait_mutex); wait_mutex.unlock(); gc_dependent(); state->set_call_frame(0); if(state->shared().config.jit_show_compiling) { llvm::outs() << "[[[ JIT compiled " << enclosure_name(code) << "#" << symbol_debug_str(code->name()) << (req->is_block() ? " (block) " : " (method) ") << queued_methods() << "/" << jitted_methods() << " ]]]\n"; } } else { background_thread_->add(req); if(state->shared().config.jit_show_compiling) { llvm::outs() << "[[[ JIT queued " << enclosure_name(code) << "#" << symbol_debug_str(code->name()) << (req->is_block() ? " (block) " : " (method) ") << queued_methods() << "/" << jitted_methods() << " ]]]\n"; } } }
void LLVMState::compile_soon(STATE, CompiledMethod* cm, Object* placement, bool is_block) { bool wait = config().jit_sync; // Ignore it! if(cm->backend_method()->call_count <= 1) { // if(config().jit_inline_debug) { // log() << "JIT: ignoring candidate! " // << symbol_debug_str(cm->name()) << "\n"; // } return; } if(debug_search) { if(is_block) { std::cout << "JIT: queueing block inside: " << enclosure_name(cm) << "#" << symbol_debug_str(cm->name()) << std::endl; } else { std::cout << "JIT: queueing method: " << enclosure_name(cm) << "#" << symbol_debug_str(cm->name()) << std::endl; } } // Don't do this because it prevents other class from heating // it up too! cm->backend_method()->call_count = -1; BackgroundCompileRequest* req = new BackgroundCompileRequest(state, cm, placement, is_block); queued_methods_++; if(wait) { thread::Condition cond; req->set_waiter(&cond); thread::Mutex mux; mux.lock(); background_thread_->add(req); cond.wait(mux); mux.unlock(); // if(config().jit_inline_debug) { // if(block) { // log() << "JIT: compiled block inside: " // << symbol_debug_str(cm->name()) << "\n"; // } else { // log() << "JIT: compiled method: " // << symbol_debug_str(cm->name()) << "\n"; // } // } } else { background_thread_->add(req); if(state->shared().config.jit_show_compiling) { llvm::outs() << "[[[ JIT Queued" << (is_block ? " block " : " method ") << queued_methods() << "/" << jitted_methods() << " ]]]\n"; } } }