]> git.saurik.com Git - apple/javascriptcore.git/blame - dfg/DFGMayExit.cpp
JavaScriptCore-7601.1.46.3.tar.gz
[apple/javascriptcore.git] / dfg / DFGMayExit.cpp
CommitLineData
ed1e77d3
A
1/*
2 * Copyright (C) 2014, 2015 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#include "config.h"
27#include "DFGMayExit.h"
28
29#if ENABLE(DFG_JIT)
30
31#include "DFGGraph.h"
32#include "DFGNode.h"
33#include "Operations.h"
34
35namespace JSC { namespace DFG {
36
37namespace {
38
39class EdgeMayExit {
40public:
41 EdgeMayExit()
42 : m_result(false)
43 {
44 }
45
46 void operator()(Node*, Edge edge)
47 {
48 if (edge.willHaveCheck()) {
49 m_result = true;
50 return;
51 }
52
53 switch (edge.useKind()) {
54 // These are shady because nodes that have these use kinds will typically exit for
55 // unrelated reasons. For example CompareEq doesn't usually exit, but if it uses ObjectUse
56 // then it will.
57 case ObjectUse:
58 case ObjectOrOtherUse:
59 m_result = true;
60 break;
61
62 // These are shady because they check the structure even if the type of the child node
63 // passes the StringObject type filter.
64 case StringObjectUse:
65 case StringOrStringObjectUse:
66 m_result = true;
67 break;
68
69 default:
70 break;
71 }
72 }
73
74 bool result() const { return m_result; }
75
76private:
77 bool m_result;
78};
79
80} // anonymous namespace
81
82bool mayExit(Graph& graph, Node* node)
83{
84 switch (node->op()) {
85 // This is a carefully curated list of nodes that definitely do not exit. We try to be very
86 // conservative when maintaining this list, because adding new node types to it doesn't
87 // generally make things a lot better but it might introduce insanely subtle bugs.
88 case SetArgument:
89 case JSConstant:
90 case DoubleConstant:
91 case Int52Constant:
92 case MovHint:
93 case SetLocal:
94 case Flush:
95 case Phantom:
96 case Check:
97 case GetLocal:
98 case LoopHint:
99 case Phi:
100 case Upsilon:
101 case ZombieHint:
102 case BottomValue:
103 case PutHint:
104 case PhantomNewObject:
105 case PutStack:
106 case KillStack:
107 case GetStack:
108 case GetCallee:
109 case GetArgumentCount:
110 case GetScope:
111 case PhantomLocal:
112 case CountExecution:
113 case Jump:
114 case Branch:
115 case Unreachable:
116 case DoubleRep:
117 case Int52Rep:
118 case ValueRep:
119 break;
120
121 default:
122 // If in doubt, return true.
123 return true;
124 }
125
126 EdgeMayExit functor;
127 DFG_NODE_DO_TO_CHILDREN(graph, node, functor);
128 return functor.result();
129}
130
131} } // namespace JSC::DFG
132
133#endif // ENABLE(DFG_JIT)