Fix TIVI-504 (backport of trac.webkit.org/changeset/144137)
[profile/ivi/webkit-efl.git] / Source / JavaScriptCore / dfg / DFGCommon.h
1 /*
2  * Copyright (C) 2011, 2012 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 DFGCommon_h
27 #define DFGCommon_h
28
29 #include <wtf/Platform.h>
30
31 #if ENABLE(DFG_JIT)
32
33 #include "CodeOrigin.h"
34 #include "VirtualRegister.h"
35
36 /* DFG_ENABLE() - turn on a specific features in the DFG JIT */
37 #define DFG_ENABLE(DFG_FEATURE) (defined DFG_ENABLE_##DFG_FEATURE && DFG_ENABLE_##DFG_FEATURE)
38
39 // Emit various logging information for debugging, including dumping the dataflow graphs.
40 #define DFG_ENABLE_DEBUG_VERBOSE 0
41 // Emit dumps during propagation, in addition to just after.
42 #define DFG_ENABLE_DEBUG_PROPAGATION_VERBOSE 0
43 // Emit logging for OSR exit value recoveries at every node, not just nodes that
44 // actually has speculation checks.
45 #define DFG_ENABLE_VERBOSE_VALUE_RECOVERIES 0
46 // Enable generation of dynamic checks into the instruction stream.
47 #if !ASSERT_DISABLED
48 #define DFG_ENABLE_JIT_ASSERT 1
49 #else
50 #define DFG_ENABLE_JIT_ASSERT 0
51 #endif
52 // Enable validation of the graph.
53 #if !ASSERT_DISABLED
54 #define DFG_ENABLE_VALIDATION 1
55 #else
56 #define DFG_ENABLE_VALIDATION 0
57 #endif
58 // Consistency check contents compiler data structures.
59 #define DFG_ENABLE_CONSISTENCY_CHECK 0
60 // Emit a breakpoint into the head of every generated function, to aid debugging in GDB.
61 #define DFG_ENABLE_JIT_BREAK_ON_EVERY_FUNCTION 0
62 // Emit a breakpoint into the head of every generated block, to aid debugging in GDB.
63 #define DFG_ENABLE_JIT_BREAK_ON_EVERY_BLOCK 0
64 // Emit a breakpoint into the head of every generated node, to aid debugging in GDB.
65 #define DFG_ENABLE_JIT_BREAK_ON_EVERY_NODE 0
66 // Emit a pair of xorPtr()'s on regT0 with the node index to make it easy to spot node boundaries in disassembled code.
67 #define DFG_ENABLE_XOR_DEBUG_AID 0
68 // Emit a breakpoint into the speculation failure code.
69 #define DFG_ENABLE_JIT_BREAK_ON_SPECULATION_FAILURE 0
70 // Log every speculation failure.
71 #define DFG_ENABLE_VERBOSE_SPECULATION_FAILURE 0
72 // Disable the DFG JIT without having to touch Platform.h
73 #define DFG_DEBUG_LOCAL_DISBALE 0
74 // Enable OSR entry from baseline JIT.
75 #define DFG_ENABLE_OSR_ENTRY ENABLE(DFG_JIT)
76 // Generate stats on how successful we were in making use of the DFG jit, and remaining on the hot path.
77 #define DFG_ENABLE_SUCCESS_STATS 0
78 // Enable verification that the DFG is able to insert code for control flow edges.
79 #define DFG_ENABLE_EDGE_CODE_VERIFICATION 0
80
81 namespace JSC { namespace DFG {
82
83 // Type for a reference to another node in the graph.
84 typedef uint32_t NodeIndex;
85 static const NodeIndex NoNode = UINT_MAX;
86
87 typedef uint32_t BlockIndex;
88 static const BlockIndex NoBlock = UINT_MAX;
89
90 struct NodeIndexTraits {
91     static NodeIndex defaultValue() { return NoNode; }
92     static void dump(NodeIndex value, FILE* out)
93     {
94         if (value == NoNode)
95             fprintf(out, "-");
96         else
97             fprintf(out, "@%u", value);
98     }
99 };
100
101 enum UseKind {
102     UntypedUse,
103     DoubleUse,
104     LastUseKind // Must always be the last entry in the enum, as it is used to denote the number of enum elements.
105 };
106
107 inline const char* useKindToString(UseKind useKind)
108 {
109     switch (useKind) {
110     case UntypedUse:
111         return "";
112     case DoubleUse:
113         return "d";
114     default:
115         ASSERT_NOT_REACHED();
116         return 0;
117     }
118 }
119
120 inline bool isX86()
121 {
122 #if CPU(X86_64) || CPU(X86)
123     return true;
124 #else
125     return false;
126 #endif
127 }
128
129 enum SpillRegistersMode { NeedToSpill, DontSpill };
130
131 enum NoResultTag { NoResult };
132
133 enum OptimizationFixpointState { FixpointConverged, FixpointNotConverged };
134
135 } } // namespace JSC::DFG
136
137 #endif // ENABLE(DFG_JIT)
138
139 namespace JSC { namespace DFG {
140
141 // Put things here that must be defined even if ENABLE(DFG_JIT) is false.
142
143 enum CapabilityLevel { CannotCompile, MayInline, CanCompile, CapabilityLevelNotSet };
144
145 } } // namespace JSC::DFG
146
147 #endif // DFGCommon_h
148