| 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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 // frame. For backward jumps, the merge code is generated at the edge | 45 // frame. For backward jumps, the merge code is generated at the edge |
| 46 // leaving the predecessor block. | 46 // leaving the predecessor block. |
| 47 // | 47 // |
| 48 // A jump target must have been reached via control flow (either by | 48 // A jump target must have been reached via control flow (either by |
| 49 // jumping, branching, or falling through) at the time it is bound. | 49 // jumping, branching, or falling through) at the time it is bound. |
| 50 // In particular, this means that at least one of the control-flow | 50 // In particular, this means that at least one of the control-flow |
| 51 // graph edges reaching the target must be a forward edge. | 51 // graph edges reaching the target must be a forward edge. |
| 52 | 52 |
| 53 class JumpTarget : public ZoneObject { // Shadows are dynamically allocated. | 53 class JumpTarget : public ZoneObject { // Shadows are dynamically allocated. |
| 54 public: | 54 public: |
| 55 // Forward-only jump targets can only be reached by forward CFG edges. |
| 56 enum Directionality { FORWARD_ONLY, BIDIRECTIONAL }; |
| 57 |
| 55 // Construct a jump target with a given code generator used to generate | 58 // Construct a jump target with a given code generator used to generate |
| 56 // code and to provide access to a current frame. | 59 // code and to provide access to a current frame. |
| 57 explicit JumpTarget(CodeGenerator* cgen); | 60 explicit JumpTarget(CodeGenerator* cgen, |
| 61 Directionality direction = FORWARD_ONLY); |
| 58 | 62 |
| 59 // Construct a jump target without a code generator. A code generator | 63 // Construct a jump target without a code generator. A code generator |
| 60 // must be supplied before using the jump target as a label. This is | 64 // must be supplied before using the jump target as a label. This is |
| 61 // useful, eg, when jump targets are embedded in AST nodes. | 65 // useful, eg, when jump targets are embedded in AST nodes. |
| 62 JumpTarget(); | 66 JumpTarget(); |
| 63 | 67 |
| 64 virtual ~JumpTarget() { Unuse(); } | 68 virtual ~JumpTarget() { Unuse(); } |
| 65 | 69 |
| 66 // Supply a code generator. This function expects to be given a non-null | 70 // Supply a code generator and directionality to an already |
| 67 // code generator, and to be called only when the code generator is not | 71 // constructed jump target. This function expects to be given a |
| 68 // yet set. | 72 // non-null code generator, and to be called only when the code |
| 69 void set_code_generator(CodeGenerator* cgen); | 73 // generator is not yet set. |
| 74 void Initialize(CodeGenerator* cgen, |
| 75 Directionality direction = FORWARD_ONLY); |
| 70 | 76 |
| 71 // Accessors. | 77 // Accessors. |
| 72 CodeGenerator* code_generator() const { return cgen_; } | 78 CodeGenerator* code_generator() const { return cgen_; } |
| 73 | 79 |
| 74 Label* entry_label() { return &entry_label_; } | 80 Label* entry_label() { return &entry_label_; } |
| 75 | 81 |
| 76 VirtualFrame* expected_frame() const { return expected_frame_; } | 82 VirtualFrame* expected_frame() const { return expected_frame_; } |
| 77 void set_expected_frame(VirtualFrame* frame) { | 83 void set_expected_frame(VirtualFrame* frame) { |
| 78 expected_frame_ = frame; | 84 expected_frame_ = frame; |
| 79 } | 85 } |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 void Call(); | 144 void Call(); |
| 139 | 145 |
| 140 protected: | 146 protected: |
| 141 // The code generator gives access to its current frame. | 147 // The code generator gives access to its current frame. |
| 142 CodeGenerator* cgen_; | 148 CodeGenerator* cgen_; |
| 143 | 149 |
| 144 // Used to emit code. | 150 // Used to emit code. |
| 145 MacroAssembler* masm_; | 151 MacroAssembler* masm_; |
| 146 | 152 |
| 147 private: | 153 private: |
| 154 // Directionality flag set at initialization time. |
| 155 Directionality direction_; |
| 156 |
| 148 // A list of frames reaching this block via forward jumps. | 157 // A list of frames reaching this block via forward jumps. |
| 149 List<VirtualFrame*> reaching_frames_; | 158 List<VirtualFrame*> reaching_frames_; |
| 150 | 159 |
| 151 // A parallel list of labels for merge code. | 160 // A parallel list of labels for merge code. |
| 152 List<Label> merge_labels_; | 161 List<Label> merge_labels_; |
| 153 | 162 |
| 154 // The (mergable) frame expected at backward jumps to the block. | 163 // The (mergable) frame expected at backward jumps to the block. |
| 155 VirtualFrame* expected_frame_; | 164 VirtualFrame* expected_frame_; |
| 156 | 165 |
| 157 // The actual entry label of the block. | 166 // The actual entry label of the block. |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 205 bool is_shadowing_; | 214 bool is_shadowing_; |
| 206 #endif | 215 #endif |
| 207 | 216 |
| 208 DISALLOW_COPY_AND_ASSIGN(ShadowTarget); | 217 DISALLOW_COPY_AND_ASSIGN(ShadowTarget); |
| 209 }; | 218 }; |
| 210 | 219 |
| 211 | 220 |
| 212 } } // namespace v8::internal | 221 } } // namespace v8::internal |
| 213 | 222 |
| 214 #endif // V8_JUMP_TARGET_H_ | 223 #endif // V8_JUMP_TARGET_H_ |
| OLD | NEW |