Commit bf7a9bf8 authored by ishell@chromium.org's avatar ishell@chromium.org

HCheckInstanceType factories unified

R=bmeurer@chromium.org

Review URL: https://codereview.chromium.org/35413007

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@17342 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 6dd69355
......@@ -2777,19 +2777,15 @@ class HCheckValue V8_FINAL : public HUnaryOperation {
class HCheckInstanceType V8_FINAL : public HUnaryOperation {
public:
static HCheckInstanceType* NewIsSpecObject(HValue* value, Zone* zone) {
return new(zone) HCheckInstanceType(value, IS_SPEC_OBJECT);
}
static HCheckInstanceType* NewIsJSArray(HValue* value, Zone* zone) {
return new(zone) HCheckInstanceType(value, IS_JS_ARRAY);
}
static HCheckInstanceType* NewIsString(HValue* value, Zone* zone) {
return new(zone) HCheckInstanceType(value, IS_STRING);
}
static HCheckInstanceType* NewIsInternalizedString(
HValue* value, Zone* zone) {
return new(zone) HCheckInstanceType(value, IS_INTERNALIZED_STRING);
}
enum Check {
IS_SPEC_OBJECT,
IS_JS_ARRAY,
IS_STRING,
IS_INTERNALIZED_STRING,
LAST_INTERVAL_CHECK = IS_JS_ARRAY
};
DECLARE_INSTRUCTION_FACTORY_P2(HCheckInstanceType, HValue*, Check);
virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
......@@ -2817,14 +2813,6 @@ class HCheckInstanceType V8_FINAL : public HUnaryOperation {
virtual int RedefinedOperandIndex() { return 0; }
private:
enum Check {
IS_SPEC_OBJECT,
IS_JS_ARRAY,
IS_STRING,
IS_INTERNALIZED_STRING,
LAST_INTERVAL_CHECK = IS_JS_ARRAY
};
const char* GetCheckName();
HCheckInstanceType(HValue* value, Check check)
......
......@@ -5960,7 +5960,7 @@ void HOptimizedGraphBuilder::BuildLoad(Property* expr,
HInstruction* checked_object;
if (AreStringTypes(types)) {
checked_object =
AddInstruction(HCheckInstanceType::NewIsString(object, zone()));
Add<HCheckInstanceType>(object, HCheckInstanceType::IS_STRING);
} else {
checked_object = Add<HCheckMaps>(object, types);
}
......@@ -7642,7 +7642,7 @@ HInstruction* HOptimizedGraphBuilder::BuildStringCharCodeAt(
}
BuildCheckHeapObject(string);
HValue* checkstring =
AddInstruction(HCheckInstanceType::NewIsString(string, zone()));
Add<HCheckInstanceType>(string, HCheckInstanceType::IS_STRING);
HInstruction* length = BuildLoadStringLength(string, checkstring);
AddInstruction(length);
HInstruction* checked_index = Add<HBoundsCheck>(index, length);
......@@ -8245,9 +8245,9 @@ void HOptimizedGraphBuilder::VisitCompareOperation(CompareOperation* expr) {
return ast_context()->ReturnControl(result, expr->id());
} else {
BuildCheckHeapObject(left);
AddInstruction(HCheckInstanceType::NewIsSpecObject(left, zone()));
Add<HCheckInstanceType>(left, HCheckInstanceType::IS_SPEC_OBJECT);
BuildCheckHeapObject(right);
AddInstruction(HCheckInstanceType::NewIsSpecObject(right, zone()));
Add<HCheckInstanceType>(right, HCheckInstanceType::IS_SPEC_OBJECT);
HCompareObjectEqAndBranch* result =
New<HCompareObjectEqAndBranch>(left, right);
return ast_context()->ReturnControl(result, expr->id());
......@@ -8259,17 +8259,17 @@ void HOptimizedGraphBuilder::VisitCompareOperation(CompareOperation* expr) {
} else if (combined_type->Is(Type::InternalizedString()) &&
Token::IsEqualityOp(op)) {
BuildCheckHeapObject(left);
AddInstruction(HCheckInstanceType::NewIsInternalizedString(left, zone()));
Add<HCheckInstanceType>(left, HCheckInstanceType::IS_INTERNALIZED_STRING);
BuildCheckHeapObject(right);
AddInstruction(HCheckInstanceType::NewIsInternalizedString(right, zone()));
Add<HCheckInstanceType>(right, HCheckInstanceType::IS_INTERNALIZED_STRING);
HCompareObjectEqAndBranch* result =
New<HCompareObjectEqAndBranch>(left, right);
return ast_context()->ReturnControl(result, expr->id());
} else if (combined_type->Is(Type::String())) {
BuildCheckHeapObject(left);
AddInstruction(HCheckInstanceType::NewIsString(left, zone()));
Add<HCheckInstanceType>(left, HCheckInstanceType::IS_STRING);
BuildCheckHeapObject(right);
AddInstruction(HCheckInstanceType::NewIsString(right, zone()));
Add<HCheckInstanceType>(right, HCheckInstanceType::IS_STRING);
HStringCompareAndBranch* result =
New<HStringCompareAndBranch>(left, right, op);
return ast_context()->ReturnControl(result, expr->id());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment