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_X64) | 30 #if defined(V8_TARGET_ARCH_X64) |
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 730 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
774 VisitForStackValue(stmt->tag()); | 774 VisitForStackValue(stmt->tag()); |
775 PrepareForBailoutForId(stmt->EntryId(), NO_REGISTERS); | 775 PrepareForBailoutForId(stmt->EntryId(), NO_REGISTERS); |
776 | 776 |
777 ZoneList<CaseClause*>* clauses = stmt->cases(); | 777 ZoneList<CaseClause*>* clauses = stmt->cases(); |
778 CaseClause* default_clause = NULL; // Can occur anywhere in the list. | 778 CaseClause* default_clause = NULL; // Can occur anywhere in the list. |
779 | 779 |
780 Label next_test; // Recycled for each test. | 780 Label next_test; // Recycled for each test. |
781 // Compile all the tests with branches to their bodies. | 781 // Compile all the tests with branches to their bodies. |
782 for (int i = 0; i < clauses->length(); i++) { | 782 for (int i = 0; i < clauses->length(); i++) { |
783 CaseClause* clause = clauses->at(i); | 783 CaseClause* clause = clauses->at(i); |
784 clause->body_target()->entry_label()->Unuse(); | 784 clause->body_target()->Unuse(); |
785 | 785 |
786 // The default is not a test, but remember it as final fall through. | 786 // The default is not a test, but remember it as final fall through. |
787 if (clause->is_default()) { | 787 if (clause->is_default()) { |
788 default_clause = clause; | 788 default_clause = clause; |
789 continue; | 789 continue; |
790 } | 790 } |
791 | 791 |
792 Comment cmnt(masm_, "[ Case comparison"); | 792 Comment cmnt(masm_, "[ Case comparison"); |
793 __ bind(&next_test); | 793 __ bind(&next_test); |
794 next_test.Unuse(); | 794 next_test.Unuse(); |
795 | 795 |
796 // Compile the label expression. | 796 // Compile the label expression. |
797 VisitForAccumulatorValue(clause->label()); | 797 VisitForAccumulatorValue(clause->label()); |
798 | 798 |
799 // Perform the comparison as if via '==='. | 799 // Perform the comparison as if via '==='. |
800 __ movq(rdx, Operand(rsp, 0)); // Switch value. | 800 __ movq(rdx, Operand(rsp, 0)); // Switch value. |
801 bool inline_smi_code = ShouldInlineSmiCase(Token::EQ_STRICT); | 801 bool inline_smi_code = ShouldInlineSmiCase(Token::EQ_STRICT); |
802 JumpPatchSite patch_site(masm_); | 802 JumpPatchSite patch_site(masm_); |
803 if (inline_smi_code) { | 803 if (inline_smi_code) { |
804 NearLabel slow_case; | 804 NearLabel slow_case; |
805 __ movq(rcx, rdx); | 805 __ movq(rcx, rdx); |
806 __ or_(rcx, rax); | 806 __ or_(rcx, rax); |
807 patch_site.EmitJumpIfNotSmi(rcx, &slow_case); | 807 patch_site.EmitJumpIfNotSmi(rcx, &slow_case); |
808 | 808 |
809 __ cmpq(rdx, rax); | 809 __ cmpq(rdx, rax); |
810 __ j(not_equal, &next_test); | 810 __ j(not_equal, &next_test); |
811 __ Drop(1); // Switch value is no longer needed. | 811 __ Drop(1); // Switch value is no longer needed. |
812 __ jmp(clause->body_target()->entry_label()); | 812 __ jmp(clause->body_target()); |
813 __ bind(&slow_case); | 813 __ bind(&slow_case); |
814 } | 814 } |
815 | 815 |
816 // Record position before stub call for type feedback. | 816 // Record position before stub call for type feedback. |
817 SetSourcePosition(clause->position()); | 817 SetSourcePosition(clause->position()); |
818 Handle<Code> ic = CompareIC::GetUninitialized(Token::EQ_STRICT); | 818 Handle<Code> ic = CompareIC::GetUninitialized(Token::EQ_STRICT); |
819 EmitCallIC(ic, &patch_site); | 819 EmitCallIC(ic, &patch_site); |
820 | 820 |
821 __ testq(rax, rax); | 821 __ testq(rax, rax); |
822 __ j(not_equal, &next_test); | 822 __ j(not_equal, &next_test); |
823 __ Drop(1); // Switch value is no longer needed. | 823 __ Drop(1); // Switch value is no longer needed. |
824 __ jmp(clause->body_target()->entry_label()); | 824 __ jmp(clause->body_target()); |
825 } | 825 } |
826 | 826 |
827 // Discard the test value and jump to the default if present, otherwise to | 827 // Discard the test value and jump to the default if present, otherwise to |
828 // the end of the statement. | 828 // the end of the statement. |
829 __ bind(&next_test); | 829 __ bind(&next_test); |
830 __ Drop(1); // Switch value is no longer needed. | 830 __ Drop(1); // Switch value is no longer needed. |
831 if (default_clause == NULL) { | 831 if (default_clause == NULL) { |
832 __ jmp(nested_statement.break_target()); | 832 __ jmp(nested_statement.break_target()); |
833 } else { | 833 } else { |
834 __ jmp(default_clause->body_target()->entry_label()); | 834 __ jmp(default_clause->body_target()); |
835 } | 835 } |
836 | 836 |
837 // Compile all the case bodies. | 837 // Compile all the case bodies. |
838 for (int i = 0; i < clauses->length(); i++) { | 838 for (int i = 0; i < clauses->length(); i++) { |
839 Comment cmnt(masm_, "[ Case body"); | 839 Comment cmnt(masm_, "[ Case body"); |
840 CaseClause* clause = clauses->at(i); | 840 CaseClause* clause = clauses->at(i); |
841 __ bind(clause->body_target()->entry_label()); | 841 __ bind(clause->body_target()); |
842 PrepareForBailoutForId(clause->EntryId(), NO_REGISTERS); | 842 PrepareForBailoutForId(clause->EntryId(), NO_REGISTERS); |
843 VisitStatements(clause->statements()); | 843 VisitStatements(clause->statements()); |
844 } | 844 } |
845 | 845 |
846 __ bind(nested_statement.break_target()); | 846 __ bind(nested_statement.break_target()); |
847 PrepareForBailoutForId(stmt->ExitId(), NO_REGISTERS); | 847 PrepareForBailoutForId(stmt->ExitId(), NO_REGISTERS); |
848 } | 848 } |
849 | 849 |
850 | 850 |
851 void FullCodeGenerator::VisitForInStatement(ForInStatement* stmt) { | 851 void FullCodeGenerator::VisitForInStatement(ForInStatement* stmt) { |
(...skipping 3478 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4330 __ ret(0); | 4330 __ ret(0); |
4331 } | 4331 } |
4332 | 4332 |
4333 | 4333 |
4334 #undef __ | 4334 #undef __ |
4335 | 4335 |
4336 | 4336 |
4337 } } // namespace v8::internal | 4337 } } // namespace v8::internal |
4338 | 4338 |
4339 #endif // V8_TARGET_ARCH_X64 | 4339 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |