Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3)

Side by Side Diff: src/interpreter/control-flow-builders.h

Issue 1373903005: [Interpreter] Add for/while/do support to the bytecode generator. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebase. Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/interpreter/bytecodes.cc ('k') | src/interpreter/control-flow-builders.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2015 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_INTERPRETER_CONTROL_FLOW_BUILDERS_H_
6 #define V8_INTERPRETER_CONTROL_FLOW_BUILDERS_H_
7
8 #include "src/interpreter/bytecode-array-builder.h"
9
10 #include "src/zone-containers.h"
11
12 namespace v8 {
13 namespace internal {
14 namespace interpreter {
15
16 class ControlFlowBuilder BASE_EMBEDDED {
17 public:
18 explicit ControlFlowBuilder(BytecodeArrayBuilder* builder)
19 : builder_(builder) {}
20 virtual ~ControlFlowBuilder() {}
21
22 protected:
23 BytecodeArrayBuilder* builder() const { return builder_; }
24
25 private:
26 BytecodeArrayBuilder* builder_;
27
28 DISALLOW_COPY_AND_ASSIGN(ControlFlowBuilder);
29 };
30
31 // A class to help with co-ordinating break and continue statements with
32 // their loop.
33 // TODO(oth): add support for TF branch/merge info.
34 class LoopBuilder : public ControlFlowBuilder {
35 public:
36 explicit LoopBuilder(BytecodeArrayBuilder* builder)
37 : ControlFlowBuilder(builder),
38 continue_sites_(builder->zone()),
39 break_sites_(builder->zone()) {}
40 ~LoopBuilder();
41
42 // These methods should be called by the LoopBuilder owner before
43 // destruction to update sites that emit jumps for break/continue.
44 void SetContinueTarget(const BytecodeLabel& continue_target);
45 void SetBreakTarget(const BytecodeLabel& break_target);
46
47 // These methods are called when visiting break and continue
48 // statements in the AST. Inserts a jump to a unbound label that is
49 // patched when the corresponding SetContinueTarget/SetBreakTarget
50 // is called.
51 void Break() { EmitJump(&break_sites_); }
52 void Continue() { EmitJump(&continue_sites_); }
53
54 private:
55 void BindLabels(const BytecodeLabel& target, ZoneVector<BytecodeLabel>* site);
56 void EmitJump(ZoneVector<BytecodeLabel>* labels);
57
58 // Unbound labels that identify jumps for continue/break statements
59 // in the code.
60 ZoneVector<BytecodeLabel> continue_sites_;
61 ZoneVector<BytecodeLabel> break_sites_;
62 };
63
64 } // namespace interpreter
65 } // namespace internal
66 } // namespace v8
67
68 #endif // V8_INTERPRETER_CONTROL_FLOW_BUILDERS_H_
OLDNEW
« no previous file with comments | « src/interpreter/bytecodes.cc ('k') | src/interpreter/control-flow-builders.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698