~ubuntu-branches/ubuntu/raring/qtwebkit-source/raring-proposed

« back to all changes in this revision

Viewing changes to Source/JavaScriptCore/dfg/DFGBasicBlock.h

  • Committer: Package Import Robot
  • Author(s): Jonathan Riddell
  • Date: 2013-02-18 14:24:18 UTC
  • Revision ID: package-import@ubuntu.com-20130218142418-eon0jmjg3nj438uy
Tags: upstream-2.3
ImportĀ upstreamĀ versionĀ 2.3

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (C) 2011 Apple Inc. All rights reserved.
 
3
 *
 
4
 * Redistribution and use in source and binary forms, with or without
 
5
 * modification, are permitted provided that the following conditions
 
6
 * are met:
 
7
 * 1. Redistributions of source code must retain the above copyright
 
8
 *    notice, this list of conditions and the following disclaimer.
 
9
 * 2. Redistributions in binary form must reproduce the above copyright
 
10
 *    notice, this list of conditions and the following disclaimer in the
 
11
 *    documentation and/or other materials provided with the distribution.
 
12
 *
 
13
 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
 
14
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 
15
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 
16
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
 
17
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 
18
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 
19
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
 
20
 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
 
21
 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 
22
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 
23
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
 
24
 */
 
25
 
 
26
#ifndef DFGBasicBlock_h
 
27
#define DFGBasicBlock_h
 
28
 
 
29
#if ENABLE(DFG_JIT)
 
30
 
 
31
#include "DFGAbstractValue.h"
 
32
#include "DFGBranchDirection.h"
 
33
#include "DFGNode.h"
 
34
#include "Operands.h"
 
35
#include <wtf/OwnPtr.h>
 
36
#include <wtf/Vector.h>
 
37
 
 
38
namespace JSC { namespace DFG {
 
39
 
 
40
typedef Vector <BlockIndex, 2> PredecessorList;
 
41
 
 
42
struct BasicBlock : Vector<NodeIndex, 8> {
 
43
    BasicBlock(unsigned bytecodeBegin, unsigned numArguments, unsigned numLocals)
 
44
        : bytecodeBegin(bytecodeBegin)
 
45
        , isOSRTarget(false)
 
46
        , cfaHasVisited(false)
 
47
        , cfaShouldRevisit(false)
 
48
        , cfaFoundConstants(false)
 
49
        , cfaDidFinish(true)
 
50
        , cfaBranchDirection(InvalidBranchDirection)
 
51
#if !ASSERT_DISABLED
 
52
        , isLinked(false)
 
53
#endif
 
54
        , isReachable(false)
 
55
        , variablesAtHead(numArguments, numLocals)
 
56
        , variablesAtTail(numArguments, numLocals)
 
57
        , valuesAtHead(numArguments, numLocals)
 
58
        , valuesAtTail(numArguments, numLocals)
 
59
    {
 
60
    }
 
61
    
 
62
    ~BasicBlock()
 
63
    {
 
64
    }
 
65
    
 
66
    void ensureLocals(unsigned newNumLocals)
 
67
    {
 
68
        variablesAtHead.ensureLocals(newNumLocals);
 
69
        variablesAtTail.ensureLocals(newNumLocals);
 
70
        valuesAtHead.ensureLocals(newNumLocals);
 
71
        valuesAtTail.ensureLocals(newNumLocals);
 
72
    }
 
73
    
 
74
    size_t numNodes() const { return phis.size() + size(); }
 
75
    NodeIndex nodeIndex(size_t i) const
 
76
    {
 
77
        if (i < phis.size())
 
78
            return phis[i];
 
79
        return at(i - phis.size());
 
80
    }
 
81
    bool isPhiIndex(size_t i) const { return i < phis.size(); }
 
82
    
 
83
    bool isInPhis(NodeIndex nodeIndex) const
 
84
    {
 
85
        for (size_t i = 0; i < phis.size(); ++i) {
 
86
            if (phis[i] == nodeIndex)
 
87
                return true;
 
88
        }
 
89
        return false;
 
90
    }
 
91
    
 
92
    bool isInBlock(NodeIndex index) const
 
93
    {
 
94
        for (size_t i = 0; i < numNodes(); ++i) {
 
95
            if (nodeIndex(i) == index)
 
96
                return true;
 
97
        }
 
98
        return false;
 
99
    }
 
100
 
 
101
    // This value is used internally for block linking and OSR entry. It is mostly meaningless
 
102
    // for other purposes due to inlining.
 
103
    unsigned bytecodeBegin;
 
104
    
 
105
    bool isOSRTarget;
 
106
    bool cfaHasVisited;
 
107
    bool cfaShouldRevisit;
 
108
    bool cfaFoundConstants;
 
109
    bool cfaDidFinish;
 
110
    BranchDirection cfaBranchDirection;
 
111
#if !ASSERT_DISABLED
 
112
    bool isLinked;
 
113
#endif
 
114
    bool isReachable;
 
115
    
 
116
    Vector<NodeIndex> phis;
 
117
    PredecessorList m_predecessors;
 
118
    
 
119
    Operands<NodeIndex, NodeIndexTraits> variablesAtHead;
 
120
    Operands<NodeIndex, NodeIndexTraits> variablesAtTail;
 
121
    
 
122
    Operands<AbstractValue> valuesAtHead;
 
123
    Operands<AbstractValue> valuesAtTail;
 
124
};
 
125
 
 
126
struct UnlinkedBlock {
 
127
    BlockIndex m_blockIndex;
 
128
    bool m_needsNormalLinking;
 
129
    bool m_needsEarlyReturnLinking;
 
130
    
 
131
    UnlinkedBlock() { }
 
132
    
 
133
    explicit UnlinkedBlock(BlockIndex blockIndex)
 
134
        : m_blockIndex(blockIndex)
 
135
        , m_needsNormalLinking(true)
 
136
        , m_needsEarlyReturnLinking(false)
 
137
    {
 
138
    }
 
139
};
 
140
    
 
141
} } // namespace JSC::DFG
 
142
 
 
143
#endif // ENABLE(DFG_JIT)
 
144
 
 
145
#endif // DFGBasicBlock_h
 
146