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
This commit is contained in:
parent
cfd6e000ea
commit
fe2074f580
@ -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) {
|
||||
if (result > kMaxInt) {
|
||||
*overflow = true;
|
||||
|
@ -557,6 +557,7 @@ class HValue: public ZoneObject {
|
||||
RepresentationChanged(r);
|
||||
representation_ = r;
|
||||
}
|
||||
void AssumeRepresentation(Representation r);
|
||||
|
||||
virtual bool IsConvertibleToInteger() const { return true; }
|
||||
|
||||
|
@ -4636,7 +4636,7 @@ void HGraphBuilder::VisitSub(UnaryOperation* expr) {
|
||||
TypeInfo info = oracle()->UnaryType(expr);
|
||||
Representation rep = ToRepresentation(info);
|
||||
TraceRepresentation(expr->op(), info, instr, rep);
|
||||
AssumeRepresentation(instr, rep);
|
||||
instr->AssumeRepresentation(rep);
|
||||
ast_context()->ReturnInstruction(instr, expr->id());
|
||||
}
|
||||
|
||||
@ -4707,7 +4707,7 @@ HInstruction* HGraphBuilder::BuildIncrement(HValue* value,
|
||||
rep = Representation::Integer32();
|
||||
}
|
||||
TraceRepresentation(expr->op(), info, instr, rep);
|
||||
AssumeRepresentation(instr, rep);
|
||||
instr->AssumeRepresentation(rep);
|
||||
return instr;
|
||||
}
|
||||
|
||||
@ -4885,7 +4885,7 @@ HInstruction* HGraphBuilder::BuildBinaryOperation(BinaryOperation* expr,
|
||||
rep = Representation::Integer32();
|
||||
}
|
||||
TraceRepresentation(expr->op(), info, instr, rep);
|
||||
AssumeRepresentation(instr, rep);
|
||||
instr->AssumeRepresentation(rep);
|
||||
return instr;
|
||||
}
|
||||
|
||||
@ -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) {
|
||||
if (info.IsSmi()) return Representation::Integer32();
|
||||
if (info.IsInteger32()) return Representation::Integer32();
|
||||
|
Loading…
Reference in New Issue
Block a user