bool compilingLookup::isMethodOrBlockInCompileWithSICNames() { if (!CompileWithSICNames->is_objVector()) return false; if (resultType() != methodResult) return false; oop selector_to_test; switch (result()->contents()->kind()) { case OuterMethodType: // we're compiling a method. simply, test selector() against selectors in // CompileWithSICNames selector_to_test = selector(); break; case BlockMethodType: { // we're compiling a block. need to find the method containing the block, and // test that method's selector against the ones in CompileWithSICNames assert(receiver->is_block(), "expecting a block"); selector_to_test = blockOop(receiver)->outermostMethodSelector(); break; } default: ShouldNotReachHere(); } return isSelectorInCompileWithSICNames(selector_to_test); }
TIntermNode *ElseBlockRewriter::rewriteSelection(TIntermSelection *selection) { ASSERT(selection->getFalseBlock() != NULL); TString temporaryName = "cond_" + str(mTemporaryIndex++); TIntermTyped *typedCondition = selection->getCondition()->getAsTyped(); TType resultType(EbtBool, EbpUndefined); TIntermSymbol *conditionSymbolA = MakeNewTemporary(temporaryName, EbtBool); TIntermSymbol *conditionSymbolB = MakeNewTemporary(temporaryName, EbtBool); TIntermSymbol *conditionSymbolC = MakeNewTemporary(temporaryName, EbtBool); TIntermBinary *storeCondition = MakeNewBinary(EOpInitialize, conditionSymbolA, typedCondition, resultType); TIntermUnary *negatedCondition = MakeNewUnary(EOpLogicalNot, conditionSymbolB); TIntermSelection *falseBlock = new TIntermSelection(negatedCondition, selection->getFalseBlock(), NULL); TIntermSelection *newIfElse = new TIntermSelection(conditionSymbolC, selection->getTrueBlock(), falseBlock); TIntermAggregate *declaration = new TIntermAggregate(EOpDeclaration); declaration->getSequence().push_back(storeCondition); TIntermAggregate *block = new TIntermAggregate(EOpSequence); block->getSequence().push_back(declaration); block->getSequence().push_back(newIfElse); return block; }
oop abstractSlotRef::interpretData(oop receiver, oop sel, oop arg1) { switch (resultType(sel)) { case constantResult: case dataResult: return contents(); case assignmentResult: set_contents(arg1); return receiver; case methodResult: return badOop; default: fatal("should never happen"); return NULL; } }
void CallCandidate::format(FormatStream & out) const { out << method_->name(); if (typeParams_ != NULL) { out << "["; for (TupleType::const_iterator it = typeParams_->begin(); it != typeParams_->end(); ++it) { if (it != typeParams_->begin()) { out << ", "; } out << *it; } out << "]"; } out << "("; for (size_t i = 0; i < callExpr_->argCount(); ++i) { if (i != 0) { out << ", "; } out << ":" << paramType(i); } out << ") -> " << resultType(); }
bool cacheProbingLookup::mightBeAbleToReuseNMethod() { if ( !canReuseNM ) return false; // user-disabled if ( compiler != NIC ) // haven't figured out SIC reuse yet return false; // calling convention is different for methods with a static delegatee // send desc is one word longer to hold del, so return has different offset LookupType l= lookupType(); if ( needsDelegatee(l) && isDelegateeStatic() ) return false; if ( isPerformLookupType(l) ) return false; // send desc is also different // for immediate oops, the prologue is different so cannot reuse // non-imm oop method for immediate, and imms have no descendants if ( key.receiverMap()->is_smi() || key.receiverMap()->is_float() ) return false; // accessor methods not reusable cause offset might not match & // we don't check it yet switch ( resultType() ) { case dataResult: case assignmentResult: return false; default: break; } // cannot deal with DI, so forget it if have dc (DI desc) if (dc != NULL) return false; return true; // TA DA! }
void compilingLookup::chooseCompiler() { if (mustUseNIC()) { compiler = NIC; return; } if (mustUseSIC()) { compiler = SIC; return; } # ifdef SIC_COMPILER if (needDebug) { compiler= NIC; return; } compiler= status == foundOne ? currentCompiler() : compilers[0]; if (sd->isOptimized() && allowedToRecompile()) compiler = SIC; if (isCriticalMessage(selector()) && nstages > 1 && compilers[1] == SIC) { compiler = SIC; // for better recompilation } if (currentProcess->isSingleStepping()) compiler = NIC; // don't bother using the SIC for access methods - the NIC compiles // faster and the code is almost as good (and if speed really counts, // the access should be inlined anyway) if (compiler == SIC && resultType() != methodResult) { compiler = NIC; } // Implement count features for debugging: // Increment count if are or would be using SIC // Then if min or max are not == -1 (-1 means ignore), and // count is not bounded by min/max, use NIC instead. // Note: count is incremented BEFORE a Sic compile if (compiler == SIC) { ++SICCompilationCount; if ((SICMinCompilationCount != -1 && SICMinCompilationCount > SICCompilationCount) || (SICMaxCompilationCount != -1 && SICMaxCompilationCount < SICCompilationCount)) compiler = NIC; } # endif // SIC_COMPILER }
QgsSqlExpressionCompiler::Result QgsDb2ExpressionCompiler::compileNode( const QgsExpressionNode *node, QString &result ) { QgsDebugMsg( QStringLiteral( "nodeType: %1" ).arg( nodeType( node ) ) ); if ( node->nodeType() == QgsExpressionNode::ntColumnRef ) { const QgsExpressionNodeColumnRef *n( static_cast<const QgsExpressionNodeColumnRef *>( node ) ); QgsDebugMsg( QStringLiteral( "column ref node: " ) + n->dump() ); // TODO - consider escaped names - not sure how to handle QString upperName = n->name().toUpper(); int idx = mFields.indexFromName( upperName ); QgsDebugMsg( QStringLiteral( "%1 - %2" ).arg( idx ).arg( upperName ) ); if ( idx > -1 ) { result = upperName; QgsDebugMsg( QStringLiteral( "return Complete" ) ); return Complete; } QgsDebugMsg( QStringLiteral( "return Fail" ) ); return Fail; } // Seemed necessary in initial Python testing but can't identify failing case now #if 0 if ( node->nodeType() == QgsExpressionNode::ntLiteral ) { const QgsExpression::NodeLiteral *n = static_cast<const QgsExpression::NodeLiteral *>( node ); bool ok = false; if ( n->dump().toUpper() == "NULL" ) // expression compiler doesn't handle this correctly { result = "NULL"; ok = true; } else { result = quotedValue( n->value(), ok ); } QgsDebugMsg( QStringLiteral( "ok: %1; literal node: " ).arg( ok ) + n->value().toString() + "; result: " + result ); QgsDebugMsg( QStringLiteral( "n->dump: " ) + n->dump() ); QgsDebugMsg( QStringLiteral( "type: %1; typeName: %2" ).arg( n->value().type() ).arg( n->value().typeName() ) ); if ( ok ) { QgsDebugMsg( QStringLiteral( "return Complete" ) ); return Complete; } else { QgsDebugMsg( QStringLiteral( "return Fail" ) ); return Fail; } } #endif if ( node->nodeType() == QgsExpressionNode::ntUnaryOperator ) { const QgsExpressionNodeUnaryOperator *n = static_cast<const QgsExpressionNodeUnaryOperator *>( node ); Result rr = Fail; switch ( n->op() ) { case QgsExpressionNodeUnaryOperator::uoNot: rr = compileNode( n->operand(), result ); if ( "NULL" == result.toUpper() ) { result.clear(); return Fail; } result = "NOT " + result; QgsDebugMsg( QStringLiteral( "NOT; result: %1; right: %2" ).arg( resultType( rr ), result ) ); return rr; case QgsExpressionNodeUnaryOperator::uoMinus: break; } } if ( node->nodeType() == QgsExpressionNode::ntBinaryOperator ) { const QgsExpressionNodeBinaryOperator *bin( static_cast<const QgsExpressionNodeBinaryOperator *>( node ) ); QString left, right; Result lr = compileNode( bin->opLeft(), left ); Result rr = compileNode( bin->opRight(), right ); Result compileResult; QgsDebugMsg( "left: '" + left + "'; right: '" + right + QString( "'; op: %1; lr: %2; rr: %3" ).arg( bin->op() ).arg( lr ).arg( rr ) ); if ( lr == Fail || rr == Fail ) return Fail; // NULL can not appear on the left, only as part of IS NULL or IS NOT NULL if ( "NULL" == left.toUpper() ) return Fail; // NULL can only be on the right for IS and IS NOT if ( "NULL" == right.toUpper() && ( bin->op() != QgsExpressionNodeBinaryOperator::boIs && bin->op() != QgsExpressionNodeBinaryOperator::boIsNot ) ) return Fail; switch ( bin->op() ) { case QgsExpressionNodeBinaryOperator::boMod: result = QStringLiteral( "MOD(%1,%2)" ).arg( left, right ); compileResult = ( lr == Partial || rr == Partial ) ? Partial : Complete; QgsDebugMsg( QStringLiteral( "MOD compile status: %1" ).arg( compileResult ) + "; " + result ); return compileResult; case QgsExpressionNodeBinaryOperator::boPow: result = QStringLiteral( "power(%1,%2)" ).arg( left, right ); compileResult = ( lr == Partial || rr == Partial ) ? Partial : Complete; QgsDebugMsg( QStringLiteral( "POWER compile status: %1" ).arg( compileResult ) + "; " + result ); return compileResult; case QgsExpressionNodeBinaryOperator::boRegexp: return Fail; //not supported, regexp syntax is too different to Qt case QgsExpressionNodeBinaryOperator::boConcat: result = QStringLiteral( "%1 || %2" ).arg( left, right ); compileResult = ( lr == Partial || rr == Partial ) ? Partial : Complete; QgsDebugMsg( QStringLiteral( "CONCAT compile status: %1" ).arg( compileResult ) + "; " + result ); return compileResult; case QgsExpressionNodeBinaryOperator::boILike: QgsDebugMsg( QStringLiteral( "ILIKE is not supported by DB2" ) ); return Fail; /* result = QString( "%1 LIKE %2" ).arg( left, right ); compileResult = (lr == Partial || rr == Partial) ? Partial : Complete; QgsDebugMsg(QString("ILIKE compile status: %1").arg(compileResult) + "; " + result); return compileResult; */ case QgsExpressionNodeBinaryOperator::boNotILike: QgsDebugMsg( QStringLiteral( "NOT ILIKE is not supported by DB2" ) ); return Fail; /* result = QString( "%1 NOT LIKE %2" ).arg( left, right ); compileResult = (lr == Partial || rr == Partial) ? Partial : Complete; QgsDebugMsg(QString("NOT ILIKE compile status: %1").arg(compileResult) + "; " + result); return compileResult; */ // We only support IS NULL if the operand on the left is a column case QgsExpressionNodeBinaryOperator::boIs: if ( "NULL" == right.toUpper() ) { if ( bin->opLeft()->nodeType() != QgsExpressionNode::ntColumnRef ) { QgsDebugMsg( "Failing IS NULL with non-column on left: " + left ); return Fail; } } break; // We only support IS NULL if the operand on the left is a column case QgsExpressionNodeBinaryOperator::boIsNot: if ( "NULL" == right.toUpper() ) { if ( bin->opLeft()->nodeType() != QgsExpressionNode::ntColumnRef ) { QgsDebugMsg( "Failing IS NOT NULL with non-column on left: " + left ); return Fail; } } break; default: break; } } //fallback to default handling QgsDebugMsg( QStringLiteral( "fallback: %1 - " ).arg( nodeType( node ) ) ); QgsSqlExpressionCompiler::Result rc = QgsSqlExpressionCompiler::compileNode( node, result ); QgsDebugMsg( QStringLiteral( "fallback: %1 - " ).arg( resultType( rc ) ) + result ); return rc; }