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 { ...@@ -2777,19 +2777,15 @@ class HCheckValue V8_FINAL : public HUnaryOperation {
class HCheckInstanceType V8_FINAL : public HUnaryOperation { class HCheckInstanceType V8_FINAL : public HUnaryOperation {
public: public:
static HCheckInstanceType* NewIsSpecObject(HValue* value, Zone* zone) { enum Check {
return new(zone) HCheckInstanceType(value, IS_SPEC_OBJECT); IS_SPEC_OBJECT,
} IS_JS_ARRAY,
static HCheckInstanceType* NewIsJSArray(HValue* value, Zone* zone) { IS_STRING,
return new(zone) HCheckInstanceType(value, IS_JS_ARRAY); IS_INTERNALIZED_STRING,
} LAST_INTERVAL_CHECK = IS_JS_ARRAY
static HCheckInstanceType* NewIsString(HValue* value, Zone* zone) { };
return new(zone) HCheckInstanceType(value, IS_STRING);
} DECLARE_INSTRUCTION_FACTORY_P2(HCheckInstanceType, HValue*, Check);
static HCheckInstanceType* NewIsInternalizedString(
HValue* value, Zone* zone) {
return new(zone) HCheckInstanceType(value, IS_INTERNALIZED_STRING);
}
virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE; virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
...@@ -2817,14 +2813,6 @@ class HCheckInstanceType V8_FINAL : public HUnaryOperation { ...@@ -2817,14 +2813,6 @@ class HCheckInstanceType V8_FINAL : public HUnaryOperation {
virtual int RedefinedOperandIndex() { return 0; } virtual int RedefinedOperandIndex() { return 0; }
private: private:
enum Check {
IS_SPEC_OBJECT,
IS_JS_ARRAY,
IS_STRING,
IS_INTERNALIZED_STRING,
LAST_INTERVAL_CHECK = IS_JS_ARRAY
};
const char* GetCheckName(); const char* GetCheckName();
HCheckInstanceType(HValue* value, Check check) HCheckInstanceType(HValue* value, Check check)
......
...@@ -5960,7 +5960,7 @@ void HOptimizedGraphBuilder::BuildLoad(Property* expr, ...@@ -5960,7 +5960,7 @@ void HOptimizedGraphBuilder::BuildLoad(Property* expr,
HInstruction* checked_object; HInstruction* checked_object;
if (AreStringTypes(types)) { if (AreStringTypes(types)) {
checked_object = checked_object =
AddInstruction(HCheckInstanceType::NewIsString(object, zone())); Add<HCheckInstanceType>(object, HCheckInstanceType::IS_STRING);
} else { } else {
checked_object = Add<HCheckMaps>(object, types); checked_object = Add<HCheckMaps>(object, types);
} }
...@@ -7642,7 +7642,7 @@ HInstruction* HOptimizedGraphBuilder::BuildStringCharCodeAt( ...@@ -7642,7 +7642,7 @@ HInstruction* HOptimizedGraphBuilder::BuildStringCharCodeAt(
} }
BuildCheckHeapObject(string); BuildCheckHeapObject(string);
HValue* checkstring = HValue* checkstring =
AddInstruction(HCheckInstanceType::NewIsString(string, zone())); Add<HCheckInstanceType>(string, HCheckInstanceType::IS_STRING);
HInstruction* length = BuildLoadStringLength(string, checkstring); HInstruction* length = BuildLoadStringLength(string, checkstring);
AddInstruction(length); AddInstruction(length);
HInstruction* checked_index = Add<HBoundsCheck>(index, length); HInstruction* checked_index = Add<HBoundsCheck>(index, length);
...@@ -8245,9 +8245,9 @@ void HOptimizedGraphBuilder::VisitCompareOperation(CompareOperation* expr) { ...@@ -8245,9 +8245,9 @@ void HOptimizedGraphBuilder::VisitCompareOperation(CompareOperation* expr) {
return ast_context()->ReturnControl(result, expr->id()); return ast_context()->ReturnControl(result, expr->id());
} else { } else {
BuildCheckHeapObject(left); BuildCheckHeapObject(left);
AddInstruction(HCheckInstanceType::NewIsSpecObject(left, zone())); Add<HCheckInstanceType>(left, HCheckInstanceType::IS_SPEC_OBJECT);
BuildCheckHeapObject(right); BuildCheckHeapObject(right);
AddInstruction(HCheckInstanceType::NewIsSpecObject(right, zone())); Add<HCheckInstanceType>(right, HCheckInstanceType::IS_SPEC_OBJECT);
HCompareObjectEqAndBranch* result = HCompareObjectEqAndBranch* result =
New<HCompareObjectEqAndBranch>(left, right); New<HCompareObjectEqAndBranch>(left, right);
return ast_context()->ReturnControl(result, expr->id()); return ast_context()->ReturnControl(result, expr->id());
...@@ -8259,17 +8259,17 @@ void HOptimizedGraphBuilder::VisitCompareOperation(CompareOperation* expr) { ...@@ -8259,17 +8259,17 @@ void HOptimizedGraphBuilder::VisitCompareOperation(CompareOperation* expr) {
} else if (combined_type->Is(Type::InternalizedString()) && } else if (combined_type->Is(Type::InternalizedString()) &&
Token::IsEqualityOp(op)) { Token::IsEqualityOp(op)) {
BuildCheckHeapObject(left); BuildCheckHeapObject(left);
AddInstruction(HCheckInstanceType::NewIsInternalizedString(left, zone())); Add<HCheckInstanceType>(left, HCheckInstanceType::IS_INTERNALIZED_STRING);
BuildCheckHeapObject(right); BuildCheckHeapObject(right);
AddInstruction(HCheckInstanceType::NewIsInternalizedString(right, zone())); Add<HCheckInstanceType>(right, HCheckInstanceType::IS_INTERNALIZED_STRING);
HCompareObjectEqAndBranch* result = HCompareObjectEqAndBranch* result =
New<HCompareObjectEqAndBranch>(left, right); New<HCompareObjectEqAndBranch>(left, right);
return ast_context()->ReturnControl(result, expr->id()); return ast_context()->ReturnControl(result, expr->id());
} else if (combined_type->Is(Type::String())) { } else if (combined_type->Is(Type::String())) {
BuildCheckHeapObject(left); BuildCheckHeapObject(left);
AddInstruction(HCheckInstanceType::NewIsString(left, zone())); Add<HCheckInstanceType>(left, HCheckInstanceType::IS_STRING);
BuildCheckHeapObject(right); BuildCheckHeapObject(right);
AddInstruction(HCheckInstanceType::NewIsString(right, zone())); Add<HCheckInstanceType>(right, HCheckInstanceType::IS_STRING);
HStringCompareAndBranch* result = HStringCompareAndBranch* result =
New<HStringCompareAndBranch>(left, right, op); New<HStringCompareAndBranch>(left, right, op);
return ast_context()->ReturnControl(result, expr->id()); 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