Chromium Code Reviews| 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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 49 // A jump target must have been reached via control flow (either by | 49 // A jump target must have been reached via control flow (either by |
| 50 // jumping, branching, or falling through) at the time it is bound. | 50 // jumping, branching, or falling through) at the time it is bound. |
| 51 // In particular, this means that at least one of the control-flow | 51 // In particular, this means that at least one of the control-flow |
| 52 // graph edges reaching the target must be a forward edge. | 52 // graph edges reaching the target must be a forward edge. |
| 53 | 53 |
| 54 class JumpTarget : public ZoneObject { // Shadows are dynamically allocated. | 54 class JumpTarget : public ZoneObject { // Shadows are dynamically allocated. |
| 55 public: | 55 public: |
| 56 // Forward-only jump targets can only be reached by forward CFG edges. | 56 // Forward-only jump targets can only be reached by forward CFG edges. |
| 57 enum Directionality { FORWARD_ONLY, BIDIRECTIONAL }; | 57 enum Directionality { FORWARD_ONLY, BIDIRECTIONAL }; |
| 58 | 58 |
| 59 // Construct a jump target with a given code generator used to generate | 59 // Construct a jump target with a given code generator used to generate |
|
William Hesse
2009/05/18 12:18:24
This comment should be changed.
| |
| 60 // code and to provide access to a current frame. | 60 // code and to provide access to a current frame. |
| 61 explicit JumpTarget(CodeGenerator* cgen, | 61 explicit JumpTarget(Directionality direction) |
| 62 Directionality direction = FORWARD_ONLY); | 62 : direction_(direction), |
| 63 reaching_frames_(0), | |
| 64 merge_labels_(0), | |
| 65 entry_frame_(NULL) { | |
| 66 } | |
| 63 | 67 |
| 64 // Construct a jump target without a code generator. A code | 68 // Construct a jump target without a code generator. A code |
|
William Hesse
2009/05/18 12:18:24
This comment should be changed.
| |
| 65 // generator must be supplied before using the jump target as a | 69 // generator must be supplied before using the jump target as a |
| 66 // label. This is useful, eg, when break targets are embedded in | 70 // label. This is useful, eg, when break targets are embedded in |
| 67 // AST nodes. | 71 // AST nodes. |
| 68 JumpTarget(); | 72 JumpTarget() |
| 73 : direction_(FORWARD_ONLY), | |
| 74 reaching_frames_(0), | |
| 75 merge_labels_(0), | |
| 76 entry_frame_(NULL) { | |
| 77 } | |
| 69 | 78 |
| 70 virtual ~JumpTarget() {} | 79 virtual ~JumpTarget() {} |
| 71 | 80 |
| 72 // Supply a code generator and directionality to an already | 81 // Set the direction of the jump target. |
| 73 // constructed jump target. This function expects to be given a | 82 virtual void set_direction(Directionality direction) { |
| 74 // non-null code generator, and to be called only when the code | 83 direction_ = direction; |
| 75 // generator is not yet set. | 84 } |
| 76 virtual void Initialize(CodeGenerator* cgen, | |
| 77 Directionality direction = FORWARD_ONLY); | |
| 78 | 85 |
| 79 // Treat the jump target as a fresh one. The state is reset. | 86 // Treat the jump target as a fresh one. The state is reset. |
| 80 void Unuse(); | 87 void Unuse(); |
| 81 | 88 |
| 82 // Accessors. | 89 inline CodeGenerator* cgen(); |
| 83 CodeGenerator* code_generator() const { return cgen_; } | |
| 84 | 90 |
| 85 Label* entry_label() { return &entry_label_; } | 91 Label* entry_label() { return &entry_label_; } |
| 86 | 92 |
| 87 VirtualFrame* entry_frame() const { return entry_frame_; } | 93 VirtualFrame* entry_frame() const { return entry_frame_; } |
| 88 void set_entry_frame(VirtualFrame* frame) { | 94 void set_entry_frame(VirtualFrame* frame) { |
| 89 entry_frame_ = frame; | 95 entry_frame_ = frame; |
| 90 } | 96 } |
| 91 | 97 |
| 92 // Predicates testing the state of the encapsulated label. | 98 // Predicates testing the state of the encapsulated label. |
| 93 bool is_bound() const { return entry_label_.is_bound(); } | 99 bool is_bound() const { return entry_label_.is_bound(); } |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 156 // after the call is the same as the frame before the call. | 162 // after the call is the same as the frame before the call. |
| 157 void Call(); | 163 void Call(); |
| 158 | 164 |
| 159 static const int kAllElements = -1; // Not a valid number of elements. | 165 static const int kAllElements = -1; // Not a valid number of elements. |
| 160 | 166 |
| 161 static void set_compiling_deferred_code(bool flag) { | 167 static void set_compiling_deferred_code(bool flag) { |
| 162 compiling_deferred_code_ = flag; | 168 compiling_deferred_code_ = flag; |
| 163 } | 169 } |
| 164 | 170 |
| 165 protected: | 171 protected: |
| 166 // The code generator gives access to its current frame. | |
| 167 CodeGenerator* cgen_; | |
| 168 | |
| 169 // Used to emit code. | |
| 170 MacroAssembler* masm_; | |
| 171 | |
| 172 // Directionality flag set at initialization time. | 172 // Directionality flag set at initialization time. |
| 173 Directionality direction_; | 173 Directionality direction_; |
| 174 | 174 |
| 175 // A list of frames reaching this block via forward jumps. | 175 // A list of frames reaching this block via forward jumps. |
| 176 ZoneList<VirtualFrame*> reaching_frames_; | 176 ZoneList<VirtualFrame*> reaching_frames_; |
| 177 | 177 |
| 178 // A parallel list of labels for merge code. | 178 // A parallel list of labels for merge code. |
| 179 ZoneList<Label> merge_labels_; | 179 ZoneList<Label> merge_labels_; |
| 180 | 180 |
| 181 // The frame used on entry to the block and expected at backward | 181 // The frame used on entry to the block and expected at backward |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 225 class BreakTarget : public JumpTarget { | 225 class BreakTarget : public JumpTarget { |
| 226 public: | 226 public: |
| 227 // Construct a break target without a code generator. A code | 227 // Construct a break target without a code generator. A code |
| 228 // generator must be supplied before using the break target as a | 228 // generator must be supplied before using the break target as a |
| 229 // label. This is useful, eg, when break targets are embedded in AST | 229 // label. This is useful, eg, when break targets are embedded in AST |
| 230 // nodes. | 230 // nodes. |
| 231 BreakTarget() {} | 231 BreakTarget() {} |
| 232 | 232 |
| 233 virtual ~BreakTarget() {} | 233 virtual ~BreakTarget() {} |
| 234 | 234 |
| 235 // Supply a code generator, expected expression stack height, and | 235 // Set the direction of the break target. |
| 236 // directionality to an already constructed break target. This | 236 virtual void set_direction(Directionality direction); |
| 237 // function expects to be given a non-null code generator, and to be | |
| 238 // called only when the code generator is not yet set. | |
| 239 virtual void Initialize(CodeGenerator* cgen, | |
| 240 Directionality direction = FORWARD_ONLY); | |
| 241 | 237 |
| 242 // Copy the state of this break target to the destination. The | 238 // Copy the state of this break target to the destination. The |
| 243 // lists of forward-reaching frames and merge-point labels are | 239 // lists of forward-reaching frames and merge-point labels are |
| 244 // copied. All virtual frame pointers are copied, not the | 240 // copied. All virtual frame pointers are copied, not the |
| 245 // pointed-to frames. The previous state of the destination is | 241 // pointed-to frames. The previous state of the destination is |
| 246 // overwritten, without deallocating pointed-to virtual frames. | 242 // overwritten, without deallocating pointed-to virtual frames. |
| 247 void CopyTo(BreakTarget* destination); | 243 void CopyTo(BreakTarget* destination); |
| 248 | 244 |
| 249 // Emit a jump to the target. There must be a current frame at the | 245 // Emit a jump to the target. There must be a current frame at the |
| 250 // jump and there will be no current frame after the jump. | 246 // jump and there will be no current frame after the jump. |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 314 bool is_shadowing_; | 310 bool is_shadowing_; |
| 315 #endif | 311 #endif |
| 316 | 312 |
| 317 DISALLOW_COPY_AND_ASSIGN(ShadowTarget); | 313 DISALLOW_COPY_AND_ASSIGN(ShadowTarget); |
| 318 }; | 314 }; |
| 319 | 315 |
| 320 | 316 |
| 321 } } // namespace v8::internal | 317 } } // namespace v8::internal |
| 322 | 318 |
| 323 #endif // V8_JUMP_TARGET_H_ | 319 #endif // V8_JUMP_TARGET_H_ |
| OLD | NEW |