V8 Project
control-builders.h
Go to the documentation of this file.
1 // Copyright 2013 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef V8_COMPILER_CONTROL_BUILDERS_H_
6 #define V8_COMPILER_CONTROL_BUILDERS_H_
7 
8 #include "src/v8.h"
9 
11 #include "src/compiler/node.h"
12 
13 namespace v8 {
14 namespace internal {
15 namespace compiler {
16 
17 
18 // Base class for all control builders. Also provides a common interface for
19 // control builders to handle 'break' and 'continue' statements when they are
20 // used to model breakable statements.
22  public:
24  : builder_(builder) {}
25  virtual ~ControlBuilder() {}
26 
27  // Interface for break and continue.
28  virtual void Break() { UNREACHABLE(); }
29  virtual void Continue() { UNREACHABLE(); }
30 
31  protected:
34 
35  Zone* zone() const { return builder_->zone(); }
38 
40 };
41 
42 
43 // Tracks control flow for a conditional statement.
44 class IfBuilder : public ControlBuilder {
45  public:
46  explicit IfBuilder(StructuredGraphBuilder* builder)
47  : ControlBuilder(builder),
50 
51  // Primitive control commands.
52  void If(Node* condition);
53  void Then();
54  void Else();
55  void End();
56 
57  private:
58  Environment* then_environment_; // Environment after the 'then' body.
59  Environment* else_environment_; // Environment for the 'else' body.
60 };
61 
62 
63 // Tracks control flow for an iteration statement.
64 class LoopBuilder : public ControlBuilder {
65  public:
67  : ControlBuilder(builder),
71 
72  // Primitive control commands.
73  void BeginLoop();
74  void EndBody();
75  void EndLoop();
76 
77  // Primitive support for break and continue.
78  virtual void Continue();
79  virtual void Break();
80 
81  // Compound control command for conditional break.
82  void BreakUnless(Node* condition);
83 
84  private:
85  Environment* loop_environment_; // Environment of the loop header.
86  Environment* continue_environment_; // Environment after the loop body.
87  Environment* break_environment_; // Environment after the loop exits.
88 };
89 
90 
91 // Tracks control flow for a switch statement.
92 class SwitchBuilder : public ControlBuilder {
93  public:
95  : ControlBuilder(builder),
100 
101  // Primitive control commands.
102  void BeginSwitch();
103  void BeginLabel(int index, Node* condition);
104  void EndLabel();
105  void DefaultAt(int index);
106  void BeginCase(int index);
107  void EndCase();
108  void EndSwitch();
109 
110  // Primitive support for break.
111  virtual void Break();
112 
113  // The number of cases within a switch is statically known.
114  int case_count() const { return body_environments_.capacity(); }
115 
116  private:
117  Environment* body_environment_; // Environment after last case body.
118  Environment* label_environment_; // Environment for next label condition.
119  Environment* break_environment_; // Environment after the switch exits.
121 };
122 
123 
124 // Tracks control flow for a block statement.
125 class BlockBuilder : public ControlBuilder {
126  public:
128  : ControlBuilder(builder), break_environment_(NULL) {}
129 
130  // Primitive control commands.
131  void BeginBlock();
132  void EndBlock();
133 
134  // Primitive support for break.
135  virtual void Break();
136 
137  private:
138  Environment* break_environment_; // Environment after the block exits.
139 };
140 }
141 }
142 } // namespace v8::internal::compiler
143 
144 #endif // V8_COMPILER_CONTROL_BUILDERS_H_
BlockBuilder(StructuredGraphBuilder *builder)
StructuredGraphBuilder::Environment Environment
ControlBuilder(StructuredGraphBuilder *builder)
IfBuilder(StructuredGraphBuilder *builder)
LoopBuilder(StructuredGraphBuilder *builder)
SwitchBuilder(StructuredGraphBuilder *builder, int case_count)
ZoneList< Environment * > body_environments_
void BeginLabel(int index, Node *condition)
enable harmony numeric enable harmony object literal extensions Optimize object Array DOM strings and string trace pretenuring decisions of HAllocate instructions Enables optimizations which favor memory size over execution speed maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining trace the tracking of allocation sites deoptimize every n garbage collections perform array bounds checks elimination analyze liveness of environment slots and zap dead values flushes the cache of optimized code for closures on every GC allow uint32 values on optimize frames if they are used only in safe operations track concurrent recompilation artificial compilation delay in ms do not emit check maps for constant values that have a leaf deoptimize the optimized code if the layout of the maps changes enable context specialization in TurboFan execution budget before interrupt is triggered max percentage of megamorphic generic ICs to allow optimization enable use of SAHF instruction if enable use of VFP3 instructions if available enable use of NEON instructions if enable use of SDIV and UDIV instructions if enable use of MLS instructions if enable loading bit constant by means of movw movt instruction enable unaligned accesses for enable use of d16 d31 registers on ARM this requires VFP3 force all emitted branches to be in long enable alignment of csp to bytes on platforms which prefer the register to always be NULL
#define UNREACHABLE()
Definition: logging.h:30
Debugger support for the V8 JavaScript engine.
Definition: accessors.cc:20