From da87c188ad7c9774594472deb083264ed330da36 Mon Sep 17 00:00:00 2001 From: "bmeurer@chromium.org" Date: Fri, 22 Nov 2013 07:27:26 +0000 Subject: [PATCH] Rework BuildCheckString() to be compatible with the other BuildCheck*() methods. R=svenpanne@chromium.org Review URL: https://codereview.chromium.org/79343009 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@17985 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/code-stubs-hydrogen.cc | 10 ++-------- src/hydrogen.cc | 23 +++++++++-------------- src/hydrogen.h | 2 +- 3 files changed, 12 insertions(+), 23 deletions(-) diff --git a/src/code-stubs-hydrogen.cc b/src/code-stubs-hydrogen.cc index 62e19e1..0e690cb 100644 --- a/src/code-stubs-hydrogen.cc +++ b/src/code-stubs-hydrogen.cc @@ -992,16 +992,10 @@ HValue* CodeStubGraphBuilder::BuildCodeInitializedStub() { // Make sure that both arguments are strings if not known in advance. if ((flags & STRING_ADD_CHECK_LEFT) == STRING_ADD_CHECK_LEFT) { - IfBuilder if_leftnotstring(this); - if_leftnotstring.IfNot(left); - if_leftnotstring.Then(); - if_leftnotstring.Deopt("Expected string for LHS of string addition"); + left = BuildCheckString(left); } if ((flags & STRING_ADD_CHECK_RIGHT) == STRING_ADD_CHECK_RIGHT) { - IfBuilder if_rightnotstring(this); - if_rightnotstring.IfNot(right); - if_rightnotstring.Then(); - if_rightnotstring.Deopt("Expected string for RHS of string addition"); + right = BuildCheckString(right); } return BuildStringAdd(left, right, pretenure_flag); diff --git a/src/hydrogen.cc b/src/hydrogen.cc index f7b3100..fd93ce3 100644 --- a/src/hydrogen.cc +++ b/src/hydrogen.cc @@ -1273,17 +1273,14 @@ HValue* HGraphBuilder::BuildCheckMap(HValue* obj, Handle 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(object); - if_isstring.Then(); - if_isstring.ElseDeopt(failure_reason); +HValue* HGraphBuilder::BuildCheckString(HValue* string) { + if (!string->type().IsString()) { + ASSERT(!string->IsConstant() || + !HConstant::cast(string)->HasStringValue()); + BuildCheckHeapObject(string); + return Add(string, HCheckInstanceType::IS_STRING); } - return object; + return string; } @@ -8657,14 +8654,12 @@ HValue* HGraphBuilder::BuildBinaryOperation( (left_type->Is(Type::String()) || right_type->Is(Type::String()))) { // Validate type feedback for left argument. if (left_type->Is(Type::String())) { - left = BuildCheckString( - left, "Expected string for LHS of binary operation"); + left = BuildCheckString(left); } // Validate type feedback for right argument. if (right_type->Is(Type::String())) { - right = BuildCheckString( - right, "Expected string for RHS of binary operation"); + right = BuildCheckString(right); } // Convert left argument as necessary. diff --git a/src/hydrogen.h b/src/hydrogen.h index a117c55..d11fbc0 100644 --- a/src/hydrogen.h +++ b/src/hydrogen.h @@ -1256,7 +1256,7 @@ class HGraphBuilder { HValue* BuildCheckHeapObject(HValue* object); HValue* BuildCheckMap(HValue* obj, Handle map); - HValue* BuildCheckString(HValue* object, const char* failure_reason); + HValue* BuildCheckString(HValue* string); HValue* BuildWrapReceiver(HValue* object, HValue* function); // Building common constructs -- 2.7.4