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

Unified Diff: src/hydrogen.cc

Issue 1122823002: When adding constant string with something unknown, assume it's a string. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/hydrogen.cc
diff --git a/src/hydrogen.cc b/src/hydrogen.cc
index 9bdc070300512b44f0c6ea5ba292b8530655ef9f..603b1fa62b6ece1728037c045f9795fe37537072 100644
--- a/src/hydrogen.cc
+++ b/src/hydrogen.cc
@@ -10610,15 +10610,30 @@ HValue* HGraphBuilder::BuildBinaryOperation(
Maybe<int> fixed_right_arg,
HAllocationMode allocation_mode,
LanguageMode language_mode) {
+ bool maybe_string_add = false;
+ if (op == Token::ADD) {
+ // If we are adding constant string with something for which we don't have
+ // a feedback yet, assume that it's also going to be a string and don't
+ // generate deopt instructions.
+ if (!left_type->IsInhabited() && right->IsConstant() &&
+ HConstant::cast(right)->HasStringValue()) {
+ left_type = Type::String();
+ }
+
+ if (!right_type->IsInhabited() && left->IsConstant() &&
+ HConstant::cast(left)->HasStringValue()) {
+ right_type = Type::String();
+ }
+
+ maybe_string_add = (left_type->Maybe(Type::String()) ||
+ left_type->Maybe(Type::Receiver()) ||
+ right_type->Maybe(Type::String()) ||
+ right_type->Maybe(Type::Receiver()));
+ }
+
Representation left_rep = RepresentationFor(left_type);
Representation right_rep = RepresentationFor(right_type);
- bool maybe_string_add = op == Token::ADD &&
- (left_type->Maybe(Type::String()) ||
- left_type->Maybe(Type::Receiver()) ||
- right_type->Maybe(Type::String()) ||
- right_type->Maybe(Type::Receiver()));
-
if (!left_type->IsInhabited()) {
Add<HDeoptimize>(
Deoptimizer::kInsufficientTypeFeedbackForLHSOfBinaryOperation,
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698