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

Unified Diff: src/code-stubs.cc

Issue 2392533002: Reland of [interpreter] Add string type feedback to add (Closed)
Patch Set: Un-inline calling the stub Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/globals.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/code-stubs.cc
diff --git a/src/code-stubs.cc b/src/code-stubs.cc
index de18700d5ee7856c0b302fdb7ef516f99e088fda..303b68b4219723b51d98ec82fd2027bed9c24c62 100644
--- a/src/code-stubs.cc
+++ b/src/code-stubs.cc
@@ -1048,7 +1048,7 @@ compiler::Node* AddWithFeedbackStub::Generate(
// Shared entry for floating point addition.
Label do_fadd(assembler), end(assembler),
- call_add_stub(assembler, Label::kDeferred);
+ do_add_any(assembler, Label::kDeferred), call_add_stub(assembler);
Variable var_fadd_lhs(assembler, MachineRepresentation::kFloat64),
var_fadd_rhs(assembler, MachineRepresentation::kFloat64),
var_type_feedback(assembler, MachineRepresentation::kWord32),
@@ -1096,8 +1096,7 @@ compiler::Node* AddWithFeedbackStub::Generate(
Node* rhs_map = assembler->LoadMap(rhs);
// Check if the {rhs} is a HeapNumber.
- assembler->GotoUnless(assembler->IsHeapNumberMap(rhs_map),
- &call_add_stub);
+ assembler->GotoUnless(assembler->IsHeapNumberMap(rhs_map), &do_add_any);
var_fadd_lhs.Bind(assembler->SmiToFloat64(lhs));
var_fadd_rhs.Bind(assembler->LoadHeapNumberValue(rhs));
@@ -1107,12 +1106,14 @@ compiler::Node* AddWithFeedbackStub::Generate(
assembler->Bind(&if_lhsisnotsmi);
{
+ Label check_string(assembler);
+
// Load the map of {lhs}.
Node* lhs_map = assembler->LoadMap(lhs);
// Check if {lhs} is a HeapNumber.
Label if_lhsisnumber(assembler), if_lhsisnotnumber(assembler);
- assembler->GotoUnless(assembler->IsHeapNumberMap(lhs_map), &call_add_stub);
+ assembler->GotoUnless(assembler->IsHeapNumberMap(lhs_map), &check_string);
// Check if the {rhs} is Smi.
Label if_rhsissmi(assembler), if_rhsisnotsmi(assembler);
@@ -1131,13 +1132,38 @@ compiler::Node* AddWithFeedbackStub::Generate(
Node* rhs_map = assembler->LoadMap(rhs);
// Check if the {rhs} is a HeapNumber.
- assembler->GotoUnless(assembler->IsHeapNumberMap(rhs_map),
- &call_add_stub);
+ assembler->GotoUnless(assembler->IsHeapNumberMap(rhs_map), &do_add_any);
var_fadd_lhs.Bind(assembler->LoadHeapNumberValue(lhs));
var_fadd_rhs.Bind(assembler->LoadHeapNumberValue(rhs));
assembler->Goto(&do_fadd);
}
+
+ assembler->Bind(&check_string);
+ {
+ // Check if the {rhs} is a smi, and exit the string check early if it is.
+ assembler->GotoIf(assembler->WordIsSmi(rhs), &do_add_any);
+
+ Node* lhs_instance_type = assembler->LoadMapInstanceType(lhs_map);
+
+ // Exit unless {lhs} is a string
+ assembler->GotoUnless(assembler->Int32LessThan(
+ lhs_instance_type,
+ assembler->Int32Constant(FIRST_NONSTRING_TYPE)),
+ &do_add_any);
rmcilroy 2016/10/05 11:03:12 Could you use IsStringInstanceType (as added in ht
Leszek Swirski 2016/10/05 13:10:55 Done.
+
+ Node* rhs_instance_type = assembler->LoadInstanceType(rhs);
+
+ // Exit unless {rhs} is a string
+ assembler->GotoUnless(assembler->Int32LessThan(
+ rhs_instance_type,
+ assembler->Int32Constant(FIRST_NONSTRING_TYPE)),
+ &do_add_any);
rmcilroy 2016/10/05 11:03:12 ditto
Leszek Swirski 2016/10/05 13:10:55 Done.
+
+ var_type_feedback.Bind(
+ assembler->Int32Constant(BinaryOperationFeedback::kString));
+ assembler->Goto(&call_add_stub);
mythria 2016/10/05 08:28:00 I am not sure if it makes sense, but would it be p
Leszek Swirski 2016/10/05 13:10:55 Nice idea, I'll punt on this for this CL and will
+ }
}
assembler->Bind(&do_fadd);
@@ -1151,10 +1177,15 @@ compiler::Node* AddWithFeedbackStub::Generate(
assembler->Goto(&end);
}
- assembler->Bind(&call_add_stub);
+ assembler->Bind(&do_add_any);
{
var_type_feedback.Bind(
assembler->Int32Constant(BinaryOperationFeedback::kAny));
+ assembler->Goto(&call_add_stub);
+ }
+
+ assembler->Bind(&call_add_stub);
+ {
Callable callable = CodeFactory::Add(assembler->isolate());
var_result.Bind(assembler->CallStub(callable, context, lhs, rhs));
assembler->Goto(&end);
« no previous file with comments | « no previous file | src/globals.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698