From c417df74f44efde5b94bc2092fddb15e83366cf1 Mon Sep 17 00:00:00 2001 From: "verwaest@chromium.org" Date: Fri, 24 May 2013 12:29:37 +0000 Subject: [PATCH] Update representation-from-uses to support smi. R=jkummerow@chromium.org Review URL: https://chromiumcodereview.appspot.com/15692004 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@14801 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/hydrogen-instructions.cc | 17 ++++++++++++----- src/hydrogen-instructions.h | 6 ++++++ src/string-stream.cc | 8 ++++++++ src/string-stream.h | 6 ++++++ 4 files changed, 32 insertions(+), 5 deletions(-) diff --git a/src/hydrogen-instructions.cc b/src/hydrogen-instructions.cc index fa8ee86..e949587 100644 --- a/src/hydrogen-instructions.cc +++ b/src/hydrogen-instructions.cc @@ -108,10 +108,12 @@ Representation HValue::RepresentationFromUses() { int tagged_count = use_count[Representation::kTagged]; int double_count = use_count[Representation::kDouble]; int int32_count = use_count[Representation::kInteger32]; + int smi_count = use_count[Representation::kSmi]; if (tagged_count > 0) return Representation::Tagged(); if (double_count > 0) return Representation::Double(); if (int32_count > 0) return Representation::Integer32(); + if (smi_count > 0) return Representation::Smi(); return Representation::None(); } @@ -1909,8 +1911,9 @@ void HPhi::PrintTo(StringStream* stream) { value->PrintNameTo(stream); stream->Add(" "); } - stream->Add(" uses:%d_%di_%dd_%dt", + stream->Add(" uses:%d_%ds_%di_%dd_%dt", UseCount(), + smi_non_phi_uses() + smi_indirect_uses(), int32_non_phi_uses() + int32_indirect_uses(), double_non_phi_uses() + double_indirect_uses(), tagged_non_phi_uses() + tagged_indirect_uses()); @@ -1989,8 +1992,9 @@ void HPhi::InitRealUses(int phi_id) { void HPhi::AddNonPhiUsesFrom(HPhi* other) { if (FLAG_trace_representation) { - PrintF("adding to #%d Phi uses of #%d Phi: i%d d%d t%d\n", + PrintF("adding to #%d Phi uses of #%d Phi: s%d i%d d%d t%d\n", id(), other->id(), + other->non_phi_uses_[Representation::kSmi], other->non_phi_uses_[Representation::kInteger32], other->non_phi_uses_[Representation::kDouble], other->non_phi_uses_[Representation::kTagged]); @@ -3546,21 +3550,24 @@ void HPhi::InferRepresentation(HInferRepresentation* h_infer) { Representation HPhi::RepresentationFromInputs() { bool double_occurred = false; bool int32_occurred = false; + bool smi_occurred = false; for (int i = 0; i < OperandCount(); ++i) { HValue* value = OperandAt(i); if (value->IsUnknownOSRValue()) { HPhi* hint_value = HUnknownOSRValue::cast(value)->incoming_value(); if (hint_value != NULL) { Representation hint = hint_value->representation(); - if (hint.IsSmiOrTagged()) return hint; + if (hint.IsTagged()) return hint; if (hint.IsDouble()) double_occurred = true; if (hint.IsInteger32()) int32_occurred = true; + if (hint.IsSmi()) smi_occurred = true; } continue; } if (value->representation().IsDouble()) double_occurred = true; if (value->representation().IsInteger32()) int32_occurred = true; - if (value->representation().IsSmiOrTagged()) { + if (value->representation().IsSmi()) smi_occurred = true; + if (value->representation().IsTagged()) { if (value->IsConstant()) { HConstant* constant = HConstant::cast(value); if (constant->IsConvertibleToInteger()) { @@ -3579,8 +3586,8 @@ Representation HPhi::RepresentationFromInputs() { } if (double_occurred) return Representation::Double(); - if (int32_occurred) return Representation::Integer32(); + if (smi_occurred) return Representation::Smi(); return Representation::None(); } diff --git a/src/hydrogen-instructions.h b/src/hydrogen-instructions.h index 116c4e7..43a5ad8 100644 --- a/src/hydrogen-instructions.h +++ b/src/hydrogen-instructions.h @@ -3000,6 +3000,9 @@ class HPhi: public HValue { int tagged_non_phi_uses() const { return non_phi_uses_[Representation::kTagged]; } + int smi_non_phi_uses() const { + return non_phi_uses_[Representation::kSmi]; + } int int32_non_phi_uses() const { return non_phi_uses_[Representation::kInteger32]; } @@ -3009,6 +3012,9 @@ class HPhi: public HValue { int tagged_indirect_uses() const { return indirect_uses_[Representation::kTagged]; } + int smi_indirect_uses() const { + return indirect_uses_[Representation::kSmi]; + } int int32_indirect_uses() const { return indirect_uses_[Representation::kInteger32]; } diff --git a/src/string-stream.cc b/src/string-stream.cc index ebe1b5b..ba4a65c 100644 --- a/src/string-stream.cc +++ b/src/string-stream.cc @@ -252,6 +252,14 @@ void StringStream::Add(const char* format, FmtElm arg0, FmtElm arg1, } +void StringStream::Add(const char* format, FmtElm arg0, FmtElm arg1, + FmtElm arg2, FmtElm arg3, FmtElm arg4) { + const char argc = 5; + FmtElm argv[argc] = { arg0, arg1, arg2, arg3, arg4 }; + Add(CStrVector(format), Vector(argv, argc)); +} + + SmartArrayPointer StringStream::ToCString() const { char* str = NewArray(length_ + 1); OS::MemCopy(str, buffer_, length_); diff --git a/src/string-stream.h b/src/string-stream.h index 88b4afe..2367994 100644 --- a/src/string-stream.h +++ b/src/string-stream.h @@ -137,6 +137,12 @@ class StringStream { FmtElm arg1, FmtElm arg2, FmtElm arg3); + void Add(const char* format, + FmtElm arg0, + FmtElm arg1, + FmtElm arg2, + FmtElm arg3, + FmtElm arg4); // Getting the message out. void OutputToFile(FILE* out); -- 2.7.4