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

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

Issue 9693: Remove the platform specific jump target files by making them have the... (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
« no previous file with comments | « src/codegen-ia32.cc ('k') | src/jump-target-arm.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2008 the V8 project authors. All rights reserved. 1 // Copyright 2008 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 10 matching lines...) Expand all
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 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. 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 27
28 #ifndef V8_JUMP_TARGET_H_ 28 #ifndef V8_JUMP_TARGET_H_
29 #define V8_JUMP_TARGET_H_ 29 #define V8_JUMP_TARGET_H_
30 30
31 #if defined(ARM) || defined (__arm__) || defined(__thumb__) 31 #include "virtual-frame.h"
32 #include "jump-target-arm.h" 32
33 #else // ia32 33 namespace v8 { namespace internal {
34 #include "jump-target-ia32.h" 34
35 // -------------------------------------------------------------------------
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. There must be a current frame before the
93 // jump and there will be no current frame after the jump.
94 void Jump();
95
96 // Emit a conditional branch to the target. If there is no current frame,
97 // there must be one expected at the target.
98 void Branch(Condition cc, Hint hint = no_hint);
99
100 // Bind a jump target. There must be a current frame and no expected
101 // frame at the target (targets are only bound once).
102 void Bind();
103
104 // Emit a call to a jump target. There must be a current frame. The
105 // frame at the target is the same as the current frame except for an
106 // extra return address on top of it.
107 void Call();
108
109 protected:
110 // The encapsulated assembler label.
111 Label label_;
112
113 // The expected frame where the label is bound, or NULL.
114 VirtualFrame* expected_frame_;
115
116 private:
117 // The code generator gives access to the current frame.
118 CodeGenerator* code_generator_;
119
120 // Used to emit code.
121 MacroAssembler* masm_;
122 };
123
124
125 // -------------------------------------------------------------------------
126 // Shadow jump targets
127 //
128 // Shadow jump targets represent a jump target that is temporarily shadowed
129 // by another one (represented by the original during shadowing). They are
130 // used to catch jumps to labels in certain contexts, e.g. try blocks.
131 // After shadowing ends, the formerly shadowed target is again represented
132 // by the original and the ShadowTarget can be used as a jump target in its
133 // own right, representing the formerly shadowing target.
134
135 class ShadowTarget : public JumpTarget {
136 public:
137 // Construct a shadow a jump target. After construction, the original
138 // jump target shadows the former target, which is hidden as the
139 // newly-constructed shadow target.
140 explicit ShadowTarget(JumpTarget* original);
141
142 virtual ~ShadowTarget() {
143 ASSERT(!is_shadowing_);
144 }
145
146 // End shadowing. After shadowing ends, the original jump target gives
147 // access to the formerly shadowed target and the shadow target object
148 // gives access to the formerly shadowing target.
149 void StopShadowing();
150
151 // During shadowing, the currently shadowing target. After shadowing, the
152 // target that was shadowed.
153 JumpTarget* original_target() const { return original_target_; }
154
155 private:
156 // During shadowing, the currently shadowing target. After shadowing, the
157 // target that was shadowed.
158 JumpTarget* original_target_;
159
160 // During shadowing, the saved state of the shadowed target's label.
161 int original_pos_;
162
163 // During shadowing, the saved state of the shadowed target's expected
164 // frame.
165 VirtualFrame* original_expected_frame_;
166
167 #ifdef DEBUG
168 bool is_shadowing_;
35 #endif 169 #endif
170 };
171
172
173 } } // namespace v8::internal
36 174
37 #endif // V8_JUMP_TARGET_H_ 175 #endif // V8_JUMP_TARGET_H_
OLDNEW
« no previous file with comments | « src/codegen-ia32.cc ('k') | src/jump-target-arm.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698