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
This commit is contained in:
bmeurer@chromium.org 2013-11-22 07:27:26 +00:00
parent f822855258
commit da87c188ad
3 changed files with 12 additions and 23 deletions

View File

@ -992,16 +992,10 @@ HValue* CodeStubGraphBuilder<NewStringAddStub>::BuildCodeInitializedStub() {
// Make sure that both arguments are strings if not known in advance. // Make sure that both arguments are strings if not known in advance.
if ((flags & STRING_ADD_CHECK_LEFT) == STRING_ADD_CHECK_LEFT) { if ((flags & STRING_ADD_CHECK_LEFT) == STRING_ADD_CHECK_LEFT) {
IfBuilder if_leftnotstring(this); left = BuildCheckString(left);
if_leftnotstring.IfNot<HIsStringAndBranch>(left);
if_leftnotstring.Then();
if_leftnotstring.Deopt("Expected string for LHS of string addition");
} }
if ((flags & STRING_ADD_CHECK_RIGHT) == STRING_ADD_CHECK_RIGHT) { if ((flags & STRING_ADD_CHECK_RIGHT) == STRING_ADD_CHECK_RIGHT) {
IfBuilder if_rightnotstring(this); right = BuildCheckString(right);
if_rightnotstring.IfNot<HIsStringAndBranch>(right);
if_rightnotstring.Then();
if_rightnotstring.Deopt("Expected string for RHS of string addition");
} }
return BuildStringAdd(left, right, pretenure_flag); return BuildStringAdd(left, right, pretenure_flag);

View File

@ -1273,17 +1273,14 @@ HValue* HGraphBuilder::BuildCheckMap(HValue* obj, Handle<Map> map) {
} }
HValue* HGraphBuilder::BuildCheckString( HValue* HGraphBuilder::BuildCheckString(HValue* string) {
HValue* object, const char* failure_reason) { if (!string->type().IsString()) {
if (!object->type().IsString()) { ASSERT(!string->IsConstant() ||
ASSERT(!object->IsConstant() || !HConstant::cast(string)->HasStringValue());
!HConstant::cast(object)->HasStringValue()); BuildCheckHeapObject(string);
IfBuilder if_isstring(this); return Add<HCheckInstanceType>(string, HCheckInstanceType::IS_STRING);
if_isstring.If<HIsStringAndBranch>(object);
if_isstring.Then();
if_isstring.ElseDeopt(failure_reason);
} }
return object; return string;
} }
@ -8657,14 +8654,12 @@ HValue* HGraphBuilder::BuildBinaryOperation(
(left_type->Is(Type::String()) || right_type->Is(Type::String()))) { (left_type->Is(Type::String()) || right_type->Is(Type::String()))) {
// Validate type feedback for left argument. // Validate type feedback for left argument.
if (left_type->Is(Type::String())) { if (left_type->Is(Type::String())) {
left = BuildCheckString( left = BuildCheckString(left);
left, "Expected string for LHS of binary operation");
} }
// Validate type feedback for right argument. // Validate type feedback for right argument.
if (right_type->Is(Type::String())) { if (right_type->Is(Type::String())) {
right = BuildCheckString( right = BuildCheckString(right);
right, "Expected string for RHS of binary operation");
} }
// Convert left argument as necessary. // Convert left argument as necessary.

View File

@ -1256,7 +1256,7 @@ class HGraphBuilder {
HValue* BuildCheckHeapObject(HValue* object); HValue* BuildCheckHeapObject(HValue* object);
HValue* BuildCheckMap(HValue* obj, Handle<Map> map); HValue* BuildCheckMap(HValue* obj, Handle<Map> map);
HValue* BuildCheckString(HValue* object, const char* failure_reason); HValue* BuildCheckString(HValue* string);
HValue* BuildWrapReceiver(HValue* object, HValue* function); HValue* BuildWrapReceiver(HValue* object, HValue* function);
// Building common constructs // Building common constructs