Reviewers: mvstanton,
Message:
Hey Michael,
This is trivial cleanup. Using HCheckInstanceType, we ensure that the
dependencies are correct in the CFG, and we may even be able to eliminate
the
check at some later optimization pass. PTAL
-- Benedikt
Description:
Rework BuildCheckString() to be compatible with the other BuildCheck*()
methods.
Please review this at https://codereview.chromium.org/79343009/
SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge
Affected files (+12, -23 lines):
M src/code-stubs-hydrogen.cc
M src/hydrogen.h
M src/hydrogen.cc
Index: src/code-stubs-hydrogen.cc
diff --git a/src/code-stubs-hydrogen.cc b/src/code-stubs-hydrogen.cc
index
62e19e12755bab3cd7d410e613bc421f468b12b0..0e690cb3e9542e8a42c21c0f7591beaa39c9f90a
100644
--- a/src/code-stubs-hydrogen.cc
+++ b/src/code-stubs-hydrogen.cc
@@ -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);
Index: src/hydrogen.cc
diff --git a/src/hydrogen.cc b/src/hydrogen.cc
index
9215d0fa27c9ee90adf2490fc64bba067e32264d..2a17f8420dc8fd345f00ecacd7419f9ef8326165
100644
--- a/src/hydrogen.cc
+++ b/src/hydrogen.cc
@@ -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;
}
@@ -8647,14 +8644,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.
Index: src/hydrogen.h
diff --git a/src/hydrogen.h b/src/hydrogen.h
index
a117c551ad6171b8f65527be34be799a541d979d..d11fbc0a0de21e66814f15526e8caafd9dfbecaa
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> map);
- HValue* BuildCheckString(HValue* object, const char* failure_reason);
+ HValue* BuildCheckString(HValue* string);
HValue* BuildWrapReceiver(HValue* object, HValue* function);
// Building common constructs
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.