Made the output of the --trace-representation flag a bit more informative and

centralized its handling.
Review URL: http://codereview.chromium.org/6969034

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@7874 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent b9c771c1
...@@ -4694,10 +4694,12 @@ HInstruction* HGraphBuilder::BuildIncrement(HValue* value, ...@@ -4694,10 +4694,12 @@ HInstruction* HGraphBuilder::BuildIncrement(HValue* value,
? graph_->GetConstant1() ? graph_->GetConstant1()
: graph_->GetConstantMinus1(); : graph_->GetConstantMinus1();
HInstruction* instr = new(zone()) HAdd(value, delta); HInstruction* instr = new(zone()) HAdd(value, delta);
Representation rep = ToRepresentation(oracle()->IncrementType(expr)); TypeInfo info = oracle()->IncrementType(expr);
Representation rep = ToRepresentation(info);
if (rep.IsTagged()) { if (rep.IsTagged()) {
rep = Representation::Integer32(); rep = Representation::Integer32();
} }
TraceRepresentation(expr->op(), info, instr, rep);
AssumeRepresentation(instr, rep); AssumeRepresentation(instr, rep);
return instr; return instr;
} }
...@@ -4870,14 +4872,12 @@ HInstruction* HGraphBuilder::BuildBinaryOperation(BinaryOperation* expr, ...@@ -4870,14 +4872,12 @@ HInstruction* HGraphBuilder::BuildBinaryOperation(BinaryOperation* expr,
(right->IsConstant() && HConstant::cast(right)->HasStringValue()))) { (right->IsConstant() && HConstant::cast(right)->HasStringValue()))) {
return instr; return instr;
} }
if (FLAG_trace_representation) {
PrintF("Info: %s/%s\n", info.ToString(), ToRepresentation(info).Mnemonic());
}
Representation rep = ToRepresentation(info); Representation rep = ToRepresentation(info);
// We only generate either int32 or generic tagged bitwise operations. // We only generate either int32 or generic tagged bitwise operations.
if (instr->IsBitwiseBinaryOperation() && rep.IsDouble()) { if (instr->IsBitwiseBinaryOperation() && rep.IsDouble()) {
rep = Representation::Integer32(); rep = Representation::Integer32();
} }
TraceRepresentation(expr->op(), info, instr, rep);
AssumeRepresentation(instr, rep); AssumeRepresentation(instr, rep);
return instr; return instr;
} }
...@@ -5046,20 +5046,32 @@ void HGraphBuilder::VisitCommon(BinaryOperation* expr) { ...@@ -5046,20 +5046,32 @@ void HGraphBuilder::VisitCommon(BinaryOperation* expr) {
} }
void HGraphBuilder::AssumeRepresentation(HValue* value, Representation r) { void HGraphBuilder::TraceRepresentation(Token::Value op,
TypeInfo info,
HValue* value,
Representation rep) {
if (!FLAG_trace_representation) return;
// TODO(svenpanne) Under which circumstances are we actually not flexible?
// At first glance, this looks a bit weird...
bool flexible = value->CheckFlag(HValue::kFlexibleRepresentation);
PrintF("Operation %s has type info %s, %schange representation assumption "
"for %s (ID %d) from %s to %s\n",
Token::Name(op),
info.ToString(),
flexible ? "" : " DO NOT ",
value->Mnemonic(),
graph_->GetMaximumValueID(),
value->representation().Mnemonic(),
rep.Mnemonic());
}
void HGraphBuilder::AssumeRepresentation(HValue* value, Representation rep) {
if (value->CheckFlag(HValue::kFlexibleRepresentation)) { if (value->CheckFlag(HValue::kFlexibleRepresentation)) {
if (FLAG_trace_representation) { value->ChangeRepresentation(rep);
PrintF("Assume representation for %s to be %s (%d)\n",
value->Mnemonic(),
r.Mnemonic(),
graph_->GetMaximumValueID());
}
value->ChangeRepresentation(r);
// The representation of the value is dictated by type feedback and // The representation of the value is dictated by type feedback and
// will not be changed later. // will not be changed later.
value->ClearFlag(HValue::kFlexibleRepresentation); value->ClearFlag(HValue::kFlexibleRepresentation);
} else if (FLAG_trace_representation) {
PrintF("No representation assumed\n");
} }
} }
......
...@@ -819,7 +819,11 @@ class HGraphBuilder: public AstVisitor { ...@@ -819,7 +819,11 @@ class HGraphBuilder: public AstVisitor {
// to push them as outgoing parameters. // to push them as outgoing parameters.
template <int V> HInstruction* PreProcessCall(HCall<V>* call); template <int V> HInstruction* PreProcessCall(HCall<V>* call);
void AssumeRepresentation(HValue* value, Representation r); void TraceRepresentation(Token::Value op,
TypeInfo info,
HValue* value,
Representation rep);
void AssumeRepresentation(HValue* value, Representation rep);
static Representation ToRepresentation(TypeInfo info); static Representation ToRepresentation(TypeInfo info);
void SetupScope(Scope* scope); void SetupScope(Scope* scope);
......
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