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 469 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
480 | 480 |
481 void StringLengthStub::GenerateAssembly(CodeStubAssembler* assembler) const { | 481 void StringLengthStub::GenerateAssembly(CodeStubAssembler* assembler) const { |
482 compiler::Node* value = assembler->Parameter(0); | 482 compiler::Node* value = assembler->Parameter(0); |
483 compiler::Node* string = | 483 compiler::Node* string = |
484 assembler->LoadObjectField(value, JSValue::kValueOffset); | 484 assembler->LoadObjectField(value, JSValue::kValueOffset); |
485 compiler::Node* result = | 485 compiler::Node* result = |
486 assembler->LoadObjectField(string, String::kLengthOffset); | 486 assembler->LoadObjectField(string, String::kLengthOffset); |
487 assembler->Return(result); | 487 assembler->Return(result); |
488 } | 488 } |
489 | 489 |
490 void AddStub::GenerateAssembly(CodeStubAssembler* assembler) const { | 490 // static |
| 491 compiler::Node* AddStub::Generate(CodeStubAssembler* assembler, |
| 492 compiler::Node* left, compiler::Node* right, |
| 493 compiler::Node* context) { |
491 typedef CodeStubAssembler::Label Label; | 494 typedef CodeStubAssembler::Label Label; |
492 typedef compiler::Node Node; | 495 typedef compiler::Node Node; |
493 typedef CodeStubAssembler::Variable Variable; | 496 typedef CodeStubAssembler::Variable Variable; |
494 | 497 |
495 Node* context = assembler->Parameter(2); | |
496 | |
497 // Shared entry for floating point addition. | 498 // Shared entry for floating point addition. |
498 Label do_fadd(assembler); | 499 Label do_fadd(assembler); |
499 Variable var_fadd_lhs(assembler, MachineRepresentation::kFloat64), | 500 Variable var_fadd_lhs(assembler, MachineRepresentation::kFloat64), |
500 var_fadd_rhs(assembler, MachineRepresentation::kFloat64); | 501 var_fadd_rhs(assembler, MachineRepresentation::kFloat64); |
501 | 502 |
502 // We might need to loop several times due to ToPrimitive, ToString and/or | 503 // We might need to loop several times due to ToPrimitive, ToString and/or |
503 // ToNumber conversions. | 504 // ToNumber conversions. |
504 Variable var_lhs(assembler, MachineRepresentation::kTagged), | 505 Variable var_lhs(assembler, MachineRepresentation::kTagged), |
505 var_rhs(assembler, MachineRepresentation::kTagged); | 506 var_rhs(assembler, MachineRepresentation::kTagged), |
| 507 var_result(assembler, MachineRepresentation::kTagged); |
506 Variable* loop_vars[2] = {&var_lhs, &var_rhs}; | 508 Variable* loop_vars[2] = {&var_lhs, &var_rhs}; |
507 Label loop(assembler, 2, loop_vars); | 509 Label loop(assembler, 2, loop_vars), end(assembler), |
508 var_lhs.Bind(assembler->Parameter(0)); | 510 string_add_convert_left(assembler, Label::kDeferred), |
509 var_rhs.Bind(assembler->Parameter(1)); | 511 string_add_convert_right(assembler, Label::kDeferred); |
| 512 var_lhs.Bind(left); |
| 513 var_rhs.Bind(right); |
510 assembler->Goto(&loop); | 514 assembler->Goto(&loop); |
511 assembler->Bind(&loop); | 515 assembler->Bind(&loop); |
512 { | 516 { |
513 // Load the current {lhs} and {rhs} values. | 517 // Load the current {lhs} and {rhs} values. |
514 Node* lhs = var_lhs.value(); | 518 Node* lhs = var_lhs.value(); |
515 Node* rhs = var_rhs.value(); | 519 Node* rhs = var_rhs.value(); |
516 | 520 |
517 // Check if the {lhs} is a Smi or a HeapObject. | 521 // Check if the {lhs} is a Smi or a HeapObject. |
518 Label if_lhsissmi(assembler), if_lhsisnotsmi(assembler); | 522 Label if_lhsissmi(assembler), if_lhsisnotsmi(assembler); |
519 assembler->Branch(assembler->WordIsSmi(lhs), &if_lhsissmi, &if_lhsisnotsmi); | 523 assembler->Branch(assembler->WordIsSmi(lhs), &if_lhsissmi, &if_lhsisnotsmi); |
(...skipping 16 matching lines...) Expand all Loading... |
536 assembler->Branch(overflow, &if_overflow, &if_notoverflow); | 540 assembler->Branch(overflow, &if_overflow, &if_notoverflow); |
537 | 541 |
538 assembler->Bind(&if_overflow); | 542 assembler->Bind(&if_overflow); |
539 { | 543 { |
540 var_fadd_lhs.Bind(assembler->SmiToFloat64(lhs)); | 544 var_fadd_lhs.Bind(assembler->SmiToFloat64(lhs)); |
541 var_fadd_rhs.Bind(assembler->SmiToFloat64(rhs)); | 545 var_fadd_rhs.Bind(assembler->SmiToFloat64(rhs)); |
542 assembler->Goto(&do_fadd); | 546 assembler->Goto(&do_fadd); |
543 } | 547 } |
544 | 548 |
545 assembler->Bind(&if_notoverflow); | 549 assembler->Bind(&if_notoverflow); |
546 assembler->Return(assembler->Projection(0, pair)); | 550 var_result.Bind(assembler->Projection(0, pair)); |
| 551 assembler->Goto(&end); |
547 } | 552 } |
548 | 553 |
549 assembler->Bind(&if_rhsisnotsmi); | 554 assembler->Bind(&if_rhsisnotsmi); |
550 { | 555 { |
551 // Load the map of {rhs}. | 556 // Load the map of {rhs}. |
552 Node* rhs_map = assembler->LoadObjectField(rhs, HeapObject::kMapOffset); | 557 Node* rhs_map = assembler->LoadObjectField(rhs, HeapObject::kMapOffset); |
553 | 558 |
554 // Check if the {rhs} is a HeapNumber. | 559 // Check if the {rhs} is a HeapNumber. |
555 Label if_rhsisnumber(assembler), | 560 Label if_rhsisnumber(assembler), |
556 if_rhsisnotnumber(assembler, Label::kDeferred); | 561 if_rhsisnotnumber(assembler, Label::kDeferred); |
(...skipping 16 matching lines...) Expand all Loading... |
573 // Check if the {rhs} is a String. | 578 // Check if the {rhs} is a String. |
574 Label if_rhsisstring(assembler, Label::kDeferred), | 579 Label if_rhsisstring(assembler, Label::kDeferred), |
575 if_rhsisnotstring(assembler, Label::kDeferred); | 580 if_rhsisnotstring(assembler, Label::kDeferred); |
576 assembler->Branch(assembler->Int32LessThan( | 581 assembler->Branch(assembler->Int32LessThan( |
577 rhs_instance_type, | 582 rhs_instance_type, |
578 assembler->Int32Constant(FIRST_NONSTRING_TYPE)), | 583 assembler->Int32Constant(FIRST_NONSTRING_TYPE)), |
579 &if_rhsisstring, &if_rhsisnotstring); | 584 &if_rhsisstring, &if_rhsisnotstring); |
580 | 585 |
581 assembler->Bind(&if_rhsisstring); | 586 assembler->Bind(&if_rhsisstring); |
582 { | 587 { |
583 // Convert {lhs}, which is a Smi, to a String and concatenate the | 588 var_lhs.Bind(lhs); |
584 // resulting string with the String {rhs}. | 589 var_rhs.Bind(rhs); |
585 Callable callable = CodeFactory::StringAdd( | 590 assembler->Goto(&string_add_convert_left); |
586 assembler->isolate(), STRING_ADD_CONVERT_LEFT, NOT_TENURED); | |
587 assembler->TailCallStub(callable, context, lhs, rhs); | |
588 } | 591 } |
589 | 592 |
590 assembler->Bind(&if_rhsisnotstring); | 593 assembler->Bind(&if_rhsisnotstring); |
591 { | 594 { |
592 // Check if {rhs} is a JSReceiver. | 595 // Check if {rhs} is a JSReceiver. |
593 Label if_rhsisreceiver(assembler, Label::kDeferred), | 596 Label if_rhsisreceiver(assembler, Label::kDeferred), |
594 if_rhsisnotreceiver(assembler, Label::kDeferred); | 597 if_rhsisnotreceiver(assembler, Label::kDeferred); |
595 assembler->Branch( | 598 assembler->Branch( |
596 assembler->Int32LessThanOrEqual( | 599 assembler->Int32LessThanOrEqual( |
597 assembler->Int32Constant(FIRST_JS_RECEIVER_TYPE), | 600 assembler->Int32Constant(FIRST_JS_RECEIVER_TYPE), |
(...skipping 29 matching lines...) Expand all Loading... |
627 | 630 |
628 // Check if {lhs} is a String. | 631 // Check if {lhs} is a String. |
629 Label if_lhsisstring(assembler), if_lhsisnotstring(assembler); | 632 Label if_lhsisstring(assembler), if_lhsisnotstring(assembler); |
630 assembler->Branch(assembler->Int32LessThan( | 633 assembler->Branch(assembler->Int32LessThan( |
631 lhs_instance_type, | 634 lhs_instance_type, |
632 assembler->Int32Constant(FIRST_NONSTRING_TYPE)), | 635 assembler->Int32Constant(FIRST_NONSTRING_TYPE)), |
633 &if_lhsisstring, &if_lhsisnotstring); | 636 &if_lhsisstring, &if_lhsisnotstring); |
634 | 637 |
635 assembler->Bind(&if_lhsisstring); | 638 assembler->Bind(&if_lhsisstring); |
636 { | 639 { |
637 // Convert {rhs} to a String (using the sequence of ToPrimitive with | 640 var_lhs.Bind(lhs); |
638 // no hint followed by ToString) and concatenate the strings. | 641 var_rhs.Bind(rhs); |
639 Callable callable = CodeFactory::StringAdd( | 642 assembler->Goto(&string_add_convert_right); |
640 assembler->isolate(), STRING_ADD_CONVERT_RIGHT, NOT_TENURED); | |
641 assembler->TailCallStub(callable, context, lhs, rhs); | |
642 } | 643 } |
643 | 644 |
644 assembler->Bind(&if_lhsisnotstring); | 645 assembler->Bind(&if_lhsisnotstring); |
645 { | 646 { |
646 // Check if {rhs} is a Smi. | 647 // Check if {rhs} is a Smi. |
647 Label if_rhsissmi(assembler), if_rhsisnotsmi(assembler); | 648 Label if_rhsissmi(assembler), if_rhsisnotsmi(assembler); |
648 assembler->Branch(assembler->WordIsSmi(rhs), &if_rhsissmi, | 649 assembler->Branch(assembler->WordIsSmi(rhs), &if_rhsissmi, |
649 &if_rhsisnotsmi); | 650 &if_rhsisnotsmi); |
650 | 651 |
651 assembler->Bind(&if_rhsissmi); | 652 assembler->Bind(&if_rhsissmi); |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
705 | 706 |
706 // Check if {rhs} is a String. | 707 // Check if {rhs} is a String. |
707 Label if_rhsisstring(assembler), if_rhsisnotstring(assembler); | 708 Label if_rhsisstring(assembler), if_rhsisnotstring(assembler); |
708 assembler->Branch(assembler->Int32LessThan( | 709 assembler->Branch(assembler->Int32LessThan( |
709 rhs_instance_type, | 710 rhs_instance_type, |
710 assembler->Int32Constant(FIRST_NONSTRING_TYPE)), | 711 assembler->Int32Constant(FIRST_NONSTRING_TYPE)), |
711 &if_rhsisstring, &if_rhsisnotstring); | 712 &if_rhsisstring, &if_rhsisnotstring); |
712 | 713 |
713 assembler->Bind(&if_rhsisstring); | 714 assembler->Bind(&if_rhsisstring); |
714 { | 715 { |
715 // Convert {lhs} to a String (using the sequence of ToPrimitive with | 716 var_lhs.Bind(lhs); |
716 // no hint followed by ToString) and concatenate the strings. | 717 var_rhs.Bind(rhs); |
717 Callable callable = CodeFactory::StringAdd( | 718 assembler->Goto(&string_add_convert_left); |
718 assembler->isolate(), STRING_ADD_CONVERT_LEFT, NOT_TENURED); | |
719 assembler->TailCallStub(callable, context, lhs, rhs); | |
720 } | 719 } |
721 | 720 |
722 assembler->Bind(&if_rhsisnotstring); | 721 assembler->Bind(&if_rhsisnotstring); |
723 { | 722 { |
724 // Check if {lhs} is a HeapNumber. | 723 // Check if {lhs} is a HeapNumber. |
725 Label if_lhsisnumber(assembler), if_lhsisnotnumber(assembler); | 724 Label if_lhsisnumber(assembler), if_lhsisnotnumber(assembler); |
726 assembler->Branch(assembler->Word32Equal( | 725 assembler->Branch(assembler->Word32Equal( |
727 lhs_instance_type, | 726 lhs_instance_type, |
728 assembler->Int32Constant(HEAP_NUMBER_TYPE)), | 727 assembler->Int32Constant(HEAP_NUMBER_TYPE)), |
729 &if_lhsisnumber, &if_lhsisnotnumber); | 728 &if_lhsisnumber, &if_lhsisnotnumber); |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
825 var_lhs.Bind(assembler->CallStub(callable, context, lhs)); | 824 var_lhs.Bind(assembler->CallStub(callable, context, lhs)); |
826 assembler->Goto(&loop); | 825 assembler->Goto(&loop); |
827 } | 826 } |
828 } | 827 } |
829 } | 828 } |
830 } | 829 } |
831 } | 830 } |
832 } | 831 } |
833 } | 832 } |
834 } | 833 } |
| 834 assembler->Bind(&string_add_convert_left); |
| 835 { |
| 836 // Convert {lhs}, which is a Smi, to a String and concatenate the |
| 837 // resulting string with the String {rhs}. |
| 838 Callable callable = CodeFactory::StringAdd( |
| 839 assembler->isolate(), STRING_ADD_CONVERT_LEFT, NOT_TENURED); |
| 840 var_result.Bind(assembler->CallStub(callable, context, var_lhs.value(), |
| 841 var_rhs.value())); |
| 842 assembler->Goto(&end); |
| 843 } |
| 844 |
| 845 assembler->Bind(&string_add_convert_right); |
| 846 { |
| 847 // Convert {lhs}, which is a Smi, to a String and concatenate the |
| 848 // resulting string with the String {rhs}. |
| 849 Callable callable = CodeFactory::StringAdd( |
| 850 assembler->isolate(), STRING_ADD_CONVERT_RIGHT, NOT_TENURED); |
| 851 var_result.Bind(assembler->CallStub(callable, context, var_lhs.value(), |
| 852 var_rhs.value())); |
| 853 assembler->Goto(&end); |
| 854 } |
835 | 855 |
836 assembler->Bind(&do_fadd); | 856 assembler->Bind(&do_fadd); |
837 { | 857 { |
838 Node* lhs_value = var_fadd_lhs.value(); | 858 Node* lhs_value = var_fadd_lhs.value(); |
839 Node* rhs_value = var_fadd_rhs.value(); | 859 Node* rhs_value = var_fadd_rhs.value(); |
840 Node* value = assembler->Float64Add(lhs_value, rhs_value); | 860 Node* value = assembler->Float64Add(lhs_value, rhs_value); |
841 Node* result = assembler->ChangeFloat64ToTagged(value); | 861 Node* result = assembler->ChangeFloat64ToTagged(value); |
842 assembler->Return(result); | 862 var_result.Bind(result); |
| 863 assembler->Goto(&end); |
843 } | 864 } |
| 865 assembler->Bind(&end); |
| 866 return var_result.value(); |
844 } | 867 } |
845 | 868 |
846 void SubtractStub::GenerateAssembly(CodeStubAssembler* assembler) const { | 869 // static |
| 870 compiler::Node* SubtractStub::Generate(CodeStubAssembler* assembler, |
| 871 compiler::Node* left, |
| 872 compiler::Node* right, |
| 873 compiler::Node* context) { |
847 typedef CodeStubAssembler::Label Label; | 874 typedef CodeStubAssembler::Label Label; |
848 typedef compiler::Node Node; | 875 typedef compiler::Node Node; |
849 typedef CodeStubAssembler::Variable Variable; | 876 typedef CodeStubAssembler::Variable Variable; |
850 | 877 |
851 Node* context = assembler->Parameter(2); | |
852 | |
853 // Shared entry for floating point subtraction. | 878 // Shared entry for floating point subtraction. |
854 Label do_fsub(assembler); | 879 Label do_fsub(assembler), end(assembler); |
855 Variable var_fsub_lhs(assembler, MachineRepresentation::kFloat64), | 880 Variable var_fsub_lhs(assembler, MachineRepresentation::kFloat64), |
856 var_fsub_rhs(assembler, MachineRepresentation::kFloat64); | 881 var_fsub_rhs(assembler, MachineRepresentation::kFloat64); |
857 | 882 |
858 // We might need to loop several times due to ToPrimitive and/or ToNumber | 883 // We might need to loop several times due to ToPrimitive and/or ToNumber |
859 // conversions. | 884 // conversions. |
860 Variable var_lhs(assembler, MachineRepresentation::kTagged), | 885 Variable var_lhs(assembler, MachineRepresentation::kTagged), |
861 var_rhs(assembler, MachineRepresentation::kTagged); | 886 var_rhs(assembler, MachineRepresentation::kTagged), |
| 887 var_result(assembler, MachineRepresentation::kTagged); |
862 Variable* loop_vars[2] = {&var_lhs, &var_rhs}; | 888 Variable* loop_vars[2] = {&var_lhs, &var_rhs}; |
863 Label loop(assembler, 2, loop_vars); | 889 Label loop(assembler, 2, loop_vars); |
864 var_lhs.Bind(assembler->Parameter(0)); | 890 var_lhs.Bind(left); |
865 var_rhs.Bind(assembler->Parameter(1)); | 891 var_rhs.Bind(right); |
866 assembler->Goto(&loop); | 892 assembler->Goto(&loop); |
867 assembler->Bind(&loop); | 893 assembler->Bind(&loop); |
868 { | 894 { |
869 // Load the current {lhs} and {rhs} values. | 895 // Load the current {lhs} and {rhs} values. |
870 Node* lhs = var_lhs.value(); | 896 Node* lhs = var_lhs.value(); |
871 Node* rhs = var_rhs.value(); | 897 Node* rhs = var_rhs.value(); |
872 | 898 |
873 // Check if the {lhs} is a Smi or a HeapObject. | 899 // Check if the {lhs} is a Smi or a HeapObject. |
874 Label if_lhsissmi(assembler), if_lhsisnotsmi(assembler); | 900 Label if_lhsissmi(assembler), if_lhsisnotsmi(assembler); |
875 assembler->Branch(assembler->WordIsSmi(lhs), &if_lhsissmi, &if_lhsisnotsmi); | 901 assembler->Branch(assembler->WordIsSmi(lhs), &if_lhsissmi, &if_lhsisnotsmi); |
(...skipping 17 matching lines...) Expand all Loading... |
893 | 919 |
894 assembler->Bind(&if_overflow); | 920 assembler->Bind(&if_overflow); |
895 { | 921 { |
896 // The result doesn't fit into Smi range. | 922 // The result doesn't fit into Smi range. |
897 var_fsub_lhs.Bind(assembler->SmiToFloat64(lhs)); | 923 var_fsub_lhs.Bind(assembler->SmiToFloat64(lhs)); |
898 var_fsub_rhs.Bind(assembler->SmiToFloat64(rhs)); | 924 var_fsub_rhs.Bind(assembler->SmiToFloat64(rhs)); |
899 assembler->Goto(&do_fsub); | 925 assembler->Goto(&do_fsub); |
900 } | 926 } |
901 | 927 |
902 assembler->Bind(&if_notoverflow); | 928 assembler->Bind(&if_notoverflow); |
903 assembler->Return(assembler->Projection(0, pair)); | 929 var_result.Bind(assembler->Projection(0, pair)); |
| 930 assembler->Goto(&end); |
904 } | 931 } |
905 | 932 |
906 assembler->Bind(&if_rhsisnotsmi); | 933 assembler->Bind(&if_rhsisnotsmi); |
907 { | 934 { |
908 // Load the map of the {rhs}. | 935 // Load the map of the {rhs}. |
909 Node* rhs_map = assembler->LoadMap(rhs); | 936 Node* rhs_map = assembler->LoadMap(rhs); |
910 | 937 |
911 // Check if {rhs} is a HeapNumber. | 938 // Check if {rhs} is a HeapNumber. |
912 Label if_rhsisnumber(assembler), | 939 Label if_rhsisnumber(assembler), |
913 if_rhsisnotnumber(assembler, Label::kDeferred); | 940 if_rhsisnotnumber(assembler, Label::kDeferred); |
914 Node* number_map = assembler->HeapNumberMapConstant(); | 941 Node* number_map = assembler->HeapNumberMapConstant(); |
915 assembler->Branch(assembler->WordEqual(rhs_map, number_map), | 942 assembler->Branch(assembler->WordEqual(rhs_map, number_map), |
916 &if_rhsisnumber, &if_rhsisnotnumber); | 943 &if_rhsisnumber, &if_rhsisnotnumber); |
917 | 944 |
918 assembler->Bind(&if_rhsisnumber); | 945 assembler->Bind(&if_rhsisnumber); |
919 { | 946 { |
920 // Perform a floating point subtraction. | 947 // Perform a floating point subtraction. |
921 var_fsub_lhs.Bind(assembler->SmiToFloat64(lhs)); | 948 var_fsub_lhs.Bind(assembler->SmiToFloat64(lhs)); |
922 var_fsub_rhs.Bind(assembler->LoadHeapNumberValue(rhs)); | 949 var_fsub_rhs.Bind(assembler->LoadHeapNumberValue(rhs)); |
923 assembler->Goto(&do_fsub); | 950 assembler->Goto(&do_fsub); |
924 } | 951 } |
925 | 952 |
926 assembler->Bind(&if_rhsisnotnumber); | 953 assembler->Bind(&if_rhsisnotnumber); |
927 { | 954 { |
928 // Convert the {rhs} to a Number first. | 955 // Convert the {rhs} to a Number first. |
929 Callable callable = CodeFactory::NonNumberToNumber(isolate()); | 956 Callable callable = |
| 957 CodeFactory::NonNumberToNumber(assembler->isolate()); |
930 var_rhs.Bind(assembler->CallStub(callable, context, rhs)); | 958 var_rhs.Bind(assembler->CallStub(callable, context, rhs)); |
931 assembler->Goto(&loop); | 959 assembler->Goto(&loop); |
932 } | 960 } |
933 } | 961 } |
934 } | 962 } |
935 | 963 |
936 assembler->Bind(&if_lhsisnotsmi); | 964 assembler->Bind(&if_lhsisnotsmi); |
937 { | 965 { |
938 // Load the map of the {lhs}. | 966 // Load the map of the {lhs}. |
939 Node* lhs_map = assembler->LoadMap(lhs); | 967 Node* lhs_map = assembler->LoadMap(lhs); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
975 { | 1003 { |
976 // Perform a floating point subtraction. | 1004 // Perform a floating point subtraction. |
977 var_fsub_lhs.Bind(assembler->LoadHeapNumberValue(lhs)); | 1005 var_fsub_lhs.Bind(assembler->LoadHeapNumberValue(lhs)); |
978 var_fsub_rhs.Bind(assembler->LoadHeapNumberValue(rhs)); | 1006 var_fsub_rhs.Bind(assembler->LoadHeapNumberValue(rhs)); |
979 assembler->Goto(&do_fsub); | 1007 assembler->Goto(&do_fsub); |
980 } | 1008 } |
981 | 1009 |
982 assembler->Bind(&if_rhsisnotnumber); | 1010 assembler->Bind(&if_rhsisnotnumber); |
983 { | 1011 { |
984 // Convert the {rhs} to a Number first. | 1012 // Convert the {rhs} to a Number first. |
985 Callable callable = CodeFactory::NonNumberToNumber(isolate()); | 1013 Callable callable = |
| 1014 CodeFactory::NonNumberToNumber(assembler->isolate()); |
986 var_rhs.Bind(assembler->CallStub(callable, context, rhs)); | 1015 var_rhs.Bind(assembler->CallStub(callable, context, rhs)); |
987 assembler->Goto(&loop); | 1016 assembler->Goto(&loop); |
988 } | 1017 } |
989 } | 1018 } |
990 } | 1019 } |
991 | 1020 |
992 assembler->Bind(&if_lhsisnotnumber); | 1021 assembler->Bind(&if_lhsisnotnumber); |
993 { | 1022 { |
994 // Convert the {lhs} to a Number first. | 1023 // Convert the {lhs} to a Number first. |
995 Callable callable = CodeFactory::NonNumberToNumber(isolate()); | 1024 Callable callable = |
| 1025 CodeFactory::NonNumberToNumber(assembler->isolate()); |
996 var_lhs.Bind(assembler->CallStub(callable, context, lhs)); | 1026 var_lhs.Bind(assembler->CallStub(callable, context, lhs)); |
997 assembler->Goto(&loop); | 1027 assembler->Goto(&loop); |
998 } | 1028 } |
999 } | 1029 } |
1000 } | 1030 } |
1001 | 1031 |
1002 assembler->Bind(&do_fsub); | 1032 assembler->Bind(&do_fsub); |
1003 { | 1033 { |
1004 Node* lhs_value = var_fsub_lhs.value(); | 1034 Node* lhs_value = var_fsub_lhs.value(); |
1005 Node* rhs_value = var_fsub_rhs.value(); | 1035 Node* rhs_value = var_fsub_rhs.value(); |
1006 Node* value = assembler->Float64Sub(lhs_value, rhs_value); | 1036 Node* value = assembler->Float64Sub(lhs_value, rhs_value); |
1007 Node* result = assembler->ChangeFloat64ToTagged(value); | 1037 var_result.Bind(assembler->ChangeFloat64ToTagged(value)); |
1008 assembler->Return(result); | 1038 assembler->Goto(&end); |
1009 } | 1039 } |
| 1040 assembler->Bind(&end); |
| 1041 return var_result.value(); |
1010 } | 1042 } |
1011 | 1043 |
1012 void MultiplyStub::GenerateAssembly(CodeStubAssembler* assembler) const { | 1044 // static |
| 1045 compiler::Node* MultiplyStub::Generate(CodeStubAssembler* assembler, |
| 1046 compiler::Node* left, |
| 1047 compiler::Node* right, |
| 1048 compiler::Node* context) { |
1013 using compiler::Node; | 1049 using compiler::Node; |
1014 typedef CodeStubAssembler::Label Label; | 1050 typedef CodeStubAssembler::Label Label; |
1015 typedef CodeStubAssembler::Variable Variable; | 1051 typedef CodeStubAssembler::Variable Variable; |
1016 | 1052 |
1017 Node* context = assembler->Parameter(2); | |
1018 | |
1019 // Shared entry point for floating point multiplication. | 1053 // Shared entry point for floating point multiplication. |
1020 Label do_fmul(assembler); | 1054 Label do_fmul(assembler); |
1021 Variable var_lhs_float64(assembler, MachineRepresentation::kFloat64), | 1055 Variable var_lhs_float64(assembler, MachineRepresentation::kFloat64), |
1022 var_rhs_float64(assembler, MachineRepresentation::kFloat64); | 1056 var_rhs_float64(assembler, MachineRepresentation::kFloat64); |
1023 | 1057 |
1024 Node* number_map = assembler->HeapNumberMapConstant(); | 1058 Node* number_map = assembler->HeapNumberMapConstant(); |
1025 | 1059 |
1026 // We might need to loop one or two times due to ToNumber conversions. | 1060 // We might need to loop one or two times due to ToNumber conversions. |
1027 Variable var_lhs(assembler, MachineRepresentation::kTagged), | 1061 Variable var_lhs(assembler, MachineRepresentation::kTagged), |
1028 var_rhs(assembler, MachineRepresentation::kTagged); | 1062 var_rhs(assembler, MachineRepresentation::kTagged); |
1029 Variable* loop_variables[] = {&var_lhs, &var_rhs}; | 1063 Variable* loop_variables[] = {&var_lhs, &var_rhs}; |
1030 Label loop(assembler, 2, loop_variables); | 1064 Label loop(assembler, 2, loop_variables); |
1031 var_lhs.Bind(assembler->Parameter(0)); | 1065 var_lhs.Bind(left); |
1032 var_rhs.Bind(assembler->Parameter(1)); | 1066 var_rhs.Bind(right); |
1033 assembler->Goto(&loop); | 1067 assembler->Goto(&loop); |
1034 assembler->Bind(&loop); | 1068 assembler->Bind(&loop); |
1035 { | 1069 { |
1036 Node* lhs = var_lhs.value(); | 1070 Node* lhs = var_lhs.value(); |
1037 Node* rhs = var_rhs.value(); | 1071 Node* rhs = var_rhs.value(); |
1038 | 1072 |
1039 Label lhs_is_smi(assembler), lhs_is_not_smi(assembler); | 1073 Label lhs_is_smi(assembler), lhs_is_not_smi(assembler); |
1040 assembler->Branch(assembler->WordIsSmi(lhs), &lhs_is_smi, &lhs_is_not_smi); | 1074 assembler->Branch(assembler->WordIsSmi(lhs), &lhs_is_smi, &lhs_is_not_smi); |
1041 | 1075 |
1042 assembler->Bind(&lhs_is_smi); | 1076 assembler->Bind(&lhs_is_smi); |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1132 var_lhs.Bind(rhs); | 1166 var_lhs.Bind(rhs); |
1133 var_rhs.Bind(lhs); | 1167 var_rhs.Bind(lhs); |
1134 assembler->Goto(&loop); | 1168 assembler->Goto(&loop); |
1135 } | 1169 } |
1136 } | 1170 } |
1137 } | 1171 } |
1138 | 1172 |
1139 assembler->Bind(&lhs_is_not_number); | 1173 assembler->Bind(&lhs_is_not_number); |
1140 { | 1174 { |
1141 // Convert {lhs} to a Number and loop. | 1175 // Convert {lhs} to a Number and loop. |
1142 Callable callable = CodeFactory::NonNumberToNumber(isolate()); | 1176 Callable callable = |
| 1177 CodeFactory::NonNumberToNumber(assembler->isolate()); |
1143 var_lhs.Bind(assembler->CallStub(callable, context, lhs)); | 1178 var_lhs.Bind(assembler->CallStub(callable, context, lhs)); |
1144 assembler->Goto(&loop); | 1179 assembler->Goto(&loop); |
1145 } | 1180 } |
1146 } | 1181 } |
1147 } | 1182 } |
1148 | 1183 |
1149 assembler->Bind(&do_fmul); | 1184 assembler->Bind(&do_fmul); |
1150 { | 1185 { |
1151 Node* value = | 1186 Node* value = |
1152 assembler->Float64Mul(var_lhs_float64.value(), var_rhs_float64.value()); | 1187 assembler->Float64Mul(var_lhs_float64.value(), var_rhs_float64.value()); |
1153 Node* result = assembler->ChangeFloat64ToTagged(value); | 1188 Node* result = assembler->ChangeFloat64ToTagged(value); |
1154 assembler->Return(result); | 1189 return result; |
1155 } | 1190 } |
1156 } | 1191 } |
1157 | 1192 |
1158 void DivideStub::GenerateAssembly(CodeStubAssembler* assembler) const { | 1193 // static |
| 1194 compiler::Node* DivideStub::Generate(CodeStubAssembler* assembler, |
| 1195 compiler::Node* left, |
| 1196 compiler::Node* right, |
| 1197 compiler::Node* context) { |
1159 using compiler::Node; | 1198 using compiler::Node; |
1160 typedef CodeStubAssembler::Label Label; | 1199 typedef CodeStubAssembler::Label Label; |
1161 typedef CodeStubAssembler::Variable Variable; | 1200 typedef CodeStubAssembler::Variable Variable; |
1162 | 1201 |
1163 Node* context = assembler->Parameter(2); | |
1164 | |
1165 // Shared entry point for floating point division. | 1202 // Shared entry point for floating point division. |
1166 Label do_fdiv(assembler); | 1203 Label do_fdiv(assembler), end(assembler); |
1167 Variable var_dividend_float64(assembler, MachineRepresentation::kFloat64), | 1204 Variable var_dividend_float64(assembler, MachineRepresentation::kFloat64), |
1168 var_divisor_float64(assembler, MachineRepresentation::kFloat64); | 1205 var_divisor_float64(assembler, MachineRepresentation::kFloat64); |
1169 | 1206 |
1170 Node* number_map = assembler->HeapNumberMapConstant(); | 1207 Node* number_map = assembler->HeapNumberMapConstant(); |
1171 | 1208 |
1172 // We might need to loop one or two times due to ToNumber conversions. | 1209 // We might need to loop one or two times due to ToNumber conversions. |
1173 Variable var_dividend(assembler, MachineRepresentation::kTagged), | 1210 Variable var_dividend(assembler, MachineRepresentation::kTagged), |
1174 var_divisor(assembler, MachineRepresentation::kTagged); | 1211 var_divisor(assembler, MachineRepresentation::kTagged), |
| 1212 var_result(assembler, MachineRepresentation::kTagged); |
1175 Variable* loop_variables[] = {&var_dividend, &var_divisor}; | 1213 Variable* loop_variables[] = {&var_dividend, &var_divisor}; |
1176 Label loop(assembler, 2, loop_variables); | 1214 Label loop(assembler, 2, loop_variables); |
1177 var_dividend.Bind(assembler->Parameter(0)); | 1215 var_dividend.Bind(left); |
1178 var_divisor.Bind(assembler->Parameter(1)); | 1216 var_divisor.Bind(right); |
1179 assembler->Goto(&loop); | 1217 assembler->Goto(&loop); |
1180 assembler->Bind(&loop); | 1218 assembler->Bind(&loop); |
1181 { | 1219 { |
1182 Node* dividend = var_dividend.value(); | 1220 Node* dividend = var_dividend.value(); |
1183 Node* divisor = var_divisor.value(); | 1221 Node* divisor = var_divisor.value(); |
1184 | 1222 |
1185 Label dividend_is_smi(assembler), dividend_is_not_smi(assembler); | 1223 Label dividend_is_smi(assembler), dividend_is_not_smi(assembler); |
1186 assembler->Branch(assembler->WordIsSmi(dividend), ÷nd_is_smi, | 1224 assembler->Branch(assembler->WordIsSmi(dividend), ÷nd_is_smi, |
1187 ÷nd_is_not_smi); | 1225 ÷nd_is_not_smi); |
1188 | 1226 |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1242 | 1280 |
1243 // TODO(epertoso): consider adding a machine instruction that returns | 1281 // TODO(epertoso): consider adding a machine instruction that returns |
1244 // both the result and the remainder. | 1282 // both the result and the remainder. |
1245 Node* untagged_result = | 1283 Node* untagged_result = |
1246 assembler->Int32Div(untagged_dividend, untagged_divisor); | 1284 assembler->Int32Div(untagged_dividend, untagged_divisor); |
1247 Node* truncated = | 1285 Node* truncated = |
1248 assembler->IntPtrMul(untagged_result, untagged_divisor); | 1286 assembler->IntPtrMul(untagged_result, untagged_divisor); |
1249 // Do floating point division if the remainder is not 0. | 1287 // Do floating point division if the remainder is not 0. |
1250 assembler->GotoIf( | 1288 assembler->GotoIf( |
1251 assembler->Word32NotEqual(untagged_dividend, truncated), &bailout); | 1289 assembler->Word32NotEqual(untagged_dividend, truncated), &bailout); |
1252 assembler->Return(assembler->SmiTag(untagged_result)); | 1290 var_result.Bind(assembler->SmiTag(untagged_result)); |
| 1291 assembler->Goto(&end); |
1253 | 1292 |
1254 // Bailout: convert {dividend} and {divisor} to double and do double | 1293 // Bailout: convert {dividend} and {divisor} to double and do double |
1255 // division. | 1294 // division. |
1256 assembler->Bind(&bailout); | 1295 assembler->Bind(&bailout); |
1257 { | 1296 { |
1258 var_dividend_float64.Bind(assembler->SmiToFloat64(dividend)); | 1297 var_dividend_float64.Bind(assembler->SmiToFloat64(dividend)); |
1259 var_divisor_float64.Bind(assembler->SmiToFloat64(divisor)); | 1298 var_divisor_float64.Bind(assembler->SmiToFloat64(divisor)); |
1260 assembler->Goto(&do_fdiv); | 1299 assembler->Goto(&do_fdiv); |
1261 } | 1300 } |
1262 } | 1301 } |
(...skipping 13 matching lines...) Expand all Loading... |
1276 // Convert {dividend} to a double and divide it with the value of | 1315 // Convert {dividend} to a double and divide it with the value of |
1277 // {divisor}. | 1316 // {divisor}. |
1278 var_dividend_float64.Bind(assembler->SmiToFloat64(dividend)); | 1317 var_dividend_float64.Bind(assembler->SmiToFloat64(dividend)); |
1279 var_divisor_float64.Bind(assembler->LoadHeapNumberValue(divisor)); | 1318 var_divisor_float64.Bind(assembler->LoadHeapNumberValue(divisor)); |
1280 assembler->Goto(&do_fdiv); | 1319 assembler->Goto(&do_fdiv); |
1281 } | 1320 } |
1282 | 1321 |
1283 assembler->Bind(&divisor_is_not_number); | 1322 assembler->Bind(&divisor_is_not_number); |
1284 { | 1323 { |
1285 // Convert {divisor} to a number and loop. | 1324 // Convert {divisor} to a number and loop. |
1286 Callable callable = CodeFactory::NonNumberToNumber(isolate()); | 1325 Callable callable = |
| 1326 CodeFactory::NonNumberToNumber(assembler->isolate()); |
1287 var_divisor.Bind(assembler->CallStub(callable, context, divisor)); | 1327 var_divisor.Bind(assembler->CallStub(callable, context, divisor)); |
1288 assembler->Goto(&loop); | 1328 assembler->Goto(&loop); |
1289 } | 1329 } |
1290 } | 1330 } |
1291 } | 1331 } |
1292 | 1332 |
1293 assembler->Bind(÷nd_is_not_smi); | 1333 assembler->Bind(÷nd_is_not_smi); |
1294 { | 1334 { |
1295 Node* dividend_map = assembler->LoadMap(dividend); | 1335 Node* dividend_map = assembler->LoadMap(dividend); |
1296 | 1336 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1331 // Both {dividend} and {divisor} are HeapNumbers. Load their values | 1371 // Both {dividend} and {divisor} are HeapNumbers. Load their values |
1332 // and divide them. | 1372 // and divide them. |
1333 var_dividend_float64.Bind(assembler->LoadHeapNumberValue(dividend)); | 1373 var_dividend_float64.Bind(assembler->LoadHeapNumberValue(dividend)); |
1334 var_divisor_float64.Bind(assembler->LoadHeapNumberValue(divisor)); | 1374 var_divisor_float64.Bind(assembler->LoadHeapNumberValue(divisor)); |
1335 assembler->Goto(&do_fdiv); | 1375 assembler->Goto(&do_fdiv); |
1336 } | 1376 } |
1337 | 1377 |
1338 assembler->Bind(&divisor_is_not_number); | 1378 assembler->Bind(&divisor_is_not_number); |
1339 { | 1379 { |
1340 // Convert {divisor} to a number and loop. | 1380 // Convert {divisor} to a number and loop. |
1341 Callable callable = CodeFactory::NonNumberToNumber(isolate()); | 1381 Callable callable = |
| 1382 CodeFactory::NonNumberToNumber(assembler->isolate()); |
1342 var_divisor.Bind(assembler->CallStub(callable, context, divisor)); | 1383 var_divisor.Bind(assembler->CallStub(callable, context, divisor)); |
1343 assembler->Goto(&loop); | 1384 assembler->Goto(&loop); |
1344 } | 1385 } |
1345 } | 1386 } |
1346 } | 1387 } |
1347 | 1388 |
1348 assembler->Bind(÷nd_is_not_number); | 1389 assembler->Bind(÷nd_is_not_number); |
1349 { | 1390 { |
1350 // Convert {dividend} to a Number and loop. | 1391 // Convert {dividend} to a Number and loop. |
1351 Callable callable = CodeFactory::NonNumberToNumber(isolate()); | 1392 Callable callable = |
| 1393 CodeFactory::NonNumberToNumber(assembler->isolate()); |
1352 var_dividend.Bind(assembler->CallStub(callable, context, dividend)); | 1394 var_dividend.Bind(assembler->CallStub(callable, context, dividend)); |
1353 assembler->Goto(&loop); | 1395 assembler->Goto(&loop); |
1354 } | 1396 } |
1355 } | 1397 } |
1356 } | 1398 } |
1357 | 1399 |
1358 assembler->Bind(&do_fdiv); | 1400 assembler->Bind(&do_fdiv); |
1359 { | 1401 { |
1360 Node* value = assembler->Float64Div(var_dividend_float64.value(), | 1402 Node* value = assembler->Float64Div(var_dividend_float64.value(), |
1361 var_divisor_float64.value()); | 1403 var_divisor_float64.value()); |
1362 Node* result = assembler->ChangeFloat64ToTagged(value); | 1404 var_result.Bind(assembler->ChangeFloat64ToTagged(value)); |
1363 assembler->Return(result); | 1405 assembler->Goto(&end); |
1364 } | 1406 } |
| 1407 assembler->Bind(&end); |
| 1408 return var_result.value(); |
1365 } | 1409 } |
1366 | 1410 |
1367 void BitwiseAndStub::GenerateAssembly(CodeStubAssembler* assembler) const { | 1411 // static |
1368 using compiler::Node; | 1412 compiler::Node* ModulusStub::Generate(CodeStubAssembler* assembler, |
1369 | 1413 compiler::Node* left, |
1370 Node* lhs = assembler->Parameter(0); | 1414 compiler::Node* right, |
1371 Node* rhs = assembler->Parameter(1); | 1415 compiler::Node* context) { |
1372 Node* context = assembler->Parameter(2); | |
1373 Node* lhs_value = assembler->TruncateTaggedToWord32(context, lhs); | |
1374 Node* rhs_value = assembler->TruncateTaggedToWord32(context, rhs); | |
1375 Node* value = assembler->Word32And(lhs_value, rhs_value); | |
1376 Node* result = assembler->ChangeInt32ToTagged(value); | |
1377 assembler->Return(result); | |
1378 } | |
1379 | |
1380 void ModulusStub::GenerateAssembly(CodeStubAssembler* assembler) const { | |
1381 using compiler::Node; | 1416 using compiler::Node; |
1382 typedef CodeStubAssembler::Label Label; | 1417 typedef CodeStubAssembler::Label Label; |
1383 typedef CodeStubAssembler::Variable Variable; | 1418 typedef CodeStubAssembler::Variable Variable; |
1384 | 1419 |
1385 Node* context = assembler->Parameter(2); | |
1386 | |
1387 // Shared entry point for floating point modulus. | 1420 // Shared entry point for floating point modulus. |
1388 Label do_fmod(assembler); | 1421 Label do_fmod(assembler); |
1389 Variable var_dividend_float64(assembler, MachineRepresentation::kFloat64), | 1422 Variable var_dividend_float64(assembler, MachineRepresentation::kFloat64), |
1390 var_divisor_float64(assembler, MachineRepresentation::kFloat64); | 1423 var_divisor_float64(assembler, MachineRepresentation::kFloat64); |
1391 | 1424 |
1392 Node* number_map = assembler->HeapNumberMapConstant(); | 1425 Node* number_map = assembler->HeapNumberMapConstant(); |
1393 | 1426 |
1394 // We might need to loop one or two times due to ToNumber conversions. | 1427 // We might need to loop one or two times due to ToNumber conversions. |
1395 Variable var_dividend(assembler, MachineRepresentation::kTagged), | 1428 Variable var_dividend(assembler, MachineRepresentation::kTagged), |
1396 var_divisor(assembler, MachineRepresentation::kTagged); | 1429 var_divisor(assembler, MachineRepresentation::kTagged); |
1397 Variable* loop_variables[] = {&var_dividend, &var_divisor}; | 1430 Variable* loop_variables[] = {&var_dividend, &var_divisor}; |
1398 Label loop(assembler, 2, loop_variables); | 1431 Label loop(assembler, 2, loop_variables); |
1399 var_dividend.Bind(assembler->Parameter(0)); | 1432 var_dividend.Bind(left); |
1400 var_divisor.Bind(assembler->Parameter(1)); | 1433 var_divisor.Bind(right); |
1401 assembler->Goto(&loop); | 1434 assembler->Goto(&loop); |
1402 assembler->Bind(&loop); | 1435 assembler->Bind(&loop); |
1403 { | 1436 { |
1404 Node* dividend = var_dividend.value(); | 1437 Node* dividend = var_dividend.value(); |
1405 Node* divisor = var_divisor.value(); | 1438 Node* divisor = var_divisor.value(); |
1406 | 1439 |
1407 Label dividend_is_smi(assembler), dividend_is_not_smi(assembler); | 1440 Label dividend_is_smi(assembler), dividend_is_not_smi(assembler); |
1408 assembler->Branch(assembler->WordIsSmi(dividend), ÷nd_is_smi, | 1441 assembler->Branch(assembler->WordIsSmi(dividend), ÷nd_is_smi, |
1409 ÷nd_is_not_smi); | 1442 ÷nd_is_not_smi); |
1410 | 1443 |
(...skipping 26 matching lines...) Expand all Loading... |
1437 // Convert {dividend} to a double and compute its modulus with the | 1470 // Convert {dividend} to a double and compute its modulus with the |
1438 // value of {dividend}. | 1471 // value of {dividend}. |
1439 var_dividend_float64.Bind(assembler->SmiToFloat64(dividend)); | 1472 var_dividend_float64.Bind(assembler->SmiToFloat64(dividend)); |
1440 var_divisor_float64.Bind(assembler->LoadHeapNumberValue(divisor)); | 1473 var_divisor_float64.Bind(assembler->LoadHeapNumberValue(divisor)); |
1441 assembler->Goto(&do_fmod); | 1474 assembler->Goto(&do_fmod); |
1442 } | 1475 } |
1443 | 1476 |
1444 assembler->Bind(&divisor_is_not_number); | 1477 assembler->Bind(&divisor_is_not_number); |
1445 { | 1478 { |
1446 // Convert {divisor} to a number and loop. | 1479 // Convert {divisor} to a number and loop. |
1447 Callable callable = CodeFactory::NonNumberToNumber(isolate()); | 1480 Callable callable = |
| 1481 CodeFactory::NonNumberToNumber(assembler->isolate()); |
1448 var_divisor.Bind(assembler->CallStub(callable, context, divisor)); | 1482 var_divisor.Bind(assembler->CallStub(callable, context, divisor)); |
1449 assembler->Goto(&loop); | 1483 assembler->Goto(&loop); |
1450 } | 1484 } |
1451 } | 1485 } |
1452 } | 1486 } |
1453 | 1487 |
1454 assembler->Bind(÷nd_is_not_smi); | 1488 assembler->Bind(÷nd_is_not_smi); |
1455 { | 1489 { |
1456 Node* dividend_map = assembler->LoadMap(dividend); | 1490 Node* dividend_map = assembler->LoadMap(dividend); |
1457 | 1491 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1492 // Both {dividend} and {divisor} are HeapNumbers. Load their values | 1526 // Both {dividend} and {divisor} are HeapNumbers. Load their values |
1493 // and compute their modulus. | 1527 // and compute their modulus. |
1494 var_dividend_float64.Bind(assembler->LoadHeapNumberValue(dividend)); | 1528 var_dividend_float64.Bind(assembler->LoadHeapNumberValue(dividend)); |
1495 var_divisor_float64.Bind(assembler->LoadHeapNumberValue(divisor)); | 1529 var_divisor_float64.Bind(assembler->LoadHeapNumberValue(divisor)); |
1496 assembler->Goto(&do_fmod); | 1530 assembler->Goto(&do_fmod); |
1497 } | 1531 } |
1498 | 1532 |
1499 assembler->Bind(&divisor_is_not_number); | 1533 assembler->Bind(&divisor_is_not_number); |
1500 { | 1534 { |
1501 // Convert {divisor} to a number and loop. | 1535 // Convert {divisor} to a number and loop. |
1502 Callable callable = CodeFactory::NonNumberToNumber(isolate()); | 1536 Callable callable = |
| 1537 CodeFactory::NonNumberToNumber(assembler->isolate()); |
1503 var_divisor.Bind(assembler->CallStub(callable, context, divisor)); | 1538 var_divisor.Bind(assembler->CallStub(callable, context, divisor)); |
1504 assembler->Goto(&loop); | 1539 assembler->Goto(&loop); |
1505 } | 1540 } |
1506 } | 1541 } |
1507 } | 1542 } |
1508 | 1543 |
1509 assembler->Bind(÷nd_is_not_number); | 1544 assembler->Bind(÷nd_is_not_number); |
1510 { | 1545 { |
1511 // Convert {dividend} to a Number and loop. | 1546 // Convert {dividend} to a Number and loop. |
1512 Callable callable = CodeFactory::NonNumberToNumber(isolate()); | 1547 Callable callable = |
| 1548 CodeFactory::NonNumberToNumber(assembler->isolate()); |
1513 var_dividend.Bind(assembler->CallStub(callable, context, dividend)); | 1549 var_dividend.Bind(assembler->CallStub(callable, context, dividend)); |
1514 assembler->Goto(&loop); | 1550 assembler->Goto(&loop); |
1515 } | 1551 } |
1516 } | 1552 } |
1517 } | 1553 } |
1518 | 1554 |
1519 assembler->Bind(&do_fmod); | 1555 assembler->Bind(&do_fmod); |
1520 { | 1556 { |
1521 Node* value = assembler->Float64Mod(var_dividend_float64.value(), | 1557 Node* value = assembler->Float64Mod(var_dividend_float64.value(), |
1522 var_divisor_float64.value()); | 1558 var_divisor_float64.value()); |
1523 Node* result = assembler->ChangeFloat64ToTagged(value); | 1559 Node* result = assembler->ChangeFloat64ToTagged(value); |
1524 assembler->Return(result); | 1560 return result; |
1525 } | 1561 } |
1526 } | 1562 } |
1527 | 1563 |
1528 void ShiftLeftStub::GenerateAssembly(CodeStubAssembler* assembler) const { | 1564 // static |
| 1565 compiler::Node* ShiftLeftStub::Generate(CodeStubAssembler* assembler, |
| 1566 compiler::Node* left, |
| 1567 compiler::Node* right, |
| 1568 compiler::Node* context) { |
1529 using compiler::Node; | 1569 using compiler::Node; |
1530 | 1570 |
1531 Node* lhs = assembler->Parameter(0); | 1571 Node* lhs_value = assembler->TruncateTaggedToWord32(context, left); |
1532 Node* rhs = assembler->Parameter(1); | 1572 Node* rhs_value = assembler->TruncateTaggedToWord32(context, right); |
1533 Node* context = assembler->Parameter(2); | |
1534 Node* lhs_value = assembler->TruncateTaggedToWord32(context, lhs); | |
1535 Node* rhs_value = assembler->TruncateTaggedToWord32(context, rhs); | |
1536 Node* shift_count = | 1573 Node* shift_count = |
1537 assembler->Word32And(rhs_value, assembler->Int32Constant(0x1f)); | 1574 assembler->Word32And(rhs_value, assembler->Int32Constant(0x1f)); |
1538 Node* value = assembler->Word32Shl(lhs_value, shift_count); | 1575 Node* value = assembler->Word32Shl(lhs_value, shift_count); |
1539 Node* result = assembler->ChangeInt32ToTagged(value); | 1576 Node* result = assembler->ChangeInt32ToTagged(value); |
1540 assembler->Return(result); | 1577 return result; |
1541 } | 1578 } |
1542 | 1579 |
1543 void ShiftRightStub::GenerateAssembly(CodeStubAssembler* assembler) const { | 1580 // static |
| 1581 compiler::Node* ShiftRightStub::Generate(CodeStubAssembler* assembler, |
| 1582 compiler::Node* left, |
| 1583 compiler::Node* right, |
| 1584 compiler::Node* context) { |
1544 using compiler::Node; | 1585 using compiler::Node; |
1545 | 1586 |
1546 Node* lhs = assembler->Parameter(0); | 1587 Node* lhs_value = assembler->TruncateTaggedToWord32(context, left); |
1547 Node* rhs = assembler->Parameter(1); | 1588 Node* rhs_value = assembler->TruncateTaggedToWord32(context, right); |
1548 Node* context = assembler->Parameter(2); | |
1549 Node* lhs_value = assembler->TruncateTaggedToWord32(context, lhs); | |
1550 Node* rhs_value = assembler->TruncateTaggedToWord32(context, rhs); | |
1551 Node* shift_count = | 1589 Node* shift_count = |
1552 assembler->Word32And(rhs_value, assembler->Int32Constant(0x1f)); | 1590 assembler->Word32And(rhs_value, assembler->Int32Constant(0x1f)); |
1553 Node* value = assembler->Word32Sar(lhs_value, shift_count); | 1591 Node* value = assembler->Word32Sar(lhs_value, shift_count); |
1554 Node* result = assembler->ChangeInt32ToTagged(value); | 1592 Node* result = assembler->ChangeInt32ToTagged(value); |
1555 assembler->Return(result); | 1593 return result; |
1556 } | 1594 } |
1557 | 1595 |
1558 void ShiftRightLogicalStub::GenerateAssembly( | 1596 // static |
1559 CodeStubAssembler* assembler) const { | 1597 compiler::Node* ShiftRightLogicalStub::Generate(CodeStubAssembler* assembler, |
| 1598 compiler::Node* left, |
| 1599 compiler::Node* right, |
| 1600 compiler::Node* context) { |
1560 using compiler::Node; | 1601 using compiler::Node; |
1561 | 1602 |
1562 Node* lhs = assembler->Parameter(0); | 1603 Node* lhs_value = assembler->TruncateTaggedToWord32(context, left); |
1563 Node* rhs = assembler->Parameter(1); | 1604 Node* rhs_value = assembler->TruncateTaggedToWord32(context, right); |
1564 Node* context = assembler->Parameter(2); | |
1565 Node* lhs_value = assembler->TruncateTaggedToWord32(context, lhs); | |
1566 Node* rhs_value = assembler->TruncateTaggedToWord32(context, rhs); | |
1567 Node* shift_count = | 1605 Node* shift_count = |
1568 assembler->Word32And(rhs_value, assembler->Int32Constant(0x1f)); | 1606 assembler->Word32And(rhs_value, assembler->Int32Constant(0x1f)); |
1569 Node* value = assembler->Word32Shr(lhs_value, shift_count); | 1607 Node* value = assembler->Word32Shr(lhs_value, shift_count); |
1570 Node* result = assembler->ChangeUint32ToTagged(value); | 1608 Node* result = assembler->ChangeUint32ToTagged(value); |
1571 assembler->Return(result); | 1609 return result; |
1572 } | 1610 } |
1573 | 1611 |
1574 void BitwiseOrStub::GenerateAssembly(CodeStubAssembler* assembler) const { | 1612 // static |
| 1613 compiler::Node* BitwiseAndStub::Generate(CodeStubAssembler* assembler, |
| 1614 compiler::Node* left, |
| 1615 compiler::Node* right, |
| 1616 compiler::Node* context) { |
1575 using compiler::Node; | 1617 using compiler::Node; |
1576 | 1618 |
1577 Node* lhs = assembler->Parameter(0); | 1619 Node* lhs_value = assembler->TruncateTaggedToWord32(context, left); |
1578 Node* rhs = assembler->Parameter(1); | 1620 Node* rhs_value = assembler->TruncateTaggedToWord32(context, right); |
1579 Node* context = assembler->Parameter(2); | 1621 Node* value = assembler->Word32And(lhs_value, rhs_value); |
1580 Node* lhs_value = assembler->TruncateTaggedToWord32(context, lhs); | 1622 Node* result = assembler->ChangeInt32ToTagged(value); |
1581 Node* rhs_value = assembler->TruncateTaggedToWord32(context, rhs); | 1623 return result; |
| 1624 } |
| 1625 |
| 1626 // static |
| 1627 compiler::Node* BitwiseOrStub::Generate(CodeStubAssembler* assembler, |
| 1628 compiler::Node* left, |
| 1629 compiler::Node* right, |
| 1630 compiler::Node* context) { |
| 1631 using compiler::Node; |
| 1632 |
| 1633 Node* lhs_value = assembler->TruncateTaggedToWord32(context, left); |
| 1634 Node* rhs_value = assembler->TruncateTaggedToWord32(context, right); |
1582 Node* value = assembler->Word32Or(lhs_value, rhs_value); | 1635 Node* value = assembler->Word32Or(lhs_value, rhs_value); |
1583 Node* result = assembler->ChangeInt32ToTagged(value); | 1636 Node* result = assembler->ChangeInt32ToTagged(value); |
1584 assembler->Return(result); | 1637 return result; |
1585 } | 1638 } |
1586 | 1639 |
1587 void BitwiseXorStub::GenerateAssembly(CodeStubAssembler* assembler) const { | 1640 // static |
| 1641 compiler::Node* BitwiseXorStub::Generate(CodeStubAssembler* assembler, |
| 1642 compiler::Node* left, |
| 1643 compiler::Node* right, |
| 1644 compiler::Node* context) { |
1588 using compiler::Node; | 1645 using compiler::Node; |
1589 | 1646 |
1590 Node* lhs = assembler->Parameter(0); | 1647 Node* lhs_value = assembler->TruncateTaggedToWord32(context, left); |
1591 Node* rhs = assembler->Parameter(1); | 1648 Node* rhs_value = assembler->TruncateTaggedToWord32(context, right); |
1592 Node* context = assembler->Parameter(2); | |
1593 Node* lhs_value = assembler->TruncateTaggedToWord32(context, lhs); | |
1594 Node* rhs_value = assembler->TruncateTaggedToWord32(context, rhs); | |
1595 Node* value = assembler->Word32Xor(lhs_value, rhs_value); | 1649 Node* value = assembler->Word32Xor(lhs_value, rhs_value); |
1596 Node* result = assembler->ChangeInt32ToTagged(value); | 1650 Node* result = assembler->ChangeInt32ToTagged(value); |
1597 assembler->Return(result); | 1651 return result; |
1598 } | 1652 } |
1599 | 1653 |
1600 void IncStub::GenerateAssembly(CodeStubAssembler* assembler) const { | 1654 void IncStub::GenerateAssembly(CodeStubAssembler* assembler) const { |
1601 typedef CodeStubAssembler::Label Label; | 1655 typedef CodeStubAssembler::Label Label; |
1602 typedef compiler::Node Node; | 1656 typedef compiler::Node Node; |
1603 typedef CodeStubAssembler::Variable Variable; | 1657 typedef CodeStubAssembler::Variable Variable; |
1604 | 1658 |
1605 Node* context = assembler->Parameter(1); | 1659 Node* context = assembler->Parameter(1); |
1606 | 1660 |
1607 // Shared entry for floating point increment. | 1661 // Shared entry for floating point increment. |
(...skipping 2820 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4428 if (type->Is(Type::UntaggedPointer())) { | 4482 if (type->Is(Type::UntaggedPointer())) { |
4429 return Representation::External(); | 4483 return Representation::External(); |
4430 } | 4484 } |
4431 | 4485 |
4432 DCHECK(!type->Is(Type::Untagged())); | 4486 DCHECK(!type->Is(Type::Untagged())); |
4433 return Representation::Tagged(); | 4487 return Representation::Tagged(); |
4434 } | 4488 } |
4435 | 4489 |
4436 } // namespace internal | 4490 } // namespace internal |
4437 } // namespace v8 | 4491 } // namespace v8 |
OLD | NEW |