OLD | NEW |
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 20 matching lines...) Expand all Loading... |
31 #include "macro-assembler.h" | 31 #include "macro-assembler.h" |
32 | 32 |
33 namespace v8 { | 33 namespace v8 { |
34 namespace internal { | 34 namespace internal { |
35 | 35 |
36 // Forward declarations. | 36 // Forward declarations. |
37 class FrameElement; | 37 class FrameElement; |
38 class Result; | 38 class Result; |
39 class VirtualFrame; | 39 class VirtualFrame; |
40 | 40 |
| 41 typedef ZoneList<Handle<Object> > ZoneObjectList; |
| 42 |
| 43 class CodeGeneratorData { |
| 44 CodeGenerator* top_; |
| 45 bool compiling_deferred_code_; |
| 46 ZoneObjectList* result_constants_list_; |
| 47 ZoneObjectList* frame_element_constants_list_; |
| 48 |
| 49 ZoneObjectList* result_constants_list(); |
| 50 ZoneObjectList* frame_element_constants_list(); |
| 51 |
| 52 friend class CodeGeneratorScope; |
| 53 friend class JumpTarget; |
| 54 friend class V8Context; |
| 55 friend class Result; |
| 56 friend class FrameElement; |
| 57 |
| 58 CodeGeneratorData(); |
| 59 ~CodeGeneratorData(); |
| 60 |
| 61 DISALLOW_COPY_AND_ASSIGN(CodeGeneratorData); |
| 62 }; |
| 63 |
41 // ------------------------------------------------------------------------- | 64 // ------------------------------------------------------------------------- |
42 // Jump targets | 65 // Jump targets |
43 // | 66 // |
44 // A jump target is an abstraction of a basic-block entry in generated | 67 // A jump target is an abstraction of a basic-block entry in generated |
45 // code. It collects all the virtual frames reaching the block by | 68 // code. It collects all the virtual frames reaching the block by |
46 // forward jumps and pairs them with labels for the merge code along | 69 // forward jumps and pairs them with labels for the merge code along |
47 // all forward-reaching paths. When bound, an expected frame for the | 70 // all forward-reaching paths. When bound, an expected frame for the |
48 // block is determined and code is generated to merge to the expected | 71 // block is determined and code is generated to merge to the expected |
49 // frame. For backward jumps, the merge code is generated at the edge | 72 // frame. For backward jumps, the merge code is generated at the edge |
50 // leaving the predecessor block. | 73 // leaving the predecessor block. |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 virtual void Bind(); | 145 virtual void Bind(); |
123 virtual void Bind(Result* arg); | 146 virtual void Bind(Result* arg); |
124 | 147 |
125 // Emit a call to a jump target. There must be a current frame at | 148 // Emit a call to a jump target. There must be a current frame at |
126 // the call. The frame at the target is the same as the current | 149 // the call. The frame at the target is the same as the current |
127 // frame except for an extra return address on top of it. The frame | 150 // frame except for an extra return address on top of it. The frame |
128 // after the call is the same as the frame before the call. | 151 // after the call is the same as the frame before the call. |
129 void Call(); | 152 void Call(); |
130 | 153 |
131 static void set_compiling_deferred_code(bool flag) { | 154 static void set_compiling_deferred_code(bool flag) { |
132 compiling_deferred_code_ = flag; | 155 v8_context()->code_generator_data_.compiling_deferred_code_ = flag; |
133 } | 156 } |
134 | 157 |
135 protected: | 158 protected: |
136 // Directionality flag set at initialization time. | 159 // Directionality flag set at initialization time. |
137 Directionality direction_; | 160 Directionality direction_; |
138 | 161 |
139 // A list of frames reaching this block via forward jumps. | 162 // A list of frames reaching this block via forward jumps. |
140 ZoneList<VirtualFrame*> reaching_frames_; | 163 ZoneList<VirtualFrame*> reaching_frames_; |
141 | 164 |
142 // A parallel list of labels for merge code. | 165 // A parallel list of labels for merge code. |
143 ZoneList<Label> merge_labels_; | 166 ZoneList<Label> merge_labels_; |
144 | 167 |
145 // The frame used on entry to the block and expected at backward | 168 // The frame used on entry to the block and expected at backward |
146 // jumps to the block. Set when the jump target is bound, but may | 169 // jumps to the block. Set when the jump target is bound, but may |
147 // or may not be set for forward-only blocks. | 170 // or may not be set for forward-only blocks. |
148 VirtualFrame* entry_frame_; | 171 VirtualFrame* entry_frame_; |
149 | 172 |
150 // The actual entry label of the block. | 173 // The actual entry label of the block. |
151 Label entry_label_; | 174 Label entry_label_; |
152 | 175 |
153 // Implementations of Jump, Branch, and Bind with all arguments and | 176 // Implementations of Jump, Branch, and Bind with all arguments and |
154 // return values using the virtual frame. | 177 // return values using the virtual frame. |
155 void DoJump(); | 178 void DoJump(); |
156 void DoBranch(Condition cc, Hint hint); | 179 void DoBranch(Condition cc, Hint hint); |
157 void DoBind(); | 180 void DoBind(); |
158 | 181 |
159 private: | 182 private: |
160 static bool compiling_deferred_code_; | |
161 | 183 |
162 // Add a virtual frame reaching this labeled block via a forward jump, | 184 // Add a virtual frame reaching this labeled block via a forward jump, |
163 // and a corresponding merge code label. | 185 // and a corresponding merge code label. |
164 void AddReachingFrame(VirtualFrame* frame); | 186 void AddReachingFrame(VirtualFrame* frame); |
165 | 187 |
166 // Perform initialization required during entry frame computation | 188 // Perform initialization required during entry frame computation |
167 // after setting the virtual frame element at index in frame to be | 189 // after setting the virtual frame element at index in frame to be |
168 // target. | 190 // target. |
169 inline void InitializeEntryElement(int index, FrameElement* target); | 191 inline void InitializeEntryElement(int index, FrameElement* target); |
170 | 192 |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
270 bool is_shadowing_; | 292 bool is_shadowing_; |
271 #endif | 293 #endif |
272 | 294 |
273 DISALLOW_COPY_AND_ASSIGN(ShadowTarget); | 295 DISALLOW_COPY_AND_ASSIGN(ShadowTarget); |
274 }; | 296 }; |
275 | 297 |
276 | 298 |
277 } } // namespace v8::internal | 299 } } // namespace v8::internal |
278 | 300 |
279 #endif // V8_JUMP_TARGET_H_ | 301 #endif // V8_JUMP_TARGET_H_ |
OLD | NEW |