Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 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 3710 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3721 break; | 3721 break; |
| 3722 } | 3722 } |
| 3723 case ALWAYS_FALSE: | 3723 case ALWAYS_FALSE: |
| 3724 UNREACHABLE(); | 3724 UNREACHABLE(); |
| 3725 break; | 3725 break; |
| 3726 } | 3726 } |
| 3727 | 3727 |
| 3728 CheckStack(); // TODO(1222600): ignore if body contains calls. | 3728 CheckStack(); // TODO(1222600): ignore if body contains calls. |
| 3729 | 3729 |
| 3730 // If we have (a) a loop with a compile-time constant trip count | 3730 // If we have (a) a loop with a compile-time constant trip count |
| 3731 // and (b) the loop induction variable is not assignend inside the | 3731 // and (b) the loop induction variable is not assignend inside the |
|
William Hesse
2010/03/18 08:52:50
The added sentence is not capitalized, and has no
fschneider
2010/03/18 09:08:20
Done.
| |
| 3732 // loop we update the number type of the induction variable to be smi. | 3732 // loop we update the number type of the induction variable to be smi. |
| 3733 | 3733 // before generating the body, the update expression and the test at |
| 3734 // the bottom. | |
| 3734 if (node->is_fast_smi_loop()) { | 3735 if (node->is_fast_smi_loop()) { |
| 3735 // Set number type of the loop variable to smi. | 3736 // Set number type of the loop variable to smi. |
| 3736 Slot* slot = node->loop_variable()->slot(); | 3737 Slot* slot = node->loop_variable()->slot(); |
| 3737 ASSERT(slot->type() == Slot::LOCAL); | 3738 ASSERT(slot->type() == Slot::LOCAL); |
| 3738 frame_->SetTypeForLocalAt(slot->index(), NumberInfo::Smi()); | 3739 frame_->SetTypeForLocalAt(slot->index(), NumberInfo::Smi()); |
| 3739 if (FLAG_debug_code) { | 3740 if (FLAG_debug_code) { |
| 3740 frame_->PushLocalAt(slot->index()); | 3741 frame_->PushLocalAt(slot->index()); |
| 3741 Result var = frame_->Pop(); | 3742 Result var = frame_->Pop(); |
| 3742 var.ToRegister(); | 3743 var.ToRegister(); |
| 3743 __ AbortIfNotSmi(var.reg(), "Loop variable not a smi."); | 3744 __ AbortIfNotSmi(var.reg(), "Loop variable not a smi."); |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 3756 // continue. | 3757 // continue. |
| 3757 if (has_valid_frame()) { | 3758 if (has_valid_frame()) { |
| 3758 // Record the source position of the statement as this code which | 3759 // Record the source position of the statement as this code which |
| 3759 // is after the code for the body actually belongs to the loop | 3760 // is after the code for the body actually belongs to the loop |
| 3760 // statement and not the body. | 3761 // statement and not the body. |
| 3761 CodeForStatementPosition(node); | 3762 CodeForStatementPosition(node); |
| 3762 Visit(node->next()); | 3763 Visit(node->next()); |
| 3763 } | 3764 } |
| 3764 } | 3765 } |
| 3765 | 3766 |
| 3766 // The update expression resets the type of the loop variable. So we | 3767 // Set the type of the loop variable to smi before compiling the test |
| 3767 // set it to smi before compiling the test expression. | 3768 // expression if we are in a fast smi loop. |
|
William Hesse
2010/03/18 08:52:50
loop condition?
fschneider
2010/03/18 09:08:20
Done.
| |
| 3768 if (node->is_fast_smi_loop()) { | 3769 if (node->is_fast_smi_loop()) { |
| 3769 // Set number type of the loop variable to smi. | 3770 // Set number type of the loop variable to smi. |
| 3770 Slot* slot = node->loop_variable()->slot(); | 3771 Slot* slot = node->loop_variable()->slot(); |
| 3771 ASSERT(slot->type() == Slot::LOCAL); | 3772 ASSERT(slot->type() == Slot::LOCAL); |
| 3772 frame_->SetTypeForLocalAt(slot->index(), NumberInfo::Smi()); | 3773 frame_->SetTypeForLocalAt(slot->index(), NumberInfo::Smi()); |
| 3773 if (FLAG_debug_code) { | 3774 if (FLAG_debug_code) { |
| 3774 frame_->PushLocalAt(slot->index()); | 3775 frame_->PushLocalAt(slot->index()); |
| 3775 Result var = frame_->Pop(); | 3776 Result var = frame_->Pop(); |
| 3776 var.ToRegister(); | 3777 var.ToRegister(); |
| 3777 __ AbortIfNotSmi(var.reg(), "Loop variable not a smi."); | 3778 __ AbortIfNotSmi(var.reg(), "Loop variable not a smi."); |
| (...skipping 8464 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 12242 | 12243 |
| 12243 // Call the runtime; it returns -1 (less), 0 (equal), or 1 (greater) | 12244 // Call the runtime; it returns -1 (less), 0 (equal), or 1 (greater) |
| 12244 // tagged as a small integer. | 12245 // tagged as a small integer. |
| 12245 __ bind(&runtime); | 12246 __ bind(&runtime); |
| 12246 __ TailCallRuntime(Runtime::kStringCompare, 2, 1); | 12247 __ TailCallRuntime(Runtime::kStringCompare, 2, 1); |
| 12247 } | 12248 } |
| 12248 | 12249 |
| 12249 #undef __ | 12250 #undef __ |
| 12250 | 12251 |
| 12251 } } // namespace v8::internal | 12252 } } // namespace v8::internal |
| OLD | NEW |