OLD | NEW |
1 // Copyright 2009 the V8 project authors. All rights reserved. | 1 // Copyright 2009 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 17 matching lines...) Expand all Loading... |
28 #include "v8.h" | 28 #include "v8.h" |
29 | 29 |
30 #include "codegen-inl.h" | 30 #include "codegen-inl.h" |
31 #include "register-allocator-inl.h" | 31 #include "register-allocator-inl.h" |
32 | 32 |
33 namespace v8 { namespace internal { | 33 namespace v8 { namespace internal { |
34 | 34 |
35 // ------------------------------------------------------------------------- | 35 // ------------------------------------------------------------------------- |
36 // JumpTarget implementation. | 36 // JumpTarget implementation. |
37 | 37 |
| 38 bool JumpTarget::compiling_deferred_code_ = false; |
| 39 |
| 40 |
38 JumpTarget::JumpTarget(CodeGenerator* cgen, Directionality direction) | 41 JumpTarget::JumpTarget(CodeGenerator* cgen, Directionality direction) |
39 : cgen_(cgen), | 42 : cgen_(cgen), |
40 direction_(direction), | 43 direction_(direction), |
41 reaching_frames_(0), | 44 reaching_frames_(0), |
42 merge_labels_(0), | 45 merge_labels_(0), |
43 entry_frame_(NULL), | 46 entry_frame_(NULL), |
44 is_bound_(false), | 47 is_bound_(false), |
45 is_linked_(false) { | 48 is_linked_(false) { |
46 ASSERT(cgen != NULL); | 49 ASSERT(cgen != NULL); |
47 masm_ = cgen->masm(); | 50 masm_ = cgen->masm(); |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 is_bound_ = false; | 93 is_bound_ = false; |
91 is_linked_ = false; | 94 is_linked_ = false; |
92 } | 95 } |
93 | 96 |
94 | 97 |
95 void JumpTarget::ComputeEntryFrame(int mergable_elements) { | 98 void JumpTarget::ComputeEntryFrame(int mergable_elements) { |
96 // Given: a collection of frames reaching by forward CFG edges and | 99 // Given: a collection of frames reaching by forward CFG edges and |
97 // the directionality of the block. Compute: an entry frame for the | 100 // the directionality of the block. Compute: an entry frame for the |
98 // block. | 101 // block. |
99 | 102 |
| 103 Counters::compute_entry_frame.Increment(); |
| 104 #ifdef DEBUG |
| 105 if (compiling_deferred_code_) { |
| 106 ASSERT(reaching_frames_.length() > 1); |
| 107 VirtualFrame* frame = reaching_frames_[0]; |
| 108 bool all_identical = true; |
| 109 for (int i = 1; i < reaching_frames_.length(); i++) { |
| 110 if (!frame->Equals(reaching_frames_[i])) { |
| 111 all_identical = false; |
| 112 break; |
| 113 } |
| 114 } |
| 115 ASSERT(!all_identical || all_identical); |
| 116 } |
| 117 #endif |
| 118 |
100 // Choose an initial frame. | 119 // Choose an initial frame. |
101 VirtualFrame* initial_frame = reaching_frames_[0]; | 120 VirtualFrame* initial_frame = reaching_frames_[0]; |
102 | 121 |
103 // A list of pointers to frame elements in the entry frame. NULL | 122 // A list of pointers to frame elements in the entry frame. NULL |
104 // indicates that the element has not yet been determined. | 123 // indicates that the element has not yet been determined. |
105 int length = initial_frame->elements_.length(); | 124 int length = initial_frame->elements_.length(); |
106 List<FrameElement*> elements(length); | 125 List<FrameElement*> elements(length); |
107 | 126 |
108 // Convert the number of mergable elements (counted from the top | 127 // Convert the number of mergable elements (counted from the top |
109 // down) to a frame high-water mark (counted from the bottom up). | 128 // down) to a frame high-water mark (counted from the bottom up). |
(...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
502 DoBind(mergable_elements); | 521 DoBind(mergable_elements); |
503 *arg3 = cgen_->frame()->Pop(); | 522 *arg3 = cgen_->frame()->Pop(); |
504 *arg2 = cgen_->frame()->Pop(); | 523 *arg2 = cgen_->frame()->Pop(); |
505 *arg1 = cgen_->frame()->Pop(); | 524 *arg1 = cgen_->frame()->Pop(); |
506 *arg0 = cgen_->frame()->Pop(); | 525 *arg0 = cgen_->frame()->Pop(); |
507 } | 526 } |
508 | 527 |
509 | 528 |
510 void JumpTarget::AddReachingFrame(VirtualFrame* frame) { | 529 void JumpTarget::AddReachingFrame(VirtualFrame* frame) { |
511 ASSERT(reaching_frames_.length() == merge_labels_.length()); | 530 ASSERT(reaching_frames_.length() == merge_labels_.length()); |
| 531 ASSERT(entry_frame_ == NULL); |
512 Label fresh; | 532 Label fresh; |
513 merge_labels_.Add(fresh); | 533 merge_labels_.Add(fresh); |
514 reaching_frames_.Add(frame); | 534 reaching_frames_.Add(frame); |
515 } | 535 } |
516 | 536 |
517 | 537 |
518 // ------------------------------------------------------------------------- | 538 // ------------------------------------------------------------------------- |
519 // BreakTarget implementation. | 539 // BreakTarget implementation. |
520 | 540 |
521 void BreakTarget::Initialize(CodeGenerator* cgen, Directionality direction) { | 541 void BreakTarget::Initialize(CodeGenerator* cgen, Directionality direction) { |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
673 temp.CopyTo(this); | 693 temp.CopyTo(this); |
674 temp.Reset(); // So the destructor does not deallocate virtual frames. | 694 temp.Reset(); // So the destructor does not deallocate virtual frames. |
675 | 695 |
676 #ifdef DEBUG | 696 #ifdef DEBUG |
677 is_shadowing_ = false; | 697 is_shadowing_ = false; |
678 #endif | 698 #endif |
679 } | 699 } |
680 | 700 |
681 | 701 |
682 } } // namespace v8::internal | 702 } } // namespace v8::internal |
OLD | NEW |