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

Side by Side Diff: src/builtins/builtins-number.cc

Issue 2415133002: [stubs] Gets rid of the Smi(Add/Sub)WithOverflow macros. (Closed)
Patch Set: Created 4 years, 2 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
« no previous file with comments | « no previous file | src/code-stub-assembler.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 2016 the V8 project authors. All rights reserved. 1 // Copyright 2016 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/builtins/builtins-utils.h" 5 #include "src/builtins/builtins-utils.h"
6 #include "src/builtins/builtins.h" 6 #include "src/builtins/builtins.h"
7 #include "src/code-factory.h" 7 #include "src/code-factory.h"
8 8
9 namespace v8 { 9 namespace v8 {
10 namespace internal { 10 namespace internal {
(...skipping 506 matching lines...) Expand 10 before | Expand all | Expand 10 after
517 assembler->Bind(&if_lhsissmi); 517 assembler->Bind(&if_lhsissmi);
518 { 518 {
519 // Check if the {rhs} is also a Smi. 519 // Check if the {rhs} is also a Smi.
520 Label if_rhsissmi(assembler), if_rhsisnotsmi(assembler); 520 Label if_rhsissmi(assembler), if_rhsisnotsmi(assembler);
521 assembler->Branch(assembler->TaggedIsSmi(rhs), &if_rhsissmi, 521 assembler->Branch(assembler->TaggedIsSmi(rhs), &if_rhsissmi,
522 &if_rhsisnotsmi); 522 &if_rhsisnotsmi);
523 523
524 assembler->Bind(&if_rhsissmi); 524 assembler->Bind(&if_rhsissmi);
525 { 525 {
526 // Try fast Smi addition first. 526 // Try fast Smi addition first.
527 Node* pair = assembler->SmiAddWithOverflow(lhs, rhs); 527 Node* pair = assembler->IntPtrAddWithOverflow(
528 assembler->BitcastTaggedToWord(lhs),
529 assembler->BitcastTaggedToWord(rhs));
528 Node* overflow = assembler->Projection(1, pair); 530 Node* overflow = assembler->Projection(1, pair);
529 531
530 // Check if the Smi additon overflowed. 532 // Check if the Smi additon overflowed.
531 Label if_overflow(assembler), if_notoverflow(assembler); 533 Label if_overflow(assembler), if_notoverflow(assembler);
532 assembler->Branch(overflow, &if_overflow, &if_notoverflow); 534 assembler->Branch(overflow, &if_overflow, &if_notoverflow);
533 535
534 assembler->Bind(&if_overflow); 536 assembler->Bind(&if_overflow);
535 { 537 {
536 var_fadd_lhs.Bind(assembler->SmiToFloat64(lhs)); 538 var_fadd_lhs.Bind(assembler->SmiToFloat64(lhs));
537 var_fadd_rhs.Bind(assembler->SmiToFloat64(rhs)); 539 var_fadd_rhs.Bind(assembler->SmiToFloat64(rhs));
538 assembler->Goto(&do_fadd); 540 assembler->Goto(&do_fadd);
539 } 541 }
540 542
541 assembler->Bind(&if_notoverflow); 543 assembler->Bind(&if_notoverflow);
542 var_result.Bind(assembler->Projection(0, pair)); 544 var_result.Bind(assembler->BitcastWordToTaggedSigned(
545 assembler->Projection(0, pair)));
543 assembler->Goto(&end); 546 assembler->Goto(&end);
544 } 547 }
545 548
546 assembler->Bind(&if_rhsisnotsmi); 549 assembler->Bind(&if_rhsisnotsmi);
547 { 550 {
548 // Load the map of {rhs}. 551 // Load the map of {rhs}.
549 Node* rhs_map = assembler->LoadMap(rhs); 552 Node* rhs_map = assembler->LoadMap(rhs);
550 553
551 // Check if the {rhs} is a HeapNumber. 554 // Check if the {rhs} is a HeapNumber.
552 Label if_rhsisnumber(assembler), 555 Label if_rhsisnumber(assembler),
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after
879 assembler->Bind(&if_lhsissmi); 882 assembler->Bind(&if_lhsissmi);
880 { 883 {
881 // Check if the {rhs} is also a Smi. 884 // Check if the {rhs} is also a Smi.
882 Label if_rhsissmi(assembler), if_rhsisnotsmi(assembler); 885 Label if_rhsissmi(assembler), if_rhsisnotsmi(assembler);
883 assembler->Branch(assembler->TaggedIsSmi(rhs), &if_rhsissmi, 886 assembler->Branch(assembler->TaggedIsSmi(rhs), &if_rhsissmi,
884 &if_rhsisnotsmi); 887 &if_rhsisnotsmi);
885 888
886 assembler->Bind(&if_rhsissmi); 889 assembler->Bind(&if_rhsissmi);
887 { 890 {
888 // Try a fast Smi subtraction first. 891 // Try a fast Smi subtraction first.
889 Node* pair = assembler->SmiSubWithOverflow(lhs, rhs); 892 Node* pair = assembler->IntPtrSubWithOverflow(
893 assembler->BitcastTaggedToWord(lhs),
894 assembler->BitcastTaggedToWord(rhs));
890 Node* overflow = assembler->Projection(1, pair); 895 Node* overflow = assembler->Projection(1, pair);
891 896
892 // Check if the Smi subtraction overflowed. 897 // Check if the Smi subtraction overflowed.
893 Label if_overflow(assembler), if_notoverflow(assembler); 898 Label if_overflow(assembler), if_notoverflow(assembler);
894 assembler->Branch(overflow, &if_overflow, &if_notoverflow); 899 assembler->Branch(overflow, &if_overflow, &if_notoverflow);
895 900
896 assembler->Bind(&if_overflow); 901 assembler->Bind(&if_overflow);
897 { 902 {
898 // The result doesn't fit into Smi range. 903 // The result doesn't fit into Smi range.
899 var_fsub_lhs.Bind(assembler->SmiToFloat64(lhs)); 904 var_fsub_lhs.Bind(assembler->SmiToFloat64(lhs));
900 var_fsub_rhs.Bind(assembler->SmiToFloat64(rhs)); 905 var_fsub_rhs.Bind(assembler->SmiToFloat64(rhs));
901 assembler->Goto(&do_fsub); 906 assembler->Goto(&do_fsub);
902 } 907 }
903 908
904 assembler->Bind(&if_notoverflow); 909 assembler->Bind(&if_notoverflow);
905 var_result.Bind(assembler->Projection(0, pair)); 910 var_result.Bind(assembler->BitcastWordToTaggedSigned(
911 assembler->Projection(0, pair)));
906 assembler->Goto(&end); 912 assembler->Goto(&end);
907 } 913 }
908 914
909 assembler->Bind(&if_rhsisnotsmi); 915 assembler->Bind(&if_rhsisnotsmi);
910 { 916 {
911 // Load the map of the {rhs}. 917 // Load the map of the {rhs}.
912 Node* rhs_map = assembler->LoadMap(rhs); 918 Node* rhs_map = assembler->LoadMap(rhs);
913 919
914 // Check if {rhs} is a HeapNumber. 920 // Check if {rhs} is a HeapNumber.
915 Label if_rhsisnumber(assembler), 921 Label if_rhsisnumber(assembler),
(...skipping 788 matching lines...) Expand 10 before | Expand all | Expand 10 after
1704 compiler::Node* lhs = assembler->Parameter(0); 1710 compiler::Node* lhs = assembler->Parameter(0);
1705 compiler::Node* rhs = assembler->Parameter(1); 1711 compiler::Node* rhs = assembler->Parameter(1);
1706 compiler::Node* context = assembler->Parameter(2); 1712 compiler::Node* context = assembler->Parameter(2);
1707 1713
1708 assembler->Return(assembler->StrictEqual(CodeStubAssembler::kNegateResult, 1714 assembler->Return(assembler->StrictEqual(CodeStubAssembler::kNegateResult,
1709 lhs, rhs, context)); 1715 lhs, rhs, context));
1710 } 1716 }
1711 1717
1712 } // namespace internal 1718 } // namespace internal
1713 } // namespace v8 1719 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | src/code-stub-assembler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698