uint8_t *TR::PPCLabelInstruction::generateBinaryEncoding() { uint8_t *instructionStart = cg()->getBinaryBufferCursor(); TR::LabelSymbol *label = getLabelSymbol(); uint8_t *cursor = instructionStart; if (getOpCode().isBranchOp()) { cursor = getOpCode().copyBinaryToBuffer(instructionStart); if (label->getCodeLocation() != NULL) { *(int32_t *)cursor |= ((label->getCodeLocation()-cursor) & 0x03fffffc); } else { cg()->addRelocation(new (cg()->trHeapMemory()) TR::LabelRelative24BitRelocation(cursor, label)); } cursor += 4; } else // regular LABEL { label->setCodeLocation(instructionStart); } setBinaryLength(cursor - instructionStart); cg()->addAccumulatedInstructionLengthError(getEstimatedBinaryLength() - getBinaryLength()); setBinaryEncoding(instructionStart); return cursor; }
uint8_t *TR::PPCTrg1Src1ImmInstruction::generateBinaryEncoding() { uint8_t *instructionStart = cg()->getBinaryBufferCursor(); uint8_t *cursor = instructionStart; cursor = getOpCode().copyBinaryToBuffer(instructionStart); insertTargetRegister(toPPCCursor(cursor)); insertSource1Register(toPPCCursor(cursor)); if (getOpCodeValue() == TR::InstOpCode::srawi || getOpCodeValue() == TR::InstOpCode::srawi_r || getOpCodeValue() == TR::InstOpCode::sradi || getOpCodeValue() == TR::InstOpCode::sradi_r || getOpCodeValue() == TR::InstOpCode::extswsli) { insertShiftAmount(toPPCCursor(cursor)); } else if (getOpCodeValue() == TR::InstOpCode::dtstdg) { setSourceImmediate(getSourceImmediate() << 10); insertImmediateField(toPPCCursor(cursor)); } else { insertImmediateField(toPPCCursor(cursor)); } addMetaDataForCodeAddress(cursor); cursor += PPC_INSTRUCTION_LENGTH; setBinaryLength(PPC_INSTRUCTION_LENGTH); setBinaryEncoding(instructionStart); return cursor; }
void Instruction::print() { switch(getOpCode()) { case ADD: cout << "ADD "; cout << getOpda() << " " << getOpdb() << " " << getJumpVal(); break; case SUB: cout << "SUB "; cout << getOpda() << " " << getOpdb() << " " << getJumpVal(); break; case MUL: cout << "MUL "; cout << getOpda() << " " << getOpdb() << " " << getJumpVal(); break; case DIV: cout << "DIV "; cout << getOpda() << " " << getOpdb() << " " << getJumpVal(); break; case BEQ: cout << "BEQ "; cout << getOpda() << " " << getOpdb() << " " << getJumpVal(); break; case BNE: cout << "BNE "; cout << getOpda() << " " << getOpdb() << " " << getJumpVal(); break; case BLT: cout << "BLT "; cout << getOpda() << " " << getOpdb() << " " << getJumpVal(); break; case BGT: cout << "BGT "; cout << getOpda() << " " << getOpdb() << " " << getJumpVal(); break; case LI: cout << "LI " << getOpda() << " " << getOpdbAlt(); break; case SR: cout << "SR " << getOpda() << " " << getOpdb(); break; case LR: cout << "LR " << getOpda() << " " << getOpdb(); break; case PRINT: cout << "PRINT " << getOpda(); break; case HALT: cout << "HALT"; break; default: cout << "OTHER"; } cout << "\n"; }
static CurOp* beginCurrentOp( Client* client, const BatchItemRef& currWrite ) { // Execute the write item as a child operation of the current operation. auto_ptr<CurOp> currentOp( new CurOp( client, client->curop() ) ); // Set up the child op with more info HostAndPort remote = client->hasRemote() ? client->getRemote() : HostAndPort( "0.0.0.0", 0 ); // TODO Modify CurOp "wrapped" constructor to take an opcode, so calling .reset() // is unneeded currentOp->reset( remote, getOpCode( currWrite.getRequest()->getBatchType() ) ); currentOp->ensureStarted(); currentOp->setNS( currWrite.getRequest()->getNS() ); currentOp->debug().ns = currentOp->getNS(); currentOp->debug().op = currentOp->getOp(); if ( currWrite.getOpType() == BatchedCommandRequest::BatchType_Insert ) { currentOp->setQuery( currWrite.getDocument() ); currentOp->debug().query = currWrite.getDocument(); } else if ( currWrite.getOpType() == BatchedCommandRequest::BatchType_Update ) { currentOp->setQuery( currWrite.getUpdate()->getQuery() ); currentOp->debug().query = currWrite.getUpdate()->getQuery(); currentOp->debug().updateobj = currWrite.getUpdate()->getUpdateExpr(); } else { dassert( currWrite.getOpType() == BatchedCommandRequest::BatchType_Delete ); currentOp->setQuery( currWrite.getDelete()->getQuery() ); currentOp->debug().query = currWrite.getDelete()->getQuery(); } return currentOp.release(); }
uint8_t *TR::PPCControlFlowInstruction::generateBinaryEncoding() { uint8_t *instructionStart = cg()->getBinaryBufferCursor(); uint8_t *cursor = instructionStart; cursor = getOpCode().copyBinaryToBuffer(instructionStart); setBinaryLength(0); return cursor; }
void displayVm(Vm* vm) { printf("PC = %d ", vm->PC); printf("IR = "); displayCharArray(vm->IR, 6); printf("; "); printf("%s\n", INSTRUCTION_NAMES[getOpCode(vm->IR)]); }
uint8_t *TR::PPCDepImmInstruction::generateBinaryEncoding() { uint8_t *instructionStart = cg()->getBinaryBufferCursor(); uint8_t *cursor = instructionStart; cursor = getOpCode().copyBinaryToBuffer(instructionStart); *(int32_t *)cursor = (int32_t)getSourceImmediate(); cursor += PPC_INSTRUCTION_LENGTH; setBinaryLength(PPC_INSTRUCTION_LENGTH); setBinaryEncoding(instructionStart); return cursor; }
uint8_t *TR::PPCTrg1Instruction::generateBinaryEncoding() { uint8_t *instructionStart = cg()->getBinaryBufferCursor(); uint8_t *cursor = instructionStart; cursor = getOpCode().copyBinaryToBuffer(instructionStart); insertTargetRegister(toPPCCursor(cursor)); cursor += PPC_INSTRUCTION_LENGTH; setBinaryLength(PPC_INSTRUCTION_LENGTH); setBinaryEncoding(instructionStart); return cursor; }
uint8_t *TR::PPCMemInstruction::generateBinaryEncoding() { uint8_t *instructionStart = cg()->getBinaryBufferCursor(); uint8_t *cursor = instructionStart; getMemoryReference()->mapOpCode(this); cursor = getOpCode().copyBinaryToBuffer(instructionStart); cursor = getMemoryReference()->generateBinaryEncoding(this, cursor, cg()); setBinaryLength(cursor-instructionStart); setBinaryEncoding(instructionStart); cg()->addAccumulatedInstructionLengthError(getEstimatedBinaryLength() - getBinaryLength()); return cursor; }
uint8_t *TR::PPCImm2Instruction::generateBinaryEncoding() { uint8_t *instructionStart = cg()->getBinaryBufferCursor(); uint8_t *cursor = instructionStart; cursor = getOpCode().copyBinaryToBuffer(instructionStart); insertImmediateField(toPPCCursor(cursor)); insertImmediateField2(toPPCCursor(cursor)); cursor += PPC_INSTRUCTION_LENGTH; setBinaryLength(PPC_INSTRUCTION_LENGTH); setBinaryEncoding(instructionStart); cg()->addAccumulatedInstructionLengthError(getEstimatedBinaryLength() - getBinaryLength()); return cursor; }
uint8_t *TR::PPCTrg1Src1Imm2Instruction::generateBinaryEncoding() { uint8_t *instructionStart = cg()->getBinaryBufferCursor(); uint8_t *cursor = instructionStart; cursor = getOpCode().copyBinaryToBuffer(instructionStart); insertTargetRegister(toPPCCursor(cursor)); insertSource1Register(toPPCCursor(cursor)); insertShiftAmount(toPPCCursor(cursor)); insertMaskField(toPPCCursor(cursor), getOpCodeValue(), getLongMask()); cursor += PPC_INSTRUCTION_LENGTH; setBinaryLength(PPC_INSTRUCTION_LENGTH); setBinaryEncoding(instructionStart); return cursor; }
uint8_t *TR::PPCImmInstruction::generateBinaryEncoding() { TR::Compilation *comp = cg()->comp(); uint8_t *instructionStart = cg()->getBinaryBufferCursor(); uint8_t *cursor = instructionStart; cursor = getOpCode().copyBinaryToBuffer(instructionStart); *(int32_t *)cursor = (int32_t)getSourceImmediate(); addMetaDataForCodeAddress(cursor); cursor += PPC_INSTRUCTION_LENGTH; setBinaryLength(PPC_INSTRUCTION_LENGTH); setBinaryEncoding(instructionStart); cg()->addAccumulatedInstructionLengthError(getEstimatedBinaryLength() - getBinaryLength()); return cursor; }
void outputCodeToFile(FILE* ofp, int code[][MAX_CODE_LENGTH], int codeLength) { fprintf(ofp, "line\tOP\tL\tM\n"); for (int i = 0; i < codeLength; i++) { fprintf(ofp, "%d\t", i); fprintf(ofp, "%s\t", getOpCode(code[0][i]) ); for (int j = 1; j < 4; j++) { if (j != 1) { fprintf(ofp, "%d\t", code[j][i]); } } fprintf(ofp, "\n"); } fprintf(ofp, "\n"); }
uint8_t *TR::PPCTrg1Src1Instruction::generateBinaryEncoding() { uint8_t *instructionStart = cg()->getBinaryBufferCursor(); uint8_t *cursor = instructionStart; if (isRegCopy() && (toRealRegister(getTargetRegister()) == toRealRegister(getSource1Register()))) { } else { cursor = getOpCode().copyBinaryToBuffer(instructionStart); insertTargetRegister(toPPCCursor(cursor)); insertSource1Register(toPPCCursor(cursor)); cursor += PPC_INSTRUCTION_LENGTH; } setBinaryLength(cursor - instructionStart); cg()->addAccumulatedInstructionLengthError(getEstimatedBinaryLength() - getBinaryLength()); setBinaryEncoding(instructionStart); return cursor; }
int32_t TR::PPCLabelInstruction::estimateBinaryLength(int32_t currentEstimate) { int8_t loopAlignBytes = 0; static int count=0; if (isNopCandidate()) { loopAlignBytes = MAX_LOOP_ALIGN_NOPS()*PPC_INSTRUCTION_LENGTH; } if (getOpCode().isBranchOp()) { setEstimatedBinaryLength(PPC_INSTRUCTION_LENGTH); } else { setEstimatedBinaryLength(0); getLabelSymbol()->setEstimatedCodeLocation(currentEstimate + loopAlignBytes); } return currentEstimate + getEstimatedBinaryLength() + loopAlignBytes; }
int32_t OMR::RecognizedCallTransformer::perform() { TR::NodeChecklist visited(comp()); for (auto treetop = comp()->getMethodSymbol()->getFirstTreeTop(); treetop != NULL; treetop = treetop->getNextTreeTop()) { if (treetop->getNode()->getNumChildren() > 0) { auto node = treetop->getNode()->getFirstChild(); if (node && node->getOpCode().isCall() && !visited.contains(node)) { if (isInlineable(treetop) && performTransformation(comp(), "%s Transforming recognized call node [" POINTER_PRINTF_FORMAT "]\n", optDetailString(), node)) { visited.add(node); transform(treetop); } } } } return 0; }
uint8_t *TR::PPCSrc1Instruction::generateBinaryEncoding() { uint8_t *instructionStart = cg()->getBinaryBufferCursor(); uint8_t *cursor = instructionStart; cursor = getOpCode().copyBinaryToBuffer(instructionStart); insertSource1Register(toPPCCursor(cursor)); if (getOpCodeValue() == TR::InstOpCode::mtfsf | getOpCodeValue() == TR::InstOpCode::mtfsfl || getOpCodeValue() == TR::InstOpCode::mtfsfw) { insertMaskField(toPPCCursor(cursor)); } else { insertImmediateField(toPPCCursor(cursor)); } cursor += PPC_INSTRUCTION_LENGTH; setBinaryLength(PPC_INSTRUCTION_LENGTH); setBinaryEncoding(instructionStart); cg()->addAccumulatedInstructionLengthError(getEstimatedBinaryLength() - getBinaryLength()) ; return cursor; }
uint8_t *TR::PPCTrg1ImmInstruction::generateBinaryEncoding() { uint8_t *instructionStart = cg()->getBinaryBufferCursor(); uint8_t *cursor = instructionStart; cursor = getOpCode().copyBinaryToBuffer(instructionStart); insertTargetRegister(toPPCCursor(cursor)); if (getOpCodeValue() == TR::InstOpCode::mtcrf || getOpCodeValue() == TR::InstOpCode::mfocrf) { *((int32_t *)cursor) |= (getSourceImmediate()<<12); if ((TR::Compiler->target.cpu.id() >= TR_PPCgp) && ((getSourceImmediate() & (getSourceImmediate() - 1)) == 0)) // convert to PPC AS single field form *((int32_t *)cursor) |= 0x00100000; } else if (getOpCodeValue() == TR::InstOpCode::mfcr) { if ((TR::Compiler->target.cpu.id() >= TR_PPCgp) && ((getSourceImmediate() & (getSourceImmediate() - 1)) == 0)) // convert to PPC AS single field form *((int32_t *)cursor) |= (getSourceImmediate()<<12) | 0x00100000; else TR_ASSERT(getSourceImmediate() == 0xFF, "Bad field mask on mfcr"); } else { insertImmediateField(toPPCCursor(cursor)); } addMetaDataForCodeAddress(cursor); cursor += PPC_INSTRUCTION_LENGTH; setBinaryLength(PPC_INSTRUCTION_LENGTH); setBinaryEncoding(instructionStart); return cursor; }
uint8_t *TR::PPCTrg1MemInstruction::generateBinaryEncoding() { uint8_t *instructionStart = cg()->getBinaryBufferCursor(); uint8_t *cursor = instructionStart; getMemoryReference()->mapOpCode(this); cursor = getOpCode().copyBinaryToBuffer(instructionStart); insertTargetRegister(toPPCCursor(cursor)); // Set hint bit if there is any // The control for the different values is done through asserts in the constructor if (haveHint()) { *(int32_t *)instructionStart |= getHint(); } cursor = getMemoryReference()->generateBinaryEncoding(this, cursor, cg()); setBinaryLength(cursor-instructionStart); setBinaryEncoding(instructionStart); cg()->addAccumulatedInstructionLengthError(getEstimatedBinaryLength() - getBinaryLength()); return cursor; }
bool WriteBatchExecutor::applyWriteItem( const BatchItemRef& itemRef, WriteStats* stats, BSONObj* upsertedID, BatchedErrorDetail* error ) { const BatchedCommandRequest& request = *itemRef.getRequest(); const string& ns = request.getNS(); // Clear operation's LastError before starting. _le->reset( true ); //uint64_t itemTimeMicros = 0; bool opSuccess = true; // Each write operation executes in its own PageFaultRetryableSection. This means that // a single batch can throw multiple PageFaultException's, which is not the case for // other operations. PageFaultRetryableSection s; while ( true ) { try { // Execute the write item as a child operation of the current operation. CurOp childOp( _client, _client->curop() ); HostAndPort remote = _client->hasRemote() ? _client->getRemote() : HostAndPort( "0.0.0.0", 0 ); // TODO Modify CurOp "wrapped" constructor to take an opcode, so calling .reset() // is unneeded childOp.reset( remote, getOpCode( request.getBatchType() ) ); childOp.ensureStarted(); OpDebug& opDebug = childOp.debug(); opDebug.ns = ns; { Lock::DBWrite dbLock( ns ); Client::Context ctx( ns, storageGlobalParams.dbpath, // TODO: better constructor? false /* don't check version here */); opSuccess = doWrite( ns, itemRef, &childOp, stats, upsertedID, error ); } childOp.done(); //itemTimeMicros = childOp.totalTimeMicros(); opDebug.executionTime = childOp.totalTimeMillis(); opDebug.recordStats(); // Log operation if running with at least "-v", or if exceeds slow threshold. if (logger::globalLogDomain()->shouldLog(logger::LogSeverity::Debug(1)) || opDebug.executionTime > serverGlobalParams.slowMS + childOp.getExpectedLatencyMs()) { MONGO_TLOG(1) << opDebug.report( childOp ) << endl; } // TODO Log operation if logLevel >= 3 and assertion thrown (as assembleResponse() // does). // Save operation to system.profile if shouldDBProfile(). if ( childOp.shouldDBProfile( opDebug.executionTime ) ) { profile( *_client, getOpCode( request.getBatchType() ), childOp ); } break; } catch ( PageFaultException& e ) { e.touch(); } } return opSuccess; }
bool KeyListOps::isNumericOp(const QuickString &op) const { return isNumericOp(getOpCode(op)); }
bool WebSocketFrame::isContinuationFrame() const { return getOpCode() == OpCode::Continuation; }
int main() { int buffer, counter = 0, codeLen = 0;; int i, j; int line = 0; // Stack int stack[MAX_STACK_HEIGHT]; for ( i = 0; i < MAX_STACK_HEIGHT; i++ ) { stack[i] = 0; } // Program code array int code[4][MAX_CODE_LENGTH]; for ( i = 0; i < MAX_CODE_LENGTH; i++ ) { for ( j = 0; j < 4; j++ ) { code[j][i] = 0; } } // CPU registers int stackPtr = 0; int basePtr = 1; int PC = 0; instruction ir; ir.op = 0; ir.r = 0; ir.l = 0; ir.m = 0; int reg[16]; for (i = 0; i < 16; i++) { reg[i] = 0; } int ActRecLen[20]; int curActRec = 0; // Set halt int halt = 0; FILE *inputPointer = fopen("temp.txt", "rb"); if ( ! inputPointer) { printf("Code for PMachine not found\n"); exit(1); } // Read the file and put it into the code memory while (fscanf(inputPointer, "%d", &buffer) != EOF) { code[counter % 4][counter/4] = buffer; counter++; } codeLen = counter / 4; fclose (inputPointer); FILE *outputPointer = fopen("stacktrace.txt", "w+"); outputCodeToFile(outputPointer, code, codeLen); // print headers for the stack info fprintf(outputPointer, "\t\t\t\tPC\tBP\tSP\tstack \n"); fprintf(outputPointer, "Initial values \t\t\t%d\t", PC); fprintf(outputPointer, "%d\t", basePtr); fprintf(outputPointer, "%d\t", stackPtr); fprintf(outputPointer, "%d\n", stack[0]); // Fetch and Execute while ( ! halt) { line = PC; // fetch the next line of code ir = fetch( PC, code ); // increment the program counter PC = PC + 1; // execute cycle switch ( ir.op ) { case 1: // LIT reg[ir.r] = ir.m; break; case 2: // RTN stackPtr = basePtr - 1; basePtr = stack[stackPtr + 3]; PC = stack[stackPtr + 4]; curActRec--; break; case 3: // LOD reg[ir.r] = stack[ base(ir.l, basePtr, stack) + ir.m ]; break; case 4: // STO stack[ base(ir.l, basePtr, stack) + ir.m] = reg[ir.r]; break; case 5: // CAL stack[stackPtr + 1] = 0; stack[stackPtr + 2] = base(ir.l, basePtr, stack); stack[stackPtr + 3] = basePtr; stack[stackPtr + 4] = PC; basePtr = stackPtr + 1; PC = ir.m; break; case 6: // INC stackPtr = stackPtr + ir.m; ActRecLen[curActRec+1]=ir.m + ActRecLen[curActRec]; curActRec++; break; case 7: // JMP PC = ir.m; break; case 8: // JPC if ( reg[ir.r] == 0 ){ PC = ir.m; } break; case 9: // SIO R, 0, 1 printf("%d\n", reg[ir.r] ); break; case 10: // SIO R, 0, 2 printf("Enter value: \t"); scanf("%d", ®[ir.r] ); break; case 11: // SIO R, 0, 3 halt = 1; break; case 12: // NEG reg[ ir.r ] = - reg[ir.l]; break; case 13: // ADD reg[ir.r] = reg[ir.l] + reg[ir.m]; break; case 14: // SUB reg[ir.r] = reg[ir.l] - reg[ir.m]; break; case 15: // MUL reg[ir.r] = reg[ir.l] * reg[ir.m]; break; case 16: // DIV reg[ir.r] = reg[ir.l] / reg[ir.m]; break; case 17: // ODD reg[ir.r] = reg[ir.r] % 2; break; case 18: // MOD reg[ir.r] = reg[ir.l] % reg[ir.m]; break; case 19: // EQL reg[ir.r] = reg[ir.l] == reg[ir.m]; break; case 20: // NEQ reg[ir.r] = reg[ir.l] != reg[ir.m]; break; case 21: // LSS reg[ir.r] = reg[ir.l] < reg[ir.m]; break; case 22: // LEQ reg[ir.r] = reg[ir.l] <= reg[ir.m]; break; case 23: // GTR reg[ir.r] = reg[ir.l] > reg[ir.m]; break; case 24: // GEQ reg[ir.r] = reg[ir.l] >= reg[ir.m]; break; default: printf("Invalid op code.\n"); exit(1); } fprintf(outputPointer, "%d\t", line ); fprintf(outputPointer, "%s\t", getOpCode(ir.op) ); fprintf(outputPointer, "%d\t", ir.r); fprintf(outputPointer, "%d\t", ir.l); fprintf(outputPointer, "%d\t", ir.m); fprintf(outputPointer, "%d\t", PC); fprintf(outputPointer, "%d\t", basePtr); fprintf(outputPointer, "%d\t", stackPtr); // Output stack i = 1; for (j = 0; j <= stackPtr; j++) { fprintf(outputPointer, "%d ", stack[j] ); // print out separators btwn the activation records if (j == ActRecLen[i] && j != stackPtr) { fprintf(outputPointer, "| "); i++; } } fprintf(outputPointer, "\n"); // If at the end, halt if ( stackPtr == 0 && basePtr == 0 && PC == 0) halt = 1; } fclose(outputPointer); return 0; }
bool KeyListOps::isValidColumnOps(FileRecordMgr *dbFile) { //get the strings from context containing the comma-delimited lists of columns //and operations. Split both of these into vectors. Get the operation code //for each operation string. Finally, make a vector of pairs, where the first //member of each pair is a column number, and the second member is the code for the //operation to perform on that column. Tokenizer colTokens; Tokenizer opsTokens; int numCols = colTokens.tokenize(_columns, ','); int numOps = opsTokens.tokenize(_operations, ','); if (numOps < 1 || numCols < 1) { cerr << endl << "*****" << endl << "***** ERROR: There must be at least one column and at least one operation named." << endl; return false; } if (numOps > 1 && numCols > 1 && numCols != numOps) { cerr << endl << "*****" << endl << "***** ERROR: There are " << numCols <<" columns given, but there are " << numOps << " operations." << endl; cerr << "\tPlease provide either a single operation that will be applied to all listed columns, " << endl; cerr << "\ta single column to which all operations will be applied," << endl; cerr << "\tor an operation for each column." << endl; return false; } int loop = max(numCols, numOps); // If there is only one column, all ops are performed on it. // Otherwise, if there is only op, it is performed on all columns. // Besides that, ops are performed on columns in their respective // ordering. for (int i=0; i < loop; i++) { int col = str2chrPos(colTokens.getElem(numCols > 1 ? i : 0)); //check that the column number is valid if (col < 1 || col > dbFile->getNumFields()) { cerr << endl << "*****" << endl << "***** ERROR: Requested column " << col << ", but database file " << dbFile->getFileName() << " only has fields 1 - " << dbFile->getNumFields() << "." << endl; return false; } const QuickString &operation = opsTokens.getElem(numOps > 1 ? i : 0); OP_TYPES opCode = getOpCode(operation); if (opCode == INVALID) { cerr << endl << "*****" << endl << "***** ERROR: " << operation << " is not a valid operation. " << endl; return false; } _colOps.push_back(pair<int, OP_TYPES>(col, opCode)); } //lastly, if the file is BAM, and they asked for column 2, which is the //flags field, then for now we have to throw an error, as the flag field //is currently not supported. if (_dbFileType == FileRecordTypeChecker::BAM_FILE_TYPE) { //also, tell the methods class we're dealing with BAM. _methods.setIsBam(true); for (size_t i = 0; i < _colOps.size(); i++) { if (_colOps[i].first == 2) { cerr << endl << "*****" << endl << "***** ERROR: Requested column 2 of a BAM file, which is the Flags field." << endl; cerr << " We currently do not support this, but may in future versions." << endl; return false; } } } return true; }
uint8_t *TR::PPCConditionalBranchInstruction::generateBinaryEncoding() { uint8_t *instructionStart = cg()->getBinaryBufferCursor(); TR::LabelSymbol *label = getLabelSymbol(); uint8_t *cursor = instructionStart; TR::Compilation *comp = cg()->comp(); cursor = getOpCode().copyBinaryToBuffer(instructionStart); // bclr doesn't have a label if (label) { if (label->getCodeLocation() != NULL) { if (!getFarRelocation()) { insertConditionRegister((uint32_t *)cursor); *(int32_t *)cursor |= ((label->getCodeLocation()-cursor) & 0xffff); } else // too far - need fix up { TR::InstOpCode::Mnemonic reversedOp; bool linkForm = reversedConditionalBranchOpCode(getOpCodeValue(), &reversedOp); TR::InstOpCode reversedOpCode(reversedOp); TR::InstOpCode extraOpCode(linkForm?TR::InstOpCode::bl:TR::InstOpCode::b); cursor = reversedOpCode.copyBinaryToBuffer(cursor); insertConditionRegister((uint32_t *)cursor); *(int32_t *)cursor |= 0x0008; cursor += 4; cursor = extraOpCode.copyBinaryToBuffer(cursor); *(int32_t *)cursor |= ((label->getCodeLocation() - cursor) & 0x03fffffc); } } else { if (!getFarRelocation()) { insertConditionRegister((uint32_t *)cursor); cg()->addRelocation(new (cg()->trHeapMemory()) TR::LabelRelative16BitRelocation(cursor, label)); } else // too far - need fix up { TR::InstOpCode::Mnemonic reversedOp; bool linkForm = reversedConditionalBranchOpCode(getOpCodeValue(), &reversedOp); TR::InstOpCode reversedOpCode(reversedOp); TR::InstOpCode extraOpCode(linkForm?TR::InstOpCode::bl:TR::InstOpCode::b); cursor = reversedOpCode.copyBinaryToBuffer(cursor); insertConditionRegister((uint32_t *)cursor); *(int32_t *)cursor |= 0x0008; cursor += 4; cursor = extraOpCode.copyBinaryToBuffer(cursor); cg()->addRelocation(new (cg()->trHeapMemory()) TR::LabelRelative24BitRelocation(cursor, label)); } } } else insertConditionRegister((uint32_t *)cursor); // set up prediction bits if there is any. if (haveHint()) { if (getFarRelocation()) reverseLikeliness(); if (getOpCode().setsCTR()) *(int32_t *)instructionStart |= (getLikeliness() ? PPCOpProp_BranchLikelyMaskCtr : PPCOpProp_BranchUnlikelyMaskCtr); else *(int32_t *)instructionStart |= (getLikeliness() ? PPCOpProp_BranchLikelyMask : PPCOpProp_BranchUnlikelyMask) ; } cursor += 4; setBinaryLength(cursor - instructionStart); cg()->addAccumulatedInstructionLengthError(getEstimatedBinaryLength() - getBinaryLength()); setBinaryEncoding(instructionStart); return cursor; }
bool WriteBatchExecutor::applyWriteItem(const string& ns, const WriteBatch::WriteItem& writeItem, BSONObjBuilder* results) { // Clear operation's LastError before starting. _le->reset(true); uint64_t itemTimeMicros = 0; bool opSuccess = true; // Each write operation executes in its own PageFaultRetryableSection. This means that // a single batch can throw multiple PageFaultException's, which is not the case for // other operations. PageFaultRetryableSection s; while (true) { try { // Execute the write item as a child operation of the current operation. CurOp childOp(_client, _client->curop()); // TODO Modify CurOp "wrapped" constructor to take an opcode, so calling .reset() // is unneeded childOp.reset(_client->getRemote(), getOpCode(writeItem.getWriteType())); childOp.ensureStarted(); OpDebug& opDebug = childOp.debug(); opDebug.ns = ns; { Client::WriteContext ctx(ns); switch(writeItem.getWriteType()) { case WriteBatch::WRITE_INSERT: opSuccess = applyInsert(ns, writeItem, &childOp); break; case WriteBatch::WRITE_UPDATE: opSuccess = applyUpdate(ns, writeItem, &childOp); break; case WriteBatch::WRITE_DELETE: opSuccess = applyDelete(ns, writeItem, &childOp); break; } } childOp.done(); itemTimeMicros = childOp.totalTimeMicros(); opDebug.executionTime = childOp.totalTimeMillis(); opDebug.recordStats(); // Log operation if running with at least "-v", or if exceeds slow threshold. if (logger::globalLogDomain()->shouldLog(logger::LogSeverity::Debug(1)) || opDebug.executionTime > cmdLine.slowMS + childOp.getExpectedLatencyMs()) { MONGO_TLOG(1) << opDebug.report(childOp) << endl; } // TODO Log operation if logLevel >= 3 and assertion thrown (as assembleResponse() // does). // Save operation to system.profile if shouldDBProfile(). if (childOp.shouldDBProfile(opDebug.executionTime)) { profile(*_client, getOpCode(writeItem.getWriteType()), childOp); } break; } catch (PageFaultException& e) { e.touch(); } } // Fill caller's builder with results of operation, using LastError. results->append("ok", opSuccess); _le->appendSelf(*results, false); results->append("micros", static_cast<long long>(itemTimeMicros)); return opSuccess; }
bool WebSocketFrame::isControlFrame() const { return getOpCode() >= OpCode::ConnectionClose; }