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

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

Issue 2152693002: [stubs] Introduce NonPrimitiveToPrimitive builtin. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Address comments. Created 4 years, 5 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-factory.cc ('k') | src/compiler/code-assembler.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 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 601 matching lines...) Expand 10 before | Expand all | Expand 10 after
612 if_rhsisnotreceiver(assembler, Label::kDeferred); 612 if_rhsisnotreceiver(assembler, Label::kDeferred);
613 assembler->Branch( 613 assembler->Branch(
614 assembler->Int32LessThanOrEqual( 614 assembler->Int32LessThanOrEqual(
615 assembler->Int32Constant(FIRST_JS_RECEIVER_TYPE), 615 assembler->Int32Constant(FIRST_JS_RECEIVER_TYPE),
616 rhs_instance_type), 616 rhs_instance_type),
617 &if_rhsisreceiver, &if_rhsisnotreceiver); 617 &if_rhsisreceiver, &if_rhsisnotreceiver);
618 618
619 assembler->Bind(&if_rhsisreceiver); 619 assembler->Bind(&if_rhsisreceiver);
620 { 620 {
621 // Convert {rhs} to a primitive first passing no hint. 621 // Convert {rhs} to a primitive first passing no hint.
622 // TODO(bmeurer): Hook up ToPrimitiveStub here, once it's there. 622 Callable callable =
623 var_rhs.Bind( 623 CodeFactory::NonPrimitiveToPrimitive(assembler->isolate());
624 assembler->CallRuntime(Runtime::kToPrimitive, context, rhs)); 624 var_rhs.Bind(assembler->CallStub(callable, context, rhs));
625 assembler->Goto(&loop); 625 assembler->Goto(&loop);
626 } 626 }
627 627
628 assembler->Bind(&if_rhsisnotreceiver); 628 assembler->Bind(&if_rhsisnotreceiver);
629 { 629 {
630 // Convert {rhs} to a Number first. 630 // Convert {rhs} to a Number first.
631 Callable callable = 631 Callable callable =
632 CodeFactory::NonNumberToNumber(assembler->isolate()); 632 CodeFactory::NonNumberToNumber(assembler->isolate());
633 var_rhs.Bind(assembler->CallStub(callable, context, rhs)); 633 var_rhs.Bind(assembler->CallStub(callable, context, rhs));
634 assembler->Goto(&loop); 634 assembler->Goto(&loop);
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
690 if_lhsisnotreceiver(assembler, Label::kDeferred); 690 if_lhsisnotreceiver(assembler, Label::kDeferred);
691 assembler->Branch( 691 assembler->Branch(
692 assembler->Int32LessThanOrEqual( 692 assembler->Int32LessThanOrEqual(
693 assembler->Int32Constant(FIRST_JS_RECEIVER_TYPE), 693 assembler->Int32Constant(FIRST_JS_RECEIVER_TYPE),
694 lhs_instance_type), 694 lhs_instance_type),
695 &if_lhsisreceiver, &if_lhsisnotreceiver); 695 &if_lhsisreceiver, &if_lhsisnotreceiver);
696 696
697 assembler->Bind(&if_lhsisreceiver); 697 assembler->Bind(&if_lhsisreceiver);
698 { 698 {
699 // Convert {lhs} to a primitive first passing no hint. 699 // Convert {lhs} to a primitive first passing no hint.
700 // TODO(bmeurer): Hook up ToPrimitiveStub here, once it's there. 700 Callable callable =
701 var_lhs.Bind( 701 CodeFactory::NonPrimitiveToPrimitive(assembler->isolate());
702 assembler->CallRuntime(Runtime::kToPrimitive, context, lhs)); 702 var_lhs.Bind(assembler->CallStub(callable, context, lhs));
703 assembler->Goto(&loop); 703 assembler->Goto(&loop);
704 } 704 }
705 705
706 assembler->Bind(&if_lhsisnotreceiver); 706 assembler->Bind(&if_lhsisnotreceiver);
707 { 707 {
708 // Convert {lhs} to a Number first. 708 // Convert {lhs} to a Number first.
709 Callable callable = 709 Callable callable =
710 CodeFactory::NonNumberToNumber(assembler->isolate()); 710 CodeFactory::NonNumberToNumber(assembler->isolate());
711 var_lhs.Bind(assembler->CallStub(callable, context, lhs)); 711 var_lhs.Bind(assembler->CallStub(callable, context, lhs));
712 assembler->Goto(&loop); 712 assembler->Goto(&loop);
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
767 if_rhsisnotreceiver(assembler, Label::kDeferred); 767 if_rhsisnotreceiver(assembler, Label::kDeferred);
768 assembler->Branch( 768 assembler->Branch(
769 assembler->Int32LessThanOrEqual( 769 assembler->Int32LessThanOrEqual(
770 assembler->Int32Constant(FIRST_JS_RECEIVER_TYPE), 770 assembler->Int32Constant(FIRST_JS_RECEIVER_TYPE),
771 rhs_instance_type), 771 rhs_instance_type),
772 &if_rhsisreceiver, &if_rhsisnotreceiver); 772 &if_rhsisreceiver, &if_rhsisnotreceiver);
773 773
774 assembler->Bind(&if_rhsisreceiver); 774 assembler->Bind(&if_rhsisreceiver);
775 { 775 {
776 // Convert {rhs} to a primitive first passing no hint. 776 // Convert {rhs} to a primitive first passing no hint.
777 // TODO(bmeurer): Hook up ToPrimitiveStub here too. 777 Callable callable = CodeFactory::NonPrimitiveToPrimitive(
778 var_rhs.Bind(assembler->CallRuntime(Runtime::kToPrimitive, 778 assembler->isolate());
779 context, rhs)); 779 var_rhs.Bind(assembler->CallStub(callable, context, rhs));
780 assembler->Goto(&loop); 780 assembler->Goto(&loop);
781 } 781 }
782 782
783 assembler->Bind(&if_rhsisnotreceiver); 783 assembler->Bind(&if_rhsisnotreceiver);
784 { 784 {
785 // Convert {rhs} to a Number first. 785 // Convert {rhs} to a Number first.
786 Callable callable = 786 Callable callable =
787 CodeFactory::NonNumberToNumber(assembler->isolate()); 787 CodeFactory::NonNumberToNumber(assembler->isolate());
788 var_rhs.Bind(assembler->CallStub(callable, context, rhs)); 788 var_rhs.Bind(assembler->CallStub(callable, context, rhs));
789 assembler->Goto(&loop); 789 assembler->Goto(&loop);
790 } 790 }
791 } 791 }
792 } 792 }
793 793
794 assembler->Bind(&if_lhsisnotnumber); 794 assembler->Bind(&if_lhsisnotnumber);
795 { 795 {
796 // Check if {lhs} is a JSReceiver. 796 // Check if {lhs} is a JSReceiver.
797 Label if_lhsisreceiver(assembler, Label::kDeferred), 797 Label if_lhsisreceiver(assembler, Label::kDeferred),
798 if_lhsisnotreceiver(assembler); 798 if_lhsisnotreceiver(assembler);
799 assembler->Branch( 799 assembler->Branch(
800 assembler->Int32LessThanOrEqual( 800 assembler->Int32LessThanOrEqual(
801 assembler->Int32Constant(FIRST_JS_RECEIVER_TYPE), 801 assembler->Int32Constant(FIRST_JS_RECEIVER_TYPE),
802 lhs_instance_type), 802 lhs_instance_type),
803 &if_lhsisreceiver, &if_lhsisnotreceiver); 803 &if_lhsisreceiver, &if_lhsisnotreceiver);
804 804
805 assembler->Bind(&if_lhsisreceiver); 805 assembler->Bind(&if_lhsisreceiver);
806 { 806 {
807 // Convert {lhs} to a primitive first passing no hint. 807 // Convert {lhs} to a primitive first passing no hint.
808 // TODO(bmeurer): Hook up ToPrimitiveStub here, once it's there. 808 Callable callable =
809 var_lhs.Bind(assembler->CallRuntime(Runtime::kToPrimitive, 809 CodeFactory::NonPrimitiveToPrimitive(assembler->isolate());
810 context, lhs)); 810 var_lhs.Bind(assembler->CallStub(callable, context, lhs));
811 assembler->Goto(&loop); 811 assembler->Goto(&loop);
812 } 812 }
813 813
814 assembler->Bind(&if_lhsisnotreceiver); 814 assembler->Bind(&if_lhsisnotreceiver);
815 { 815 {
816 // Check if {rhs} is a JSReceiver. 816 // Check if {rhs} is a JSReceiver.
817 Label if_rhsisreceiver(assembler, Label::kDeferred), 817 Label if_rhsisreceiver(assembler, Label::kDeferred),
818 if_rhsisnotreceiver(assembler, Label::kDeferred); 818 if_rhsisnotreceiver(assembler, Label::kDeferred);
819 assembler->Branch( 819 assembler->Branch(
820 assembler->Int32LessThanOrEqual( 820 assembler->Int32LessThanOrEqual(
821 assembler->Int32Constant(FIRST_JS_RECEIVER_TYPE), 821 assembler->Int32Constant(FIRST_JS_RECEIVER_TYPE),
822 rhs_instance_type), 822 rhs_instance_type),
823 &if_rhsisreceiver, &if_rhsisnotreceiver); 823 &if_rhsisreceiver, &if_rhsisnotreceiver);
824 824
825 assembler->Bind(&if_rhsisreceiver); 825 assembler->Bind(&if_rhsisreceiver);
826 { 826 {
827 // Convert {rhs} to a primitive first passing no hint. 827 // Convert {rhs} to a primitive first passing no hint.
828 // TODO(bmeurer): Hook up ToPrimitiveStub here too. 828 Callable callable = CodeFactory::NonPrimitiveToPrimitive(
829 var_rhs.Bind(assembler->CallRuntime(Runtime::kToPrimitive, 829 assembler->isolate());
830 context, rhs)); 830 var_rhs.Bind(assembler->CallStub(callable, context, rhs));
831 assembler->Goto(&loop); 831 assembler->Goto(&loop);
832 } 832 }
833 833
834 assembler->Bind(&if_rhsisnotreceiver); 834 assembler->Bind(&if_rhsisnotreceiver);
835 { 835 {
836 // Convert {lhs} to a Number first. 836 // Convert {lhs} to a Number first.
837 Callable callable = 837 Callable callable =
838 CodeFactory::NonNumberToNumber(assembler->isolate()); 838 CodeFactory::NonNumberToNumber(assembler->isolate());
839 var_lhs.Bind(assembler->CallStub(callable, context, lhs)); 839 var_lhs.Bind(assembler->CallStub(callable, context, lhs));
840 assembler->Goto(&loop); 840 assembler->Goto(&loop);
(...skipping 1363 matching lines...) Expand 10 before | Expand all | Expand 10 after
2204 if_rhsisnotreceiver(assembler, Label::kDeferred); 2204 if_rhsisnotreceiver(assembler, Label::kDeferred);
2205 assembler->Branch( 2205 assembler->Branch(
2206 assembler->Int32LessThanOrEqual( 2206 assembler->Int32LessThanOrEqual(
2207 assembler->Int32Constant(FIRST_JS_RECEIVER_TYPE), 2207 assembler->Int32Constant(FIRST_JS_RECEIVER_TYPE),
2208 rhs_instance_type), 2208 rhs_instance_type),
2209 &if_rhsisreceiver, &if_rhsisnotreceiver); 2209 &if_rhsisreceiver, &if_rhsisnotreceiver);
2210 2210
2211 assembler->Bind(&if_rhsisreceiver); 2211 assembler->Bind(&if_rhsisreceiver);
2212 { 2212 {
2213 // Convert {rhs} to a primitive first passing Number hint. 2213 // Convert {rhs} to a primitive first passing Number hint.
2214 // TODO(bmeurer): Hook up ToPrimitiveStub here, once it's there. 2214 Callable callable = CodeFactory::NonPrimitiveToPrimitive(
2215 var_rhs.Bind(assembler->CallRuntime( 2215 assembler->isolate(), ToPrimitiveHint::kNumber);
2216 Runtime::kToPrimitive_Number, context, rhs)); 2216 var_rhs.Bind(assembler->CallStub(callable, context, rhs));
2217 assembler->Goto(&loop); 2217 assembler->Goto(&loop);
2218 } 2218 }
2219 2219
2220 assembler->Bind(&if_rhsisnotreceiver); 2220 assembler->Bind(&if_rhsisnotreceiver);
2221 { 2221 {
2222 // Convert both {lhs} and {rhs} to Number. 2222 // Convert both {lhs} and {rhs} to Number.
2223 Callable callable = CodeFactory::ToNumber(assembler->isolate()); 2223 Callable callable = CodeFactory::ToNumber(assembler->isolate());
2224 var_lhs.Bind(assembler->CallStub(callable, context, lhs)); 2224 var_lhs.Bind(assembler->CallStub(callable, context, lhs));
2225 var_rhs.Bind(assembler->CallStub(callable, context, rhs)); 2225 var_rhs.Bind(assembler->CallStub(callable, context, rhs));
2226 assembler->Goto(&loop); 2226 assembler->Goto(&loop);
(...skipping 11 matching lines...) Expand all
2238 if_lhsisnotreceiver(assembler, Label::kDeferred); 2238 if_lhsisnotreceiver(assembler, Label::kDeferred);
2239 assembler->Branch( 2239 assembler->Branch(
2240 assembler->Int32LessThanOrEqual( 2240 assembler->Int32LessThanOrEqual(
2241 assembler->Int32Constant(FIRST_JS_RECEIVER_TYPE), 2241 assembler->Int32Constant(FIRST_JS_RECEIVER_TYPE),
2242 lhs_instance_type), 2242 lhs_instance_type),
2243 &if_lhsisreceiver, &if_lhsisnotreceiver); 2243 &if_lhsisreceiver, &if_lhsisnotreceiver);
2244 2244
2245 assembler->Bind(&if_lhsisreceiver); 2245 assembler->Bind(&if_lhsisreceiver);
2246 { 2246 {
2247 // Convert {lhs} to a primitive first passing Number hint. 2247 // Convert {lhs} to a primitive first passing Number hint.
2248 // TODO(bmeurer): Hook up ToPrimitiveStub here, once it's there. 2248 Callable callable = CodeFactory::NonPrimitiveToPrimitive(
2249 var_lhs.Bind(assembler->CallRuntime(Runtime::kToPrimitive_Number, 2249 assembler->isolate(), ToPrimitiveHint::kNumber);
2250 context, lhs)); 2250 var_lhs.Bind(assembler->CallStub(callable, context, lhs));
2251 assembler->Goto(&loop); 2251 assembler->Goto(&loop);
2252 } 2252 }
2253 2253
2254 assembler->Bind(&if_lhsisnotreceiver); 2254 assembler->Bind(&if_lhsisnotreceiver);
2255 { 2255 {
2256 // Convert both {lhs} and {rhs} to Number. 2256 // Convert both {lhs} and {rhs} to Number.
2257 Callable callable = CodeFactory::ToNumber(assembler->isolate()); 2257 Callable callable = CodeFactory::ToNumber(assembler->isolate());
2258 var_lhs.Bind(assembler->CallStub(callable, context, lhs)); 2258 var_lhs.Bind(assembler->CallStub(callable, context, lhs));
2259 var_rhs.Bind(assembler->CallStub(callable, context, rhs)); 2259 var_rhs.Bind(assembler->CallStub(callable, context, rhs));
2260 assembler->Goto(&loop); 2260 assembler->Goto(&loop);
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after
2564 if_rhsisnotreceiver(assembler); 2564 if_rhsisnotreceiver(assembler);
2565 assembler->Branch( 2565 assembler->Branch(
2566 assembler->Int32LessThanOrEqual( 2566 assembler->Int32LessThanOrEqual(
2567 assembler->Int32Constant(FIRST_JS_RECEIVER_TYPE), 2567 assembler->Int32Constant(FIRST_JS_RECEIVER_TYPE),
2568 rhs_instance_type), 2568 rhs_instance_type),
2569 &if_rhsisreceiver, &if_rhsisnotreceiver); 2569 &if_rhsisreceiver, &if_rhsisnotreceiver);
2570 2570
2571 assembler->Bind(&if_rhsisreceiver); 2571 assembler->Bind(&if_rhsisreceiver);
2572 { 2572 {
2573 // Convert {rhs} to a primitive first (passing no hint). 2573 // Convert {rhs} to a primitive first (passing no hint).
2574 // TODO(bmeurer): Hook up ToPrimitiveStub here once it exists. 2574 Callable callable = CodeFactory::NonPrimitiveToPrimitive(
2575 var_rhs.Bind(assembler->CallRuntime(Runtime::kToPrimitive, 2575 assembler->isolate());
2576 context, rhs)); 2576 var_rhs.Bind(assembler->CallStub(callable, context, rhs));
2577 assembler->Goto(&loop); 2577 assembler->Goto(&loop);
2578 } 2578 }
2579 2579
2580 assembler->Bind(&if_rhsisnotreceiver); 2580 assembler->Bind(&if_rhsisnotreceiver);
2581 assembler->Goto(&if_notequal); 2581 assembler->Goto(&if_notequal);
2582 } 2582 }
2583 } 2583 }
2584 } 2584 }
2585 } 2585 }
2586 } 2586 }
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after
2922 assembler->Word32And( 2922 assembler->Word32And(
2923 lhs_bitfield, 2923 lhs_bitfield,
2924 assembler->Int32Constant(1 << Map::kIsUndetectable)), 2924 assembler->Int32Constant(1 << Map::kIsUndetectable)),
2925 assembler->Int32Constant(0), &if_notequal, &if_equal); 2925 assembler->Int32Constant(0), &if_notequal, &if_equal);
2926 } 2926 }
2927 2927
2928 assembler->Bind(&if_rhsisnotundetectable); 2928 assembler->Bind(&if_rhsisnotundetectable);
2929 { 2929 {
2930 // The {rhs} is some Primitive different from Null and 2930 // The {rhs} is some Primitive different from Null and
2931 // Undefined, need to convert {lhs} to Primitive first. 2931 // Undefined, need to convert {lhs} to Primitive first.
2932 // TODO(bmeurer): Hook up ToPrimitiveStub here once it exists. 2932 Callable callable =
2933 var_lhs.Bind(assembler->CallRuntime(Runtime::kToPrimitive, 2933 CodeFactory::NonPrimitiveToPrimitive(assembler->isolate());
2934 context, lhs)); 2934 var_lhs.Bind(assembler->CallStub(callable, context, lhs));
2935 assembler->Goto(&loop); 2935 assembler->Goto(&loop);
2936 } 2936 }
2937 } 2937 }
2938 } 2938 }
2939 } 2939 }
2940 } 2940 }
2941 } 2941 }
2942 2942
2943 assembler->Bind(&do_rhsstringtonumber); 2943 assembler->Bind(&do_rhsstringtonumber);
2944 { 2944 {
(...skipping 2035 matching lines...) Expand 10 before | Expand all | Expand 10 after
4980 if (type->Is(Type::UntaggedPointer())) { 4980 if (type->Is(Type::UntaggedPointer())) {
4981 return Representation::External(); 4981 return Representation::External();
4982 } 4982 }
4983 4983
4984 DCHECK(!type->Is(Type::Untagged())); 4984 DCHECK(!type->Is(Type::Untagged()));
4985 return Representation::Tagged(); 4985 return Representation::Tagged();
4986 } 4986 }
4987 4987
4988 } // namespace internal 4988 } // namespace internal
4989 } // namespace v8 4989 } // namespace v8
OLDNEW
« no previous file with comments | « src/code-factory.cc ('k') | src/compiler/code-assembler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698