| 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 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 } else { | 132 } else { |
| 133 return right; | 133 return right; |
| 134 } | 134 } |
| 135 } | 135 } |
| 136 | 136 |
| 137 // Otherwise they are incompatible and we will reallocate them. | 137 // Otherwise they are incompatible and we will reallocate them. |
| 138 return NULL; | 138 return NULL; |
| 139 } | 139 } |
| 140 | 140 |
| 141 | 141 |
| 142 void JumpTarget::ComputeEntryFrame() { | 142 void JumpTarget::ComputeEntryFrame(int mergable_elements) { |
| 143 // Given: a collection of frames reaching by forward CFG edges | 143 // Given: a collection of frames reaching by forward CFG edges |
| 144 // (including the code generator's current frame) and the | 144 // (including the code generator's current frame) and the |
| 145 // directionality of the block. Compute: an entry frame for the | 145 // directionality of the block. Compute: an entry frame for the |
| 146 // block. | 146 // block. |
| 147 | 147 |
| 148 // Choose an initial frame, either the code generator's current | 148 // Choose an initial frame, either the code generator's current |
| 149 // frame if there is one, or the first reaching frame if not. | 149 // frame if there is one, or the first reaching frame if not. |
| 150 VirtualFrame* initial_frame = cgen_->frame(); | 150 VirtualFrame* initial_frame = cgen_->frame(); |
| 151 int start_index = 0; // Begin iteration with the 1st reaching frame. | 151 int start_index = 0; // Begin iteration with the 1st reaching frame. |
| 152 if (initial_frame == NULL) { | 152 if (initial_frame == NULL) { |
| 153 initial_frame = reaching_frames_[0]; | 153 initial_frame = reaching_frames_[0]; |
| 154 start_index = 1; // Begin iteration with the 2nd reaching frame. | 154 start_index = 1; // Begin iteration with the 2nd reaching frame. |
| 155 } | 155 } |
| 156 | 156 |
| 157 // A list of pointers to frame elements in the entry frame. NULL | 157 // A list of pointers to frame elements in the entry frame. NULL |
| 158 // indicates that the element has not yet been determined. | 158 // indicates that the element has not yet been determined. |
| 159 int length = initial_frame->elements_.length(); | 159 int length = initial_frame->elements_.length(); |
| 160 List<FrameElement*> elements(length); | 160 List<FrameElement*> elements(length); |
| 161 | 161 |
| 162 // Convert the number of mergable elements (counted from the top |
| 163 // down) to a frame high-water mark (counted from the bottom up). |
| 164 // Elements strictly above the high-water index will be mergable in |
| 165 // entry frames for bidirectional jump targets. |
| 166 int high_water_mark = (mergable_elements == kAllElements) |
| 167 ? VirtualFrame::kIllegalIndex // All frame indices are above this. |
| 168 : length - mergable_elements - 1; // Top index if m_e == 0. |
| 169 |
| 162 // Initially populate the list of elements based on the initial | 170 // Initially populate the list of elements based on the initial |
| 163 // frame. | 171 // frame. |
| 164 for (int i = 0; i < length; i++) { | 172 for (int i = 0; i < length; i++) { |
| 165 FrameElement element = initial_frame->elements_[i]; | 173 FrameElement element = initial_frame->elements_[i]; |
| 166 // We do not allow copies or constants in bidirectional frames. | 174 // We do not allow copies or constants in bidirectional frames. |
| 167 if (direction_ == BIDIRECTIONAL && | 175 if (direction_ == BIDIRECTIONAL && |
| 176 i > high_water_mark && |
| 168 (element.is_constant() || element.is_copy())) { | 177 (element.is_constant() || element.is_copy())) { |
| 169 elements.Add(NULL); | 178 elements.Add(NULL); |
| 170 } else { | 179 } else { |
| 171 elements.Add(&initial_frame->elements_[i]); | 180 elements.Add(&initial_frame->elements_[i]); |
| 172 } | 181 } |
| 173 } | 182 } |
| 174 | 183 |
| 175 // Compute elements based on the other reaching frames. | 184 // Compute elements based on the other reaching frames. |
| 176 if (start_index < reaching_frames_.length()) { | 185 if (start_index < reaching_frames_.length()) { |
| 177 for (int i = 0; i < length; i++) { | 186 for (int i = 0; i < length; i++) { |
| (...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 433 ASSERT_ARGCHECK(arg0); | 442 ASSERT_ARGCHECK(arg0); |
| 434 ASSERT_ARGCHECK(arg1); | 443 ASSERT_ARGCHECK(arg1); |
| 435 ASSERT_ARGCHECK(arg2); | 444 ASSERT_ARGCHECK(arg2); |
| 436 ASSERT_ARGCHECK(arg3); | 445 ASSERT_ARGCHECK(arg3); |
| 437 } | 446 } |
| 438 | 447 |
| 439 #undef DECLARE_ARGCHECK_VARS | 448 #undef DECLARE_ARGCHECK_VARS |
| 440 #undef ASSERT_ARGCHECK | 449 #undef ASSERT_ARGCHECK |
| 441 | 450 |
| 442 | 451 |
| 443 void JumpTarget::Bind(Result* arg) { | 452 void JumpTarget::Bind(Result* arg, int mergable_elements) { |
| 444 ASSERT(cgen_ != NULL); | 453 ASSERT(cgen_ != NULL); |
| 445 | 454 |
| 446 if (cgen_->has_valid_frame()) { | 455 if (cgen_->has_valid_frame()) { |
| 447 cgen_->frame()->Push(arg); | 456 cgen_->frame()->Push(arg); |
| 448 } | 457 } |
| 449 Bind(); | 458 Bind(mergable_elements); |
| 450 *arg = cgen_->frame()->Pop(); | 459 *arg = cgen_->frame()->Pop(); |
| 451 } | 460 } |
| 452 | 461 |
| 453 | 462 |
| 454 void JumpTarget::Bind(Result* arg0, Result* arg1) { | 463 void JumpTarget::Bind(Result* arg0, Result* arg1, int mergable_elements) { |
| 455 ASSERT(cgen_ != NULL); | 464 ASSERT(cgen_ != NULL); |
| 456 | 465 |
| 457 if (cgen_->has_valid_frame()) { | 466 if (cgen_->has_valid_frame()) { |
| 458 cgen_->frame()->Push(arg0); | 467 cgen_->frame()->Push(arg0); |
| 459 cgen_->frame()->Push(arg1); | 468 cgen_->frame()->Push(arg1); |
| 460 } | 469 } |
| 461 Bind(); | 470 Bind(mergable_elements); |
| 462 *arg1 = cgen_->frame()->Pop(); | 471 *arg1 = cgen_->frame()->Pop(); |
| 463 *arg0 = cgen_->frame()->Pop(); | 472 *arg0 = cgen_->frame()->Pop(); |
| 464 } | 473 } |
| 465 | 474 |
| 466 | 475 |
| 467 void JumpTarget::Bind(Result* arg0, Result* arg1, Result* arg2) { | 476 void JumpTarget::Bind(Result* arg0, |
| 477 Result* arg1, |
| 478 Result* arg2, |
| 479 int mergable_elements) { |
| 468 ASSERT(cgen_ != NULL); | 480 ASSERT(cgen_ != NULL); |
| 469 | 481 |
| 470 if (cgen_->has_valid_frame()) { | 482 if (cgen_->has_valid_frame()) { |
| 471 cgen_->frame()->Push(arg0); | 483 cgen_->frame()->Push(arg0); |
| 472 cgen_->frame()->Push(arg1); | 484 cgen_->frame()->Push(arg1); |
| 473 cgen_->frame()->Push(arg2); | 485 cgen_->frame()->Push(arg2); |
| 474 } | 486 } |
| 475 Bind(); | 487 Bind(mergable_elements); |
| 476 *arg2 = cgen_->frame()->Pop(); | 488 *arg2 = cgen_->frame()->Pop(); |
| 477 *arg1 = cgen_->frame()->Pop(); | 489 *arg1 = cgen_->frame()->Pop(); |
| 478 *arg0 = cgen_->frame()->Pop(); | 490 *arg0 = cgen_->frame()->Pop(); |
| 479 } | 491 } |
| 480 | 492 |
| 481 | 493 |
| 482 void JumpTarget::Bind(Result* arg0, Result* arg1, Result* arg2, Result* arg3) { | 494 void JumpTarget::Bind(Result* arg0, |
| 495 Result* arg1, |
| 496 Result* arg2, |
| 497 Result* arg3, |
| 498 int mergable_elements) { |
| 483 ASSERT(cgen_ != NULL); | 499 ASSERT(cgen_ != NULL); |
| 484 | 500 |
| 485 if (cgen_->has_valid_frame()) { | 501 if (cgen_->has_valid_frame()) { |
| 486 cgen_->frame()->Push(arg0); | 502 cgen_->frame()->Push(arg0); |
| 487 cgen_->frame()->Push(arg1); | 503 cgen_->frame()->Push(arg1); |
| 488 cgen_->frame()->Push(arg2); | 504 cgen_->frame()->Push(arg2); |
| 489 cgen_->frame()->Push(arg3); | 505 cgen_->frame()->Push(arg3); |
| 490 } | 506 } |
| 491 Bind(); | 507 Bind(mergable_elements); |
| 492 *arg3 = cgen_->frame()->Pop(); | 508 *arg3 = cgen_->frame()->Pop(); |
| 493 *arg2 = cgen_->frame()->Pop(); | 509 *arg2 = cgen_->frame()->Pop(); |
| 494 *arg1 = cgen_->frame()->Pop(); | 510 *arg1 = cgen_->frame()->Pop(); |
| 495 *arg0 = cgen_->frame()->Pop(); | 511 *arg0 = cgen_->frame()->Pop(); |
| 496 } | 512 } |
| 497 | 513 |
| 498 | 514 |
| 499 void JumpTarget::CopyTo(JumpTarget* destination) { | 515 void JumpTarget::CopyTo(JumpTarget* destination) { |
| 500 ASSERT(destination != NULL); | 516 ASSERT(destination != NULL); |
| 501 destination->cgen_ = cgen_; | 517 destination->cgen_ = cgen_; |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 564 temp.CopyTo(this); | 580 temp.CopyTo(this); |
| 565 temp.Reset(); // So the destructor does not deallocate virtual frames. | 581 temp.Reset(); // So the destructor does not deallocate virtual frames. |
| 566 | 582 |
| 567 #ifdef DEBUG | 583 #ifdef DEBUG |
| 568 is_shadowing_ = false; | 584 is_shadowing_ = false; |
| 569 #endif | 585 #endif |
| 570 } | 586 } |
| 571 | 587 |
| 572 | 588 |
| 573 } } // namespace v8::internal | 589 } } // namespace v8::internal |
| OLD | NEW |