]> git.saurik.com Git - apple/javascriptcore.git/blob - dfg/DFGCommon.h
JavaScriptCore-1097.13.tar.gz
[apple/javascriptcore.git] / 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 // Consistency check contents compiler data structures.
53 #define DFG_ENABLE_CONSISTENCY_CHECK 0
54 // Emit a breakpoint into the head of every generated function, to aid debugging in GDB.
55 #define DFG_ENABLE_JIT_BREAK_ON_EVERY_FUNCTION 0
56 // Emit a breakpoint into the head of every generated block, to aid debugging in GDB.
57 #define DFG_ENABLE_JIT_BREAK_ON_EVERY_BLOCK 0
58 // Emit a breakpoint into the head of every generated node, to aid debugging in GDB.
59 #define DFG_ENABLE_JIT_BREAK_ON_EVERY_NODE 0
60 // Emit a pair of xorPtr()'s on regT0 with the node index to make it easy to spot node boundaries in disassembled code.
61 #define DFG_ENABLE_XOR_DEBUG_AID 0
62 // Emit a breakpoint into the speculation failure code.
63 #define DFG_ENABLE_JIT_BREAK_ON_SPECULATION_FAILURE 0
64 // Log every speculation failure.
65 #define DFG_ENABLE_VERBOSE_SPECULATION_FAILURE 0
66 // Disable the DFG JIT without having to touch Platform.h
67 #define DFG_DEBUG_LOCAL_DISBALE 0
68 // Enable OSR entry from baseline JIT.
69 #define DFG_ENABLE_OSR_ENTRY ENABLE(DFG_JIT)
70 // Generate stats on how successful we were in making use of the DFG jit, and remaining on the hot path.
71 #define DFG_ENABLE_SUCCESS_STATS 0
72 // Enable verification that the DFG is able to insert code for control flow edges.
73 #define DFG_ENABLE_EDGE_CODE_VERIFICATION 0
74 // Pretend that all variables in the top-level code block got captured. Great
75 // for testing code gen for activations.
76 #define DFG_ENABLE_ALL_VARIABLES_CAPTURED 0
77
78 namespace JSC { namespace DFG {
79
80 // Type for a reference to another node in the graph.
81 typedef uint32_t NodeIndex;
82 static const NodeIndex NoNode = UINT_MAX;
83
84 typedef uint32_t BlockIndex;
85 static const BlockIndex NoBlock = UINT_MAX;
86
87 struct NodeIndexTraits {
88 static NodeIndex defaultValue() { return NoNode; }
89 static void dump(NodeIndex value, FILE* out)
90 {
91 if (value == NoNode)
92 fprintf(out, "-");
93 else
94 fprintf(out, "@%u", value);
95 }
96 };
97
98 enum UseKind {
99 UntypedUse,
100 DoubleUse,
101 LastUseKind // Must always be the last entry in the enum, as it is used to denote the number of enum elements.
102 };
103
104 inline const char* useKindToString(UseKind useKind)
105 {
106 switch (useKind) {
107 case UntypedUse:
108 return "";
109 case DoubleUse:
110 return "d";
111 default:
112 ASSERT_NOT_REACHED();
113 return 0;
114 }
115 }
116
117 inline bool isX86()
118 {
119 #if CPU(X86_64) || CPU(X86)
120 return true;
121 #else
122 return false;
123 #endif
124 }
125
126 } } // namespace JSC::DFG
127
128 #endif // ENABLE(DFG_JIT)
129
130 #endif // DFGCommon_h
131