OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/code-stubs.h" | 5 #include "src/code-stubs.h" |
6 | 6 |
7 #include <sstream> | 7 #include <sstream> |
8 | 8 |
9 #include "src/bootstrapper.h" | 9 #include "src/bootstrapper.h" |
10 #include "src/code-factory.h" | 10 #include "src/code-factory.h" |
(...skipping 537 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
548 | 548 |
549 assembler->Bind(&if_lhsissmi); | 549 assembler->Bind(&if_lhsissmi); |
550 { | 550 { |
551 // Check if the {rhs} is also a Smi. | 551 // Check if the {rhs} is also a Smi. |
552 Label if_rhsissmi(assembler), if_rhsisnotsmi(assembler); | 552 Label if_rhsissmi(assembler), if_rhsisnotsmi(assembler); |
553 assembler->Branch(assembler->WordIsSmi(rhs), &if_rhsissmi, | 553 assembler->Branch(assembler->WordIsSmi(rhs), &if_rhsissmi, |
554 &if_rhsisnotsmi); | 554 &if_rhsisnotsmi); |
555 | 555 |
556 assembler->Bind(&if_rhsissmi); | 556 assembler->Bind(&if_rhsissmi); |
557 { | 557 { |
558 // TODO(bmeurer): Properly fuse Int64AddWithOverflow on x64 | 558 // Try fast Smi addition first. |
559 Node* pair = assembler->SmiAddWithOverflow(lhs, rhs); | 559 Node* pair = assembler->SmiAddWithOverflow(lhs, rhs); |
560 Node* result = assembler->Projection(0, pair); | |
561 Node* overflow = assembler->Projection(1, pair); | 560 Node* overflow = assembler->Projection(1, pair); |
562 | 561 |
| 562 // Check if the Smi additon overflowed. |
563 Label if_overflow(assembler), if_notoverflow(assembler); | 563 Label if_overflow(assembler), if_notoverflow(assembler); |
564 assembler->Branch(overflow, &if_overflow, &if_notoverflow); | 564 assembler->Branch(overflow, &if_overflow, &if_notoverflow); |
565 | 565 |
566 assembler->Bind(&if_overflow); | 566 assembler->Bind(&if_overflow); |
567 { | 567 { |
568 var_fadd_lhs.Bind(assembler->SmiToFloat64(lhs)); | 568 var_fadd_lhs.Bind(assembler->SmiToFloat64(lhs)); |
569 var_fadd_rhs.Bind(assembler->SmiToFloat64(rhs)); | 569 var_fadd_rhs.Bind(assembler->SmiToFloat64(rhs)); |
570 assembler->Goto(&do_fadd); | 570 assembler->Goto(&do_fadd); |
571 } | 571 } |
572 | 572 |
573 assembler->Bind(&if_notoverflow); | 573 assembler->Bind(&if_notoverflow); |
574 assembler->Return(result); | 574 assembler->Return(assembler->Projection(0, pair)); |
575 } | 575 } |
576 | 576 |
577 assembler->Bind(&if_rhsisnotsmi); | 577 assembler->Bind(&if_rhsisnotsmi); |
578 { | 578 { |
579 // Load the map of {rhs}. | 579 // Load the map of {rhs}. |
580 Node* rhs_map = assembler->LoadObjectField(rhs, HeapObject::kMapOffset); | 580 Node* rhs_map = assembler->LoadObjectField(rhs, HeapObject::kMapOffset); |
581 | 581 |
582 // Check if the {rhs} is a HeapNumber. | 582 // Check if the {rhs} is a HeapNumber. |
583 Label if_rhsisnumber(assembler), | 583 Label if_rhsisnumber(assembler), |
584 if_rhsisnotnumber(assembler, Label::kDeferred); | 584 if_rhsisnotnumber(assembler, Label::kDeferred); |
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
912 { | 912 { |
913 // Check if the {rhs} is also a Smi. | 913 // Check if the {rhs} is also a Smi. |
914 Label if_rhsissmi(assembler), if_rhsisnotsmi(assembler); | 914 Label if_rhsissmi(assembler), if_rhsisnotsmi(assembler); |
915 assembler->Branch(assembler->WordIsSmi(rhs), &if_rhsissmi, | 915 assembler->Branch(assembler->WordIsSmi(rhs), &if_rhsissmi, |
916 &if_rhsisnotsmi); | 916 &if_rhsisnotsmi); |
917 | 917 |
918 assembler->Bind(&if_rhsissmi); | 918 assembler->Bind(&if_rhsissmi); |
919 { | 919 { |
920 // Try a fast Smi subtraction first. | 920 // Try a fast Smi subtraction first. |
921 Node* pair = assembler->SmiSubWithOverflow(lhs, rhs); | 921 Node* pair = assembler->SmiSubWithOverflow(lhs, rhs); |
922 Node* result = assembler->Projection(0, pair); | |
923 Node* overflow = assembler->Projection(1, pair); | 922 Node* overflow = assembler->Projection(1, pair); |
924 | 923 |
925 // Check if the Smi subtraction overflowed. | 924 // Check if the Smi subtraction overflowed. |
926 Label if_overflow(assembler), if_notoverflow(assembler); | 925 Label if_overflow(assembler), if_notoverflow(assembler); |
927 assembler->Branch(overflow, &if_overflow, &if_notoverflow); | 926 assembler->Branch(overflow, &if_overflow, &if_notoverflow); |
928 | 927 |
929 assembler->Bind(&if_overflow); | 928 assembler->Bind(&if_overflow); |
930 { | 929 { |
931 // The result doesn't fit into Smi range. | 930 // The result doesn't fit into Smi range. |
932 var_fsub_lhs.Bind(assembler->SmiToFloat64(lhs)); | 931 var_fsub_lhs.Bind(assembler->SmiToFloat64(lhs)); |
933 var_fsub_rhs.Bind(assembler->SmiToFloat64(rhs)); | 932 var_fsub_rhs.Bind(assembler->SmiToFloat64(rhs)); |
934 assembler->Goto(&do_fsub); | 933 assembler->Goto(&do_fsub); |
935 } | 934 } |
936 | 935 |
937 assembler->Bind(&if_notoverflow); | 936 assembler->Bind(&if_notoverflow); |
938 assembler->Return(result); | 937 assembler->Return(assembler->Projection(0, pair)); |
939 } | 938 } |
940 | 939 |
941 assembler->Bind(&if_rhsisnotsmi); | 940 assembler->Bind(&if_rhsisnotsmi); |
942 { | 941 { |
943 // Load the map of the {rhs}. | 942 // Load the map of the {rhs}. |
944 Node* rhs_map = assembler->LoadMap(rhs); | 943 Node* rhs_map = assembler->LoadMap(rhs); |
945 | 944 |
946 // Check if {rhs} is a HeapNumber. | 945 // Check if {rhs} is a HeapNumber. |
947 Label if_rhsisnumber(assembler), | 946 Label if_rhsisnumber(assembler), |
948 if_rhsisnotnumber(assembler, Label::kDeferred); | 947 if_rhsisnotnumber(assembler, Label::kDeferred); |
(...skipping 2402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3351 if (type->Is(Type::UntaggedPointer())) { | 3350 if (type->Is(Type::UntaggedPointer())) { |
3352 return Representation::External(); | 3351 return Representation::External(); |
3353 } | 3352 } |
3354 | 3353 |
3355 DCHECK(!type->Is(Type::Untagged())); | 3354 DCHECK(!type->Is(Type::Untagged())); |
3356 return Representation::Tagged(); | 3355 return Representation::Tagged(); |
3357 } | 3356 } |
3358 | 3357 |
3359 } // namespace internal | 3358 } // namespace internal |
3360 } // namespace v8 | 3359 } // namespace v8 |
OLD | NEW |