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

Unified Diff: src/hydrogen.cc

Issue 78063002: Don't generate useless string checks for string adds. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 1 month 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 | « src/hydrogen.h ('k') | 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 22da9477e53608ce1b4df08357bfce25960e2e53..b47bb956630b35dfdb9457c9c80934440e9d21f4 100644
--- a/src/hydrogen.cc
+++ b/src/hydrogen.cc
@@ -1273,6 +1273,20 @@ HValue* HGraphBuilder::BuildCheckMap(HValue* obj, Handle<Map> map) {
}
+HValue* HGraphBuilder::BuildCheckString(
+ HValue* object, const char* failure_reason) {
+ if (!object->type().IsString()) {
+ ASSERT(!object->IsConstant() ||
+ !HConstant::cast(object)->HasStringValue());
+ IfBuilder if_isstring(this);
+ if_isstring.If<HIsStringAndBranch>(object);
+ if_isstring.Then();
+ if_isstring.ElseDeopt(failure_reason);
+ }
+ return object;
+}
+
+
HValue* HGraphBuilder::BuildWrapReceiver(HValue* object, HValue* function) {
if (object->type().IsJSObject()) return object;
return Add<HWrapReceiver>(object, function);
@@ -8631,18 +8645,14 @@ HInstruction* HGraphBuilder::BuildBinaryOperation(
(left_type->Is(Type::String()) || right_type->Is(Type::String()))) {
// Validate type feedback for left argument.
if (left_type->Is(Type::String())) {
- IfBuilder if_isstring(this);
- if_isstring.If<HIsStringAndBranch>(left);
- if_isstring.Then();
- if_isstring.ElseDeopt("Expected string for LHS of binary operation");
+ left = BuildCheckString(
+ left, "Expected string for LHS of binary operation");
}
// Validate type feedback for right argument.
if (right_type->Is(Type::String())) {
- IfBuilder if_isstring(this);
- if_isstring.If<HIsStringAndBranch>(right);
- if_isstring.Then();
- if_isstring.ElseDeopt("Expected string for RHS of binary operation");
+ right = BuildCheckString(
+ right, "Expected string for RHS of binary operation");
}
// Convert left argument as necessary.
« no previous file with comments | « src/hydrogen.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698