Exemplo n.º 1
0
void CCoreServerThreadMgr::Unit()
{
	if(!ms_pInst)
		GenErr("Can't Unit because the mgr is already uninitial ");

	delete Inst();
	Inst() = NULL;
}
Exemplo n.º 2
0
int CLoungeServer::SendPlayerUnseated(CPlayer* p)
{
    if (Inst())
    {
        return Inst()->sendPlayerUnseated(p);
    }
    else
    {
        return 0;
    }
}
Exemplo n.º 3
0
template <typename Visitor> void enumerateFields_gen(InstImage obj,  Visitor & vis) {
  enumerateFields_gen(Inst(obj), vis);
  vis(obj.imageType(),"imageType");
  vis(obj.coordType(),"coordType");
  vis(obj.geometry(),"geometry");
  vis(obj.equivClass(),"equivClass");
}
Exemplo n.º 4
0
void CBaseScriptApp::DisbindPvFun(void* pObj)
{
	CScript* pScript=Inst()->GetScript();
	if (!pScript)
		return;
	pScript->UnlinkCppObj(pObj);
}
Exemplo n.º 5
0
template <typename Visitor> void enumerateFields_gen(InstCmp obj,  Visitor & vis) {
  enumerateFields_gen(Inst(obj), vis);
  vis(obj.sourceType(),"sourceType");
  enumerateFields(obj.modifier(), vis);
  vis(obj.compare(),"compare");
  vis(obj.pack(),"pack");
}
Exemplo n.º 6
0
void CBaseScriptApp::DelPvRefFun(void* pObj)
{
	CScript* pScript=Inst()->GetScript();
	if (!pScript)
		return;
	pScript->UnrefScriptObj(pObj);
}
Exemplo n.º 7
0
void CBaseScriptApp::AddRefFun(CBaseObject* pObj)
{
	CScript* pScript=Inst()->GetScript();
	if (!pScript)
		return;
	pScript->RefScriptObj(pObj);
}
Exemplo n.º 8
0
template <typename Visitor> void enumerateFields_gen(InstMemFence obj,  Visitor & vis) {
  enumerateFields_gen(Inst(obj), vis);
  vis(obj.memoryOrder(),"memoryOrder");
  vis(obj.globalSegmentMemoryScope(),"globalSegmentMemoryScope");
  vis(obj.groupSegmentMemoryScope(),"groupSegmentMemoryScope");
  vis(obj.imageSegmentMemoryScope(),"imageSegmentMemoryScope");
}
Exemplo n.º 9
0
template <typename Visitor> void enumerateFields_gen(InstAtomic obj,  Visitor & vis) {
  enumerateFields_gen(Inst(obj), vis);
  vis(obj.segment(),"segment");
  vis(obj.memoryOrder(),"memoryOrder");
  vis(obj.memoryScope(),"memoryScope");
  vis(obj.atomicOperation(),"atomicOperation");
  vis(obj.equivClass(),"equivClass");
}
Exemplo n.º 10
0
template <typename Visitor> void enumerateFields_gen(InstMem obj,  Visitor & vis) {
  enumerateFields_gen(Inst(obj), vis);
  vis(obj.segment(),"segment");
  vis(obj.align(),"align");
  vis(obj.equivClass(),"equivClass");
  vis(obj.width(),"width");
  enumerateFields(obj.modifier(), vis);
}
Exemplo n.º 11
0
bool CBaseScriptApp::CallClassCallBack(void* pCall, CBaseObject* pObject, char* pDataBuf)
{
	CScript* pScript=Inst()->GetScript();
	if (!pScript)
		return false;

	return pScript->CallClassCallBack(pCall, pObject, pDataBuf);
}
Exemplo n.º 12
0
void* CBaseScriptApp::GetCallBackData(CBaseObject* pObject, const char* szFunName)
{
	CScript* pScript=Inst()->GetScript();
	if (!pScript)
		return NULL;

	return pScript->GetCallBackData(pObject, szFunName);
}
Exemplo n.º 13
0
/// Compiler generated metadata object, accessed through this function
const F8MetaCntx& ctx() // avoid SIOF
{
   static const BaseMsgEntry nvbme = { Minst(Type2Type<void *>()) };
   static const Myfix_BaseMsgEntry bme(msgpairs, 119, nvbme);
   static const BaseEntry nvbe = { Inst(Type2Type<void *>()) };
   static const Myfix_BaseEntry be(fldpairs, 1562, nvbe);
   static const F8MetaCntx _ctx(1100, bme, be, cn, "FIXT.1.1");
   return _ctx;
}
Exemplo n.º 14
0
void  CBaseScriptApp::GetCallBackAttr(void* pCall, size_t& stBufSize, size_t*& pParamOffset, 
									  size_t& iRetOffset)
{
	CScript* pScript=Inst()->GetScript();
	if (!pScript)
		return;

	pScript->GetCallBackAttr(pCall, stBufSize, pParamOffset, iRetOffset);
}
Exemplo n.º 15
0
CConnClient::CConnClient()
{
	Ast(!Inst());
	Inst()=this;

	m_uLastSyncedServerFrameTime		= 0;
	m_pSlowSigner			= NULL;
	m_uCurrentDelay			= 0;
	m_bWaitingDisconnect	= false;
	m_bGlobalTimeSynced		= false;
	m_bShutting = false;
	m_bRecvTrafficStatStarted = false;

	CCoreObjectDirector::GetLastDistortedProcessTime() = 0;
	CCoreObjectDirector::GetLastProcessTime() = 0;
	CCoreObjectDirector::GetLastDistortedFrameTime() = 0;
	CCoreObjectDirector::GetLastFrameTime() = 0;
	m_EstimatedServerTime = new CServerTimeGuesser;
}
Exemplo n.º 16
0
CCoreServerThreadMgr::CCoreServerThreadMgr()
: Parent_t(10240, 1024 * 1024, CAsynServerTrMsgBufferSwapper::Inst())
{
	Inst() = this;

	//为了保证wi buffer持续更新,所以我们每150毫秒加入一个result5	
	m_pWISwapedTick = new CAddWIBufferSwapedResultTick;
	CSyncTimeSystemServer::Inst()->Register(m_pWISwapedTick, 150);

	m_pThread = new CCoreServerThread(this);
}
Exemplo n.º 17
0
  // Here is the test Eval function specialization. Here the CallExpr to the
  // function is created.
  CallExpr*
  EvaluateTSynthesizer::BuildEvalCallExpr(const QualType InstTy,
                                            Expr* SubTree,
                                            ASTOwningVector<Expr*>& CallArgs) {
    // Set up new context for the new FunctionDecl
    DeclContext* PrevContext = m_Sema->CurContext;

    m_Sema->CurContext = m_EvalDecl->getDeclContext();

    // Create template arguments
    Sema::InstantiatingTemplate Inst(*m_Sema, m_NoSLoc, m_EvalDecl);
    TemplateArgument Arg(InstTy);
    TemplateArgumentList TemplateArgs(TemplateArgumentList::OnStack, &Arg, 1U);

    // Substitute the declaration of the templated function, with the
    // specified template argument
    Decl* D = m_Sema->SubstDecl(m_EvalDecl,
                                m_EvalDecl->getDeclContext(),
                                MultiLevelTemplateArgumentList(TemplateArgs));

    FunctionDecl* Fn = dyn_cast<FunctionDecl>(D);
    // Creates new body of the substituted declaration
    m_Sema->InstantiateFunctionDefinition(Fn->getLocation(), Fn, true, true);

    m_Sema->CurContext = PrevContext;

    const FunctionProtoType* FPT = Fn->getType()->getAs<FunctionProtoType>();
    FunctionProtoType::ExtProtoInfo EPI = FPT->getExtProtoInfo();
    QualType FnTy = m_Context->getFunctionType(Fn->getResultType(),
                                               FPT->arg_type_begin(),
                                               FPT->getNumArgs(),
                                               EPI);
    DeclRefExpr* DRE = m_Sema->BuildDeclRefExpr(Fn,
                                                FnTy,
                                                VK_RValue,
                                                m_NoSLoc
                                                ).takeAs<DeclRefExpr>();

    // TODO: Figure out a way to avoid passing in wrong source locations
    // of the symbol being replaced. This is important when we calculate the
    // size of the memory buffers and may lead to creation of wrong wrappers.
    Scope* S = m_Sema->getScopeForContext(m_Sema->CurContext);
    CallExpr* EvalCall = m_Sema->ActOnCallExpr(S,
                                               DRE,
                                               SubTree->getLocStart(),
                                               move_arg(CallArgs),
                                               SubTree->getLocEnd()
                                               ).takeAs<CallExpr>();
    assert (EvalCall && "Cannot create call to Eval");

    return EvalCall;

  }
Exemplo n.º 18
0
int main()
{
	Matrix a, b;
	printf("=====矩阵转置 By:落絮飞雁=====\n");
	while (1)
	{
		Inst(a);
		Trans(a, b);
		Out(b);
	}
	return 0;
}
Exemplo n.º 19
0
CAoiThreadMgr::CAoiThreadMgr(uint32 num)
: Parent_t(1024, 1024 * 100, CSyncServerTrMsgBufferMgrSwapper::Inst())
, m_bEndThreads(false)
{
    MgrInit();

	CAoi2LogicThreadMsgBuffer::Init();

    CreateAoiThreads(num);

    Inst() = this;
}
Exemplo n.º 20
0
CConnClient::~CConnClient(void)
{
	Inst()=NULL;

	delete m_EstimatedServerTime;
	m_EstimatedServerTime = NULL;

	CCoreObjectDirector::GetLastDistortedProcessTime() = 0;
	CCoreObjectDirector::GetLastProcessTime() = 0;
	CCoreObjectDirector::GetLastDistortedFrameTime() = 0;
	CCoreObjectDirector::GetLastFrameTime() = 0;

	GenRecvTrafficStatFile();
}
Exemplo n.º 21
0
Inst ExtManager::parseExtInstMnemo(Scanner& scanner, Brigantine& bw, int* vx) const
{
    assert(scanner.peek().kind() == EExtInstName);

    // Parse mnemo prefix adding suffices until there is an extension which can handle it.
    // This prefix has the form <vendor>_<extension>

    string prefix = scanner.scan().text();
    while (!isMnemoPrefix(prefix) && scanner.peek().kind() == EExtInstSuff) 
    {
        prefix += scanner.scan().text();
    }

    // Parse remaining part of instruction mnemo (typically in the form <opcode>_<suff>)

    if (const Extension* e = getByPrefix(prefix)) return e->parseInstMnemo(prefix, scanner, bw, vx);

    // Enabled extensions failed to parse this mnemo.
    // Search for a disabled extension which might have handled it
    const char* s = 0;
    for (unsigned i = 0; i < size(); ++i)
    {
        if (!isEnabled[i] && (s = extension[i]->matchInstMnemo(prefix)) != 0)
        {
            scanner.syntaxError(string("Instruction \"") + s + "\" cannot be used (extension \"" + extension[i]->getName() + "\" is not enabled)");
            return Inst();
        }
    }

    // Extensions (including disabled) cannot handle this mnemo

    if (!hasEnabled()) scanner.scan(); // show offending token
    scanner.syntaxError("Undefined instruction");

    return Inst();
}
Exemplo n.º 22
0
void CConnClient::ShutDown(const char* szMsg)
{
	if(m_bShutting)
		return;
	m_bShutting = true;
	CCoreSceneMgrClient::Inst()->DestroyMainSceneIfNotBeingUsedByLogic();
	CTimeSystemClient::Inst()->UnRegister(this);
	if (IntShutDown() && szMsg)
	{
		ostringstream strm;
		CAddress addr;
		const char* szUserName = GetValue("UserName");
		szUserName = szUserName?szUserName:"";
		GetLocalAddress(addr);
		LogTime(strm);
		strm << " account:" << szUserName << " reason:" << szMsg << " localip:" << addr.GetAddress() << " remoteip: " << endl;
		LogOnOffLineMsg(strm.str().c_str());
	}
	Inst()=NULL;
}
Exemplo n.º 23
0
template <typename Visitor> void enumerateFields_gen(InstSignal obj,  Visitor & vis) {
  enumerateFields_gen(Inst(obj), vis);
  vis(obj.signalType(),"signalType");
  vis(obj.memoryOrder(),"memoryOrder");
  vis(obj.signalOperation(),"signalOperation");
}
Exemplo n.º 24
0
template <typename Visitor> void enumerateFields_gen(InstSeg obj,  Visitor & vis) {
  enumerateFields_gen(Inst(obj), vis);
  vis(obj.segment(),"segment");
}
Exemplo n.º 25
0
template <typename Visitor> void enumerateFields_gen(InstSegCvt obj,  Visitor & vis) {
  enumerateFields_gen(Inst(obj), vis);
  vis(obj.sourceType(),"sourceType");
  vis(obj.segment(),"segment");
  enumerateFields(obj.modifier(), vis);
}
Exemplo n.º 26
0
template <typename Visitor> void enumerateFields_gen(InstSourceType obj,  Visitor & vis) {
  enumerateFields_gen(Inst(obj), vis);
  vis(obj.sourceType(),"sourceType");
}
Exemplo n.º 27
0
/*
=================
VM_Compile
=================
*/
void VM_Compile( vm_t *vm, vmHeader_t *header ) {
	int		op;
	int		maxLength;
	int		v;
	int		i;
	
	// set up the into-to-float variables
   	((int *)itofConvert)[0] = 0x43300000;
   	((int *)itofConvert)[1] = 0x80000000;
   	((int *)itofConvert)[2] = 0x43300000;

	// allocate a very large temp buffer, we will shrink it later
	maxLength = header->codeLength * 8;
	buf = Z_Malloc( maxLength );
	jused = Z_Malloc(header->instructionCount + 2);
	Com_Memset(jused, 0, header->instructionCount+2);
	
    // compile everything twice, so the second pass will have valid instruction
    // pointers for branches
    for ( pass = -1 ; pass < 2 ; pass++ ) {

	rtopped = qfalse;
        // translate all instructions
        pc = 0;
	
	pop0 = 343545;
	pop1 = 2443545;
	oc0 = -2343535;
	oc1 = 24353454;
	tvm = vm;
	
        code = (byte *)header + header->codeOffset;
        compiledOfs = 0;
#ifndef __GNUC__
		// metrowerks seems to require this header in front of functions
		Emit4( (int)(buf+2) );
		Emit4( 0 );
#endif

		for ( instruction = 0 ; instruction < header->instructionCount ; instruction++ ) {
            if ( compiledOfs*4 > maxLength - 16 ) {
                Com_Error( ERR_DROP, "VM_Compile: maxLength exceeded" );
            }

            op = code[ pc ];
            if ( !pass ) {
                vm->instructionPointers[ instruction ] = compiledOfs * 4;
            }
            pc++;
            switch ( op ) {
            case 0:
                break;
            case OP_BREAK:
                InstImmU( PPC_ADDI, R_TOP, 0, 0 );
                InstImm( PPC_LWZ, R_TOP, R_TOP, 0 );			// *(int *)0 to crash to debugger
		rtopped = qfalse;
                break;
            case OP_ENTER:
                InstImm( PPC_ADDI, R_STACK, R_STACK, -Constant4() );	// sub R_STACK, R_STACK, imm
		rtopped = qfalse;
                break;
            case OP_CONST:
                v = Constant4();
		if (code[pc] == OP_LOAD4 || code[pc] == OP_LOAD2 || code[pc] == OP_LOAD1) {
		    v &= vm->dataMask;
		}
                if ( v < 32768 && v >= -32768 ) {
                    InstImmU( PPC_ADDI, R_TOP, 0, v & 0xffff );
                } else {
                    InstImmU( PPC_ADDIS, R_TOP, 0, (v >> 16)&0xffff );
                    if ( v & 0xffff ) {
                        InstImmU( PPC_ORI, R_TOP, R_TOP, v & 0xffff );
                    }
                }
		if (code[pc] == OP_LOAD4) {
		    Inst( PPC_LWZX, R_TOP, R_TOP, R_MEMBASE );		// load from memory base
		    pc++;
		    instruction++;
		} else if (code[pc] == OP_LOAD2) {
		    Inst( PPC_LHZX, R_TOP, R_TOP, R_MEMBASE );		// load from memory base
		    pc++;
		    instruction++;
		} else if (code[pc] == OP_LOAD1) {
		    Inst( PPC_LBZX, R_TOP, R_TOP, R_MEMBASE );		// load from memory base
		    pc++;
		    instruction++;
		}
		if (code[pc] == OP_STORE4) {
		    InstImm( PPC_LWZ, R_SECOND, R_OPSTACK, 0 );	// get value from opstack
		    InstImm( PPC_ADDI, R_OPSTACK, R_OPSTACK, -4 );
		    //Inst( PPC_AND, R_MEMMASK, R_SECOND, R_SECOND );	// mask it
		    Inst( PPC_STWX, R_TOP, R_SECOND, R_MEMBASE );	// store from memory base
		    pc++;
		    instruction++;
		    rtopped = qfalse;
		    break;
		} else if (code[pc] == OP_STORE2) {
		    InstImm( PPC_LWZ, R_SECOND, R_OPSTACK, 0 );	// get value from opstack
		    InstImm( PPC_ADDI, R_OPSTACK, R_OPSTACK, -4 );
		    //Inst( PPC_AND, R_MEMMASK, R_SECOND, R_SECOND );	// mask it
		    Inst( PPC_STHX, R_TOP, R_SECOND, R_MEMBASE );	// store from memory base
		    pc++;
		    instruction++;
		    rtopped = qfalse;
		    break;
		} else if (code[pc] == OP_STORE1) {
		    InstImm( PPC_LWZ, R_SECOND, R_OPSTACK, 0 );	// get value from opstack
		    InstImm( PPC_ADDI, R_OPSTACK, R_OPSTACK, -4 );
		    //Inst( PPC_AND, R_MEMMASK, R_SECOND, R_SECOND );	// mask it
		    Inst( PPC_STBX, R_TOP, R_SECOND, R_MEMBASE );	// store from memory base
		    pc++;
		    instruction++;
		    rtopped = qfalse;
		    break;
		}
		if (code[pc] == OP_JUMP) {
		    jused[v] = 1;
		}
		InstImm( PPC_STWU, R_TOP, R_OPSTACK, 4 );
		rtopped = qtrue;
		break;
            case OP_LOCAL:
		oc0 = oc1;
		oc1 = Constant4();
		if (code[pc] == OP_LOAD4 || code[pc] == OP_LOAD2 || code[pc] == OP_LOAD1) {
		    oc1 &= vm->dataMask;
		}
                InstImm( PPC_ADDI, R_TOP, R_STACK, oc1 );
		if (code[pc] == OP_LOAD4) {
		    Inst( PPC_LWZX, R_TOP, R_TOP, R_MEMBASE );		// load from memory base
		    pc++;
		    instruction++;
		} else if (code[pc] == OP_LOAD2) {
		    Inst( PPC_LHZX, R_TOP, R_TOP, R_MEMBASE );		// load from memory base
		    pc++;
		    instruction++;
		} else if (code[pc] == OP_LOAD1) {
		    Inst( PPC_LBZX, R_TOP, R_TOP, R_MEMBASE );		// load from memory base
		    pc++;
		    instruction++;
		}
		if (code[pc] == OP_STORE4) {
		    InstImm( PPC_LWZ, R_SECOND, R_OPSTACK, 0 );		// get value from opstack
		    InstImm( PPC_ADDI, R_OPSTACK, R_OPSTACK, -4 );
		    //Inst( PPC_AND, R_MEMMASK, R_SECOND, R_SECOND );	// mask it
		    Inst( PPC_STWX, R_TOP, R_SECOND, R_MEMBASE );	// store from memory base
		    pc++;
		    instruction++;
		    rtopped = qfalse;
		    break;
		} else if (code[pc] == OP_STORE2) {
		    InstImm( PPC_LWZ, R_SECOND, R_OPSTACK, 0 );		// get value from opstack
		    InstImm( PPC_ADDI, R_OPSTACK, R_OPSTACK, -4 );
		    //Inst( PPC_AND, R_MEMMASK, R_SECOND, R_SECOND );	// mask it
		    Inst( PPC_STHX, R_TOP, R_SECOND, R_MEMBASE );	// store from memory base
		    pc++;
		    instruction++;
		    rtopped = qfalse;
		    break;
		} else if (code[pc] == OP_STORE1) {
		    InstImm( PPC_LWZ, R_SECOND, R_OPSTACK, 0 );		// get value from opstack
		    InstImm( PPC_ADDI, R_OPSTACK, R_OPSTACK, -4 );
		    //Inst( PPC_AND, R_MEMMASK, R_SECOND, R_SECOND );	// mask it
		    Inst( PPC_STBX, R_TOP, R_SECOND, R_MEMBASE );	// store from memory base
		    pc++;
		    instruction++;
		    rtopped = qfalse;
		    break;
		}
                InstImm( PPC_STWU, R_TOP, R_OPSTACK, 4 );
		rtopped = qtrue;
                break;
            case OP_ARG:
                ltop();							// get value from opstack
                InstImm( PPC_ADDI, R_OPSTACK, R_OPSTACK, -4 );
                InstImm( PPC_ADDI, R_EA, R_STACK, Constant1() );	// location to put it
                Inst( PPC_STWX, R_TOP, R_EA, R_MEMBASE );
		rtopped = qfalse;
                break;
            case OP_CALL:
                Inst( PPC_MFSPR, R_SECOND, 8, 0 );			// move from link register
                InstImm( PPC_STWU, R_SECOND, R_REAL_STACK, -16 );	// save off the old return address

                Inst( PPC_MTSPR, R_ASMCALL, 9, 0 );			// move to count register
                Inst( PPC_BCCTR | 1, 20, 0, 0 );			// jump and link to the count register

                InstImm( PPC_LWZ, R_SECOND, R_REAL_STACK, 0 );		// fetch the old return address
                InstImm( PPC_ADDI, R_REAL_STACK, R_REAL_STACK, 16 );
                Inst( PPC_MTSPR, R_SECOND, 8, 0 );			// move to link register
		rtopped = qfalse;
                break;
            case OP_PUSH:
                InstImm( PPC_ADDI, R_OPSTACK, R_OPSTACK, 4 );
		rtopped = qfalse;
                break;
            case OP_POP:
                InstImm( PPC_ADDI, R_OPSTACK, R_OPSTACK, -4 );
		rtopped = qfalse;
                break;
            case OP_LEAVE:
                InstImm( PPC_ADDI, R_STACK, R_STACK, Constant4() );	// add R_STACK, R_STACK, imm
                Inst( PPC_BCLR, 20, 0, 0 );							// branch unconditionally to link register
		rtopped = qfalse;
                break;
            case OP_LOAD4:
                ltop();							// get value from opstack
		//Inst( PPC_AND, R_MEMMASK, R_TOP, R_TOP );		// mask it
                Inst( PPC_LWZX, R_TOP, R_TOP, R_MEMBASE );		// load from memory base
                InstImm( PPC_STW, R_TOP, R_OPSTACK, 0 );
		rtopped = qtrue;
                break;
            case OP_LOAD2:
                ltop();							// get value from opstack
		//Inst( PPC_AND, R_MEMMASK, R_TOP, R_TOP );		// mask it
                Inst( PPC_LHZX, R_TOP, R_TOP, R_MEMBASE );		// load from memory base
                InstImm( PPC_STW, R_TOP, R_OPSTACK, 0 );
		rtopped = qtrue;
                break;
            case OP_LOAD1:
                ltop();							// get value from opstack
		//Inst( PPC_AND, R_MEMMASK, R_TOP, R_TOP );		// mask it
                Inst( PPC_LBZX, R_TOP, R_TOP, R_MEMBASE );		// load from memory base
                InstImm( PPC_STW, R_TOP, R_OPSTACK, 0 );
		rtopped = qtrue;
                break;
            case OP_STORE4:
                ltopandsecond();					// get value from opstack
		//Inst( PPC_AND, R_MEMMASK, R_SECOND, R_SECOND );		// mask it
                Inst( PPC_STWX, R_TOP, R_SECOND, R_MEMBASE );		// store from memory base
		rtopped = qfalse;
                break;
            case OP_STORE2:
                ltopandsecond();					// get value from opstack
		//Inst( PPC_AND, R_MEMMASK, R_SECOND, R_SECOND );		// mask it
                Inst( PPC_STHX, R_TOP, R_SECOND, R_MEMBASE );		// store from memory base
		rtopped = qfalse;
                break;
            case OP_STORE1:
                ltopandsecond();					// get value from opstack
		//Inst( PPC_AND, R_MEMMASK, R_SECOND, R_SECOND );		// mask it
                Inst( PPC_STBX, R_TOP, R_SECOND, R_MEMBASE );		// store from memory base
		rtopped = qfalse;
                break;

            case OP_EQ:
                ltopandsecond();					// get value from opstack
                Inst( PPC_CMP, 0, R_SECOND, R_TOP );
                i = Constant4();
				jused[i] = 1;
                InstImm( PPC_BC, 4, 2, 8 );
                if ( pass==1 ) {
                    v = vm->instructionPointers[ i ] - (int)&buf[compiledOfs];                    
                } else {
                    v = 0;             
                }
                Emit4(PPC_B | (v&0x3ffffff) );
				rtopped = qfalse;
                break;
            case OP_NE:
                ltopandsecond();					// get value from opstack
                Inst( PPC_CMP, 0, R_SECOND, R_TOP );
                i = Constant4();
				jused[i] = 1;
                InstImm( PPC_BC, 12, 2, 8 );
                if ( pass==1 ) {
                    v = vm->instructionPointers[ i ] - (int)&buf[compiledOfs];                    
                } else {
                    v = 0;
                }
                Emit4(PPC_B | (unsigned int)(v&0x3ffffff) );
//                InstImm( PPC_BC, 4, 2, v );

				rtopped = qfalse;
                break;
            case OP_LTI:
                ltopandsecond();					// get value from opstack
                Inst( PPC_CMP, 0, R_SECOND, R_TOP );
                i = Constant4();
				jused[i] = 1;
                InstImm( PPC_BC, 4, 0, 8 );
                if ( pass==1 ) {
                    v = vm->instructionPointers[ i ] - (int)&buf[compiledOfs];
                } else {
                    v = 0;
                }
                Emit4(PPC_B | (unsigned int)(v&0x3ffffff) );
//                InstImm( PPC_BC, 12, 0, v );
				rtopped = qfalse;
                break;
            case OP_LEI:
                ltopandsecond();					// get value from opstack
                Inst( PPC_CMP, 0, R_SECOND, R_TOP );
                i = Constant4();
				jused[i] = 1;
                InstImm( PPC_BC, 12, 1, 8 );
                if ( pass==1 ) {
                    v = vm->instructionPointers[ i ] - (int)&buf[compiledOfs];
                } else {
                    v = 0;
                }
                Emit4(PPC_B | (unsigned int)(v&0x3ffffff) );
//                InstImm( PPC_BC, 4, 1, v );
				rtopped = qfalse;
                break;
            case OP_GTI:
                ltopandsecond();		// get value from opstack
                Inst( PPC_CMP, 0, R_SECOND, R_TOP );
                i = Constant4();
				jused[i] = 1;
                InstImm( PPC_BC, 4, 1, 8 );
                if ( pass==1 ) {
                    v = vm->instructionPointers[ i ] - (int)&buf[compiledOfs];
                } else {
                    v = 0;
                }
                Emit4(PPC_B | (unsigned int)(v&0x3ffffff) );
//                InstImm( PPC_BC, 12, 1, v );
				rtopped = qfalse;
                break;
            case OP_GEI:
                ltopandsecond();		// get value from opstack
                Inst( PPC_CMP, 0, R_SECOND, R_TOP );
                i = Constant4();
				jused[i] = 1;
                if ( pass==1 ) {
                    v = vm->instructionPointers[ i ] - (int)&buf[compiledOfs];
                } else {
                    v = 0;
                }
                InstImm( PPC_BC, 4, 0, v );
				rtopped = qfalse;
                break;
            case OP_LTU:
                ltopandsecond();		// get value from opstack
                Inst( PPC_CMPL, 0, R_SECOND, R_TOP );
                i = Constant4();
		jused[i] = 1;
                if ( pass==1 ) {
                    v = vm->instructionPointers[ i ] - (int)&buf[compiledOfs];
                } else {
                    v = 0;
                }
                InstImm( PPC_BC, 12, 0, v );
		rtopped = qfalse;
                break;
            case OP_LEU:
                ltopandsecond();		// get value from opstack
                Inst( PPC_CMPL, 0, R_SECOND, R_TOP );
                i = Constant4();
		jused[i] = 1;
                if ( pass==1 ) {
                    v = vm->instructionPointers[ i ] - (int)&buf[compiledOfs];
                } else {
                    v = 0;
                }
                InstImm( PPC_BC, 4, 1, v );
		rtopped = qfalse;
                break;
            case OP_GTU:
                ltopandsecond();		// get value from opstack
                Inst( PPC_CMPL, 0, R_SECOND, R_TOP );
                i = Constant4();
		jused[i] = 1;
                if ( pass==1 ) {
                    v = vm->instructionPointers[ i ] - (int)&buf[compiledOfs];
                } else {
                    v = 0;
                }
                InstImm( PPC_BC, 12, 1, v );
		rtopped = qfalse;
                break;
            case OP_GEU:
                ltopandsecond();		// get value from opstack
                Inst( PPC_CMPL, 0, R_SECOND, R_TOP );
                i = Constant4();
		jused[i] = 1;
                if ( pass==1 ) {
                    v = vm->instructionPointers[ i ] - (int)&buf[compiledOfs];
                } else {
                    v = 0;
                }
                InstImm( PPC_BC, 4, 0, v );
		rtopped = qfalse;
                break;
                
            case OP_EQF:
                fltopandsecond();		// get value from opstack
                Inst( PPC_FCMPU, 0, R_TOP, R_SECOND );
                i = Constant4();
		jused[i] = 1;
                if ( pass==1 ) {
                    v = vm->instructionPointers[ i ] - (int)&buf[compiledOfs];
                } else {
                    v = 0;
                }
                InstImm( PPC_BC, 12, 2, v );
		rtopped = qfalse;
                break;			
            case OP_NEF:
                fltopandsecond();		// get value from opstack
                Inst( PPC_FCMPU, 0, R_TOP, R_SECOND );
                i = Constant4();
		jused[i] = 1;
                if ( pass==1 ) {
                    v = vm->instructionPointers[ i ] - (int)&buf[compiledOfs];
                } else {
                    v = 0;
                }
                InstImm( PPC_BC, 4, 2, v );
		rtopped = qfalse;
                break;			
            case OP_LTF:
                fltopandsecond();		// get value from opstack
                Inst( PPC_FCMPU, 0, R_SECOND, R_TOP );
                i = Constant4();
		jused[i] = 1;
                if ( pass==1 ) {
                    v = vm->instructionPointers[ i ] - (int)&buf[compiledOfs];
                } else {
                    v = 0;
                }
                InstImm( PPC_BC, 12, 0, v );
		rtopped = qfalse;
                break;			
            case OP_LEF:
                fltopandsecond();		// get value from opstack
                Inst( PPC_FCMPU, 0, R_SECOND, R_TOP );
                i = Constant4();
		jused[i] = 1;
                if ( pass==1 ) {
                    v = vm->instructionPointers[ i ] - (int)&buf[compiledOfs];
                } else {
                    v = 0;
                }
                InstImm( PPC_BC, 4, 1, v );
		rtopped = qfalse;
                break;			
            case OP_GTF:
                fltopandsecond();		// get value from opstack
                Inst( PPC_FCMPU, 0, R_SECOND, R_TOP );
                i = Constant4();
		jused[i] = 1;
                if ( pass==1 ) {
                    v = vm->instructionPointers[ i ] - (int)&buf[compiledOfs];
                } else {
                    v = 0;
                }
                InstImm( PPC_BC, 12, 1, v );
		rtopped = qfalse;
                break;			
            case OP_GEF:
                fltopandsecond();		// get value from opstack
                Inst( PPC_FCMPU, 0, R_SECOND, R_TOP );
                i = Constant4();
		jused[i] = 1;
                if ( pass==1 ) {
                    v = vm->instructionPointers[ i ] - (int)&buf[compiledOfs];
                } else {
                    v = 0;
                }
                InstImm( PPC_BC, 4, 0, v );
		rtopped = qfalse;
                break;

            case OP_NEGI:
                ltop();		// get value from opstack
                InstImm( PPC_SUBFIC, R_TOP, R_TOP, 0 );
                InstImm( PPC_STW, R_TOP, R_OPSTACK, 0 );		// save value to opstack
		rtopped = qtrue;
                break;
            case OP_ADD:
                ltop();		// get value from opstack
                InstImm( PPC_LWZU, R_SECOND, R_OPSTACK, -4 );		// get value from opstack
                Inst( PPC_ADD, R_TOP, R_TOP, R_SECOND );
                InstImm( PPC_STW, R_TOP, R_OPSTACK, 0 );		// save value to opstack
		rtopped = qtrue;
                break;
            case OP_SUB:
                ltop();		// get value from opstack
                InstImm( PPC_LWZU, R_SECOND, R_OPSTACK, -4 );		// get value from opstack
                Inst( PPC_SUBF, R_TOP, R_TOP, R_SECOND );
                InstImm( PPC_STW, R_TOP, R_OPSTACK, 0 );		// save value to opstack
		rtopped = qtrue;
                break;
            case OP_DIVI:
                ltop();		// get value from opstack
                InstImm( PPC_LWZU, R_SECOND, R_OPSTACK, -4 );		// get value from opstack
                Inst( PPC_DIVW, R_TOP, R_SECOND, R_TOP );
                InstImm( PPC_STW, R_TOP, R_OPSTACK, 0 );		// save value to opstack
		rtopped = qtrue;
                break;
            case OP_DIVU:
                ltop();		// get value from opstack
                InstImm( PPC_LWZU, R_SECOND, R_OPSTACK, -4 );		// get value from opstack
                Inst( PPC_DIVWU, R_TOP, R_SECOND, R_TOP );
                InstImm( PPC_STW, R_TOP, R_OPSTACK, 0 );		// save value to opstack
		rtopped = qtrue;
                break;
            case OP_MODI:
                ltop();		// get value from opstack
                InstImm( PPC_LWZU, R_SECOND, R_OPSTACK, -4 );		// get value from opstack
                Inst( PPC_DIVW, R_EA, R_SECOND, R_TOP );
                Inst( PPC_MULLW, R_EA, R_TOP, R_EA );
                Inst( PPC_SUBF, R_TOP, R_EA, R_SECOND );
                InstImm( PPC_STW, R_TOP, R_OPSTACK, 0 );		// save value to opstack
		rtopped = qtrue;
                break;
            case OP_MODU:
                ltop();		// get value from opstack
                InstImm( PPC_LWZU, R_SECOND, R_OPSTACK, -4 );		// get value from opstack
                Inst( PPC_DIVWU, R_EA, R_SECOND, R_TOP );
                Inst( PPC_MULLW, R_EA, R_TOP, R_EA );
                Inst( PPC_SUBF, R_TOP, R_EA, R_SECOND );
                InstImm( PPC_STW, R_TOP, R_OPSTACK, 0 );		// save value to opstack
		rtopped = qtrue;
                break;
            case OP_MULI:
            case OP_MULU:
                ltop();		// get value from opstack
                InstImm( PPC_LWZU, R_SECOND, R_OPSTACK, -4 );		// get value from opstack
                Inst( PPC_MULLW, R_TOP, R_SECOND, R_TOP );
                InstImm( PPC_STW, R_TOP, R_OPSTACK, 0 );		// save value to opstack
		rtopped = qtrue;
                break;
            case OP_BAND:
                ltop();		// get value from opstack
                InstImm( PPC_LWZU, R_SECOND, R_OPSTACK, -4 );		// get value from opstack
                Inst( PPC_AND, R_SECOND, R_TOP, R_TOP );
                InstImm( PPC_STW, R_TOP, R_OPSTACK, 0 );		// save value to opstack
		rtopped = qtrue;
                break;
            case OP_BOR:
                ltop();		// get value from opstack
                InstImm( PPC_LWZU, R_SECOND, R_OPSTACK, -4 );		// get value from opstack
                Inst( PPC_OR, R_SECOND, R_TOP, R_TOP );
                InstImm( PPC_STW, R_TOP, R_OPSTACK, 0 );		// save value to opstack
		rtopped = qtrue;
                break;
            case OP_BXOR:
                ltop();		// get value from opstack
                InstImm( PPC_LWZU, R_SECOND, R_OPSTACK, -4 );		// get value from opstack
                Inst( PPC_XOR, R_SECOND, R_TOP, R_TOP );
                InstImm( PPC_STW, R_TOP, R_OPSTACK, 0 );		// save value to opstack
		rtopped = qtrue;
                break;
            case OP_BCOM:
                ltop();		// get value from opstack
                Inst( PPC_NOR, R_TOP, R_TOP, R_TOP );
                InstImm( PPC_STW, R_TOP, R_OPSTACK, 0 );		// save value to opstack
		rtopped = qtrue;
                break;
            case OP_LSH:
                ltop();		// get value from opstack
                InstImm( PPC_LWZU, R_SECOND, R_OPSTACK, -4 );		// get value from opstack
                Inst( PPC_SLW, R_SECOND, R_TOP, R_TOP );
                InstImm( PPC_STW, R_TOP, R_OPSTACK, 0 );		// save value to opstack
		rtopped = qtrue;
                break;
            case OP_RSHI:
                ltop();		// get value from opstack
                InstImm( PPC_LWZU, R_SECOND, R_OPSTACK, -4 );		// get value from opstack
                Inst( PPC_SRAW, R_SECOND, R_TOP, R_TOP );
                InstImm( PPC_STW, R_TOP, R_OPSTACK, 0 );		// save value to opstack
		rtopped = qtrue;
                break;
            case OP_RSHU:
                ltop();		// get value from opstack
                InstImm( PPC_LWZU, R_SECOND, R_OPSTACK, -4 );		// get value from opstack
                Inst( PPC_SRW, R_SECOND, R_TOP, R_TOP );
                InstImm( PPC_STW, R_TOP, R_OPSTACK, 0 );		// save value to opstack
		rtopped = qtrue;
                break;

            case OP_NEGF:
                InstImm( PPC_LFS, R_TOP, R_OPSTACK, 0 );		// get value from opstack
                Inst( PPC_FNEG, R_TOP, 0, R_TOP );
                InstImm( PPC_STFS, R_TOP, R_OPSTACK, 0 );		// save value to opstack
		rtopped = qfalse;
                break;
            case OP_ADDF:
                InstImm( PPC_LFS, R_TOP, R_OPSTACK, 0 );		// get value from opstack
                InstImm( PPC_LFSU, R_SECOND, R_OPSTACK, -4 );		// get value from opstack
                Inst( PPC_FADDS, R_TOP, R_SECOND, R_TOP );
                InstImm( PPC_STFS, R_TOP, R_OPSTACK, 0 );		// save value to opstack
		rtopped = qfalse;
                break;
            case OP_SUBF:
                InstImm( PPC_LFS, R_TOP, R_OPSTACK, 0 );		// get value from opstack
                InstImm( PPC_LFSU, R_SECOND, R_OPSTACK, -4 );		// get value from opstack
                Inst( PPC_FSUBS, R_TOP, R_SECOND, R_TOP );
                InstImm( PPC_STFS, R_TOP, R_OPSTACK, 0 );		// save value to opstack
		rtopped = qfalse;
                break;
            case OP_DIVF:
                InstImm( PPC_LFS, R_TOP, R_OPSTACK, 0 );		// get value from opstack
                InstImm( PPC_LFSU, R_SECOND, R_OPSTACK, -4 );		// get value from opstack
                Inst( PPC_FDIVS, R_TOP, R_SECOND, R_TOP );
                InstImm( PPC_STFS, R_TOP, R_OPSTACK, 0 );		// save value to opstack
		rtopped = qfalse;
                break;
            case OP_MULF:
                InstImm( PPC_LFS, R_TOP, R_OPSTACK, 0 );		// get value from opstack
                InstImm( PPC_LFSU, R_SECOND, R_OPSTACK, -4 );		// get value from opstack
                Inst4( PPC_FMULS, R_TOP, R_SECOND, 0, R_TOP );
                InstImm( PPC_STFS, R_TOP, R_OPSTACK, 0 );		// save value to opstack
		rtopped = qfalse;
                break;

            case OP_CVIF:
                v = (int)&itofConvert;
                InstImmU( PPC_ADDIS, R_EA, 0, (v >> 16)&0xffff );
                InstImmU( PPC_ORI, R_EA, R_EA, v & 0xffff );
		InstImm( PPC_LWZ, R_TOP, R_OPSTACK, 0 );		// get value from opstack
                InstImmU( PPC_XORIS, R_TOP, R_TOP, 0x8000 );
                InstImm( PPC_STW, R_TOP, R_EA, 12 );
                InstImm( PPC_LFD, R_TOP, R_EA, 0 );
                InstImm( PPC_LFD, R_SECOND, R_EA, 8 );
                Inst( PPC_FSUB, R_TOP, R_SECOND, R_TOP );
    //            Inst( PPC_FRSP, R_TOP, 0, R_TOP );
                InstImm( PPC_STFS, R_TOP, R_OPSTACK, 0 );		// save value to opstack
		rtopped = qfalse;
                break;
            case OP_CVFI:
                InstImm( PPC_LFS, R_TOP, R_OPSTACK, 0 );		// get value from opstack
                Inst( PPC_FCTIWZ, R_TOP, 0, R_TOP );
                Inst( PPC_STFIWX, R_TOP, 0, R_OPSTACK );		// save value to opstack
		rtopped = qfalse;
                break;
            case OP_SEX8:
                ltop();	// get value from opstack
                Inst( PPC_EXTSB, R_TOP, R_TOP, 0 );
                InstImm( PPC_STW, R_TOP, R_OPSTACK, 0 );
		rtopped = qtrue;
                break;
            case OP_SEX16:
                ltop();	// get value from opstack
                Inst( PPC_EXTSH, R_TOP, R_TOP, 0 );
                InstImm( PPC_STW, R_TOP, R_OPSTACK, 0 );
		rtopped = qtrue;
                break;

            case OP_BLOCK_COPY:
                v = Constant4() >> 2;
                ltop();		// source
                InstImm( PPC_LWZ, R_SECOND, R_OPSTACK, -4 );	// dest
                InstImm( PPC_ADDI, R_OPSTACK, R_OPSTACK, -8 );
                InstImmU( PPC_ADDI, R_EA, 0, v );				// count
				// FIXME: range check
              	Inst( PPC_MTSPR, R_EA, 9, 0 );					// move to count register

                Inst( PPC_ADD, R_TOP, R_TOP, R_MEMBASE );
                InstImm( PPC_ADDI, R_TOP, R_TOP, -4 );
                Inst( PPC_ADD, R_SECOND, R_SECOND, R_MEMBASE );
                InstImm( PPC_ADDI, R_SECOND, R_SECOND, -4 );

                InstImm( PPC_LWZU, R_EA, R_TOP, 4 );		// source
                InstImm( PPC_STWU, R_EA, R_SECOND, 4 );	// dest
                Inst( PPC_BC | 0xfff8 , 16, 0, 0 );					// loop
		rtopped = qfalse;
                break;

            case OP_JUMP:
                ltop();	// get value from opstack
                InstImm( PPC_ADDI, R_OPSTACK, R_OPSTACK, -4 );
                Inst( PPC_RLWINM | ( 29 << 1 ), R_TOP, R_TOP, 2 );
		// FIXME: range check
		Inst( PPC_LWZX, R_TOP, R_TOP, R_INSTRUCTIONS );
                Inst( PPC_MTSPR, R_TOP, 9, 0 );		// move to count register
                Inst( PPC_BCCTR, 20, 0, 0 );		// jump to the count register
		rtopped = qfalse;
                break;
            default:
                Com_Error( ERR_DROP, "VM_CompilePPC: bad opcode %i at instruction %i, offset %i", op, instruction, pc );
            }
	    pop0 = pop1;
	    pop1 = op;
        }

	Com_Printf( "VM file %s pass %d compiled to %i bytes of code\n", vm->name, (pass+1), compiledOfs*4 );

    	if ( pass == 0 ) {
	    // copy to an exact size buffer on the hunk
	    vm->codeLength = compiledOfs * 4;
	    vm->codeBase = Hunk_Alloc( vm->codeLength, h_low );
	    Com_Memcpy( vm->codeBase, buf, vm->codeLength );
	    Z_Free( buf );
	
	    // offset all the instruction pointers for the new location
	    for ( i = 0 ; i < header->instructionCount ; i++ ) {
		vm->instructionPointers[i] += (int)vm->codeBase;
	    }

	    // go back over it in place now to fixup reletive jump targets
	    buf = (unsigned *)vm->codeBase;
	}
    }
    Z_Free( jused );
}
Exemplo n.º 28
0
CPipeTrMsgBufferSwapper::CPipeTrMsgBufferSwapper()
{
	Inst() = this;
}
Exemplo n.º 29
0
CPipeTrMsgBufferSwapper::~CPipeTrMsgBufferSwapper()
{
	Inst() = NULL;
}
Exemplo n.º 30
0
size_t MainThread::Run()
{
    Inst().ios_->run();
    return 0;
}