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

Side by Side Diff: src/code-stubs.cc

Issue 1902823002: [ignition] Inline the binary op TurboFan code stubs in the bytecode handlers. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Update Created 4 years, 8 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 | « src/code-stubs.h ('k') | src/compiler/register-allocator-verifier.cc » ('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 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 480 matching lines...) Expand 10 before | Expand all | Expand 10 after
491 491
492 void StringLengthStub::GenerateAssembly(CodeStubAssembler* assembler) const { 492 void StringLengthStub::GenerateAssembly(CodeStubAssembler* assembler) const {
493 compiler::Node* value = assembler->Parameter(0); 493 compiler::Node* value = assembler->Parameter(0);
494 compiler::Node* string = 494 compiler::Node* string =
495 assembler->LoadObjectField(value, JSValue::kValueOffset); 495 assembler->LoadObjectField(value, JSValue::kValueOffset);
496 compiler::Node* result = 496 compiler::Node* result =
497 assembler->LoadObjectField(string, String::kLengthOffset); 497 assembler->LoadObjectField(string, String::kLengthOffset);
498 assembler->Return(result); 498 assembler->Return(result);
499 } 499 }
500 500
501 void AddStub::GenerateAssembly(CodeStubAssembler* assembler) const { 501 compiler::Node* AddStub::Generate(CodeStubAssembler* assembler,
502 compiler::Node* left, compiler::Node* right,
503 compiler::Node* context) {
502 typedef CodeStubAssembler::Label Label; 504 typedef CodeStubAssembler::Label Label;
503 typedef compiler::Node Node; 505 typedef compiler::Node Node;
504 typedef CodeStubAssembler::Variable Variable; 506 typedef CodeStubAssembler::Variable Variable;
505 507
506 Node* context = assembler->Parameter(2);
507
508 // Shared entry for floating point addition. 508 // Shared entry for floating point addition.
509 Label do_fadd(assembler); 509 Label do_fadd(assembler), end(assembler);
510 Variable var_fadd_lhs(assembler, MachineRepresentation::kFloat64), 510 Variable var_fadd_lhs(assembler, MachineRepresentation::kFloat64),
511 var_fadd_rhs(assembler, MachineRepresentation::kFloat64); 511 var_fadd_rhs(assembler, MachineRepresentation::kFloat64);
512 512
513 // We might need to loop several times due to ToPrimitive, ToString and/or 513 // We might need to loop several times due to ToPrimitive, ToString and/or
514 // ToNumber conversions. 514 // ToNumber conversions.
515 Variable var_lhs(assembler, MachineRepresentation::kTagged), 515 Variable var_lhs(assembler, MachineRepresentation::kTagged),
516 var_rhs(assembler, MachineRepresentation::kTagged); 516 var_rhs(assembler, MachineRepresentation::kTagged),
517 var_result(assembler, MachineRepresentation::kTagged);
517 Variable* loop_vars[2] = {&var_lhs, &var_rhs}; 518 Variable* loop_vars[2] = {&var_lhs, &var_rhs};
518 Label loop(assembler, 2, loop_vars); 519 Label loop(assembler, 2, loop_vars);
519 var_lhs.Bind(assembler->Parameter(0)); 520 var_lhs.Bind(left);
520 var_rhs.Bind(assembler->Parameter(1)); 521 var_rhs.Bind(right);
521 assembler->Goto(&loop); 522 assembler->Goto(&loop);
522 assembler->Bind(&loop); 523 assembler->Bind(&loop);
523 { 524 {
524 // Load the current {lhs} and {rhs} values. 525 // Load the current {lhs} and {rhs} values.
525 Node* lhs = var_lhs.value(); 526 Node* lhs = var_lhs.value();
526 Node* rhs = var_rhs.value(); 527 Node* rhs = var_rhs.value();
527 528
528 // Check if the {lhs} is a Smi or a HeapObject. 529 // Check if the {lhs} is a Smi or a HeapObject.
529 Label if_lhsissmi(assembler), if_lhsisnotsmi(assembler); 530 Label if_lhsissmi(assembler), if_lhsisnotsmi(assembler);
530 assembler->Branch(assembler->WordIsSmi(lhs), &if_lhsissmi, &if_lhsisnotsmi); 531 assembler->Branch(assembler->WordIsSmi(lhs), &if_lhsissmi, &if_lhsisnotsmi);
(...skipping 16 matching lines...) Expand all
547 assembler->Branch(overflow, &if_overflow, &if_notoverflow); 548 assembler->Branch(overflow, &if_overflow, &if_notoverflow);
548 549
549 assembler->Bind(&if_overflow); 550 assembler->Bind(&if_overflow);
550 { 551 {
551 var_fadd_lhs.Bind(assembler->SmiToFloat64(lhs)); 552 var_fadd_lhs.Bind(assembler->SmiToFloat64(lhs));
552 var_fadd_rhs.Bind(assembler->SmiToFloat64(rhs)); 553 var_fadd_rhs.Bind(assembler->SmiToFloat64(rhs));
553 assembler->Goto(&do_fadd); 554 assembler->Goto(&do_fadd);
554 } 555 }
555 556
556 assembler->Bind(&if_notoverflow); 557 assembler->Bind(&if_notoverflow);
557 assembler->Return(assembler->Projection(0, pair)); 558 var_result.Bind(assembler->Projection(0, pair));
559 assembler->Goto(&end);
558 } 560 }
559 561
560 assembler->Bind(&if_rhsisnotsmi); 562 assembler->Bind(&if_rhsisnotsmi);
561 { 563 {
562 // Load the map of {rhs}. 564 // Load the map of {rhs}.
563 Node* rhs_map = assembler->LoadObjectField(rhs, HeapObject::kMapOffset); 565 Node* rhs_map = assembler->LoadObjectField(rhs, HeapObject::kMapOffset);
564 566
565 // Check if the {rhs} is a HeapNumber. 567 // Check if the {rhs} is a HeapNumber.
566 Label if_rhsisnumber(assembler), 568 Label if_rhsisnumber(assembler),
567 if_rhsisnotnumber(assembler, Label::kDeferred); 569 if_rhsisnotnumber(assembler, Label::kDeferred);
(...skipping 20 matching lines...) Expand all
588 rhs_instance_type, 590 rhs_instance_type,
589 assembler->Int32Constant(FIRST_NONSTRING_TYPE)), 591 assembler->Int32Constant(FIRST_NONSTRING_TYPE)),
590 &if_rhsisstring, &if_rhsisnotstring); 592 &if_rhsisstring, &if_rhsisnotstring);
591 593
592 assembler->Bind(&if_rhsisstring); 594 assembler->Bind(&if_rhsisstring);
593 { 595 {
594 // Convert {lhs}, which is a Smi, to a String and concatenate the 596 // Convert {lhs}, which is a Smi, to a String and concatenate the
595 // resulting string with the String {rhs}. 597 // resulting string with the String {rhs}.
596 Callable callable = CodeFactory::StringAdd( 598 Callable callable = CodeFactory::StringAdd(
597 assembler->isolate(), STRING_ADD_CONVERT_LEFT, NOT_TENURED); 599 assembler->isolate(), STRING_ADD_CONVERT_LEFT, NOT_TENURED);
598 assembler->TailCallStub(callable, context, lhs, rhs); 600 var_result.Bind(assembler->CallStub(callable, context, lhs, rhs));
601 assembler->Goto(&end);
599 } 602 }
600 603
601 assembler->Bind(&if_rhsisnotstring); 604 assembler->Bind(&if_rhsisnotstring);
602 { 605 {
603 // Check if {rhs} is a JSReceiver. 606 // Check if {rhs} is a JSReceiver.
604 Label if_rhsisreceiver(assembler, Label::kDeferred), 607 Label if_rhsisreceiver(assembler, Label::kDeferred),
605 if_rhsisnotreceiver(assembler, Label::kDeferred); 608 if_rhsisnotreceiver(assembler, Label::kDeferred);
606 assembler->Branch( 609 assembler->Branch(
607 assembler->Int32LessThanOrEqual( 610 assembler->Int32LessThanOrEqual(
608 assembler->Int32Constant(FIRST_JS_RECEIVER_TYPE), 611 assembler->Int32Constant(FIRST_JS_RECEIVER_TYPE),
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
642 lhs_instance_type, 645 lhs_instance_type,
643 assembler->Int32Constant(FIRST_NONSTRING_TYPE)), 646 assembler->Int32Constant(FIRST_NONSTRING_TYPE)),
644 &if_lhsisstring, &if_lhsisnotstring); 647 &if_lhsisstring, &if_lhsisnotstring);
645 648
646 assembler->Bind(&if_lhsisstring); 649 assembler->Bind(&if_lhsisstring);
647 { 650 {
648 // Convert {rhs} to a String (using the sequence of ToPrimitive with 651 // Convert {rhs} to a String (using the sequence of ToPrimitive with
649 // no hint followed by ToString) and concatenate the strings. 652 // no hint followed by ToString) and concatenate the strings.
650 Callable callable = CodeFactory::StringAdd( 653 Callable callable = CodeFactory::StringAdd(
651 assembler->isolate(), STRING_ADD_CONVERT_RIGHT, NOT_TENURED); 654 assembler->isolate(), STRING_ADD_CONVERT_RIGHT, NOT_TENURED);
652 assembler->TailCallStub(callable, context, lhs, rhs); 655 var_result.Bind(assembler->CallStub(callable, context, lhs, rhs));
656 assembler->Goto(&end);
653 } 657 }
654 658
655 assembler->Bind(&if_lhsisnotstring); 659 assembler->Bind(&if_lhsisnotstring);
656 { 660 {
657 // Check if {rhs} is a Smi. 661 // Check if {rhs} is a Smi.
658 Label if_rhsissmi(assembler), if_rhsisnotsmi(assembler); 662 Label if_rhsissmi(assembler), if_rhsisnotsmi(assembler);
659 assembler->Branch(assembler->WordIsSmi(rhs), &if_rhsissmi, 663 assembler->Branch(assembler->WordIsSmi(rhs), &if_rhsissmi,
660 &if_rhsisnotsmi); 664 &if_rhsisnotsmi);
661 665
662 assembler->Bind(&if_rhsissmi); 666 assembler->Bind(&if_rhsissmi);
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
720 rhs_instance_type, 724 rhs_instance_type,
721 assembler->Int32Constant(FIRST_NONSTRING_TYPE)), 725 assembler->Int32Constant(FIRST_NONSTRING_TYPE)),
722 &if_rhsisstring, &if_rhsisnotstring); 726 &if_rhsisstring, &if_rhsisnotstring);
723 727
724 assembler->Bind(&if_rhsisstring); 728 assembler->Bind(&if_rhsisstring);
725 { 729 {
726 // Convert {lhs} to a String (using the sequence of ToPrimitive with 730 // Convert {lhs} to a String (using the sequence of ToPrimitive with
727 // no hint followed by ToString) and concatenate the strings. 731 // no hint followed by ToString) and concatenate the strings.
728 Callable callable = CodeFactory::StringAdd( 732 Callable callable = CodeFactory::StringAdd(
729 assembler->isolate(), STRING_ADD_CONVERT_LEFT, NOT_TENURED); 733 assembler->isolate(), STRING_ADD_CONVERT_LEFT, NOT_TENURED);
730 assembler->TailCallStub(callable, context, lhs, rhs); 734 var_result.Bind(assembler->CallStub(callable, context, lhs, rhs));
735 assembler->Goto(&end);
731 } 736 }
732 737
733 assembler->Bind(&if_rhsisnotstring); 738 assembler->Bind(&if_rhsisnotstring);
734 { 739 {
735 // Check if {lhs} is a HeapNumber. 740 // Check if {lhs} is a HeapNumber.
736 Label if_lhsisnumber(assembler), if_lhsisnotnumber(assembler); 741 Label if_lhsisnumber(assembler), if_lhsisnotnumber(assembler);
737 assembler->Branch(assembler->Word32Equal( 742 assembler->Branch(assembler->Word32Equal(
738 lhs_instance_type, 743 lhs_instance_type,
739 assembler->Int32Constant(HEAP_NUMBER_TYPE)), 744 assembler->Int32Constant(HEAP_NUMBER_TYPE)),
740 &if_lhsisnumber, &if_lhsisnotnumber); 745 &if_lhsisnumber, &if_lhsisnotnumber);
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
842 } 847 }
843 } 848 }
844 } 849 }
845 } 850 }
846 851
847 assembler->Bind(&do_fadd); 852 assembler->Bind(&do_fadd);
848 { 853 {
849 Node* lhs_value = var_fadd_lhs.value(); 854 Node* lhs_value = var_fadd_lhs.value();
850 Node* rhs_value = var_fadd_rhs.value(); 855 Node* rhs_value = var_fadd_rhs.value();
851 Node* value = assembler->Float64Add(lhs_value, rhs_value); 856 Node* value = assembler->Float64Add(lhs_value, rhs_value);
852 Node* result = assembler->ChangeFloat64ToTagged(value); 857 var_result.Bind(assembler->ChangeFloat64ToTagged(value));
853 assembler->Return(result); 858 assembler->Goto(&end);
854 } 859 }
860 assembler->Bind(&end);
861 return var_result.value();
855 } 862 }
856 863
857 void SubtractStub::GenerateAssembly(CodeStubAssembler* assembler) const { 864 compiler::Node* SubtractStub::Generate(CodeStubAssembler* assembler,
865 compiler::Node* left,
866 compiler::Node* right,
867 compiler::Node* context) {
858 typedef CodeStubAssembler::Label Label; 868 typedef CodeStubAssembler::Label Label;
859 typedef compiler::Node Node; 869 typedef compiler::Node Node;
860 typedef CodeStubAssembler::Variable Variable; 870 typedef CodeStubAssembler::Variable Variable;
861 871
862 Node* context = assembler->Parameter(2);
863
864 // Shared entry for floating point subtraction. 872 // Shared entry for floating point subtraction.
865 Label do_fsub(assembler); 873 Label do_fsub(assembler), end(assembler);
866 Variable var_fsub_lhs(assembler, MachineRepresentation::kFloat64), 874 Variable var_fsub_lhs(assembler, MachineRepresentation::kFloat64),
867 var_fsub_rhs(assembler, MachineRepresentation::kFloat64); 875 var_fsub_rhs(assembler, MachineRepresentation::kFloat64);
868 876
869 // We might need to loop several times due to ToPrimitive and/or ToNumber 877 // We might need to loop several times due to ToPrimitive and/or ToNumber
870 // conversions. 878 // conversions.
871 Variable var_lhs(assembler, MachineRepresentation::kTagged), 879 Variable var_lhs(assembler, MachineRepresentation::kTagged),
872 var_rhs(assembler, MachineRepresentation::kTagged); 880 var_rhs(assembler, MachineRepresentation::kTagged),
881 var_result(assembler, MachineRepresentation::kTagged);
873 Variable* loop_vars[2] = {&var_lhs, &var_rhs}; 882 Variable* loop_vars[2] = {&var_lhs, &var_rhs};
874 Label loop(assembler, 2, loop_vars); 883 Label loop(assembler, 2, loop_vars);
875 var_lhs.Bind(assembler->Parameter(0)); 884 var_lhs.Bind(left);
876 var_rhs.Bind(assembler->Parameter(1)); 885 var_rhs.Bind(right);
877 assembler->Goto(&loop); 886 assembler->Goto(&loop);
878 assembler->Bind(&loop); 887 assembler->Bind(&loop);
879 { 888 {
880 // Load the current {lhs} and {rhs} values. 889 // Load the current {lhs} and {rhs} values.
881 Node* lhs = var_lhs.value(); 890 Node* lhs = var_lhs.value();
882 Node* rhs = var_rhs.value(); 891 Node* rhs = var_rhs.value();
883 892
884 // Check if the {lhs} is a Smi or a HeapObject. 893 // Check if the {lhs} is a Smi or a HeapObject.
885 Label if_lhsissmi(assembler), if_lhsisnotsmi(assembler); 894 Label if_lhsissmi(assembler), if_lhsisnotsmi(assembler);
886 assembler->Branch(assembler->WordIsSmi(lhs), &if_lhsissmi, &if_lhsisnotsmi); 895 assembler->Branch(assembler->WordIsSmi(lhs), &if_lhsissmi, &if_lhsisnotsmi);
(...skipping 17 matching lines...) Expand all
904 913
905 assembler->Bind(&if_overflow); 914 assembler->Bind(&if_overflow);
906 { 915 {
907 // The result doesn't fit into Smi range. 916 // The result doesn't fit into Smi range.
908 var_fsub_lhs.Bind(assembler->SmiToFloat64(lhs)); 917 var_fsub_lhs.Bind(assembler->SmiToFloat64(lhs));
909 var_fsub_rhs.Bind(assembler->SmiToFloat64(rhs)); 918 var_fsub_rhs.Bind(assembler->SmiToFloat64(rhs));
910 assembler->Goto(&do_fsub); 919 assembler->Goto(&do_fsub);
911 } 920 }
912 921
913 assembler->Bind(&if_notoverflow); 922 assembler->Bind(&if_notoverflow);
914 assembler->Return(assembler->Projection(0, pair)); 923 var_result.Bind(assembler->Projection(0, pair));
924 assembler->Goto(&end);
915 } 925 }
916 926
917 assembler->Bind(&if_rhsisnotsmi); 927 assembler->Bind(&if_rhsisnotsmi);
918 { 928 {
919 // Load the map of the {rhs}. 929 // Load the map of the {rhs}.
920 Node* rhs_map = assembler->LoadMap(rhs); 930 Node* rhs_map = assembler->LoadMap(rhs);
921 931
922 // Check if {rhs} is a HeapNumber. 932 // Check if {rhs} is a HeapNumber.
923 Label if_rhsisnumber(assembler), 933 Label if_rhsisnumber(assembler),
924 if_rhsisnotnumber(assembler, Label::kDeferred); 934 if_rhsisnotnumber(assembler, Label::kDeferred);
925 Node* number_map = assembler->HeapNumberMapConstant(); 935 Node* number_map = assembler->HeapNumberMapConstant();
926 assembler->Branch(assembler->WordEqual(rhs_map, number_map), 936 assembler->Branch(assembler->WordEqual(rhs_map, number_map),
927 &if_rhsisnumber, &if_rhsisnotnumber); 937 &if_rhsisnumber, &if_rhsisnotnumber);
928 938
929 assembler->Bind(&if_rhsisnumber); 939 assembler->Bind(&if_rhsisnumber);
930 { 940 {
931 // Perform a floating point subtraction. 941 // Perform a floating point subtraction.
932 var_fsub_lhs.Bind(assembler->SmiToFloat64(lhs)); 942 var_fsub_lhs.Bind(assembler->SmiToFloat64(lhs));
933 var_fsub_rhs.Bind(assembler->LoadHeapNumberValue(rhs)); 943 var_fsub_rhs.Bind(assembler->LoadHeapNumberValue(rhs));
934 assembler->Goto(&do_fsub); 944 assembler->Goto(&do_fsub);
935 } 945 }
936 946
937 assembler->Bind(&if_rhsisnotnumber); 947 assembler->Bind(&if_rhsisnotnumber);
938 { 948 {
939 // Convert the {rhs} to a Number first. 949 // Convert the {rhs} to a Number first.
940 Callable callable = CodeFactory::NonNumberToNumber(isolate()); 950 Callable callable =
951 CodeFactory::NonNumberToNumber(assembler->isolate());
941 var_rhs.Bind(assembler->CallStub(callable, context, rhs)); 952 var_rhs.Bind(assembler->CallStub(callable, context, rhs));
942 assembler->Goto(&loop); 953 assembler->Goto(&loop);
943 } 954 }
944 } 955 }
945 } 956 }
946 957
947 assembler->Bind(&if_lhsisnotsmi); 958 assembler->Bind(&if_lhsisnotsmi);
948 { 959 {
949 // Load the map of the {lhs}. 960 // Load the map of the {lhs}.
950 Node* lhs_map = assembler->LoadMap(lhs); 961 Node* lhs_map = assembler->LoadMap(lhs);
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
986 { 997 {
987 // Perform a floating point subtraction. 998 // Perform a floating point subtraction.
988 var_fsub_lhs.Bind(assembler->LoadHeapNumberValue(lhs)); 999 var_fsub_lhs.Bind(assembler->LoadHeapNumberValue(lhs));
989 var_fsub_rhs.Bind(assembler->LoadHeapNumberValue(rhs)); 1000 var_fsub_rhs.Bind(assembler->LoadHeapNumberValue(rhs));
990 assembler->Goto(&do_fsub); 1001 assembler->Goto(&do_fsub);
991 } 1002 }
992 1003
993 assembler->Bind(&if_rhsisnotnumber); 1004 assembler->Bind(&if_rhsisnotnumber);
994 { 1005 {
995 // Convert the {rhs} to a Number first. 1006 // Convert the {rhs} to a Number first.
996 Callable callable = CodeFactory::NonNumberToNumber(isolate()); 1007 Callable callable =
1008 CodeFactory::NonNumberToNumber(assembler->isolate());
997 var_rhs.Bind(assembler->CallStub(callable, context, rhs)); 1009 var_rhs.Bind(assembler->CallStub(callable, context, rhs));
998 assembler->Goto(&loop); 1010 assembler->Goto(&loop);
999 } 1011 }
1000 } 1012 }
1001 } 1013 }
1002 1014
1003 assembler->Bind(&if_lhsisnotnumber); 1015 assembler->Bind(&if_lhsisnotnumber);
1004 { 1016 {
1005 // Convert the {lhs} to a Number first. 1017 // Convert the {lhs} to a Number first.
1006 Callable callable = CodeFactory::NonNumberToNumber(isolate()); 1018 Callable callable =
1019 CodeFactory::NonNumberToNumber(assembler->isolate());
1007 var_lhs.Bind(assembler->CallStub(callable, context, lhs)); 1020 var_lhs.Bind(assembler->CallStub(callable, context, lhs));
1008 assembler->Goto(&loop); 1021 assembler->Goto(&loop);
1009 } 1022 }
1010 } 1023 }
1011 } 1024 }
1012 1025
1013 assembler->Bind(&do_fsub); 1026 assembler->Bind(&do_fsub);
1014 { 1027 {
1015 Node* lhs_value = var_fsub_lhs.value(); 1028 Node* lhs_value = var_fsub_lhs.value();
1016 Node* rhs_value = var_fsub_rhs.value(); 1029 Node* rhs_value = var_fsub_rhs.value();
1017 Node* value = assembler->Float64Sub(lhs_value, rhs_value); 1030 Node* value = assembler->Float64Sub(lhs_value, rhs_value);
1018 Node* result = assembler->ChangeFloat64ToTagged(value); 1031 var_result.Bind(assembler->ChangeFloat64ToTagged(value));
1019 assembler->Return(result); 1032 assembler->Goto(&end);
1020 } 1033 }
1034 assembler->Bind(&end);
1035 return var_result.value();
1021 } 1036 }
1022 1037
1023 void MultiplyStub::GenerateAssembly(CodeStubAssembler* assembler) const { 1038 // static
1039 compiler::Node* MultiplyStub::Generate(CodeStubAssembler* assembler,
1040 compiler::Node* left,
1041 compiler::Node* right,
1042 compiler::Node* context) {
1024 using compiler::Node; 1043 using compiler::Node;
1025 typedef CodeStubAssembler::Label Label; 1044 typedef CodeStubAssembler::Label Label;
1026 typedef CodeStubAssembler::Variable Variable; 1045 typedef CodeStubAssembler::Variable Variable;
1027 1046
1028 Node* context = assembler->Parameter(2);
1029
1030 // Shared entry point for floating point multiplication. 1047 // Shared entry point for floating point multiplication.
1031 Label do_fmul(assembler); 1048 Label do_fmul(assembler);
1032 Variable var_lhs_float64(assembler, MachineRepresentation::kFloat64), 1049 Variable var_lhs_float64(assembler, MachineRepresentation::kFloat64),
1033 var_rhs_float64(assembler, MachineRepresentation::kFloat64); 1050 var_rhs_float64(assembler, MachineRepresentation::kFloat64);
1034 1051
1035 Node* number_map = assembler->HeapNumberMapConstant(); 1052 Node* number_map = assembler->HeapNumberMapConstant();
1036 1053
1037 // We might need to loop one or two times due to ToNumber conversions. 1054 // We might need to loop one or two times due to ToNumber conversions.
1038 Variable var_lhs(assembler, MachineRepresentation::kTagged), 1055 Variable var_lhs(assembler, MachineRepresentation::kTagged),
1039 var_rhs(assembler, MachineRepresentation::kTagged); 1056 var_rhs(assembler, MachineRepresentation::kTagged);
1040 Variable* loop_variables[] = {&var_lhs, &var_rhs}; 1057 Variable* loop_variables[] = {&var_lhs, &var_rhs};
1041 Label loop(assembler, 2, loop_variables); 1058 Label loop(assembler, 2, loop_variables);
1042 var_lhs.Bind(assembler->Parameter(0)); 1059 var_lhs.Bind(left);
1043 var_rhs.Bind(assembler->Parameter(1)); 1060 var_rhs.Bind(right);
1044 assembler->Goto(&loop); 1061 assembler->Goto(&loop);
1045 assembler->Bind(&loop); 1062 assembler->Bind(&loop);
1046 { 1063 {
1047 Node* lhs = var_lhs.value(); 1064 Node* lhs = var_lhs.value();
1048 Node* rhs = var_rhs.value(); 1065 Node* rhs = var_rhs.value();
1049 1066
1050 Label lhs_is_smi(assembler), lhs_is_not_smi(assembler); 1067 Label lhs_is_smi(assembler), lhs_is_not_smi(assembler);
1051 assembler->Branch(assembler->WordIsSmi(lhs), &lhs_is_smi, &lhs_is_not_smi); 1068 assembler->Branch(assembler->WordIsSmi(lhs), &lhs_is_smi, &lhs_is_not_smi);
1052 1069
1053 assembler->Bind(&lhs_is_smi); 1070 assembler->Bind(&lhs_is_smi);
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
1143 var_lhs.Bind(rhs); 1160 var_lhs.Bind(rhs);
1144 var_rhs.Bind(lhs); 1161 var_rhs.Bind(lhs);
1145 assembler->Goto(&loop); 1162 assembler->Goto(&loop);
1146 } 1163 }
1147 } 1164 }
1148 } 1165 }
1149 1166
1150 assembler->Bind(&lhs_is_not_number); 1167 assembler->Bind(&lhs_is_not_number);
1151 { 1168 {
1152 // Convert {lhs} to a Number and loop. 1169 // Convert {lhs} to a Number and loop.
1153 Callable callable = CodeFactory::NonNumberToNumber(isolate()); 1170 Callable callable =
1171 CodeFactory::NonNumberToNumber(assembler->isolate());
1154 var_lhs.Bind(assembler->CallStub(callable, context, lhs)); 1172 var_lhs.Bind(assembler->CallStub(callable, context, lhs));
1155 assembler->Goto(&loop); 1173 assembler->Goto(&loop);
1156 } 1174 }
1157 } 1175 }
1158 } 1176 }
1159 1177
1160 assembler->Bind(&do_fmul); 1178 assembler->Bind(&do_fmul);
1161 { 1179 {
1162 Node* value = 1180 Node* value =
1163 assembler->Float64Mul(var_lhs_float64.value(), var_rhs_float64.value()); 1181 assembler->Float64Mul(var_lhs_float64.value(), var_rhs_float64.value());
1164 Node* result = assembler->ChangeFloat64ToTagged(value); 1182 Node* result = assembler->ChangeFloat64ToTagged(value);
1165 assembler->Return(result); 1183 return result;
1166 } 1184 }
1167 } 1185 }
1168 1186
1169 void DivideStub::GenerateAssembly(CodeStubAssembler* assembler) const { 1187 // static
1188 compiler::Node* DivideStub::Generate(CodeStubAssembler* assembler,
1189 compiler::Node* left,
1190 compiler::Node* right,
1191 compiler::Node* context) {
1170 using compiler::Node; 1192 using compiler::Node;
1171 typedef CodeStubAssembler::Label Label; 1193 typedef CodeStubAssembler::Label Label;
1172 typedef CodeStubAssembler::Variable Variable; 1194 typedef CodeStubAssembler::Variable Variable;
1173 1195
1174 Node* context = assembler->Parameter(2);
1175
1176 // Shared entry point for floating point division. 1196 // Shared entry point for floating point division.
1177 Label do_fdiv(assembler); 1197 Label do_fdiv(assembler), end(assembler);
1178 Variable var_dividend_float64(assembler, MachineRepresentation::kFloat64), 1198 Variable var_dividend_float64(assembler, MachineRepresentation::kFloat64),
1179 var_divisor_float64(assembler, MachineRepresentation::kFloat64); 1199 var_divisor_float64(assembler, MachineRepresentation::kFloat64);
1180 1200
1181 Node* number_map = assembler->HeapNumberMapConstant(); 1201 Node* number_map = assembler->HeapNumberMapConstant();
1182 1202
1183 // We might need to loop one or two times due to ToNumber conversions. 1203 // We might need to loop one or two times due to ToNumber conversions.
1184 Variable var_dividend(assembler, MachineRepresentation::kTagged), 1204 Variable var_dividend(assembler, MachineRepresentation::kTagged),
1185 var_divisor(assembler, MachineRepresentation::kTagged); 1205 var_divisor(assembler, MachineRepresentation::kTagged),
1206 var_result(assembler, MachineRepresentation::kTagged);
1186 Variable* loop_variables[] = {&var_dividend, &var_divisor}; 1207 Variable* loop_variables[] = {&var_dividend, &var_divisor};
1187 Label loop(assembler, 2, loop_variables); 1208 Label loop(assembler, 2, loop_variables);
1188 var_dividend.Bind(assembler->Parameter(0)); 1209 var_dividend.Bind(left);
1189 var_divisor.Bind(assembler->Parameter(1)); 1210 var_divisor.Bind(right);
1190 assembler->Goto(&loop); 1211 assembler->Goto(&loop);
1191 assembler->Bind(&loop); 1212 assembler->Bind(&loop);
1192 { 1213 {
1193 Node* dividend = var_dividend.value(); 1214 Node* dividend = var_dividend.value();
1194 Node* divisor = var_divisor.value(); 1215 Node* divisor = var_divisor.value();
1195 1216
1196 Label dividend_is_smi(assembler), dividend_is_not_smi(assembler); 1217 Label dividend_is_smi(assembler), dividend_is_not_smi(assembler);
1197 assembler->Branch(assembler->WordIsSmi(dividend), &dividend_is_smi, 1218 assembler->Branch(assembler->WordIsSmi(dividend), &dividend_is_smi,
1198 &dividend_is_not_smi); 1219 &dividend_is_not_smi);
1199 1220
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
1253 1274
1254 // TODO(epertoso): consider adding a machine instruction that returns 1275 // TODO(epertoso): consider adding a machine instruction that returns
1255 // both the result and the remainder. 1276 // both the result and the remainder.
1256 Node* untagged_result = 1277 Node* untagged_result =
1257 assembler->Int32Div(untagged_dividend, untagged_divisor); 1278 assembler->Int32Div(untagged_dividend, untagged_divisor);
1258 Node* truncated = 1279 Node* truncated =
1259 assembler->IntPtrMul(untagged_result, untagged_divisor); 1280 assembler->IntPtrMul(untagged_result, untagged_divisor);
1260 // Do floating point division if the remainder is not 0. 1281 // Do floating point division if the remainder is not 0.
1261 assembler->GotoIf( 1282 assembler->GotoIf(
1262 assembler->Word32NotEqual(untagged_dividend, truncated), &bailout); 1283 assembler->Word32NotEqual(untagged_dividend, truncated), &bailout);
1263 assembler->Return(assembler->SmiTag(untagged_result)); 1284 var_result.Bind(assembler->SmiTag(untagged_result));
1285 assembler->Goto(&end);
1264 1286
1265 // Bailout: convert {dividend} and {divisor} to double and do double 1287 // Bailout: convert {dividend} and {divisor} to double and do double
1266 // division. 1288 // division.
1267 assembler->Bind(&bailout); 1289 assembler->Bind(&bailout);
1268 { 1290 {
1269 var_dividend_float64.Bind(assembler->SmiToFloat64(dividend)); 1291 var_dividend_float64.Bind(assembler->SmiToFloat64(dividend));
1270 var_divisor_float64.Bind(assembler->SmiToFloat64(divisor)); 1292 var_divisor_float64.Bind(assembler->SmiToFloat64(divisor));
1271 assembler->Goto(&do_fdiv); 1293 assembler->Goto(&do_fdiv);
1272 } 1294 }
1273 } 1295 }
(...skipping 13 matching lines...) Expand all
1287 // Convert {dividend} to a double and divide it with the value of 1309 // Convert {dividend} to a double and divide it with the value of
1288 // {divisor}. 1310 // {divisor}.
1289 var_dividend_float64.Bind(assembler->SmiToFloat64(dividend)); 1311 var_dividend_float64.Bind(assembler->SmiToFloat64(dividend));
1290 var_divisor_float64.Bind(assembler->LoadHeapNumberValue(divisor)); 1312 var_divisor_float64.Bind(assembler->LoadHeapNumberValue(divisor));
1291 assembler->Goto(&do_fdiv); 1313 assembler->Goto(&do_fdiv);
1292 } 1314 }
1293 1315
1294 assembler->Bind(&divisor_is_not_number); 1316 assembler->Bind(&divisor_is_not_number);
1295 { 1317 {
1296 // Convert {divisor} to a number and loop. 1318 // Convert {divisor} to a number and loop.
1297 Callable callable = CodeFactory::NonNumberToNumber(isolate()); 1319 Callable callable =
1320 CodeFactory::NonNumberToNumber(assembler->isolate());
1298 var_divisor.Bind(assembler->CallStub(callable, context, divisor)); 1321 var_divisor.Bind(assembler->CallStub(callable, context, divisor));
1299 assembler->Goto(&loop); 1322 assembler->Goto(&loop);
1300 } 1323 }
1301 } 1324 }
1302 } 1325 }
1303 1326
1304 assembler->Bind(&dividend_is_not_smi); 1327 assembler->Bind(&dividend_is_not_smi);
1305 { 1328 {
1306 Node* dividend_map = assembler->LoadMap(dividend); 1329 Node* dividend_map = assembler->LoadMap(dividend);
1307 1330
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
1342 // Both {dividend} and {divisor} are HeapNumbers. Load their values 1365 // Both {dividend} and {divisor} are HeapNumbers. Load their values
1343 // and divide them. 1366 // and divide them.
1344 var_dividend_float64.Bind(assembler->LoadHeapNumberValue(dividend)); 1367 var_dividend_float64.Bind(assembler->LoadHeapNumberValue(dividend));
1345 var_divisor_float64.Bind(assembler->LoadHeapNumberValue(divisor)); 1368 var_divisor_float64.Bind(assembler->LoadHeapNumberValue(divisor));
1346 assembler->Goto(&do_fdiv); 1369 assembler->Goto(&do_fdiv);
1347 } 1370 }
1348 1371
1349 assembler->Bind(&divisor_is_not_number); 1372 assembler->Bind(&divisor_is_not_number);
1350 { 1373 {
1351 // Convert {divisor} to a number and loop. 1374 // Convert {divisor} to a number and loop.
1352 Callable callable = CodeFactory::NonNumberToNumber(isolate()); 1375 Callable callable =
1376 CodeFactory::NonNumberToNumber(assembler->isolate());
1353 var_divisor.Bind(assembler->CallStub(callable, context, divisor)); 1377 var_divisor.Bind(assembler->CallStub(callable, context, divisor));
1354 assembler->Goto(&loop); 1378 assembler->Goto(&loop);
1355 } 1379 }
1356 } 1380 }
1357 } 1381 }
1358 1382
1359 assembler->Bind(&dividend_is_not_number); 1383 assembler->Bind(&dividend_is_not_number);
1360 { 1384 {
1361 // Convert {dividend} to a Number and loop. 1385 // Convert {dividend} to a Number and loop.
1362 Callable callable = CodeFactory::NonNumberToNumber(isolate()); 1386 Callable callable =
1387 CodeFactory::NonNumberToNumber(assembler->isolate());
1363 var_dividend.Bind(assembler->CallStub(callable, context, dividend)); 1388 var_dividend.Bind(assembler->CallStub(callable, context, dividend));
1364 assembler->Goto(&loop); 1389 assembler->Goto(&loop);
1365 } 1390 }
1366 } 1391 }
1367 } 1392 }
1368 1393
1369 assembler->Bind(&do_fdiv); 1394 assembler->Bind(&do_fdiv);
1370 { 1395 {
1371 Node* value = assembler->Float64Div(var_dividend_float64.value(), 1396 Node* value = assembler->Float64Div(var_dividend_float64.value(),
1372 var_divisor_float64.value()); 1397 var_divisor_float64.value());
1373 Node* result = assembler->ChangeFloat64ToTagged(value); 1398 var_result.Bind(assembler->ChangeFloat64ToTagged(value));
1374 assembler->Return(result); 1399 assembler->Goto(&end);
1375 } 1400 }
1401 assembler->Bind(&end);
1402 return var_result.value();
1376 } 1403 }
1377 1404
1378 void BitwiseAndStub::GenerateAssembly(CodeStubAssembler* assembler) const { 1405 // static
1379 using compiler::Node; 1406 compiler::Node* ModulusStub::Generate(CodeStubAssembler* assembler,
1380 1407 compiler::Node* left,
1381 Node* lhs = assembler->Parameter(0); 1408 compiler::Node* right,
1382 Node* rhs = assembler->Parameter(1); 1409 compiler::Node* context) {
1383 Node* context = assembler->Parameter(2);
1384 Node* lhs_value = assembler->TruncateTaggedToWord32(context, lhs);
1385 Node* rhs_value = assembler->TruncateTaggedToWord32(context, rhs);
1386 Node* value = assembler->Word32And(lhs_value, rhs_value);
1387 Node* result = assembler->ChangeInt32ToTagged(value);
1388 assembler->Return(result);
1389 }
1390
1391 void ModulusStub::GenerateAssembly(CodeStubAssembler* assembler) const {
1392 using compiler::Node; 1410 using compiler::Node;
1393 typedef CodeStubAssembler::Label Label; 1411 typedef CodeStubAssembler::Label Label;
1394 typedef CodeStubAssembler::Variable Variable; 1412 typedef CodeStubAssembler::Variable Variable;
1395 1413
1396 Node* context = assembler->Parameter(2);
1397
1398 // Shared entry point for floating point modulus. 1414 // Shared entry point for floating point modulus.
1399 Label do_fmod(assembler); 1415 Label do_fmod(assembler);
1400 Variable var_dividend_float64(assembler, MachineRepresentation::kFloat64), 1416 Variable var_dividend_float64(assembler, MachineRepresentation::kFloat64),
1401 var_divisor_float64(assembler, MachineRepresentation::kFloat64); 1417 var_divisor_float64(assembler, MachineRepresentation::kFloat64);
1402 1418
1403 Node* number_map = assembler->HeapNumberMapConstant(); 1419 Node* number_map = assembler->HeapNumberMapConstant();
1404 1420
1405 // We might need to loop one or two times due to ToNumber conversions. 1421 // We might need to loop one or two times due to ToNumber conversions.
1406 Variable var_dividend(assembler, MachineRepresentation::kTagged), 1422 Variable var_dividend(assembler, MachineRepresentation::kTagged),
1407 var_divisor(assembler, MachineRepresentation::kTagged); 1423 var_divisor(assembler, MachineRepresentation::kTagged);
1408 Variable* loop_variables[] = {&var_dividend, &var_divisor}; 1424 Variable* loop_variables[] = {&var_dividend, &var_divisor};
1409 Label loop(assembler, 2, loop_variables); 1425 Label loop(assembler, 2, loop_variables);
1410 var_dividend.Bind(assembler->Parameter(0)); 1426 var_dividend.Bind(left);
1411 var_divisor.Bind(assembler->Parameter(1)); 1427 var_divisor.Bind(right);
1412 assembler->Goto(&loop); 1428 assembler->Goto(&loop);
1413 assembler->Bind(&loop); 1429 assembler->Bind(&loop);
1414 { 1430 {
1415 Node* dividend = var_dividend.value(); 1431 Node* dividend = var_dividend.value();
1416 Node* divisor = var_divisor.value(); 1432 Node* divisor = var_divisor.value();
1417 1433
1418 Label dividend_is_smi(assembler), dividend_is_not_smi(assembler); 1434 Label dividend_is_smi(assembler), dividend_is_not_smi(assembler);
1419 assembler->Branch(assembler->WordIsSmi(dividend), &dividend_is_smi, 1435 assembler->Branch(assembler->WordIsSmi(dividend), &dividend_is_smi,
1420 &dividend_is_not_smi); 1436 &dividend_is_not_smi);
1421 1437
(...skipping 26 matching lines...) Expand all
1448 // Convert {dividend} to a double and compute its modulus with the 1464 // Convert {dividend} to a double and compute its modulus with the
1449 // value of {dividend}. 1465 // value of {dividend}.
1450 var_dividend_float64.Bind(assembler->SmiToFloat64(dividend)); 1466 var_dividend_float64.Bind(assembler->SmiToFloat64(dividend));
1451 var_divisor_float64.Bind(assembler->LoadHeapNumberValue(divisor)); 1467 var_divisor_float64.Bind(assembler->LoadHeapNumberValue(divisor));
1452 assembler->Goto(&do_fmod); 1468 assembler->Goto(&do_fmod);
1453 } 1469 }
1454 1470
1455 assembler->Bind(&divisor_is_not_number); 1471 assembler->Bind(&divisor_is_not_number);
1456 { 1472 {
1457 // Convert {divisor} to a number and loop. 1473 // Convert {divisor} to a number and loop.
1458 Callable callable = CodeFactory::NonNumberToNumber(isolate()); 1474 Callable callable =
1475 CodeFactory::NonNumberToNumber(assembler->isolate());
1459 var_divisor.Bind(assembler->CallStub(callable, context, divisor)); 1476 var_divisor.Bind(assembler->CallStub(callable, context, divisor));
1460 assembler->Goto(&loop); 1477 assembler->Goto(&loop);
1461 } 1478 }
1462 } 1479 }
1463 } 1480 }
1464 1481
1465 assembler->Bind(&dividend_is_not_smi); 1482 assembler->Bind(&dividend_is_not_smi);
1466 { 1483 {
1467 Node* dividend_map = assembler->LoadMap(dividend); 1484 Node* dividend_map = assembler->LoadMap(dividend);
1468 1485
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
1503 // Both {dividend} and {divisor} are HeapNumbers. Load their values 1520 // Both {dividend} and {divisor} are HeapNumbers. Load their values
1504 // and compute their modulus. 1521 // and compute their modulus.
1505 var_dividend_float64.Bind(assembler->LoadHeapNumberValue(dividend)); 1522 var_dividend_float64.Bind(assembler->LoadHeapNumberValue(dividend));
1506 var_divisor_float64.Bind(assembler->LoadHeapNumberValue(divisor)); 1523 var_divisor_float64.Bind(assembler->LoadHeapNumberValue(divisor));
1507 assembler->Goto(&do_fmod); 1524 assembler->Goto(&do_fmod);
1508 } 1525 }
1509 1526
1510 assembler->Bind(&divisor_is_not_number); 1527 assembler->Bind(&divisor_is_not_number);
1511 { 1528 {
1512 // Convert {divisor} to a number and loop. 1529 // Convert {divisor} to a number and loop.
1513 Callable callable = CodeFactory::NonNumberToNumber(isolate()); 1530 Callable callable =
1531 CodeFactory::NonNumberToNumber(assembler->isolate());
1514 var_divisor.Bind(assembler->CallStub(callable, context, divisor)); 1532 var_divisor.Bind(assembler->CallStub(callable, context, divisor));
1515 assembler->Goto(&loop); 1533 assembler->Goto(&loop);
1516 } 1534 }
1517 } 1535 }
1518 } 1536 }
1519 1537
1520 assembler->Bind(&dividend_is_not_number); 1538 assembler->Bind(&dividend_is_not_number);
1521 { 1539 {
1522 // Convert {dividend} to a Number and loop. 1540 // Convert {dividend} to a Number and loop.
1523 Callable callable = CodeFactory::NonNumberToNumber(isolate()); 1541 Callable callable =
1542 CodeFactory::NonNumberToNumber(assembler->isolate());
1524 var_dividend.Bind(assembler->CallStub(callable, context, dividend)); 1543 var_dividend.Bind(assembler->CallStub(callable, context, dividend));
1525 assembler->Goto(&loop); 1544 assembler->Goto(&loop);
1526 } 1545 }
1527 } 1546 }
1528 } 1547 }
1529 1548
1530 assembler->Bind(&do_fmod); 1549 assembler->Bind(&do_fmod);
1531 { 1550 {
1532 Node* value = assembler->Float64Mod(var_dividend_float64.value(), 1551 Node* value = assembler->Float64Mod(var_dividend_float64.value(),
1533 var_divisor_float64.value()); 1552 var_divisor_float64.value());
1534 Node* result = assembler->ChangeFloat64ToTagged(value); 1553 Node* result = assembler->ChangeFloat64ToTagged(value);
1535 assembler->Return(result); 1554 return result;
1536 } 1555 }
1537 } 1556 }
1538 1557
1539 void ShiftLeftStub::GenerateAssembly(CodeStubAssembler* assembler) const { 1558 // static
1559 compiler::Node* ShiftLeftStub::Generate(CodeStubAssembler* assembler,
1560 compiler::Node* left,
1561 compiler::Node* right,
1562 compiler::Node* context) {
1540 using compiler::Node; 1563 using compiler::Node;
1541 1564
1542 Node* lhs = assembler->Parameter(0); 1565 Node* lhs_value = assembler->TruncateTaggedToWord32(context, left);
1543 Node* rhs = assembler->Parameter(1); 1566 Node* rhs_value = assembler->TruncateTaggedToWord32(context, right);
1544 Node* context = assembler->Parameter(2);
1545 Node* lhs_value = assembler->TruncateTaggedToWord32(context, lhs);
1546 Node* rhs_value = assembler->TruncateTaggedToWord32(context, rhs);
1547 Node* shift_count = 1567 Node* shift_count =
1548 assembler->Word32And(rhs_value, assembler->Int32Constant(0x1f)); 1568 assembler->Word32And(rhs_value, assembler->Int32Constant(0x1f));
1549 Node* value = assembler->Word32Shl(lhs_value, shift_count); 1569 Node* value = assembler->Word32Shl(lhs_value, shift_count);
1550 Node* result = assembler->ChangeInt32ToTagged(value); 1570 Node* result = assembler->ChangeInt32ToTagged(value);
1551 assembler->Return(result); 1571 return result;
1552 } 1572 }
1553 1573
1554 void ShiftRightStub::GenerateAssembly(CodeStubAssembler* assembler) const { 1574 compiler::Node* ShiftRightStub::Generate(CodeStubAssembler* assembler,
1575 compiler::Node* left,
1576 compiler::Node* right,
1577 compiler::Node* context) {
1555 using compiler::Node; 1578 using compiler::Node;
1556 1579
1557 Node* lhs = assembler->Parameter(0); 1580 Node* lhs_value = assembler->TruncateTaggedToWord32(context, left);
1558 Node* rhs = assembler->Parameter(1); 1581 Node* rhs_value = assembler->TruncateTaggedToWord32(context, right);
1559 Node* context = assembler->Parameter(2);
1560 Node* lhs_value = assembler->TruncateTaggedToWord32(context, lhs);
1561 Node* rhs_value = assembler->TruncateTaggedToWord32(context, rhs);
1562 Node* shift_count = 1582 Node* shift_count =
1563 assembler->Word32And(rhs_value, assembler->Int32Constant(0x1f)); 1583 assembler->Word32And(rhs_value, assembler->Int32Constant(0x1f));
1564 Node* value = assembler->Word32Sar(lhs_value, shift_count); 1584 Node* value = assembler->Word32Sar(lhs_value, shift_count);
1565 Node* result = assembler->ChangeInt32ToTagged(value); 1585 Node* result = assembler->ChangeInt32ToTagged(value);
1566 assembler->Return(result); 1586 return result;
1567 } 1587 }
1568 1588
1569 void ShiftRightLogicalStub::GenerateAssembly( 1589 compiler::Node* ShiftRightLogicalStub::Generate(CodeStubAssembler* assembler,
1570 CodeStubAssembler* assembler) const { 1590 compiler::Node* left,
1591 compiler::Node* right,
1592 compiler::Node* context) {
1571 using compiler::Node; 1593 using compiler::Node;
1572 1594
1573 Node* lhs = assembler->Parameter(0); 1595 Node* lhs_value = assembler->TruncateTaggedToWord32(context, left);
1574 Node* rhs = assembler->Parameter(1); 1596 Node* rhs_value = assembler->TruncateTaggedToWord32(context, right);
1575 Node* context = assembler->Parameter(2);
1576 Node* lhs_value = assembler->TruncateTaggedToWord32(context, lhs);
1577 Node* rhs_value = assembler->TruncateTaggedToWord32(context, rhs);
1578 Node* shift_count = 1597 Node* shift_count =
1579 assembler->Word32And(rhs_value, assembler->Int32Constant(0x1f)); 1598 assembler->Word32And(rhs_value, assembler->Int32Constant(0x1f));
1580 Node* value = assembler->Word32Shr(lhs_value, shift_count); 1599 Node* value = assembler->Word32Shr(lhs_value, shift_count);
1581 Node* result = assembler->ChangeUint32ToTagged(value); 1600 Node* result = assembler->ChangeUint32ToTagged(value);
1582 assembler->Return(result); 1601 return result;
1583 } 1602 }
1584 1603
1585 void BitwiseOrStub::GenerateAssembly(CodeStubAssembler* assembler) const { 1604 compiler::Node* BitwiseAndStub::Generate(CodeStubAssembler* assembler,
1605 compiler::Node* left,
1606 compiler::Node* right,
1607 compiler::Node* context) {
1586 using compiler::Node; 1608 using compiler::Node;
1587 1609
1588 Node* lhs = assembler->Parameter(0); 1610 Node* lhs_value = assembler->TruncateTaggedToWord32(context, left);
1589 Node* rhs = assembler->Parameter(1); 1611 Node* rhs_value = assembler->TruncateTaggedToWord32(context, right);
1590 Node* context = assembler->Parameter(2); 1612 Node* value = assembler->Word32And(lhs_value, rhs_value);
1591 Node* lhs_value = assembler->TruncateTaggedToWord32(context, lhs); 1613 Node* result = assembler->ChangeInt32ToTagged(value);
1592 Node* rhs_value = assembler->TruncateTaggedToWord32(context, rhs); 1614 return result;
1615 }
1616
1617 compiler::Node* BitwiseOrStub::Generate(CodeStubAssembler* assembler,
1618 compiler::Node* left,
1619 compiler::Node* right,
1620 compiler::Node* context) {
1621 using compiler::Node;
1622
1623 Node* lhs_value = assembler->TruncateTaggedToWord32(context, left);
1624 Node* rhs_value = assembler->TruncateTaggedToWord32(context, right);
1593 Node* value = assembler->Word32Or(lhs_value, rhs_value); 1625 Node* value = assembler->Word32Or(lhs_value, rhs_value);
1594 Node* result = assembler->ChangeInt32ToTagged(value); 1626 Node* result = assembler->ChangeInt32ToTagged(value);
1595 assembler->Return(result); 1627 return result;
1596 } 1628 }
1597 1629
1598 void BitwiseXorStub::GenerateAssembly(CodeStubAssembler* assembler) const { 1630 compiler::Node* BitwiseXorStub::Generate(CodeStubAssembler* assembler,
1631 compiler::Node* left,
1632 compiler::Node* right,
1633 compiler::Node* context) {
1599 using compiler::Node; 1634 using compiler::Node;
1600 1635 Node* lhs_value = assembler->TruncateTaggedToWord32(context, left);
1601 Node* lhs = assembler->Parameter(0); 1636 Node* rhs_value = assembler->TruncateTaggedToWord32(context, right);
1602 Node* rhs = assembler->Parameter(1);
1603 Node* context = assembler->Parameter(2);
1604 Node* lhs_value = assembler->TruncateTaggedToWord32(context, lhs);
1605 Node* rhs_value = assembler->TruncateTaggedToWord32(context, rhs);
1606 Node* value = assembler->Word32Xor(lhs_value, rhs_value); 1637 Node* value = assembler->Word32Xor(lhs_value, rhs_value);
1607 Node* result = assembler->ChangeInt32ToTagged(value); 1638 Node* result = assembler->ChangeInt32ToTagged(value);
1608 assembler->Return(result); 1639 return result;
1609 } 1640 }
1610 1641
1611 namespace { 1642 namespace {
1612 1643
1613 enum RelationalComparisonMode { 1644 enum RelationalComparisonMode {
1614 kLessThan, 1645 kLessThan,
1615 kLessThanOrEqual, 1646 kLessThanOrEqual,
1616 kGreaterThan, 1647 kGreaterThan,
1617 kGreaterThanOrEqual 1648 kGreaterThanOrEqual
1618 }; 1649 };
(...skipping 2494 matching lines...) Expand 10 before | Expand all | Expand 10 after
4113 if (type->Is(Type::UntaggedPointer())) { 4144 if (type->Is(Type::UntaggedPointer())) {
4114 return Representation::External(); 4145 return Representation::External();
4115 } 4146 }
4116 4147
4117 DCHECK(!type->Is(Type::Untagged())); 4148 DCHECK(!type->Is(Type::Untagged()));
4118 return Representation::Tagged(); 4149 return Representation::Tagged();
4119 } 4150 }
4120 4151
4121 } // namespace internal 4152 } // namespace internal
4122 } // namespace v8 4153 } // namespace v8
OLDNEW
« no previous file with comments | « src/code-stubs.h ('k') | src/compiler/register-allocator-verifier.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698