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.
if ((flags & STRING_ADD_CHECK_LEFT) == STRING_ADD_CHECK_LEFT) {
IfBuilder if_leftnotstring(this);
if_leftnotstring.IfNot<HIsStringAndBranch>(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<HIsStringAndBranch>(right);
if_rightnotstring.Then();
if_rightnotstring.Deopt("Expected string for RHS of string addition");
right = BuildCheckString(right);
}
return BuildStringAdd(left, right, pretenure_flag);

View File

@ -1273,17 +1273,14 @@ 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);
HValue* HGraphBuilder::BuildCheckString(HValue* string) {
if (!string->type().IsString()) {
ASSERT(!string->IsConstant() ||
!HConstant::cast(string)->HasStringValue());
BuildCheckHeapObject(string);
return Add<HCheckInstanceType>(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.

View File

@ -1256,7 +1256,7 @@ class HGraphBuilder {
HValue* BuildCheckHeapObject(HValue* object);
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);
// Building common constructs