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 19 matching lines...) Expand all Loading... |
30 #include "codegen.h" | 30 #include "codegen.h" |
31 #include "jump-target.h" | 31 #include "jump-target.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 JumpTarget::JumpTarget(CodeGenerator* cgen, Directionality direction) | 38 JumpTarget::JumpTarget(CodeGenerator* cgen, Directionality direction) |
39 : cgen_(cgen), | 39 : cgen_(cgen), |
| 40 masm_(cgen == NULL ? NULL : cgen->masm()), |
40 direction_(direction), | 41 direction_(direction), |
41 reaching_frames_(0), | 42 reaching_frames_(0), |
42 merge_labels_(0), | 43 merge_labels_(0), |
43 entry_frame_(NULL), | 44 entry_frame_(NULL), |
44 is_bound_(false), | 45 is_bound_(false), |
45 is_linked_(false) { | 46 is_linked_(false) { |
46 ASSERT(cgen_ != NULL); | |
47 masm_ = cgen_->masm(); | |
48 } | |
49 | |
50 | |
51 JumpTarget::JumpTarget() | |
52 : cgen_(NULL), | |
53 masm_(NULL), | |
54 direction_(FORWARD_ONLY), | |
55 reaching_frames_(0), | |
56 merge_labels_(0), | |
57 entry_frame_(NULL), | |
58 is_bound_(false), | |
59 is_linked_(false) { | |
60 } | 47 } |
61 | 48 |
62 | 49 |
63 void JumpTarget::Initialize(CodeGenerator* cgen, Directionality direction) { | |
64 ASSERT(cgen != NULL); | |
65 ASSERT(cgen_ == NULL); | |
66 cgen_ = cgen; | |
67 masm_ = cgen->masm(); | |
68 direction_ = direction; | |
69 } | |
70 | |
71 | |
72 void JumpTarget::Unuse() { | 50 void JumpTarget::Unuse() { |
73 ASSERT(!is_linked()); | 51 ASSERT(!is_linked()); |
74 entry_label_.Unuse(); | 52 entry_label_.Unuse(); |
75 delete entry_frame_; | 53 delete entry_frame_; |
76 entry_frame_ = NULL; | 54 entry_frame_ = NULL; |
77 is_bound_ = false; | 55 is_bound_ = false; |
78 is_linked_ = false; | 56 is_linked_ = false; |
79 } | 57 } |
80 | 58 |
81 | 59 |
(...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
505 cgen_->frame()->Push(arg3); | 483 cgen_->frame()->Push(arg3); |
506 } | 484 } |
507 Bind(mergable_elements); | 485 Bind(mergable_elements); |
508 *arg3 = cgen_->frame()->Pop(); | 486 *arg3 = cgen_->frame()->Pop(); |
509 *arg2 = cgen_->frame()->Pop(); | 487 *arg2 = cgen_->frame()->Pop(); |
510 *arg1 = cgen_->frame()->Pop(); | 488 *arg1 = cgen_->frame()->Pop(); |
511 *arg0 = cgen_->frame()->Pop(); | 489 *arg0 = cgen_->frame()->Pop(); |
512 } | 490 } |
513 | 491 |
514 | 492 |
515 void JumpTarget::CopyTo(JumpTarget* destination) { | 493 void JumpTarget::AddReachingFrame(VirtualFrame* frame) { |
| 494 ASSERT(reaching_frames_.length() == merge_labels_.length()); |
| 495 Label fresh; |
| 496 merge_labels_.Add(fresh); |
| 497 reaching_frames_.Add(frame); |
| 498 } |
| 499 |
| 500 |
| 501 // ------------------------------------------------------------------------- |
| 502 // BreakTarget implementation. |
| 503 |
| 504 BreakTarget::BreakTarget() : JumpTarget(NULL, FORWARD_ONLY) { |
| 505 } |
| 506 |
| 507 |
| 508 void BreakTarget::Initialize(CodeGenerator* cgen, Directionality direction) { |
| 509 ASSERT(cgen != NULL); |
| 510 ASSERT(cgen_ == NULL); |
| 511 cgen_ = cgen; |
| 512 masm_ = cgen->masm(); |
| 513 direction_ = direction; |
| 514 } |
| 515 |
| 516 |
| 517 void BreakTarget::CopyTo(BreakTarget* destination) { |
516 ASSERT(destination != NULL); | 518 ASSERT(destination != NULL); |
517 destination->cgen_ = cgen_; | 519 destination->cgen_ = cgen_; |
518 destination->masm_ = masm_; | 520 destination->masm_ = masm_; |
519 destination->direction_ = direction_; | 521 destination->direction_ = direction_; |
520 destination->reaching_frames_.Clear(); | 522 destination->reaching_frames_.Clear(); |
521 destination->merge_labels_.Clear(); | 523 destination->merge_labels_.Clear(); |
522 ASSERT(reaching_frames_.length() == merge_labels_.length()); | 524 ASSERT(reaching_frames_.length() == merge_labels_.length()); |
523 for (int i = 0; i < reaching_frames_.length(); i++) { | 525 for (int i = 0; i < reaching_frames_.length(); i++) { |
524 destination->reaching_frames_.Add(reaching_frames_[i]); | 526 destination->reaching_frames_.Add(reaching_frames_[i]); |
525 destination->merge_labels_.Add(merge_labels_[i]); | 527 destination->merge_labels_.Add(merge_labels_[i]); |
526 } | 528 } |
527 destination->entry_frame_ = entry_frame_; | 529 destination->entry_frame_ = entry_frame_; |
528 destination->entry_label_ = entry_label_; | 530 destination->entry_label_ = entry_label_; |
529 destination->is_bound_ = is_bound_; | 531 destination->is_bound_ = is_bound_; |
530 destination->is_linked_ = is_linked_; | 532 destination->is_linked_ = is_linked_; |
531 } | 533 } |
532 | 534 |
533 | 535 |
534 void JumpTarget::AddReachingFrame(VirtualFrame* frame) { | |
535 ASSERT(reaching_frames_.length() == merge_labels_.length()); | |
536 Label fresh; | |
537 merge_labels_.Add(fresh); | |
538 reaching_frames_.Add(frame); | |
539 } | |
540 | |
541 | |
542 // ------------------------------------------------------------------------- | 536 // ------------------------------------------------------------------------- |
543 // ShadowTarget implementation. | 537 // ShadowTarget implementation. |
544 | 538 |
545 ShadowTarget::ShadowTarget(JumpTarget* shadowed) { | 539 ShadowTarget::ShadowTarget(BreakTarget* shadowed) { |
546 ASSERT(shadowed != NULL); | 540 ASSERT(shadowed != NULL); |
547 other_target_ = shadowed; | 541 other_target_ = shadowed; |
548 | 542 |
549 #ifdef DEBUG | 543 #ifdef DEBUG |
550 is_shadowing_ = true; | 544 is_shadowing_ = true; |
551 #endif | 545 #endif |
552 // While shadowing this shadow target saves the state of the original. | 546 // While shadowing this shadow target saves the state of the original. |
553 shadowed->CopyTo(this); | 547 shadowed->CopyTo(this); |
554 | 548 |
555 // Setting the code generator to null prevents the shadow target from | 549 // Setting the code generator to null prevents the shadow target from |
(...skipping 11 matching lines...) Expand all Loading... |
567 void ShadowTarget::StopShadowing() { | 561 void ShadowTarget::StopShadowing() { |
568 ASSERT(is_shadowing_); | 562 ASSERT(is_shadowing_); |
569 | 563 |
570 // This target does not have a valid code generator yet. | 564 // This target does not have a valid code generator yet. |
571 cgen_ = other_target_->code_generator(); | 565 cgen_ = other_target_->code_generator(); |
572 ASSERT(cgen_ != NULL); | 566 ASSERT(cgen_ != NULL); |
573 masm_ = cgen_->masm(); | 567 masm_ = cgen_->masm(); |
574 | 568 |
575 // The states of this target, which was shadowed, and the original | 569 // The states of this target, which was shadowed, and the original |
576 // target, which was shadowing, are swapped. | 570 // target, which was shadowing, are swapped. |
577 JumpTarget temp; | 571 BreakTarget temp; |
578 other_target_->CopyTo(&temp); | 572 other_target_->CopyTo(&temp); |
579 CopyTo(other_target_); | 573 CopyTo(other_target_); |
580 temp.CopyTo(this); | 574 temp.CopyTo(this); |
581 temp.Reset(); // So the destructor does not deallocate virtual frames. | 575 temp.Reset(); // So the destructor does not deallocate virtual frames. |
582 | 576 |
583 #ifdef DEBUG | 577 #ifdef DEBUG |
584 is_shadowing_ = false; | 578 is_shadowing_ = false; |
585 #endif | 579 #endif |
586 } | 580 } |
587 | 581 |
588 | 582 |
589 } } // namespace v8::internal | 583 } } // namespace v8::internal |
OLD | NEW |