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

Side by Side Diff: src/jump-target-arm.h

Issue 9328: Initial (stub) port of jump targets to the ARM platform.... (Closed) Base URL: http://v8.googlecode.com/svn/branches/experimental/toiger/
Patch Set: '' Created 12 years, 1 month 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 | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright 2008 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are
4 // met:
5 //
6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided
11 // with the distribution.
12 // * Neither the name of Google Inc. nor the names of its
13 // contributors may be used to endorse or promote products derived
14 // from this software without specific prior written permission.
15 //
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
28 #ifndef V8_JUMP_TARGET_ARM_H_
29 #define V8_JUMP_TARGET_ARM_H_
30
31 #include "virtual-frame-arm.h"
32
33 namespace v8 { namespace internal {
34
35 // -------------------------------------------------------------------------
Erik Corry 2008/11/07 11:55:10 Almost everything in this file looks architecture
36 // Jump targets
37 //
38 // A jump target is an abstraction of a control-flow target in generated
39 // code. It encapsulates an assembler label and an expected virtual frame
40 // layout at that label. The first time control flow reaches the target,
41 // either via jumping or branching or by binding the target, the expected
42 // frame is set. If control flow subsequently reaches the target, code may
43 // be emitted to ensure that the current frame matches the expected frame.
44 //
45 // A jump target must have been reached via control flow (either by jumping,
46 // branching, or falling through) when it is bound. In particular, this
47 // means that at least one of the control-flow graph edges reaching the
48 // target must be a forward edge and must be compiled before any backward
49 // edges.
50
51 class JumpTarget : public ZoneObject { // Shadows are dynamically allocated.
52 public:
53 // Construct a jump target with a given code generator used to generate
54 // code and to provide access to a current frame.
55 explicit JumpTarget(CodeGenerator* cgen);
56
57 // Construct a jump target without a code generator. A code generator
58 // must be supplied before using the jump target as a label. This is
59 // useful, eg, when jump targets are embedded in AST nodes.
60 JumpTarget();
61
62 virtual ~JumpTarget() { delete expected_frame_; }
63
64 // Supply a code generator. This function expects to be given a non-null
65 // code generator, and to be called only when the code generator is not
66 // yet set.
67 void set_code_generator(CodeGenerator* cgen);
68
69 // Accessors.
70 CodeGenerator* code_generator() const { return code_generator_; }
71
72 Label* label() { return &label_; }
73
74 VirtualFrame* expected_frame() const { return expected_frame_; }
75 void set_expected_frame(VirtualFrame* frame) {
76 expected_frame_ = frame;
77 }
78
79 // Predicates testing the state of the encapsulated label.
80 bool is_bound() const { return label_.is_bound(); }
81 bool is_linked() const { return label_.is_linked(); }
82 bool is_unused() const { return label_.is_unused(); }
83
84 // Treat the jump target as a fresh one---the label is unused and the
85 // expected frame if any is reset.
86 void Unuse() {
87 label_.Unuse();
88 delete expected_frame_;
89 expected_frame_ = NULL;
90 }
91
92 // Emit a jump to the target. If there is no expected frame, the code
93 // generator's current frame becomes the expected one. If there is
94 // already an expected frame, code may be emitted to merge the current
95 // frame to the expected one. After the jump, the code generate has no
96 // current frame (because control flow does not fall through from a jump).
97 // A new current frame can be picked up by, eg, binding a jump target with
98 // an expected frame.
99 void Jump();
100
101 // Emit a conditional branch to the target. If there is no expected
102 // frame, a clone of the code generator's current frame becomes the
103 // expected one. If there is already an expected frame, code may be
104 // emitted to merge the current frame to the expected one.
105 void Branch(Condition cc);
106
107 // Bind a jump target. If there is no expected frame and there is a
108 // current frame (ie, control flow is falling through to the target), then
109 // a clone of the current frame becomes the expected one. If there is a
110 // current frame and an expected one (eg, control flow is falling through
111 // to a target that has already been reached via a jump or branch), then
112 // code may be emitted to merge the frames. A jump target that already
113 // has an expected frame can be bound even if there is no current
114 // frame---in that case, the new current frame is picked up from the jump
115 // target.
116 void Bind();
117
118 protected:
119 // The encapsulated assembler label.
120 Label label_;
121
122 // The expected frame where the label is bound, or NULL.
123 VirtualFrame* expected_frame_;
124
125 private:
126 // The code generator gives access to the current frame.
127 CodeGenerator* code_generator_;
128
129 // Used to emit code.
130 MacroAssembler* masm_;
131 };
132
133
134 // -------------------------------------------------------------------------
135 // Shadow jump targets
136 //
137 // Shadow jump targets represent a jump target that is temporarily shadowed
138 // by another one (represented by the original during shadowing). They are
139 // used to catch jumps to labels in certain contexts, e.g. try blocks.
140 // After shadowing ends, the formerly shadowed target is again represented
141 // by the original and the ShadowTarget can be used as a jump target in its
142 // own right, representing the formerly shadowing target.
143
144 class ShadowTarget : public JumpTarget {
145 public:
146 // Construct a shadow a jump target. After construction, the original
147 // jump target shadows the former target, which is hidden as the
148 // newly-constructed shadow target.
149 explicit ShadowTarget(JumpTarget* original);
150
151 virtual ~ShadowTarget() {
152 ASSERT(!is_shadowing_);
153 }
154
155 // End shadowing. After shadowing ends, the original jump target gives
156 // access to the formerly shadowed target and the shadow target object
157 // gives access to the formerly shadowing target.
158 void StopShadowing();
159
160 // During shadowing, the currently shadowing target. After shadowing, the
161 // target that was shadowed.
162 JumpTarget* original_target() const { return original_target_; }
163
164 private:
165 // During shadowing, the currently shadowing target. After shadowing, the
166 // target that was shadowed.
167 JumpTarget* original_target_;
168
169 // During shadowing, the saved state of the shadowed target's label.
170 int original_pos_;
171
172 // During shadowing, the saved state of the shadowed target's expected
173 // frame.
174 VirtualFrame* original_expected_frame_;
175
176 #ifdef DEBUG
177 bool is_shadowing_;
178 #endif
179 };
180
181
182 } } // namespace v8::internal
183
184 #endif // V8_JUMP_TARGET_ARM_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698