示例#1
0
void destroyStringTable()
{
    for (HashSet<const char*>::iterator itr = s_stringTable.begin(); itr != s_stringTable.end(); ++itr)
        fastFree((void*)*itr);

    s_stringTable.clear();

    for (HashSet<const wchar_t*>::iterator itr = s_stringTableW.begin(); itr != s_stringTableW.end(); ++itr)
        fastFree((void*)*itr);

    s_stringTableW.clear();
}
示例#2
0
bool parseGlyphName(const String& input, HashSet<String>& values)
{
    // FIXME: Parsing error detection is missing.
    values.clear();

    const UChar* ptr = input.characters();
    const UChar* end = ptr + input.length();
    skipOptionalSVGSpaces(ptr, end);

    while (ptr < end) {
        // Leading and trailing white space, and white space before and after separators, will be ignored.
        const UChar* inputStart = ptr;
        while (ptr < end && *ptr != ',')
            ++ptr;

        if (ptr == inputStart)
            break;

        // walk backwards from the ; to ignore any whitespace
        const UChar* inputEnd = ptr - 1;
        while (inputStart < inputEnd && isSVGSpace(*inputEnd))
            --inputEnd;

        values.add(String(inputStart, inputEnd - inputStart + 1));
        skipOptionalSVGSpacesOrDelimiter(ptr, end, ',');
    }

    return true;
}
示例#3
0
bool parseGlyphName(const String& input, HashSet<String>& values)
{
    // FIXME: Parsing error detection is missing.
    values.clear();
    if (input.isEmpty())
        return true;
    if (input.is8Bit()) {
        const LChar* ptr = input.characters8();
        const LChar* end = ptr + input.length();
        return parseGlyphName(ptr, end, values);
    }
    const UChar* ptr = input.characters16();
    const UChar* end = ptr + input.length();
    return parseGlyphName(ptr, end, values);
}
示例#4
0
TEST(WTF_HashSet, UniquePtrKey)
{
    ConstructorDestructorCounter::TestingScope scope;

    HashSet<std::unique_ptr<ConstructorDestructorCounter>> set;

    auto uniquePtr = std::make_unique<ConstructorDestructorCounter>();
    set.add(WTF::move(uniquePtr));

    EXPECT_EQ(1u, ConstructorDestructorCounter::constructionCount);
    EXPECT_EQ(0u, ConstructorDestructorCounter::destructionCount);

    set.clear();

    EXPECT_EQ(1u, ConstructorDestructorCounter::constructionCount);
    EXPECT_EQ(1u, ConstructorDestructorCounter::destructionCount);
}
示例#5
0
void JSDictionary::convertValue(ExecState* exec, JSValue value, HashSet<AtomicString>& result)
{
    result.clear();

    if (value.isUndefinedOrNull())
        return;

    unsigned length = 0;
    JSObject* object = toJSSequence(exec, value, length);
    if (exec->hadException())
        return;

    for (unsigned i = 0 ; i < length; ++i) {
        JSValue itemValue = object->get(exec, i);
        if (exec->hadException())
            return;
        result.add(itemValue.toString(exec)->value(exec));
    }
}
示例#6
0
int main(int argc, char *argv[])
{
	// INPUT 
	ifstream inFile;
	ofstream outFile;
	
	inFile.open(argv[1]);
	outFile.open(argv[2]);
	string cmd;
	while(inFile >> cmd)

	if(cmd == "clear" )
	{
		set.clear();
		outFile << "clear" << endl;
	}
	else if (cmd == "add" )
	{
		string item;
		inFile >> item;
		set.add(item);
		outFile << "add " << item << endl;
	}
    void handleNode(HashSet<Node*>& dontNeedBarriers, Node* node)
    {
        if (doesGC(m_graph, node))
            dontNeedBarriers.clear();

        if (allocatesFreshObject(node))
            noticeFreshObject(dontNeedBarriers, node);

        if (!node->isStoreBarrier())
            return;

        if (shouldBeElided(dontNeedBarriers, node)) {
            elideBarrier(node);
            return;
        }

        Node* base = getBaseOfStore(node);
        if (!base)
            return;

        if (dontNeedBarriers.contains(base))
            return;
        dontNeedBarriers.add(base);
    }
示例#8
0
void syntaxTest_HashSet()
{
    {
        HashSet<int> s;
        s.insert(1);
        s.insert(2);
        s.insert(1);
        s.insert(3);
        s.insert(2);
        assert(s.size() == 3);
        s.erase(3);
        assert(s.size() == 2);
        s.erase(3);
        assert(s.size() == 2);
    }
    {
        int a[5] = {1, 3, 2, 4, 1};
        HashSet<int> s(a, a + 5);
        assert(s.size() == 4);
        {
            HashSet<int> s2(s);
            assert(s2.size() == 4);
        }
        {
            HashSet<int> s2;
            assert(s2.empty());
            s2 = s;
            assert(s2.size() == 4);
            assert(!s2.empty());
            assert(s2.contain(3));
            assert(s2.count(2) == 1);
            assert(s2 == s);
            assert(!(s2 != s));
        }
    }
    {
        std::vector<int> v(5, 0);
        HashSet<int> s;
        s.insert(v.begin(), v.end());
        assert(s.size() == 1);
        assert(s.find(1) == s.end());
        assert(s.find(0) != s.end());
        assert(s.find(0) == s.begin());
        s.erase(s.find(0));
        assert(s.empty());
        s.insert(5);
        assert(!s.empty());
        s.clear();
        assert(s.empty());

        HashSet<int> s2;
        s2.insert(5);
        std::swap(s, s2);
        assert(s2.empty());
        assert(s.find(5) != s.end());
    }
    {
        int a[4] = {1,2, 3, 1};
        const HashSet<int> s(a, a + 4);
        HashSet<int> b;
        for (HashSet<int>::ConstIterator iter = s.begin();
                iter != s.end();
                ++iter) {
            b.insert(*iter);
        }
        assert(b.size() == 3);
    }
}
    void handleBlockForTryCatch(BasicBlock* block, InsertionSet& insertionSet)
    {
        HandlerInfo* currentExceptionHandler = nullptr;
        FastBitVector liveAtCatchHead;
        liveAtCatchHead.resize(m_graph.block(0)->variablesAtTail.numberOfLocals());

        HandlerInfo* cachedHandlerResult;
        CodeOrigin cachedCodeOrigin;
        auto catchHandler = [&] (CodeOrigin origin) -> HandlerInfo* {
            ASSERT(origin);
            if (origin == cachedCodeOrigin)
                return cachedHandlerResult;

            unsigned bytecodeIndexToCheck = origin.bytecodeIndex;

            cachedCodeOrigin = origin;

            while (1) {
                InlineCallFrame* inlineCallFrame = origin.inlineCallFrame;
                CodeBlock* codeBlock = m_graph.baselineCodeBlockFor(inlineCallFrame);
                if (HandlerInfo* handler = codeBlock->handlerForBytecodeOffset(bytecodeIndexToCheck)) {
                    liveAtCatchHead.clearAll();

                    unsigned catchBytecodeIndex = handler->target;
                    m_graph.forAllLocalsLiveInBytecode(CodeOrigin(catchBytecodeIndex, inlineCallFrame), [&] (VirtualRegister operand) {
                        liveAtCatchHead[operand.toLocal()] = true;
                    });

                    cachedHandlerResult = handler;
                    break;
                }

                if (!inlineCallFrame) {
                    cachedHandlerResult = nullptr;
                    break;
                }

                bytecodeIndexToCheck = inlineCallFrame->directCaller.bytecodeIndex;
                origin = inlineCallFrame->directCaller;
            }

            return cachedHandlerResult;
        };

        Operands<VariableAccessData*> currentBlockAccessData(block->variablesAtTail.numberOfArguments(), block->variablesAtTail.numberOfLocals(), nullptr);
        HashSet<InlineCallFrame*> seenInlineCallFrames;

        auto flushEverything = [&] (NodeOrigin origin, unsigned index) {
            RELEASE_ASSERT(currentExceptionHandler);
            auto flush = [&] (VirtualRegister operand, bool alwaysInsert) {
                if ((operand.isLocal() && liveAtCatchHead[operand.toLocal()]) 
                    || operand.isArgument()
                    || alwaysInsert) {

                    ASSERT(isValidFlushLocation(block, index, operand));

                    VariableAccessData* accessData = currentBlockAccessData.operand(operand);
                    if (!accessData)
                        accessData = newVariableAccessData(operand);

                    currentBlockAccessData.operand(operand) = accessData;

                    insertionSet.insertNode(index, SpecNone, 
                        Flush, origin, OpInfo(accessData));
                }
            };

            for (unsigned local = 0; local < block->variablesAtTail.numberOfLocals(); local++)
                flush(virtualRegisterForLocal(local), false);
            for (InlineCallFrame* inlineCallFrame : seenInlineCallFrames)
                flush(VirtualRegister(inlineCallFrame->stackOffset + CallFrame::thisArgumentOffset()), true);
            flush(VirtualRegister(CallFrame::thisArgumentOffset()), true);

            seenInlineCallFrames.clear();
        };

        for (unsigned nodeIndex = 0; nodeIndex < block->size(); nodeIndex++) {
            Node* node = block->at(nodeIndex);

            {
                HandlerInfo* newHandler = catchHandler(node->origin.semantic);
                if (newHandler != currentExceptionHandler && currentExceptionHandler)
                    flushEverything(node->origin, nodeIndex);
                currentExceptionHandler = newHandler;
            }

            if (currentExceptionHandler && (node->op() == SetLocal || node->op() == SetArgument)) {
                InlineCallFrame* inlineCallFrame = node->origin.semantic.inlineCallFrame;
                if (inlineCallFrame)
                    seenInlineCallFrames.add(inlineCallFrame);
                VirtualRegister operand = node->local();

                int stackOffset = inlineCallFrame ? inlineCallFrame->stackOffset : 0;
                if ((operand.isLocal() && liveAtCatchHead[operand.toLocal()])
                    || operand.isArgument()
                    || (operand.offset() == stackOffset + CallFrame::thisArgumentOffset())) {

                    ASSERT(isValidFlushLocation(block, nodeIndex, operand));

                    VariableAccessData* variableAccessData = currentBlockAccessData.operand(operand);
                    if (!variableAccessData)
                        variableAccessData = newVariableAccessData(operand);

                    insertionSet.insertNode(nodeIndex, SpecNone, 
                        Flush, node->origin, OpInfo(variableAccessData));
                }
            }

            if (node->accessesStack(m_graph))
                currentBlockAccessData.operand(node->local()) = node->variableAccessData();
        }

        if (currentExceptionHandler) {
            NodeOrigin origin = block->at(block->size() - 1)->origin;
            flushEverything(origin, block->size());
        }
    }