Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(35)

Side by Side Diff: src/ia32/codegen-ia32.cc

Issue 1138003: Fix code generation for fast smi loops to support parameters as well.... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 10 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/ia32/codegen-ia32.h ('k') | src/ia32/virtual-frame-ia32.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 3634 matching lines...) Expand 10 before | Expand all | Expand 10 after
3645 3645
3646 // The break target may be already bound (by the condition), or there 3646 // The break target may be already bound (by the condition), or there
3647 // may not be a valid frame. Bind it only if needed. 3647 // may not be a valid frame. Bind it only if needed.
3648 if (node->break_target()->is_linked()) { 3648 if (node->break_target()->is_linked()) {
3649 node->break_target()->Bind(); 3649 node->break_target()->Bind();
3650 } 3650 }
3651 DecrementLoopNesting(); 3651 DecrementLoopNesting();
3652 } 3652 }
3653 3653
3654 3654
3655 void CodeGenerator::SetTypeForStackSlot(Slot* slot, NumberInfo info) {
3656 ASSERT(slot->type() == Slot::LOCAL || slot->type() == Slot::PARAMETER);
3657 if (slot->type() == Slot::LOCAL) {
3658 frame_->SetTypeForLocalAt(slot->index(), info);
3659 } else {
3660 frame_->SetTypeForParamAt(slot->index(), info);
3661 }
3662 if (FLAG_debug_code && info.IsSmi()) {
3663 if (slot->type() == Slot::LOCAL) {
3664 frame_->PushLocalAt(slot->index());
3665 } else {
3666 frame_->PushParameterAt(slot->index());
3667 }
3668 Result var = frame_->Pop();
3669 var.ToRegister();
3670 __ AbortIfNotSmi(var.reg());
3671 }
3672 }
3673
3674
3655 void CodeGenerator::VisitForStatement(ForStatement* node) { 3675 void CodeGenerator::VisitForStatement(ForStatement* node) {
3656 ASSERT(!in_spilled_code()); 3676 ASSERT(!in_spilled_code());
3657 Comment cmnt(masm_, "[ ForStatement"); 3677 Comment cmnt(masm_, "[ ForStatement");
3658 CodeForStatementPosition(node); 3678 CodeForStatementPosition(node);
3659 3679
3660 // Compile the init expression if present. 3680 // Compile the init expression if present.
3661 if (node->init() != NULL) { 3681 if (node->init() != NULL) {
3662 Visit(node->init()); 3682 Visit(node->init());
3663 } 3683 }
3664 3684
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
3745 3765
3746 CheckStack(); // TODO(1222600): ignore if body contains calls. 3766 CheckStack(); // TODO(1222600): ignore if body contains calls.
3747 3767
3748 // We know that the loop index is a smi if it is not modified in the 3768 // We know that the loop index is a smi if it is not modified in the
3749 // loop body and it is checked against a constant limit in the loop 3769 // loop body and it is checked against a constant limit in the loop
3750 // condition. In this case, we reset the static type information of the 3770 // condition. In this case, we reset the static type information of the
3751 // loop index to smi before compiling the body, the update expression, and 3771 // loop index to smi before compiling the body, the update expression, and
3752 // the bottom check of the loop condition. 3772 // the bottom check of the loop condition.
3753 if (node->is_fast_smi_loop()) { 3773 if (node->is_fast_smi_loop()) {
3754 // Set number type of the loop variable to smi. 3774 // Set number type of the loop variable to smi.
3755 Slot* slot = node->loop_variable()->slot(); 3775 SetTypeForStackSlot(node->loop_variable()->slot(), NumberInfo::Smi());
3756 ASSERT(slot->type() == Slot::LOCAL);
3757 frame_->SetTypeForLocalAt(slot->index(), NumberInfo::Smi());
3758 if (FLAG_debug_code) {
3759 frame_->PushLocalAt(slot->index());
3760 Result var = frame_->Pop();
3761 var.ToRegister();
3762 __ AbortIfNotSmi(var.reg());
3763 }
3764 } 3776 }
3765 3777
3766 Visit(node->body()); 3778 Visit(node->body());
3767 3779
3768 // If there is an update expression, compile it if necessary. 3780 // If there is an update expression, compile it if necessary.
3769 if (node->next() != NULL) { 3781 if (node->next() != NULL) {
3770 if (node->continue_target()->is_linked()) { 3782 if (node->continue_target()->is_linked()) {
3771 node->continue_target()->Bind(); 3783 node->continue_target()->Bind();
3772 } 3784 }
3773 3785
3774 // Control can reach the update by falling out of the body or by a 3786 // Control can reach the update by falling out of the body or by a
3775 // continue. 3787 // continue.
3776 if (has_valid_frame()) { 3788 if (has_valid_frame()) {
3777 // Record the source position of the statement as this code which 3789 // Record the source position of the statement as this code which
3778 // is after the code for the body actually belongs to the loop 3790 // is after the code for the body actually belongs to the loop
3779 // statement and not the body. 3791 // statement and not the body.
3780 CodeForStatementPosition(node); 3792 CodeForStatementPosition(node);
3781 Visit(node->next()); 3793 Visit(node->next());
3782 } 3794 }
3783 } 3795 }
3784 3796
3785 // Set the type of the loop variable to smi before compiling the test 3797 // Set the type of the loop variable to smi before compiling the test
3786 // expression if we are in a fast smi loop condition. 3798 // expression if we are in a fast smi loop condition.
3787 if (node->is_fast_smi_loop() && has_valid_frame()) { 3799 if (node->is_fast_smi_loop() && has_valid_frame()) {
3788 // Set number type of the loop variable to smi. 3800 // Set number type of the loop variable to smi.
3789 Slot* slot = node->loop_variable()->slot(); 3801 SetTypeForStackSlot(node->loop_variable()->slot(), NumberInfo::Smi());
3790 ASSERT(slot->type() == Slot::LOCAL);
3791 frame_->SetTypeForLocalAt(slot->index(), NumberInfo::Smi());
3792 if (FLAG_debug_code) {
3793 frame_->PushLocalAt(slot->index());
3794 Result var = frame_->Pop();
3795 var.ToRegister();
3796 __ AbortIfNotSmi(var.reg());
3797 }
3798 } 3802 }
3799 3803
3800 // Based on the condition analysis, compile the backward jump as 3804 // Based on the condition analysis, compile the backward jump as
3801 // necessary. 3805 // necessary.
3802 switch (info) { 3806 switch (info) {
3803 case ALWAYS_TRUE: 3807 case ALWAYS_TRUE:
3804 if (has_valid_frame()) { 3808 if (has_valid_frame()) {
3805 if (node->next() == NULL) { 3809 if (node->next() == NULL) {
3806 node->continue_target()->Jump(); 3810 node->continue_target()->Jump();
3807 } else { 3811 } else {
(...skipping 8462 matching lines...) Expand 10 before | Expand all | Expand 10 after
12270 12274
12271 // Call the runtime; it returns -1 (less), 0 (equal), or 1 (greater) 12275 // Call the runtime; it returns -1 (less), 0 (equal), or 1 (greater)
12272 // tagged as a small integer. 12276 // tagged as a small integer.
12273 __ bind(&runtime); 12277 __ bind(&runtime);
12274 __ TailCallRuntime(Runtime::kStringCompare, 2, 1); 12278 __ TailCallRuntime(Runtime::kStringCompare, 2, 1);
12275 } 12279 }
12276 12280
12277 #undef __ 12281 #undef __
12278 12282
12279 } } // namespace v8::internal 12283 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/ia32/codegen-ia32.h ('k') | src/ia32/virtual-frame-ia32.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698