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

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

Issue 1818923002: [stubs] Split ToNumberStub into reusable subparts. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: REBASE Created 4 years, 9 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/js-typed-lowering.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 581 matching lines...) Expand 10 before | Expand all | Expand 10 after
592 var_fcmp_rhs.Bind(assembler->LoadHeapNumberValue(rhs)); 592 var_fcmp_rhs.Bind(assembler->LoadHeapNumberValue(rhs));
593 assembler->Goto(&do_fcmp); 593 assembler->Goto(&do_fcmp);
594 } 594 }
595 595
596 assembler->Bind(&if_rhsisnotnumber); 596 assembler->Bind(&if_rhsisnotnumber);
597 { 597 {
598 // Convert the {rhs} to a Number; we don't need to perform the 598 // Convert the {rhs} to a Number; we don't need to perform the
599 // dedicated ToPrimitive(rhs, hint Number) operation, as the 599 // dedicated ToPrimitive(rhs, hint Number) operation, as the
600 // ToNumber(rhs) will by itself already invoke ToPrimitive with 600 // ToNumber(rhs) will by itself already invoke ToPrimitive with
601 // a Number hint. 601 // a Number hint.
602 Callable callable = CodeFactory::ToNumber(assembler->isolate()); 602 Callable callable =
603 CodeFactory::NonNumberToNumber(assembler->isolate());
603 var_rhs.Bind(assembler->CallStub(callable, context, rhs)); 604 var_rhs.Bind(assembler->CallStub(callable, context, rhs));
604 assembler->Goto(&loop); 605 assembler->Goto(&loop);
605 } 606 }
606 } 607 }
607 } 608 }
608 609
609 assembler->Bind(&if_lhsisnotsmi); 610 assembler->Bind(&if_lhsisnotsmi);
610 { 611 {
611 // Load the HeapNumber map for later comparisons. 612 // Load the HeapNumber map for later comparisons.
612 Node* number_map = assembler->HeapNumberMapConstant(); 613 Node* number_map = assembler->HeapNumberMapConstant();
(...skipping 22 matching lines...) Expand all
635 var_fcmp_rhs.Bind(assembler->SmiToFloat64(rhs)); 636 var_fcmp_rhs.Bind(assembler->SmiToFloat64(rhs));
636 assembler->Goto(&do_fcmp); 637 assembler->Goto(&do_fcmp);
637 } 638 }
638 639
639 assembler->Bind(&if_lhsisnotnumber); 640 assembler->Bind(&if_lhsisnotnumber);
640 { 641 {
641 // Convert the {lhs} to a Number; we don't need to perform the 642 // Convert the {lhs} to a Number; we don't need to perform the
642 // dedicated ToPrimitive(lhs, hint Number) operation, as the 643 // dedicated ToPrimitive(lhs, hint Number) operation, as the
643 // ToNumber(lhs) will by itself already invoke ToPrimitive with 644 // ToNumber(lhs) will by itself already invoke ToPrimitive with
644 // a Number hint. 645 // a Number hint.
645 Callable callable = CodeFactory::ToNumber(assembler->isolate()); 646 Callable callable =
647 CodeFactory::NonNumberToNumber(assembler->isolate());
646 var_lhs.Bind(assembler->CallStub(callable, context, lhs)); 648 var_lhs.Bind(assembler->CallStub(callable, context, lhs));
647 assembler->Goto(&loop); 649 assembler->Goto(&loop);
648 } 650 }
649 } 651 }
650 652
651 assembler->Bind(&if_rhsisnotsmi); 653 assembler->Bind(&if_rhsisnotsmi);
652 { 654 {
653 // Load the map of {rhs}. 655 // Load the map of {rhs}.
654 Node* rhs_map = assembler->LoadMap(rhs); 656 Node* rhs_map = assembler->LoadMap(rhs);
655 657
(...skipping 18 matching lines...) Expand all
674 var_fcmp_rhs.Bind(assembler->LoadHeapNumberValue(rhs)); 676 var_fcmp_rhs.Bind(assembler->LoadHeapNumberValue(rhs));
675 assembler->Goto(&do_fcmp); 677 assembler->Goto(&do_fcmp);
676 } 678 }
677 679
678 assembler->Bind(&if_rhsisnotnumber); 680 assembler->Bind(&if_rhsisnotnumber);
679 { 681 {
680 // Convert the {rhs} to a Number; we don't need to perform 682 // Convert the {rhs} to a Number; we don't need to perform
681 // dedicated ToPrimitive(rhs, hint Number) operation, as the 683 // dedicated ToPrimitive(rhs, hint Number) operation, as the
682 // ToNumber(rhs) will by itself already invoke ToPrimitive with 684 // ToNumber(rhs) will by itself already invoke ToPrimitive with
683 // a Number hint. 685 // a Number hint.
684 Callable callable = CodeFactory::ToNumber(assembler->isolate()); 686 Callable callable =
687 CodeFactory::NonNumberToNumber(assembler->isolate());
685 var_rhs.Bind(assembler->CallStub(callable, context, rhs)); 688 var_rhs.Bind(assembler->CallStub(callable, context, rhs));
686 assembler->Goto(&loop); 689 assembler->Goto(&loop);
687 } 690 }
688 } 691 }
689 692
690 assembler->Bind(&if_lhsisnotnumber); 693 assembler->Bind(&if_lhsisnotnumber);
691 { 694 {
692 // Load the instance type of {lhs}. 695 // Load the instance type of {lhs}.
693 Node* lhs_instance_type = assembler->LoadMapInstanceType(lhs_map); 696 Node* lhs_instance_type = assembler->LoadMapInstanceType(lhs_map);
694 697
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after
1065 Label if_rhsisstring(assembler, Label::kDeferred), 1068 Label if_rhsisstring(assembler, Label::kDeferred),
1066 if_rhsisnotstring(assembler, Label::kDeferred); 1069 if_rhsisnotstring(assembler, Label::kDeferred);
1067 assembler->Branch(assembler->Int32LessThan( 1070 assembler->Branch(assembler->Int32LessThan(
1068 rhs_instance_type, assembler->Int32Constant( 1071 rhs_instance_type, assembler->Int32Constant(
1069 FIRST_NONSTRING_TYPE)), 1072 FIRST_NONSTRING_TYPE)),
1070 &if_rhsisstring, &if_rhsisnotstring); 1073 &if_rhsisstring, &if_rhsisnotstring);
1071 1074
1072 assembler->Bind(&if_rhsisstring); 1075 assembler->Bind(&if_rhsisstring);
1073 { 1076 {
1074 // Convert the {rhs} to a Number. 1077 // Convert the {rhs} to a Number.
1075 Callable callable = CodeFactory::ToNumber(assembler->isolate()); 1078 Callable callable =
1079 CodeFactory::StringToNumber(assembler->isolate());
1076 var_rhs.Bind(assembler->CallStub(callable, context, rhs)); 1080 var_rhs.Bind(assembler->CallStub(callable, context, rhs));
1077 assembler->Goto(&loop); 1081 assembler->Goto(&loop);
1078 } 1082 }
1079 1083
1080 assembler->Bind(&if_rhsisnotstring); 1084 assembler->Bind(&if_rhsisnotstring);
1081 { 1085 {
1082 // Check if the {rhs} is a Boolean. 1086 // Check if the {rhs} is a Boolean.
1083 Node* boolean_map = assembler->BooleanMapConstant(); 1087 Node* boolean_map = assembler->BooleanMapConstant();
1084 Label if_rhsisboolean(assembler, Label::kDeferred), 1088 Label if_rhsisboolean(assembler, Label::kDeferred),
1085 if_rhsisnotboolean(assembler, Label::kDeferred); 1089 if_rhsisnotboolean(assembler, Label::kDeferred);
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
1240 assembler->Int32LessThan( 1244 assembler->Int32LessThan(
1241 rhs_instance_type, 1245 rhs_instance_type,
1242 assembler->Int32Constant(FIRST_NONSTRING_TYPE)), 1246 assembler->Int32Constant(FIRST_NONSTRING_TYPE)),
1243 &if_rhsisstring, &if_rhsisnotstring); 1247 &if_rhsisstring, &if_rhsisnotstring);
1244 1248
1245 assembler->Bind(&if_rhsisstring); 1249 assembler->Bind(&if_rhsisstring);
1246 { 1250 {
1247 // The {rhs} is a String and the {lhs} is a HeapNumber; we need 1251 // The {rhs} is a String and the {lhs} is a HeapNumber; we need
1248 // to convert the {rhs} to a Number and compare the output to 1252 // to convert the {rhs} to a Number and compare the output to
1249 // the Number on the {lhs}. 1253 // the Number on the {lhs}.
1250 Callable callable = CodeFactory::ToNumber(assembler->isolate()); 1254 Callable callable =
1255 CodeFactory::StringToNumber(assembler->isolate());
1251 var_rhs.Bind(assembler->CallStub(callable, context, rhs)); 1256 var_rhs.Bind(assembler->CallStub(callable, context, rhs));
1252 assembler->Goto(&loop); 1257 assembler->Goto(&loop);
1253 } 1258 }
1254 1259
1255 assembler->Bind(&if_rhsisnotstring); 1260 assembler->Bind(&if_rhsisnotstring);
1256 { 1261 {
1257 // Check if the {rhs} is a JSReceiver. 1262 // Check if the {rhs} is a JSReceiver.
1258 Label if_rhsisreceiver(assembler, Label::kDeferred), 1263 Label if_rhsisreceiver(assembler, Label::kDeferred),
1259 if_rhsisnotreceiver(assembler); 1264 if_rhsisnotreceiver(assembler);
1260 STATIC_ASSERT(LAST_TYPE == LAST_JS_RECEIVER_TYPE); 1265 STATIC_ASSERT(LAST_TYPE == LAST_JS_RECEIVER_TYPE);
(...skipping 1494 matching lines...) Expand 10 before | Expand all | Expand 10 after
2755 if (type->Is(Type::UntaggedPointer())) { 2760 if (type->Is(Type::UntaggedPointer())) {
2756 return Representation::External(); 2761 return Representation::External();
2757 } 2762 }
2758 2763
2759 DCHECK(!type->Is(Type::Untagged())); 2764 DCHECK(!type->Is(Type::Untagged()));
2760 return Representation::Tagged(); 2765 return Representation::Tagged();
2761 } 2766 }
2762 2767
2763 } // namespace internal 2768 } // namespace internal
2764 } // namespace v8 2769 } // namespace v8
OLDNEW
« no previous file with comments | « src/code-stubs.h ('k') | src/compiler/js-typed-lowering.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698