OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 12 matching lines...) Expand all Loading... |
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
27 | 27 |
28 #include "v8.h" | 28 #include "v8.h" |
29 | 29 |
30 #if defined(V8_TARGET_ARCH_IA32) | 30 #if defined(V8_TARGET_ARCH_IA32) |
31 | 31 |
32 #include "code-stubs.h" | 32 #include "code-stubs.h" |
33 #include "codegen-inl.h" | 33 #include "codegen.h" |
34 #include "compiler.h" | 34 #include "compiler.h" |
35 #include "debug.h" | 35 #include "debug.h" |
36 #include "full-codegen.h" | 36 #include "full-codegen.h" |
37 #include "parser.h" | 37 #include "parser.h" |
38 #include "scopes.h" | 38 #include "scopes.h" |
39 #include "stub-cache.h" | 39 #include "stub-cache.h" |
40 | 40 |
41 namespace v8 { | 41 namespace v8 { |
42 namespace internal { | 42 namespace internal { |
43 | 43 |
(...skipping 722 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
766 VisitForStackValue(stmt->tag()); | 766 VisitForStackValue(stmt->tag()); |
767 PrepareForBailoutForId(stmt->EntryId(), NO_REGISTERS); | 767 PrepareForBailoutForId(stmt->EntryId(), NO_REGISTERS); |
768 | 768 |
769 ZoneList<CaseClause*>* clauses = stmt->cases(); | 769 ZoneList<CaseClause*>* clauses = stmt->cases(); |
770 CaseClause* default_clause = NULL; // Can occur anywhere in the list. | 770 CaseClause* default_clause = NULL; // Can occur anywhere in the list. |
771 | 771 |
772 Label next_test; // Recycled for each test. | 772 Label next_test; // Recycled for each test. |
773 // Compile all the tests with branches to their bodies. | 773 // Compile all the tests with branches to their bodies. |
774 for (int i = 0; i < clauses->length(); i++) { | 774 for (int i = 0; i < clauses->length(); i++) { |
775 CaseClause* clause = clauses->at(i); | 775 CaseClause* clause = clauses->at(i); |
776 clause->body_target()->entry_label()->Unuse(); | 776 clause->body_target()->Unuse(); |
777 | 777 |
778 // The default is not a test, but remember it as final fall through. | 778 // The default is not a test, but remember it as final fall through. |
779 if (clause->is_default()) { | 779 if (clause->is_default()) { |
780 default_clause = clause; | 780 default_clause = clause; |
781 continue; | 781 continue; |
782 } | 782 } |
783 | 783 |
784 Comment cmnt(masm_, "[ Case comparison"); | 784 Comment cmnt(masm_, "[ Case comparison"); |
785 __ bind(&next_test); | 785 __ bind(&next_test); |
786 next_test.Unuse(); | 786 next_test.Unuse(); |
787 | 787 |
788 // Compile the label expression. | 788 // Compile the label expression. |
789 VisitForAccumulatorValue(clause->label()); | 789 VisitForAccumulatorValue(clause->label()); |
790 | 790 |
791 // Perform the comparison as if via '==='. | 791 // Perform the comparison as if via '==='. |
792 __ mov(edx, Operand(esp, 0)); // Switch value. | 792 __ mov(edx, Operand(esp, 0)); // Switch value. |
793 bool inline_smi_code = ShouldInlineSmiCase(Token::EQ_STRICT); | 793 bool inline_smi_code = ShouldInlineSmiCase(Token::EQ_STRICT); |
794 JumpPatchSite patch_site(masm_); | 794 JumpPatchSite patch_site(masm_); |
795 if (inline_smi_code) { | 795 if (inline_smi_code) { |
796 NearLabel slow_case; | 796 NearLabel slow_case; |
797 __ mov(ecx, edx); | 797 __ mov(ecx, edx); |
798 __ or_(ecx, Operand(eax)); | 798 __ or_(ecx, Operand(eax)); |
799 patch_site.EmitJumpIfNotSmi(ecx, &slow_case); | 799 patch_site.EmitJumpIfNotSmi(ecx, &slow_case); |
800 | 800 |
801 __ cmp(edx, Operand(eax)); | 801 __ cmp(edx, Operand(eax)); |
802 __ j(not_equal, &next_test); | 802 __ j(not_equal, &next_test); |
803 __ Drop(1); // Switch value is no longer needed. | 803 __ Drop(1); // Switch value is no longer needed. |
804 __ jmp(clause->body_target()->entry_label()); | 804 __ jmp(clause->body_target()); |
805 __ bind(&slow_case); | 805 __ bind(&slow_case); |
806 } | 806 } |
807 | 807 |
808 // Record position before stub call for type feedback. | 808 // Record position before stub call for type feedback. |
809 SetSourcePosition(clause->position()); | 809 SetSourcePosition(clause->position()); |
810 Handle<Code> ic = CompareIC::GetUninitialized(Token::EQ_STRICT); | 810 Handle<Code> ic = CompareIC::GetUninitialized(Token::EQ_STRICT); |
811 EmitCallIC(ic, &patch_site); | 811 EmitCallIC(ic, &patch_site); |
812 __ test(eax, Operand(eax)); | 812 __ test(eax, Operand(eax)); |
813 __ j(not_equal, &next_test); | 813 __ j(not_equal, &next_test); |
814 __ Drop(1); // Switch value is no longer needed. | 814 __ Drop(1); // Switch value is no longer needed. |
815 __ jmp(clause->body_target()->entry_label()); | 815 __ jmp(clause->body_target()); |
816 } | 816 } |
817 | 817 |
818 // Discard the test value and jump to the default if present, otherwise to | 818 // Discard the test value and jump to the default if present, otherwise to |
819 // the end of the statement. | 819 // the end of the statement. |
820 __ bind(&next_test); | 820 __ bind(&next_test); |
821 __ Drop(1); // Switch value is no longer needed. | 821 __ Drop(1); // Switch value is no longer needed. |
822 if (default_clause == NULL) { | 822 if (default_clause == NULL) { |
823 __ jmp(nested_statement.break_target()); | 823 __ jmp(nested_statement.break_target()); |
824 } else { | 824 } else { |
825 __ jmp(default_clause->body_target()->entry_label()); | 825 __ jmp(default_clause->body_target()); |
826 } | 826 } |
827 | 827 |
828 // Compile all the case bodies. | 828 // Compile all the case bodies. |
829 for (int i = 0; i < clauses->length(); i++) { | 829 for (int i = 0; i < clauses->length(); i++) { |
830 Comment cmnt(masm_, "[ Case body"); | 830 Comment cmnt(masm_, "[ Case body"); |
831 CaseClause* clause = clauses->at(i); | 831 CaseClause* clause = clauses->at(i); |
832 __ bind(clause->body_target()->entry_label()); | 832 __ bind(clause->body_target()); |
833 PrepareForBailoutForId(clause->EntryId(), NO_REGISTERS); | 833 PrepareForBailoutForId(clause->EntryId(), NO_REGISTERS); |
834 VisitStatements(clause->statements()); | 834 VisitStatements(clause->statements()); |
835 } | 835 } |
836 | 836 |
837 __ bind(nested_statement.break_target()); | 837 __ bind(nested_statement.break_target()); |
838 PrepareForBailoutForId(stmt->ExitId(), NO_REGISTERS); | 838 PrepareForBailoutForId(stmt->ExitId(), NO_REGISTERS); |
839 } | 839 } |
840 | 840 |
841 | 841 |
842 void FullCodeGenerator::VisitForInStatement(ForInStatement* stmt) { | 842 void FullCodeGenerator::VisitForInStatement(ForInStatement* stmt) { |
(...skipping 3505 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4348 // And return. | 4348 // And return. |
4349 __ ret(0); | 4349 __ ret(0); |
4350 } | 4350 } |
4351 | 4351 |
4352 | 4352 |
4353 #undef __ | 4353 #undef __ |
4354 | 4354 |
4355 } } // namespace v8::internal | 4355 } } // namespace v8::internal |
4356 | 4356 |
4357 #endif // V8_TARGET_ARCH_IA32 | 4357 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |