Пример #1
0
void SlotVisitor::drain()
{
    StackStats::probe();
    ASSERT(m_isInParallelMode);
   
#if ENABLE(PARALLEL_GC)
    if (Options::numberOfGCMarkers() > 1) {
        while (!m_stack.isEmpty()) {
            m_stack.refill();
            for (unsigned countdown = Options::minimumNumberOfScansBetweenRebalance(); m_stack.canRemoveLast() && countdown--;)
                visitChildren(*this, m_stack.removeLast());
            donateKnownParallel();
        }
        
        mergeOpaqueRootsIfNecessary();
        return;
    }
#endif
    
    while (!m_stack.isEmpty()) {
        m_stack.refill();
        while (m_stack.canRemoveLast())
            visitChildren(*this, m_stack.removeLast());
    }
}
Пример #2
0
void QSGNodeVisitor::visitNode(QSGNode *n)
{
    switch (n->type()) {
    case QSGNode::TransformNodeType: {
        QSGTransformNode *t = static_cast<QSGTransformNode *>(n);
        enterTransformNode(t);
        visitChildren(t);
        leaveTransformNode(t);
        break; }
    case QSGNode::GeometryNodeType: {
        QSGGeometryNode *g = static_cast<QSGGeometryNode *>(n);
        enterGeometryNode(g);
        visitChildren(g);
        leaveGeometryNode(g);
        break; }
    case QSGNode::ClipNodeType: {
        QSGClipNode *c = static_cast<QSGClipNode *>(n);
        enterClipNode(c);
        visitChildren(c);
        leaveClipNode(c);
        break; }
    case QSGNode::OpacityNodeType: {
        QSGOpacityNode *o = static_cast<QSGOpacityNode *>(n);
        enterOpacityNode(o);
        visitChildren(o);
        leaveOpacityNode(o);
        break; }
    default:
        visitChildren(n);
        break;
    }
}
Пример #3
0
void QSGNodeUpdater::visitNode(QSGNode *n)
{
#ifdef QSG_UPDATER_DEBUG
    qDebug() << "enter:" << n;
#endif

    if (!n->dirtyFlags() && !m_force_update)
        return;
    if (n->isSubtreeBlocked())
        return;

    bool forceUpdate = n->dirtyFlags() & (QSGNode::DirtyNodeAdded | QSGNode::DirtyForceUpdate);
    if (forceUpdate)
        ++m_force_update;

    switch (n->type()) {
    case QSGNode::TransformNodeType: {
        QSGTransformNode *t = static_cast<QSGTransformNode *>(n);
        enterTransformNode(t);
        visitChildren(t);
        leaveTransformNode(t);
        break; }
    case QSGNode::GeometryNodeType: {
        QSGGeometryNode *g = static_cast<QSGGeometryNode *>(n);
        enterGeometryNode(g);
        visitChildren(g);
        leaveGeometryNode(g);
        break; }
    case QSGNode::ClipNodeType: {
        QSGClipNode *c = static_cast<QSGClipNode *>(n);
        enterClipNode(c);
        visitChildren(c);
        leaveClipNode(c);
        break; }
    case QSGNode::OpacityNodeType: {
        QSGOpacityNode *o = static_cast<QSGOpacityNode *>(n);
        enterOpacityNode(o);
        visitChildren(o);
        leaveOpacityNode(o);
        break; }
    default:
        visitChildren(n);
        break;
    }

    if (forceUpdate)
        --m_force_update;

    n->clearDirty();
}
Пример #4
0
void MarkStack::drain()
{
#if !ASSERT_DISABLED
    ASSERT(!m_isDraining);
    m_isDraining = true;
#endif
    while (!m_markSets.isEmpty() || !m_values.isEmpty()) {
        while (!m_markSets.isEmpty() && m_values.size() < 50) {
            ASSERT(!m_markSets.isEmpty());
            MarkSet& current = m_markSets.last();
            ASSERT(current.m_values);
            JSValue* end = current.m_end;
            ASSERT(current.m_values);
            ASSERT(current.m_values != end);
        findNextUnmarkedNullValue:
            ASSERT(current.m_values != end);
            JSValue value = *current.m_values;
            current.m_values++;

            JSCell* cell;
            if (!value || !value.isCell() || Heap::testAndSetMarked(cell = value.asCell())) {
                if (current.m_values == end) {
                    m_markSets.removeLast();
                    continue;
                }
                goto findNextUnmarkedNullValue;
            }

            if (cell->structure()->typeInfo().type() < CompoundType) {
                cell->JSCell::visitChildren(*this);
                if (current.m_values == end) {
                    m_markSets.removeLast();
                    continue;
                }
                goto findNextUnmarkedNullValue;
            }

            if (current.m_values == end)
                m_markSets.removeLast();

            visitChildren(cell);
        }
        while (!m_values.isEmpty())
            visitChildren(m_values.removeLast());
    }
#if !ASSERT_DISABLED
    m_isDraining = false;
#endif
}
void cpt::semantics::PFTypeValidator::processBinaryArithmeticExpression(cdk::node::expression::BinaryExpression * const node, int lvl) {
	visitChildren(node, lvl);

	// Check for invalid types in expression
	// FIXME: this is too long, better negate this...
	if((node->left()->type()->name() == ExpressionType::TYPE_STRING)
	|| (node->right()->type()->name() == ExpressionType::TYPE_STRING)
	|| (node->left()->type()->name() == ExpressionType::TYPE_VOID)
	|| (node->right()->type()->name() == ExpressionType::TYPE_VOID)
	|| (node->left()->type()->name() == ExpressionType::TYPE_POINTER)
	|| (node->right()->type()->name() == ExpressionType::TYPE_POINTER)
	|| (node->left()->type()->name() == ExpressionType::TYPE_ERROR)
	|| (node->right()->type()->name() == ExpressionType::TYPE_ERROR)) {
		node->type(new ExpressionType(0, ExpressionType::TYPE_ERROR));
	}

	// If an operand is of type double, the binary expression is of type double
	if((node->left()->type()->name() == ExpressionType::TYPE_DOUBLE)
	|| (node->right()->type()->name() == ExpressionType::TYPE_DOUBLE)) {
		node->type(new ExpressionType(8, ExpressionType::TYPE_DOUBLE));
	}
	// Otherwise, they are both integers, and the binary expression has type integer as well
	else {
		node->type(new ExpressionType(4, ExpressionType::TYPE_INT));
	}

}
Пример #6
0
void CqParseTreeViz::Visit(IqParseNodeGatherConstruct& node)
{
	setNodeProperty(node, "label", "GATHER");
	setNodeProperty(node, "fillcolor", blockConstructColor);
	setNodeProperty(node, "shape", "Msquare");
	visitChildren(node);
}
Пример #7
0
void CqParseTreeViz::Visit(IqParseNodeIlluminanceConstruct& node)
{
	setNodeProperty(node, "label", "ILLUMINANCE");
	setNodeProperty(node, "fillcolor", blockConstructColor);
	setNodeProperty(node, "shape", "Msquare");
	visitChildren(node);
}
Пример #8
0
void CqParseTreeViz::Visit(IqParseNodeOperator& node)
{
	setNodeProperty(node, "label", opToString(node.Operator()));
	setNodeProperty(node, "shape", "box");
	setNodeProperty(node, "fillcolor", operatorColor);
	visitChildren(node);
}
Пример #9
0
void CqParseTreeViz::Visit(IqParseNodeUnresolvedCall& node)
{
	setNodeProperty(node, "label", std::string("UnresolvedCall\\n") + node.strName());
	setNodeProperty(node, "fillcolor", unresolvedCallColor);
	setNodeProperty(node, "shape", "box");
	visitChildren(node);
}
Пример #10
0
void index_std()
{
    std::cout << "index_std=======================================================\n";
    clang::index index;
    
    std::vector<std::string> args = {"CC", "/home/nicholas/dev/cxxide/ex/stdlib-c++03.cpp"};
    args.push_back("-I/usr/include/clang/3.0/include/");

    auto& tu = index.parse_translation_unit(args);
    std::cout << "parsed: " << tu.spelling() << "\n";
    
    {
        auto cursor = tu.get_cursor();
        
        unsigned depth = 1;
        std::function<CXChildVisitResult(const clang::cursor& cur, const clang::cursor& parent)> visitor = [&depth, &visitor](clang::cursor cur, clang::cursor parent) -> CXChildVisitResult
        {
            if(!cur.isUnexposed())
            {
                std::cout << std::string(depth, ' ') << cur.location() << " " << clang::to_string(cur.kind()) << " " << cur.spelling() << "\n";
            }
            
            ++depth;
            cur.visitChildren(visitor);
            --depth;
            
            return CXChildVisit_Continue;
        };
        cursor.visitChildren(visitor);
    }
    std::cout << "index_std=======================================================\n";
}
Пример #11
0
void SymbolCheckVisitor::visit(ASTFunction& ast)
{
   ScopedScope scope(mScopeStack);
   ScopedValue<ASTFunction*> scopedfunction(&mpFunction, &ast, mpFunction);
   ASSERT_PTR(mpFunction);

   visitChildren(ast); // <-- arguments

   if ( ast.isConstructor() && ast.getName() != mpClass->getName() )
   {
      error(E0005, UTEXT("Function ") + ast.getName() + UTEXT(" must have a return type (or equal class name as constructor)."), ast);
   }

   if ( ast.hasBody() )
   {
      if ( ast.getModifiers().isAbstract() )
      {
         error(E0006, UTEXT("Abstract function ") + ast.getName() + UTEXT(" should not have a body."), ast);
      }
      else
      {
         checkReturn(ast);

         ast.getBody().accept(*this);
      }
   }
   else if ( !ast.getModifiers().isAbstract() && !ast.getModifiers().isPureNative() )
   {
      error(E0007, UTEXT("Function ") + ast.getName() + UTEXT(" requires a body."), ast);
   }

   mCurrentType.clear();
}
Пример #12
0
void SymbolCheckVisitor::visit(ASTUnary& ast)
{
   visitChildren(ast);

   checkOperator(ast, ast.getPre());
   checkOperator(ast, ast.getPost());
}
Пример #13
0
void CqParseTreeViz::Visit(IqParseNodeConditional& node)
{
	setNodeProperty(node, "label", "IF");
	setNodeProperty(node, "fillcolor", blockConstructColor);
	setNodeProperty(node, "shape", "Msquare");
	visitChildren(node);
}
Пример #14
0
void CqParseTreeViz::Visit(IqParseNodeArrayVariable& node)
{
	const char* varName = static_cast<IqParseNodeVariable*>(
			node.GetInterface(ParseNode_Variable))->strName();
	setNodeProperty(node, "label", splitVarNameToLines(varName) + " []");
	setNodeProperty(node, "color", variableColor);
	visitChildren(node);
}
Пример #15
0
void SymbolCheckVisitor::visit(ASTClass& ast)
{
   ScopedScope scope(mScopeStack);

   mpClass = &ast;

   visitChildren(ast);
}
Пример #16
0
void CqParseTreeViz::Visit(IqParseNodeFunctionCall& node)
{
	IqFuncDef* funcDef = node.pFuncDef();
	setNodeProperty(node, "label", funcDef->strVMName());
	setNodeProperty(node, "shape", "box");
	setNodeProperty(node, "fillcolor", functionCallColor);
	m_calledFunctions.insert(funcDef);
	visitChildren(node);
}
Пример #17
0
void CallTranslator::VisitStmt(const clang::Stmt *s) {
    // Insert braces around all if and for statement bodies
    if (const clang::CallExpr *call = clang::dyn_cast<clang::CallExpr>(s)) {
        const clang::FunctionDecl *callee = call->getDirectCallee();

        if (callee) {
            std::string callee_name = callee->getNameAsString();
            assert(callee_name.size() > 0);

            std::string replace_with;
            if (curr_func_is_quick == YES &&
                    is_quick_transformed(callee_name)) {
                replace_with = callee_name + "_quick";
            } else if (curr_func_is_npm == YES) {
                if (ignorable->find(callee_name) != ignorable->end()) {
                    /*
                     * Skip this function, we know it is an externally defined
                     * function that won't create a checkpoint.
                     */
                } else if (is_npm_transformed(callee_name)) {
                    /*
                     * There is a local NPM version of this function defined in
                     * the same compilation unit. We can simply reference it
                     * directly.
                     */
                    replace_with = callee_name + "_npm";
                } else {
                    /*
                     * We need to reference an externally defined NPM function
                     * through a function pointer.
                     */
                    std::string varname = get_external_func_name(
                            callee_name);

                    replace_with = ("(*" + varname + ")");
                }
            }

            if (replace_with.size() > 0) {
                std::stringstream ss;
                ss << replace_with << "(";

                for (int i = 0; i < call->getNumArgs(); i++) {
                    if (i != 0) ss << ", ";
                    ss << to_string(call->getArg(i));
                }
                ss << ")";
                rewriter->ReplaceText(clang::SourceRange(
                            call->getLocStart(), call->getLocEnd()),
                        ss.str());
            }
        }
    }

    visitChildren(s);
}
Пример #18
0
void SymbolCheckVisitor::visit(ASTArrayInit& ast)
{
   visitChildren(ast);

   ASTType elementtype = mCurrentType;

   mCurrentType.setKind(ASTType::eArray);
   mCurrentType.setArrayType(elementtype.clone());
   mCurrentType.setArrayDimension(1); // need to determine the depth of the array!
}
Пример #19
0
void CqParseTreeViz::Visit(IqParseNodeArrayVariableAssign& node)
{
	IqParseNodeVariable* varNode = static_cast<IqParseNodeVariable*>(
			node.GetInterface(ParseNode_Variable));

	setNodeProperty(node, "label", boost::format("%s [] := ")
			% splitVarNameToLines(varNode->strName()));
	setNodeProperty(node, "fillcolor", variableAssignColor);
	visitChildren(node);
}
Пример #20
0
void visitIfExists(CDGNode * node, CDGNode * nodes[], int size) {
  int i;
  for (i = 0; i < size; i++) {
    if (getID(node) == getID(nodes[i])) {
      visitChildren(node, getOutcome(nodes[i]));
      return;
    }
  }
  return;
}
Пример #21
0
void SymbolCheckVisitor::visit(ASTTry& ast)
{
   ast.getBody().accept(*this);

   if ( ast.hasFinallyBlock() )
   {
      ast.getFinallyBlock().accept(*this);
   }

   visitChildren(ast);
}
void cpt::semantics::PFTypeValidator::processUnaryIncrementExpression(cdk::node::expression::UnaryExpression * const node, int lvl) {
	visitChildren(node, lvl);

	// Check if argument has a compatible type - integer or pointer
	if((node->argument()->type()->name() != ExpressionType::TYPE_INT)
	&& (node->argument()->type()->name() != ExpressionType::TYPE_POINTER)) {
		node->type(new ExpressionType(0, ExpressionType::TYPE_ERROR));
	}

	// It has the same type as its child
	node->type(node->argument()->type());
}
Пример #23
0
void SlotVisitor::drain()
{
    ASSERT(m_isInParallelMode);
   
    while (!m_stack.isEmpty()) {
        m_stack.refill();
        for (unsigned countdown = Options::minimumNumberOfScansBetweenRebalance(); m_stack.canRemoveLast() && countdown--;)
            visitChildren(m_stack.removeLast());
        donateKnownParallel();
    }
    
    mergeOpaqueRootsIfNecessary();
}
void cpt::semantics::PFTypeValidator::processBinaryLogicalExpression(cdk::node::expression::BinaryExpression * const node, int lvl) {
	visitChildren(node, lvl);

	// Check if operands have compatible types (i.e. integer)
	if((node->left()->type()->name() != ExpressionType::TYPE_INT)
	|| (node->right()->type()->name() != ExpressionType::TYPE_INT)) {
		node->type(new ExpressionType(0, ExpressionType::TYPE_ERROR));
		return;
	}

	// It is always of type boolean (booleans are integers in mayfly)
	node->type(new ExpressionType(4, ExpressionType::TYPE_INT));
}
Пример #25
0
void 
DOMWriter::visitElement(Element * node)
{
  out << '<' << node->getNodeName();
  visitNamedNodeMap(node->getAttributes());
  if (node->hasChildNodes()) {
    out << '>';
    visitChildren(node->getChildNodes());
    out << '<' << '/' << node->getNodeName() << '>';
  }
  else {
    out << '/' << '>';
  }
}
void cpt::semantics::PFTypeValidator::processAddressing(mayfly::node::expression::Addressing * const node, int lvl) {
	visitChildren(node, lvl);

	// Check if argument has a compatible type (i.e. integer)
	if(node->argument()->type()->name() != ExpressionType::TYPE_POINTER) {
		node->type(new ExpressionType(0, ExpressionType::TYPE_ERROR));
		return;
	}

	// It is always of type boolean (booleans are integers in mayfly)
	node->type(new ExpressionType(4, ExpressionType::TYPE_INT));

	finalizeNodeValidation(node, lvl);
}
Пример #27
0
void CqParseTreeViz::Visit(IqParseNodeTypeCast& node)
{
	setNodeProperty(node, "fillcolor", typeCastColor);
	setNodeProperty(node, "shape", "box");

	IqParseNode* operand = static_cast<IqParseNode*>(
			node.GetInterface(ParseNode_Base))->pChild();

	const char* pstrToType = gVariableTypeNames[node.CastTo() & Type_Mask];
	const char* pstrFromType = gVariableTypeNames[operand->ResType() & Type_Mask];
	setNodeProperty(node, "label", 
			boost::format("%s<-\\n<-%s") % pstrToType % pstrFromType);
	visitChildren(node);
}
void cpt::semantics::PFTypeValidator::processAssignment(mayfly::node::expression::Assignment * const node, int lvl) {

	_assignments.push(node);
	visitChildren(node, lvl);
	_assignments.pop();
	std::string right_child_name(node->right()->name());

	// Check for invalid types in assignment
	if((node->left()->type()->name() == ExpressionType::TYPE_VOID)
	|| (node->right()->type()->name() == ExpressionType::TYPE_VOID)
	|| (node->left()->type()->name() == ExpressionType::TYPE_ERROR)
	|| (node->right()->type()->name() == ExpressionType::TYPE_ERROR)
	|| (node->left()->type()->name() == ExpressionType::TYPE_UNSPEC)) {
		node->type(new ExpressionType(0, ExpressionType::TYPE_ERROR));
		finalizeNodeValidation(node, lvl);
		return;
	}

	// We can assign an integer to a double
	else if((node->left()->type()->name() == ExpressionType::TYPE_DOUBLE)
	&& (node->right()->type()->name() == ExpressionType::TYPE_INT)) {
		node->type(node->left()->type()); // not necessary but...
	}

	// We can assign the integer literal zero to a pointer
	else if((node->left()->type()->name() == ExpressionType::TYPE_POINTER)
	&& (right_child_name == "Integer")
	&& (((cdk::node::expression::Simple<int>*)node->right())->value() == 0)) {
		node->type(node->left()->type()); // not necessary but...
	}

	// Right values can be left unspecified - memoryreservation and read nodes
	else if(node->right()->type()->name() == ExpressionType::TYPE_UNSPEC) {
		node->type(node->left()->type());
	}

	// Otherwise, if operand types do not match, its an error
	else if(node->left()->type()->name() != node->right()->type()->name()) {
		node->type(new ExpressionType(0, ExpressionType::TYPE_ERROR));
		finalizeNodeValidation(node, lvl);
		return;
	}

	// Otherwise, both operands have the same type
	// The assignment type has the same type of both
	node->type(node->left()->type());

	finalizeNodeValidation(node, lvl);
}
Пример #29
0
void SlotVisitor::drain(MonotonicTime timeout)
{
    ASSERT(m_isInParallelMode);
   
    while ((!m_collectorStack.isEmpty() || !m_mutatorStack.isEmpty()) && !hasElapsed(timeout)) {
        if (!m_collectorStack.isEmpty()) {
            m_collectorStack.refill();
            m_isVisitingMutatorStack = false;
            for (unsigned countdown = Options::minimumNumberOfScansBetweenRebalance(); m_collectorStack.canRemoveLast() && countdown--;)
                visitChildren(m_collectorStack.removeLast());
        } else if (!m_mutatorStack.isEmpty()) {
            m_mutatorStack.refill();
            // We know for sure that we are visiting objects because of the barrier, not because of
            // marking. Marking will visit an object exactly once. The barrier will visit it
            // possibly many times, and always after it was already marked.
            m_isVisitingMutatorStack = true;
            for (unsigned countdown = Options::minimumNumberOfScansBetweenRebalance(); m_mutatorStack.canRemoveLast() && countdown--;)
                visitChildren(m_mutatorStack.removeLast());
        }
        donateKnownParallel();
    }
    
    mergeOpaqueRootsIfNecessary();
}
Пример #30
0
bool TreeModel::romoveChildren(const QModelIndex &index)
{
    bool success = true;

    QList<qint64> ids;
    visitChildren(index, ids);
    foreach( qint64 id, ids)
    {
        bool ret = m_queryItem->removeRecord(id);
        if( !ret )
        {
            success = false;
            break;
        }
    }