bool Directory::cp(const File& file) { // exe ise direk deep-independet copy al const Executable *temp = dynamic_cast<const Executable *> (&file); if (temp != NULL) { Executable *nExe = new Executable(*temp); nExe->setTime("18/12/15"); // zamanlar temsilidir nExe->updatePath(this->path() + "/" + nExe->getName()); //path guncelle m_inFiles.insert(nExe); // containere sirali olarak ekle } // klasor ise copy constuctor ile o klasorun deep copy sini al const Directory *temp1 = dynamic_cast<const Directory *> (&file); if (temp1 != NULL) { Directory *nDir = new Directory(*temp1); nDir->setTime("19/12/15"); // zamanlar temsilidir nDir->updatePath(this->path() + "/" + nDir->getName()); // path upd. m_inFiles.insert(nDir); } // text dosyasi ise direk copy al const TextFile *temp2 = dynamic_cast<const TextFile *> (&file); if (temp2 != NULL) { TextFile *nText = new TextFile(*temp2); nText->setTime("21/12/15"); // zamanlar temsilidir nText->updatePath(this->path() + "/" + nText->getName()); m_inFiles.insert(nText); } // dangling pointers temp = NULL; temp1 = NULL; temp2 = NULL; return true; }
Object* CallSite::empty_cache(STATE, CallSite* call_site, CallFrame* call_frame, Arguments& args) { Object* const recv = args.recv(); Class* const recv_class = recv->direct_class(state); LookupData lookup(call_frame->self(), recv->lookup_begin(state), G(sym_public)); Dispatch dis(call_site->name()); if(!dis.resolve(state, call_site->name(), lookup)) { if(!lookup_method_missing(state, call_frame, args, dis, call_frame->self(), recv->lookup_begin(state))) { return NULL; } } state->vm()->metrics().machine.methods_invoked++; call_site->update(state, recv_class, dis); Executable* meth = dis.method; Module* mod = dis.module; if(meth->custom_call_site_p()) { CallSiteInformation info(call_site->executable(), call_site->ip()); state->set_call_site_information(&info); Object* res = meth->execute(state, call_frame, meth, mod, args); state->set_call_site_information(NULL); return res; } else { return meth->execute(state, call_frame, meth, mod, args); } }
void SafeManager::onExecutableStdout(void* which, const char* msg) { WAIT_SEMAPHOR(); Executable* exe = static_cast<Executable*>(which); if(eventReceiver) eventReceiver->onModStdout(exe->getID(), msg); POST_SEMAPHOR(); }
void SafeManager::onExecutableDied(void* which) { WAIT_SEMAPHOR(); Executable* exe = static_cast<Executable*>(which); if(eventReceiver && exe) eventReceiver->onModStop(exe->getID()); POST_SEMAPHOR(); }
static void hookup_prim(STATE, Symbol* meth, Symbol* prim) { MethodTable* tbl = G(rubinius)->metaclass(state)->method_table(); Executable* oc = Executable::allocate(state, Qnil); oc->primitive(state, prim); assert(oc->resolve_primitive(state)); tbl->store(state, meth, oc, G(sym_public)); }
Object* CallSite::empty_cache_super(STATE, CallSite* call_site, CallFrame* call_frame, Arguments& args) { Symbol* original_name = call_frame->original_name(); if(call_site->name_ != original_name) { call_site->name_ = original_name; args.set_name(call_site->name_); } Object* const recv = args.recv(); Class* const recv_class = recv->direct_class(state); Module* const start = call_frame->module()->superclass(); LookupData lookup(call_frame->self(), start, G(sym_private)); Dispatch dis(call_site->name()); if(start->nil_p() || !dis.resolve(state, call_site->name(), lookup)) { LookupData missing_lookup(call_frame->self(), recv->lookup_begin(state), G(sym_private)); Dispatch missing_dis(G(sym_method_missing)); if(!missing_dis.resolve(state, G(sym_method_missing), missing_lookup)) { std::ostringstream msg; msg << "no method_missing for "; msg << recv_class->to_string(state); msg << "#" << call_site->name()->to_string(state); Exception::internal_error(state, call_frame, msg.str().c_str()); return 0; } args.unshift(state, call_site->name()); dis.method = missing_dis.method; dis.module = missing_dis.module; dis.method_missing = eSuper; state->vm()->set_method_missing_reason(dis.method_missing); state->vm()->global_cache()->add_seen(state, call_site->name()); } state->vm()->metrics().machine.methods_invoked++; call_site->update(state, recv_class, dis); Executable* meth = dis.method; Module* mod = dis.module; if(meth->custom_call_site_p()) { CallSiteInformation info(call_site->executable(), call_site->ip()); state->set_call_site_information(&info); Object* res = meth->execute(state, call_frame, meth, mod, args); state->set_call_site_information(NULL); return res; } else { return meth->execute(state, call_frame, meth, mod, args); } }
Executable* Executable::allocate(STATE, Object* self) { Executable* executable = state->memory()->new_object<Executable>(state, G(executable)); Executable::initialize(state, executable, Executable::default_executor); if(Class* cls = try_as<Class>(self)) { executable->klass(state, cls); } return executable; }
void AnimationTestDlg::closeEvent(QCloseEvent* pEvent) { if (mpPlugIn != NULL) { Executable* pExecutable = dynamic_cast<Executable*>(mpPlugIn); if (pExecutable != NULL) { pExecutable->abort(); } } QDialog::closeEvent(pEvent); }
Executable* Executable::allocate(STATE, Object* self) { Executable* executable = state->new_object<Executable>(G(executable)); executable->primitive(state, (Symbol*)Qnil); executable->serial(state, Fixnum::from(0)); executable->set_executor(Executable::default_executor); if(kind_of<Class>(self)) { state->om->set_class(executable, self); } return executable; }
bool AutoImporter::abort() { Executable* pExecutable = dynamic_cast<Executable*>(mpPlugIn); if (pExecutable != NULL) { if (pExecutable->hasAbort() == true) { return pExecutable->abort(); } } return false; }
Object* CallSite::empty_cache_super(STATE, CallSite* call_site, CallFrame* call_frame, Arguments& args) { Symbol* original_name = call_frame->original_name(); if(call_site->name_ != original_name) { call_site->name_ = original_name; args.set_name(call_site->name_); } Object* const recv = args.recv(); Class* const recv_class = recv->lookup_begin(state); Module* const start = call_frame->module()->superclass(); LookupData lookup(call_frame->self(), start, G(sym_private)); Dispatch dis(call_site->name()); if(start->nil_p() || !dis.resolve(state, call_site->name(), lookup)) { LookupData missing_lookup(call_frame->self(), recv_class, G(sym_private)); Dispatch missing_dis(G(sym_method_missing)); missing_dis.resolve(state, G(sym_method_missing), missing_lookup); if(missing_dis.method_missing != eNone) { Exception::internal_error(state, call_frame, "no method_missing"); return 0; } args.unshift(state, call_site->name()); dis.method = missing_dis.method; dis.module = missing_dis.module; dis.method_missing = eSuper; state->vm()->set_method_missing_reason(dis.method_missing); } call_site->update(state, recv_class, dis); Executable* meth = dis.method; Module* mod = dis.module; if(meth->custom_call_site_p()) { CallSiteInformation info(call_site->executable(), call_site->ip()); state->set_call_site_information(&info); Object* res = meth->execute(state, call_frame, meth, mod, args); state->set_call_site_information(NULL); return res; } else { return meth->execute(state, call_frame, meth, mod, args); } }
Object* InlineCache::empty_cache(STATE, InlineCache* cache, CallFrame* call_frame, Arguments& args) { args.set_name(cache->name); Object* const recv = args.recv(); Class* const recv_class = recv->lookup_begin(state); MethodCacheEntry* mce = 0; MethodMissingReason reason = cache->fill_public(state, call_frame->self(), cache->name, recv_class, mce); if(reason != eNone) { state->vm()->set_method_missing_reason(reason); if(!cache->fill_method_missing(state, recv_class, mce)) { Exception::internal_error(state, call_frame, "no method_missing"); return 0; } args.unshift(state, cache->name); cache->execute_backend_ = check_cache_mm; } else { if(recv->fixnum_p()) { cache->execute_backend_ = check_cache_fixnum; } else if(recv->symbol_p()) { cache->execute_backend_ = check_cache_symbol; } else if(recv->reference_p()) { cache->execute_backend_ = check_cache_reference; } else { cache->execute_backend_ = check_cache; } } // Make sure we sync here, so the MethodCacheEntry mce is // guaranteed completely initialized. Otherwise another thread // might see an incompletely initialized MethodCacheEntry. atomic::memory_barrier(); cache->cache_ = mce; cache->update_seen_classes(mce); call_frame->cm->write_barrier(state, mce); Executable* meth = mce->method(); Module* mod = mce->stored_module(); return meth->execute(state, call_frame, meth, mod, args); }
void System::attach_primitive(STATE, Module* mod, bool meta, Symbol* name, Symbol* prim) { MethodTable* tbl; if(meta) { tbl = mod->singleton_class(state)->method_table(); } else { tbl = mod->method_table(); } Executable* oc = Executable::allocate(state, Qnil); oc->primitive(state, prim); oc->resolve_primitive(state); tbl->store(state, name, oc, G(sym_public)); }
Executable* Executable::allocate(STATE, Object* self) { Executable* executable = state->new_object<Executable>(G(executable)); executable->primitive(state, nil<Symbol>()); executable->serial(state, Fixnum::from(0)); executable->inliners_ = 0; executable->prim_index_ = -1; executable->set_executor(Executable::default_executor); if(Class* cls = try_as<Class>(self)) { executable->klass(state, cls); } return executable; }
Object* InlineCache::empty_cache_super(STATE, InlineCache* cache, CallFrame* call_frame, Arguments& args) { Symbol* original_name = call_frame->original_name(); if(cache->name != original_name) { cache->name = original_name; } args.set_name(cache->name); Object* const recv = args.recv(); Class* const recv_class = recv->lookup_begin(state); MethodCacheEntry* mce = 0; Module* const start = call_frame->module()->superclass(); if(start->nil_p() || !cache->fill_private(state, cache->name, start, recv_class, mce)) { state->vm()->set_method_missing_reason(eSuper); // Don't use start when looking up method_missing! // Always completely redispatch for method_missing. // github#157 if(!cache->fill_method_missing(state, recv_class, mce)) { Exception::internal_error(state, call_frame, "no method_missing"); return 0; } args.unshift(state, cache->name); cache->execute_backend_ = check_cache_super_mm; } else { cache->execute_backend_ = check_cache_super; } // Make sure we sync here, so the MethodCacheEntry mce is // guaranteed completely initialized. Otherwise another thread // might see an incompletely initialized MethodCacheEntry. atomic::memory_barrier(); cache->cache_ = mce; cache->update_seen_classes(mce); call_frame->cm->write_barrier(state, mce); Executable* meth = mce->method(); Module* mod = mce->stored_module(); return meth->execute(state, call_frame, meth, mod, args); }
bool CallingConvention_x86_64_systemv::matches(TargetInfo &target, Executable &executable) const { const char arch[] = "x86"; const char exe[] = "ELF 64"; return strncmp(target.targetName().c_str(), arch, sizeof arch - 1) == 0 && strncmp(executable.getExecutableType().c_str(), exe, sizeof exe - 1) == 0; }
Object* InlineCache::check_cache(STATE, InlineCache* cache, CallFrame* call_frame, Arguments& args) { MethodCacheEntry* mce = cache->cache_; args.set_name(cache->name); if(likely(mce && mce->receiver_class() == args.recv()->lookup_begin(state))) { Executable* meth = mce->method(); Module* mod = mce->stored_module(); return meth->execute(state, call_frame, meth, mod, args); } return cache->initialize(state, call_frame, args); }
Object* PolyInlineCache::check_cache(STATE, CallSite* call_site, Arguments& args) { Class* const recv_class = args.recv()->direct_class(state); PolyInlineCache* cache = static_cast<PolyInlineCache*>(call_site); InlineCacheEntry* entry = cache->get_entry(recv_class); if(likely(entry)) { Executable* meth = entry->method(); Module* mod = entry->stored_module(); entry->hit(); state->vm()->metrics().machine.methods_invoked++; return meth->execute(state, meth, mod, args); } return cache->fallback(state, args); }
Case* CaseBuilder::construct() { Q_ASSERT(m_executable); QFileInfo exeLocation(m_executable->location().toLocalFile()); QString cazeName = m_executable->name(); if (!m_suite.isEmpty() && cazeName.startsWith(m_suite + '-')) { QStringList spl = cazeName.split('-'); Q_ASSERT(spl.count() > 1); spl.removeFirst(); cazeName = spl.join("-"); } Case* caze = new Case(cazeName, exeLocation); caze->setExecutable( m_executable ); Executable* exe = m_executable; //exe->setLocation(KUrl(exeLocation.absoluteFilePath())); m_executable->setCase(caze); exe->setOutputParser( new OutputParser); QStringList exeFunctionOut = m_executable->fetchFunctions(); bool success = false; foreach(QString line, exeFunctionOut) { //krazy:exclude=foreach if (line.endsWith(QLatin1String("()")) && !line.contains(QLatin1String(" "))) { // recognize this as a legit qtest function output line line.chop(2); // remove "()" Command* foo = new Command(line, caze); caze->addChild(foo); success = true; } else { // garbage if (!line.isEmpty()) { kDebug() << "Garbage line:\n" << line; } } } if (success) { return caze; } else { delete caze; return 0; } }
hsa_status_t amd_executable_iterate_loaded_code_objects( hsa_executable_t executable, hsa_status_t (*callback)( amd_loaded_code_object_t loaded_code_object, void *data), void *data) { if (!core::Runtime::runtime_singleton_->IsOpen()) { return HSA_STATUS_ERROR_NOT_INITIALIZED; } if (nullptr == callback) { return HSA_STATUS_ERROR_INVALID_ARGUMENT; } Executable *exec = Executable::Object(executable); if (nullptr == exec) { return HSA_STATUS_ERROR_INVALID_EXECUTABLE; } return exec->IterateLoadedCodeObjects(callback, data); }
void Executable::Info::mark_inliners(Object* obj, memory::ObjectMark& mark) { Executable* exc = static_cast<Executable*>(obj); if(!exc->inliners() || exc->inliners() == (Inliners*)cNil) return; Inliners* inl = exc->inliners(); inl->set_mark(); // std::cout << "Marking inliners: " << inl->inliners().size() << "\n"; for(std::vector<CompiledCode*>::iterator i = inl->inliners().begin(); i != inl->inliners().end(); ++i) { CompiledCode* code = *i; if(Object* tmp = mark.call(code)) { *i = static_cast<CompiledCode*>(tmp); mark.just_set(obj, tmp); } } }
hsa_status_t amd_executable_load_code_object( hsa_executable_t executable, hsa_agent_t agent, hsa_code_object_t code_object, const char *options, amd_loaded_code_object_t *loaded_code_object) { if (!core::Runtime::runtime_singleton_->IsOpen()) { return HSA_STATUS_ERROR_NOT_INITIALIZED; } if (nullptr == loaded_code_object) { return HSA_STATUS_ERROR_INVALID_ARGUMENT; } Executable *exec = Executable::Object(executable); if (nullptr == exec) { return HSA_STATUS_ERROR_INVALID_EXECUTABLE; } return exec->LoadCodeObject(agent, code_object, options, loaded_code_object); }
Object* InlineCache::check_cache_super_mm(STATE, InlineCache* cache, CallFrame* call_frame, Arguments& args) { MethodCacheEntry* mce = cache->cache_; Symbol* current_name = call_frame->original_name(); args.set_name(cache->name); if(likely(mce && mce->receiver_class() == args.recv()->lookup_begin(state) && current_name == cache->name)) { args.unshift(state, cache->name); Executable* meth = mce->method(); Module* mod = mce->stored_module(); return meth->execute(state, call_frame, meth, mod, args); } cache->name = current_name; return cache->initialize(state, call_frame, args); }
Object* InlineCache::check_cache_reference(STATE, InlineCache* cache, CallFrame* call_frame, Arguments& args) { MethodCacheEntry* mce = cache->cache_; args.set_name(cache->name); Object* const recv = args.recv(); if(likely(mce && recv->reference_p() && recv->reference_class() == mce->receiver_class())) { Executable* meth = mce->method(); Module* mod = mce->stored_module(); // if(mce->execute) { // return mce->execute(state, call_frame, meth, mod, args); // } return meth->execute(state, call_frame, meth, mod, args); } return cache->initialize(state, call_frame, args); }
Object* Module::reset_method_cache(STATE, Symbol* name) { if(Class* self = try_as<Class>(this)) { self->increment_serial(); } if(!name->nil_p()) { if(MethodTableBucket* b = method_table_->find_entry(state, name)) { Executable* exec = b->method(); if(!exec->nil_p()) { exec->clear_inliners(state); } } } if(!hierarchy_subclasses_->nil_p()) { for(native_int i = 0; i < hierarchy_subclasses_->size(); ++i) { WeakRef* ref = try_as<WeakRef>(hierarchy_subclasses_->get(state, i)); if(ref && ref->alive_p()) { Module* mod = as<Module>(ref->object()); mod->reset_method_cache(state, name); } } } return cNil; }
int main(int argc, char *argv[]) { const char *loglevel = std::getenv("GOLDFILTER_LOG"); if (loglevel && strcmp(loglevel, "debug") == 0) spdlog::set_level(spdlog::level::debug); else spdlog::set_level(spdlog::level::err); auto spd = spdlog::stdout_logger_mt("console", true); Executable exec; if (exec.asRoot()) { spd->error("DO NOT RUN THIS AS ROOT!"); return EXIT_FAILURE; } std::string command; if (argc == 2) command.assign(argv[1]); spd->debug("command: {}", command); if (command.empty()) { return EXIT_FAILURE; } else if (command == "--test-perm") { bool result = exec.testPermission(); spd->info("--test-perm: {}", result); return result ? EXIT_SUCCESS : EXIT_FAILURE; } else if (command.find("-") == 0) { spd->error("unrecognized option: {}", command); return EXIT_FAILURE; } Server server(command); return server.start() ? EXIT_SUCCESS : EXIT_FAILURE; }
void SafeManager::onExecutableStop(void* which) { WAIT_SEMAPHOR(); Executable* exe = static_cast<Executable*>(which); if(eventReceiver && exe) eventReceiver->onModStop(exe->getID()); POST_SEMAPHOR(); // Experimental: // do auto refresh on connections whenever a module stops /* if(checkSemaphore()) { if(!isRunning()) { conIds.clear(); for(int i=0; i<getConnections().size(); i++) conIds.push_back(i); action = MREFRESH_CNN; yarp::os::Thread::start(); } POST_SEMAPHOR(); } */ }
void YConsoleManager::onExecutableFailed(void* which) { Executable* exe = (Executable*) which; if(config.find("module_failure").asString() == "prompt") cout<<exe->getCommand()<<" from "<<exe->getHost()<<" is failed!"<<endl; if(config.find("module_failure").asString() == "recover") { cout<<endl<<exe->getCommand()<<" from "<<exe->getHost()<<" is failed! (restarting...)"<<endl; exe->start(); } if(config.find("module_failure").asString() == "terminate") { cout<<endl<<exe->getCommand()<<" from "<<exe->getHost()<<" is failed! (terminating application...)"<<endl; bShouldRun = false; stop(); reportErrors(); } }
void annotateStubs(Executable& executable, Module& module) { Function* jumpIntrin = module.getFunction("x86_jump_intrin"); // This may eventually need to be moved to a pass of its own or something. vector<Function*> functions; for (Function& fn : module.getFunctionList()) { if (md::isPrototype(fn)) { continue; } BasicBlock& entry = fn.getEntryBlock(); auto terminator = entry.getTerminator(); if (isa<UnreachableInst>(terminator)) { if (auto prev = dyn_cast<CallInst>(terminator->getPrevNode())) if (prev->getCalledFunction() == jumpIntrin) if (auto load = dyn_cast<LoadInst>(prev->getOperand(2))) if (auto constantExpr = dyn_cast<ConstantExpr>(load->getPointerOperand())) { unique_ptr<Instruction> inst(constantExpr->getAsInstruction()); if (auto int2ptr = dyn_cast<IntToPtrInst>(inst.get())) { auto value = cast<ConstantInt>(int2ptr->getOperand(0)); auto intValue = value->getLimitedValue(); if (const string* stubTarget = executable.getStubTarget(intValue)) { md::setImportName(fn, *stubTarget); fn.setName(*stubTarget); } } } } } }
bool Manager::updateExecutable(unsigned int id, const char* szparam, const char* szhost, const char* szstdio, const char* szworkdir, const char* szenv ) { if(runnables.empty()) { logger->addError("Application is not loaded."); return false; } if(id>=runnables.size()) { logger->addError("Module id is out of range."); return false; } Executable* exe = runnables[id]; exe->setParam(szparam); exe->setHost(szhost); exe->setStdio(szstdio); exe->setWorkDir(szworkdir); exe->setEnv(szenv); return true; }