Exemplo n.º 1
0
void JVMState::dump() const {
    if (_map && !((uintptr_t)_map & 1)) {
        if (_map->len() > _map->req()) {  // _map->has_exceptions()
            Node* ex = _map->in(_map->req());  // _map->next_exception()
            // skip the first one; it's already being printed
            while (ex != NULL && ex->len() > ex->req()) {
                ex = ex->in(ex->req());  // ex->next_exception()
                ex->dump(1);
            }
        }
        _map->dump(2);
    }
    tty->print("JVMS depth=%d loc=%d stk=%d mon=%d end=%d mondepth=%d sp=%d bci=%d method=",
               depth(), locoff(), stkoff(), monoff(), endoff(), monitor_depth(), sp(), bci());
    if (_method == NULL) {
        tty->print_cr("(none)");
    } else {
        _method->print_name();
        tty->cr();
        if (bci() >= 0 && bci() < _method->code_size()) {
            tty->print("    bc: ");
            _method->print_codes(bci(), bci()+1);
        }
    }
    if (caller() != NULL) {
        caller()->dump();
    }
}
Exemplo n.º 2
0
Arquivo: main.cpp Projeto: CCJY/coliru
int main()
{
    caller(std::bind(&fun1, std::placeholders::_1));
    caller(std::bind(&fun2));
    
    return 0;
}
Exemplo n.º 3
0
int
main(int argc, char *argv[])
{
	// CHECK: define [[INT:i[3264]+]] @main([[INT]] %argc, i8** %argv)
	// CHECK: call void @__tesla_instrumentation_callee_enter_main([[INT]] %argc, i8** %argv)

	// Make an assertion about calling foo() and returning from bar():
	TESLA_PERTHREAD(call(main), returnfrom(main),
		TSEQUENCE(
			caller(call(foo)),
			caller(returnfrom(bar)),
			TESLA_ASSERTION_SITE
		)
	);

	// We should instrument foo's call but not the return:
	// CHECK: call void @__tesla_instrumentation_caller_enter_foo
	foo();
	// CHECK-NOT: call void @__tesla_instrumentation_caller_return_foo

	// We should instrument bar's return but not the call:
	// CHECK-NOT: call void @__tesla_instrumentation_caller_enter_bar
	bar();
	// CHECK: call void @__tesla_instrumentation_caller_return_bar

	return 0;
}
Exemplo n.º 4
0
void JVMState::dump_spec() const {
    if( _method ) {
        _method->print_short_name();
        tty->print(" @ bci:%d ",_bci);
    } else {
        tty->print(" runtime stub ");
    }
    if (caller() != NULL)  caller()->dump_spec();
}
Exemplo n.º 5
0
/*
 * Leaf driver close entry point.  We make a vnode and go through specfs in
 * order to obtain open close exclusions guarantees.  Note that we drop
 * OTYP_LYR if it was specified - we are going through specfs and it provides
 * last close semantics (FLKYR is provided to close(9E)).
 */
int
dev_lclose(dev_t dev, int flag, int otype, struct cred *cred)
{
	struct vnode	*vp;
	int		error;
	struct vnode	*cvp;
	char		*funcname;
	ulong_t		offset;

	vp = makespecvp(dev, (otype == OTYP_BLK) ? VBLK : VCHR);
	error = VOP_CLOSE(vp, flag | FKLYR, 1, (offset_t)0, cred, NULL);

	/*
	 * Release the extra dev_lopen hold on the common vnode. We inline a
	 * VN_RELE(cvp) call so that we can detect more dev_lclose calls than
	 * dev_lopen calls without panic. See vn_rele.  If our inline of
	 * vn_rele called VOP_INACTIVE(cvp, CRED(), ...) we would panic on the
	 * "release the makespecvp vnode" VN_RELE(vp) that follows  - so
	 * instead we diagnose this situation.  Note that the driver has
	 * still seen a double close(9E), but that would have occurred with
	 * the old dev_close implementation too.
	 */
	cvp = STOV(VTOCS(vp));
	mutex_enter(&cvp->v_lock);
	switch (cvp->v_count) {
	default:
		cvp->v_count--;
		break;

	case 0:
		VTOS(vp)->s_commonvp = NULL;	/* avoid panic */
		/*FALLTHROUGH*/
	case 1:
		/*
		 * The following message indicates a serious problem in the
		 * identified driver, the driver should be fixed. If obtaining
		 * a panic dump is needed to diagnose the driver problem then
		 * adding "set dev_lclose_ce=3" to /etc/system will cause a
		 * panic when this occurs.
		 */
		funcname = modgetsymname((uintptr_t)caller(), &offset);
		cmn_err(dev_lclose_ce, "dev_lclose: extra close of dev_t 0x%lx "
		    "from %s`%s()", dev, mod_containing_pc(caller()),
		    funcname ? funcname : "unknown...");
		break;
	}
	mutex_exit(&cvp->v_lock);

	/* release the makespecvp vnode. */
	VN_RELE(vp);
	return (error);
}
Exemplo n.º 6
0
QStringList STTwitterText::extractMentions(const QString &text){
    QMutexLocker locker(g_processMutex);
    QString inText=removeUni6(text).trimmed().normalized(QString::NormalizationForm_C);
    QScriptValue caller();
    QScriptValueList args;
    args.append(inText);
    QScriptValue result=g_extractMentionsFunction->call(caller, args);
    if(g_engine->hasUncaughtException()){
        int line = g_engine->uncaughtExceptionLineNumber();

        QByteArray str=g_engine->uncaughtException().toString().toUtf8();

        qFatal("Exception while evaluating twttr.txt.extractMentions at line %d: %s", line, str.data());
    }
    if(result.isUndefined()){
        qFatal("Undefined returned by extractMentions");
    }
    if(!result.isArray()){
        qFatal("Non-array object returned by extractMentions");
    }

    int length=result.property("length").toInteger();
    QStringList res;
    for(int i=0;i<length;i++){
        res<<result.property(i).toString();
    }

    return res;
}
Exemplo n.º 7
0
int StoreStub::PHXEcho(const google::protobuf::StringValue &req,
                       google::protobuf::StringValue *resp) {
    phxrpc::HttpCaller caller(socket_, client_monitor_);
    caller.SetURI("/phxqueue_phxrpc.store/PHXEcho", -1);
    caller.SetKeepAlive(keep_alive_);
    return caller.Call(req, resp);
}
Exemplo n.º 8
0
int
MdrunTestFixture::callMdrun(const CommandLine &callerRef)
{
    /* Conforming to style guide by not passing a non-const reference
       to this function. Passing a non-const reference might make it
       easier to write code that incorrectly re-uses callerRef after
       the call to this function. */
    CommandLine caller(callerRef);
    caller.addOption("-s", tprFileName);

    caller.addOption("-g", logFileName);
    caller.addOption("-e", edrFileName);
    caller.addOption("-o", fullPrecisionTrajectoryFileName);
    caller.addOption("-x", reducedPrecisionTrajectoryFileName);

    caller.addOption("-deffnm", fileManager_.getTemporaryFilePath("state"));

    if (nsteps > -2)
    {
        caller.addOption("-nsteps", nsteps);
    }

#ifdef GMX_THREAD_MPI
    caller.addOption("-nt", g_numThreads);
#endif
#ifdef GMX_OPENMP
    caller.addOption("-ntomp", g_numOpenMPThreads);
#endif

    return gmx_mdrun(caller.argc(), caller.argv());
}
Exemplo n.º 9
0
void PoolManagerFactory (int argc, char **argv) {

	boost::xtime xt, xt2;
	boost::xtime_get(&xt, boost::TIME_UTC);

	Caller   caller(s_callee);
	s_callee.start();
	caller.shout("Welcome to the management thread!");

//	try {
	PoolManager manager(nProducers, sizeN > nConsumers ? nConsumers : sizeN);

	boost::thread thrd(manager);
	thrd.join();
//  }
//	catch (boost::exception &ex){
//		caller.shout( diagnostic_information(ex) );
//	}
	s_callee.stop();

	boost::xtime_get(&xt2, boost::TIME_UTC);
	long time = boost::lexical_cast<long>((xt2.sec*1000000000 + xt2.nsec - xt.sec*1000000000 - xt.nsec) / 1000000);
	printf("%d producer, max %d consumers: %ld msec\n", nProducers, nConsumers, time);

}
Exemplo n.º 10
0
int StoreStub::Get(const phxqueue::comm::proto::GetRequest &req,
                   phxqueue::comm::proto::GetResponse *resp) {
    phxrpc::HttpCaller caller(socket_, client_monitor_);
    caller.SetURI("/phxqueue_phxrpc.store/Get", 2);
    caller.SetKeepAlive(keep_alive_);
    return caller.Call(req, resp);
}
Exemplo n.º 11
0
static void setup_dir_watcher(const char* dir,
                              zx_status_t (*cb)(port_handler_t*, zx_signals_t, uint32_t),
                              port_handler_t* ph,
                              int* fd_out) {
    *fd_out = -1;
    fbl::unique_fd fd(open(dir, O_DIRECTORY | O_RDONLY));
    if (!fd) {
        return;
    }
    zx::channel client, server;
    if (zx::channel::create(0, &client, &server) != ZX_OK) {
        return;
    }

    fzl::FdioCaller caller(std::move(fd));
    zx_status_t status;
    zx_status_t io_status = fuchsia_io_DirectoryWatch(caller.borrow_channel(),
                                                      fuchsia_io_WATCH_MASK_ALL, 0,
                                                      server.release(),
                                                      &status);
    if (io_status != ZX_OK || status != ZX_OK) {
        return;
    }

    *fd_out = caller.release().release();
    ph->handle = client.release();
    ph->waitfor = ZX_CHANNEL_READABLE | ZX_CHANNEL_PEER_CLOSED;
    ph->func = cb;
    port_wait(&port, ph);
}
Exemplo n.º 12
0
int ShellServer::readDir(ServerContext& s, const char *dir, void *dirp, map<string, file_stat_t*>& files, bool& eof)
{
	string_list_t args;
	string name;
	string_map_t env = s.getEnv();
	process_io_t io;
	args.push_back(dir);
	int status = caller(s, "list", args, env, io);
	_DEBUG("read_dir: %s", io.output.c_str());
	if (status >= 0)
	{
		status = bufferToFileStat(io.output.c_str(), (int) io.output.length(), files, name);
	}
	if (status < 0 && files.size() > 0)
	{
		for (map<string, file_stat_t*>::iterator it = files.begin(); it != files.end(); it++)
		{
			delete it->second;
			it->second = NULL;
		}
		files.clear();
	}
	eof = true;

	return status;
}
Exemplo n.º 13
0
 void transform_pixels(
     Src1View src1, Src2View src2, DestView dest, ConverterType conv,
     int nt = 2)
 {
     detail::transform_pixels_caller<ConverterType> caller(conv);
     detail::apply_algorithm_fn(caller, make_tuple(src1, src2, dest), nt);
 }
Exemplo n.º 14
0
static int lua_log_adaptor_fn_lua_log(lua_State *L) {
    int top = lua_gettop(L);
    if (top < 2) {
        WLOGERROR("call lua function: lua_log without log level.");
        return 0;
    }

    // log 分类
    uint32_t cat = static_cast<uint32_t>(luaL_checkinteger(L, 1));

    util::log::log_wrapper::level_t::type level = WLOG_LEVELID(luaL_checkinteger(L, 2));

    util::log::log_wrapper *logger = WDTLOGGETCAT(cat);
    if (NULL != logger && logger->check_level(level)) {
        // TODO: 是否填充lua文件名和行号?但是那个操作比较耗性能
        util::log::log_wrapper::caller_info_t caller(level, "Lua", NULL, 0, NULL);

        for (int i = 3; i <= top; ++i) {
            const char *content = lua_tostring(L, i);
            if (NULL != content) {
                logger->log(caller, "%s", content);
            }
        }
    }

    return 0;
}
Exemplo n.º 15
0
int
ShellServer::flush(ServerContext& s, void *handle, int flags)
{
	(void) flags;
	int result = 0;

	shell_hdl_t *h = static_cast<shell_hdl_t *>(handle);
	if (h->dirty)
	{
		string_list_t args;
		string_map_t env = s.getEnv();
		process_io_t io;
		io.input = h->contents;
		args.push_back(h->path);
		result = caller(s, "write", args, env, io);
		if (result < 0)
		{
			return result;
		}
		string& sz = h->contents = io.output;
		result = atoi(sz.c_str());
		h->dirty = false;
	}
	return result;
}
Exemplo n.º 16
0
int ShellServer::removeFile(ServerContext& s, const char *path)
{
	string_list_t args;
	string_map_t env = s.getEnv();
	process_io_t io;
	args.push_back(path);
	return caller(s, "remove", args, env, io);
}
Exemplo n.º 17
0
//タイマ管理
//このタスク以外では、timerctl.checkTimeout()を呼ばない事!
void timer_task(void) {

	Caller caller(timerctl,&TIMERCTL::checkTimeout);
	taskctl.set_input(TIMER_ID_S,&caller);

	taskctl.waitIO(MAX_ID);					//半永久的に復帰する事はない。いわば、完全なスリープ状態

	return ;
}
Exemplo n.º 18
0
int ShellServer::wstat(ServerContext& s, const char *path, file_stat_t& in, uint32_t mask)
{
	string_list_t args;
	string_map_t env = s.getEnv();
	process_io_t io;
	char out[32];
	(void) s;

	if (readOnly(s))
	{
		return -EPERM;
	}

	if ((mask & FS_SIZE) == FS_SIZE)
	{
		sprintf(out, "%ld", (long) in.fs_size);
		env["_size"] = in.fs_size;
	}

	if ((mask & FS_MODE) == FS_MODE)
	{
		sprintf(out, "0%o", (in.fs_mode & 04777));
		env["_mode"] = out;
	}

	if ((mask & FS_UID) == FS_UID)
	{
		sprintf(out, "%d", in.fs_uid);
		env["_uid"] = out;
	}

	if ((mask & FS_GID) == FS_GID)
	{
		sprintf(out, "%d", in.fs_gid);
		env["_gid"] = out;
	}

	if ((mask & FS_ATIME) == FS_ATIME)
	{
		sprintf(out, "%ld", (long) in.fs_atime);
		env["_atime"] = out;
	}

	if ((mask & FS_MTIME) == FS_MTIME)
	{
		sprintf(out, "%ld", (long) in.fs_mtime);
		env["_mtime"] = out;
	}

	if ((mask & FS_RENAME) == FS_RENAME)
	{
		env["_rename"] = in.fs_rename;
	}

	return caller(s, "wstat", args, env, io);
}
Exemplo n.º 19
0
inline void doCast(const PMaybe &lib, PMaybe &val) {
    PMaybe func(nullptr);

    libGet<id_cast, type>(PVal(val), lib, func);

    PMaybe caller(_ptr(_quote(PVal(val)), val->getType())); // TODO simplify
    val = nullptr;

    func.call<true>(caller, lib, val);
}
Exemplo n.º 20
0
QVariant RequestManager::processMessage(QString buffered_message)
{
    // Parse function method and parameters
    buffered_message.chop(1);
    buffered_message.remove(0,1);
    // First turn string into QJSonDocument
    QJsonParseError error;
    QJsonDocument document( QJsonDocument::fromJson(buffered_message.toLocal8Bit(),&error));
    // Check if there was an error
    if(error.error != QJsonParseError::NoError)
    {
        qDebug() << "Error Parsing incoming Json Message:" << error.errorString() << "\nMessage Recieved: " << buffered_message;
        return QVariant();
    }

    // Begin Parsing Arguments
    QJsonArray request_array (document.array());
    QVariant parameter;
    QJsonObject func = request_array.first().toObject();
    int param_count = request_array.size()-1;
    if(param_count > 1)
    {
        QVariantList params;
        for(int i = 1; i < param_count+1; ++i)
        {
            params.append(request_array.at(i).toObject());
        }
        parameter.setValue(params);
    }
    else if( param_count == 1)
    {
        parameter = QVariant::fromValue(request_array.at(param_count).toObject());
    }
    else
    {
        parameter = QVariant();
    }
    QString functionname(func["FuncName"].toString());
    QTcpSocket * caller(qobject_cast<QTcpSocket*>(sender()));
    QVariant return_val = processRequest(functionname,caller,parameter);
    if(!return_val.isNull())
    {
        QJsonObject obj = return_val.value<QJsonObject>();
        QJsonDocument doc;
        doc.setObject(obj);
        QByteArray message(doc.toJson());
        return_val = QVariant::fromValue(doc);
        message.push_front("\001");
        message.push_back("\004");
        emit returnMessageReady(caller,message);
    }

    return return_val;
}
Exemplo n.º 21
0
void trampoline_push( intptr_t vp)
{
    typedef typename Coro::param_type   param_type;

    BOOST_ASSERT( vp);

    setup< Fn > * from(
        reinterpret_cast< setup< Fn > * >( vp) );

#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
    Fn fn( forward< Fn >( from->fn) );
#else
    Fn fn( move( from->fn) );
#endif

    coroutine_context caller( * from->caller);
    coroutine_context callee( * from->callee);

    Coro c( & caller, & callee,
            stack_unwind == from->attr.do_unwind,
            fpu_preserved == from->attr.preserve_fpu);
    from = 0;

    {
        param_type * from(
            reinterpret_cast< param_type * >(
                c.callee_->jump(
                    * c.caller_,
                    reinterpret_cast< intptr_t >(  & c),
                    c.preserve_fpu() ) ) );
        if ( ! from->do_unwind)
        {
            BOOST_ASSERT( from->data);

            // create push_coroutine
            typename Self::impl_type b( & callee, & caller, false, c.preserve_fpu(), from->data);
            Self yield( & b);
            try
            { fn( yield); }
            catch ( forced_unwind const&)
            {}
            catch (...)
            { c.except_ = current_exception(); }
        }
    }

    c.flags_ |= flag_complete;
    param_type to;
    c.callee_->jump(
        * c.caller_,
        reinterpret_cast< intptr_t >( & to),
        c.preserve_fpu() );
    BOOST_ASSERT_MSG( false, "push_coroutine is complete");
}
Exemplo n.º 22
0
int ShellServer::createDir(ServerContext& s, const char *path, uint32_t mode)
{
	string_list_t args;
	string_map_t env = s.getEnv();
	process_io_t io;
	char buffer[16];	
	sprintf(buffer, "0%o", mode);
	args.push_back(path);
	args.push_back(buffer);
	return caller(s, "mkdir", args, env, io);
}
Exemplo n.º 23
0
/*------------------------------------------------------------------------*
 * 4近傍のラベリング。できあがりはlong型
 *------------------------------------------------------------------------*/
long image__N4_labelling_long(image label, image original)
{
  f_caller caller;

  caller = (f_caller)image__caller("N4_labelling_long",
				   original,
				   Number(N4_long_table),N4_long_table);

  if (caller) return caller(label,original);

  return 0;
}
Exemplo n.º 24
0
int ShellServer::auth(ServerContext& s, const string& authType, const string& user,
					  const string& password, const string& home)
{
	string_list_t args;
	string_map_t env = s.getEnv();
	process_io_t io;
	args.push_back(user);
	args.push_back(s.nonce());
	args.push_back(password);
	args.push_back(s.authClientId());
	return caller(s, "auth", args, env, io);
}
Exemplo n.º 25
0
void JVMState::format(PhaseRegAlloc *regalloc, const Node *n) const {
    tty->print("        #");
    if( _method ) {
        _method->print_short_name();
        tty->print(" @ bci:%d ",_bci);
    } else {
        tty->print_cr(" runtime stub ");
        return;
    }
    MachNode *mach = ((Node *)n)->is_Mach();
    MachSafePointNode *mcall = mach->is_MachSafePoint();
    if (mcall) {
        uint i;
        // Print locals
        for( i = 0; i < (uint)loc_size(); i++ )
            format_helper( regalloc, mcall->local(this, i), "L", i );
        // Print stack
        for (i = 0; i < (uint)stk_size(); i++) {
            if ((uint)(_stkoff + i) >= mcall->len())
                tty->print(" oob ");
            else
                format_helper( regalloc, mcall->stack(this, i), "STK", i );
        }
        for (i = 0; (int)i < nof_monitors(); i++) {
            Node *box = mcall->monitor_box(this, i);
            Node *obj = mcall->monitor_obj(this, i);
            if ( regalloc->get_reg_lo(box) != OptoReg::Bad ) {
                while( !box->is_BoxLock() )  box = box->in(1);
                format_helper( regalloc, box, "MON-BOX", i );
            } else {
                OptoReg::Name box_reg = BoxLockNode::stack_slot(box);
                tty->print(" MON-BOX%d=%s+%d",i,SharedInfo::regName[SharedInfo::c_frame_pointer],regalloc->reg2offset(box_reg));
            }
            format_helper( regalloc, obj, "MON-OBJ", i );
        }
    }
    tty->print_cr("");
    if (caller() != NULL)  caller()->format(regalloc, n);
}
Exemplo n.º 26
0
/*------------------------------------------------------------------------*
 * 8近傍のラベリング。できあがりはushort型
 *------------------------------------------------------------------------*/
long image__N8_labelling_ushort(image label, image original)
{
  f_caller caller;

  caller = (f_caller)image__caller("N8_labelling_ushort",
				   original,
				   Number(N8_ushort_table),
				   N8_ushort_table);

  if (caller) return caller(label,original);

  return 0;
}
Exemplo n.º 27
0
/*------------------------------------------------------------------------*
 * 8近傍のラベリング。できあがりはlong型
 *------------------------------------------------------------------------*/
long image__N8_labelling_foreground_long(image label, image original)
{
  f_caller caller;

  caller = (f_caller)image__caller("image__N8_labelling_foreground_long",
				   original,
				   Number(N8FG_long_table),
				   N8FG_long_table);

  if (caller) return caller(label,original);

  return 0;
}
Exemplo n.º 28
0
/*------------------------------------------------------------------------*
 * 4近傍のラベリング。できあがりはushort型
 *------------------------------------------------------------------------*/
long image__N4_labelling_foreground_ushort(image label, image original)
{
  f_caller caller;

  caller = (f_caller)image__caller("image__N4_labelling_foreground_ushort",
				   original,
				   Number(N4FG_ushort_table),
				   N4FG_ushort_table);

  if (caller) return caller(label,original);

  return 0;
}
Exemplo n.º 29
0
	extern "C" void *booster_thread_func(void *p)
	{
		std::auto_ptr<thread_function_type> caller(reinterpret_cast<thread_function_type *>(p));
		try {
			thread_function_type &func = *caller;
			func();
		}
		catch(std::exception const &/*e*/) {
			/// TODO
		}
		catch(...) {
			/// TODO
		}
		return 0;
	}
Exemplo n.º 30
0
int
SimulationRunner::callMdrun(const CommandLine &callerRef)
{
    /* Conforming to style guide by not passing a non-const reference
       to this function. Passing a non-const reference might make it
       easier to write code that incorrectly re-uses callerRef after
       the call to this function. */

    CommandLine caller(callerRef);
    caller.addOption("-s", tprFileName_);

    caller.addOption("-g", logFileName_);
    caller.addOption("-e", edrFileName_);
    caller.addOption("-o", fullPrecisionTrajectoryFileName_);
    caller.addOption("-x", reducedPrecisionTrajectoryFileName_);

    caller.addOption("-deffnm", fixture_->fileManager_.getTemporaryFilePath("state"));

    if (nsteps_ > -2)
    {
        caller.addOption("-nsteps", nsteps_);
    }

#ifdef GMX_MPI
#  ifdef GMX_GPU
#    ifdef GMX_THREAD_MPI
    int         numGpusNeeded = g_numThreads;
#    else   /* Must be real MPI */
    int         numGpusNeeded = gmx_node_num();
#    endif
    std::string gpuIdString(numGpusNeeded, '0');
    caller.addOption("-gpu_id", gpuIdString.c_str());
#  endif
#endif

#ifdef GMX_THREAD_MPI
    caller.addOption("-nt", g_numThreads);
#endif

#ifdef GMX_OPENMP
    caller.addOption("-ntomp", g_numOpenMPThreads);
#endif

    return gmx_mdrun(caller.argc(), caller.argv());
}