Removed a "feature envy" bad smell: Moved AssumeRepresentation method to where

it belongs.
Review URL: http://codereview.chromium.org/7015039

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@7890 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent cfd6e000
...@@ -67,6 +67,16 @@ const char* Representation::Mnemonic() const { ...@@ -67,6 +67,16 @@ const char* Representation::Mnemonic() const {
} }
void HValue::AssumeRepresentation(Representation r) {
if (CheckFlag(kFlexibleRepresentation)) {
ChangeRepresentation(r);
// The representation of the value is dictated by type feedback and
// will not be changed later.
ClearFlag(kFlexibleRepresentation);
}
}
static int32_t ConvertAndSetOverflow(int64_t result, bool* overflow) { static int32_t ConvertAndSetOverflow(int64_t result, bool* overflow) {
if (result > kMaxInt) { if (result > kMaxInt) {
*overflow = true; *overflow = true;
......
...@@ -557,6 +557,7 @@ class HValue: public ZoneObject { ...@@ -557,6 +557,7 @@ class HValue: public ZoneObject {
RepresentationChanged(r); RepresentationChanged(r);
representation_ = r; representation_ = r;
} }
void AssumeRepresentation(Representation r);
virtual bool IsConvertibleToInteger() const { return true; } virtual bool IsConvertibleToInteger() const { return true; }
......
...@@ -4636,7 +4636,7 @@ void HGraphBuilder::VisitSub(UnaryOperation* expr) { ...@@ -4636,7 +4636,7 @@ void HGraphBuilder::VisitSub(UnaryOperation* expr) {
TypeInfo info = oracle()->UnaryType(expr); TypeInfo info = oracle()->UnaryType(expr);
Representation rep = ToRepresentation(info); Representation rep = ToRepresentation(info);
TraceRepresentation(expr->op(), info, instr, rep); TraceRepresentation(expr->op(), info, instr, rep);
AssumeRepresentation(instr, rep); instr->AssumeRepresentation(rep);
ast_context()->ReturnInstruction(instr, expr->id()); ast_context()->ReturnInstruction(instr, expr->id());
} }
...@@ -4707,7 +4707,7 @@ HInstruction* HGraphBuilder::BuildIncrement(HValue* value, ...@@ -4707,7 +4707,7 @@ HInstruction* HGraphBuilder::BuildIncrement(HValue* value,
rep = Representation::Integer32(); rep = Representation::Integer32();
} }
TraceRepresentation(expr->op(), info, instr, rep); TraceRepresentation(expr->op(), info, instr, rep);
AssumeRepresentation(instr, rep); instr->AssumeRepresentation(rep);
return instr; return instr;
} }
...@@ -4885,7 +4885,7 @@ HInstruction* HGraphBuilder::BuildBinaryOperation(BinaryOperation* expr, ...@@ -4885,7 +4885,7 @@ HInstruction* HGraphBuilder::BuildBinaryOperation(BinaryOperation* expr,
rep = Representation::Integer32(); rep = Representation::Integer32();
} }
TraceRepresentation(expr->op(), info, instr, rep); TraceRepresentation(expr->op(), info, instr, rep);
AssumeRepresentation(instr, rep); instr->AssumeRepresentation(rep);
return instr; return instr;
} }
...@@ -5073,16 +5073,6 @@ void HGraphBuilder::TraceRepresentation(Token::Value op, ...@@ -5073,16 +5073,6 @@ void HGraphBuilder::TraceRepresentation(Token::Value op,
} }
void HGraphBuilder::AssumeRepresentation(HValue* value, Representation rep) {
if (value->CheckFlag(HValue::kFlexibleRepresentation)) {
value->ChangeRepresentation(rep);
// The representation of the value is dictated by type feedback and
// will not be changed later.
value->ClearFlag(HValue::kFlexibleRepresentation);
}
}
Representation HGraphBuilder::ToRepresentation(TypeInfo info) { Representation HGraphBuilder::ToRepresentation(TypeInfo info) {
if (info.IsSmi()) return Representation::Integer32(); if (info.IsSmi()) return Representation::Integer32();
if (info.IsInteger32()) return Representation::Integer32(); if (info.IsInteger32()) return Representation::Integer32();
......
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