From f3f16dc17a8a8cbe1a8945284107cd0943e8faf6 Mon Sep 17 00:00:00 2001 From: "fschneider@chromium.org" Date: Wed, 2 Nov 2011 08:32:40 +0000 Subject: [PATCH] Make non-templatized versions of LIR printing functions. This avoid duplicating the code for each template instance. Also remove dead code from different places in our code base. Removed some verification code from release builds. Review URL: http://codereview.chromium.org/8387070 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@9860 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/code-stubs.h | 2 -- src/hashmap.cc | 6 ------ src/hashmap.h | 5 ----- src/hydrogen-instructions.cc | 29 ++++++++++------------------- src/hydrogen-instructions.h | 3 ++- src/ia32/assembler-ia32.cc | 20 -------------------- src/ia32/assembler-ia32.h | 2 -- src/ia32/lithium-ia32.cc | 15 +++++---------- src/ia32/lithium-ia32.h | 7 ++----- src/scopes.cc | 18 ------------------ src/scopes.h | 6 ------ 11 files changed, 19 insertions(+), 94 deletions(-) diff --git a/src/code-stubs.h b/src/code-stubs.h index 23544bc457..d49ff1d266 100644 --- a/src/code-stubs.h +++ b/src/code-stubs.h @@ -58,10 +58,8 @@ namespace internal { V(FastNewContext) \ V(FastNewBlockContext) \ V(FastCloneShallowArray) \ - V(RevertToNumber) \ V(ToBoolean) \ V(ToNumber) \ - V(CounterOp) \ V(ArgumentsAccess) \ V(RegExpConstructResult) \ V(NumberToString) \ diff --git a/src/hashmap.cc b/src/hashmap.cc index 1422afdc7e..37748a34f8 100644 --- a/src/hashmap.cc +++ b/src/hashmap.cc @@ -39,12 +39,6 @@ namespace internal { Allocator HashMap::DefaultAllocator; -HashMap::HashMap() { - allocator_ = NULL; - match_ = NULL; -} - - HashMap::HashMap(MatchFun match, Allocator* allocator, uint32_t initial_capacity) { diff --git a/src/hashmap.h b/src/hashmap.h index 5c13212eba..4e6a454a3c 100644 --- a/src/hashmap.h +++ b/src/hashmap.h @@ -50,11 +50,6 @@ class HashMap { typedef bool (*MatchFun) (void* key1, void* key2); - // Dummy constructor. This constructor doesn't set up the hash - // map properly so don't use it unless you have good reason (e.g., - // you know that the HashMap will never be used). - HashMap(); - // initial_capacity is the size of the initial hash map; // it must be a power of 2 (and thus must not be 0). explicit HashMap(MatchFun match, diff --git a/src/hydrogen-instructions.cc b/src/hydrogen-instructions.cc index 18a8d01f18..ae623678de 100644 --- a/src/hydrogen-instructions.cc +++ b/src/hydrogen-instructions.cc @@ -126,7 +126,9 @@ void Range::AddConstant(int32_t value) { bool may_overflow = false; // Overflow is ignored here. lower_ = AddWithoutOverflow(lower_, value, &may_overflow); upper_ = AddWithoutOverflow(upper_, value, &may_overflow); +#ifdef DEBUG Verify(); +#endif } @@ -173,7 +175,9 @@ bool Range::AddAndCheckOverflow(Range* other) { lower_ = AddWithoutOverflow(lower_, other->lower(), &may_overflow); upper_ = AddWithoutOverflow(upper_, other->upper(), &may_overflow); KeepOrder(); +#ifdef DEBUG Verify(); +#endif return may_overflow; } @@ -183,7 +187,9 @@ bool Range::SubAndCheckOverflow(Range* other) { lower_ = SubWithoutOverflow(lower_, other->upper(), &may_overflow); upper_ = SubWithoutOverflow(upper_, other->lower(), &may_overflow); KeepOrder(); +#ifdef DEBUG Verify(); +#endif return may_overflow; } @@ -197,9 +203,11 @@ void Range::KeepOrder() { } +#ifdef DEBUG void Range::Verify() const { ASSERT(lower_ <= upper_); } +#endif bool Range::MulAndCheckOverflow(Range* other) { @@ -210,7 +218,9 @@ bool Range::MulAndCheckOverflow(Range* other) { int v4 = MulWithoutOverflow(upper_, other->upper(), &may_overflow); lower_ = Min(Min(v1, v2), Min(v3, v4)); upper_ = Max(Max(v1, v2), Max(v3, v4)); +#ifdef DEBUG Verify(); +#endif return may_overflow; } @@ -234,25 +244,6 @@ const char* HType::ToString() { } -const char* HType::ToShortString() { - switch (type_) { - case kTagged: return "t"; - case kTaggedPrimitive: return "p"; - case kTaggedNumber: return "n"; - case kSmi: return "m"; - case kHeapNumber: return "h"; - case kString: return "s"; - case kBoolean: return "b"; - case kNonPrimitive: return "r"; - case kJSArray: return "a"; - case kJSObject: return "o"; - case kUninitialized: return "z"; - } - UNREACHABLE(); - return "Unreachable code"; -} - - HType HType::TypeFromValue(Handle value) { HType result = HType::Tagged(); if (value->IsSmi()) { diff --git a/src/hydrogen-instructions.h b/src/hydrogen-instructions.h index d475f0114d..101d62a85a 100644 --- a/src/hydrogen-instructions.h +++ b/src/hydrogen-instructions.h @@ -245,7 +245,9 @@ class Range: public ZoneObject { return lower_ >= Smi::kMinValue && upper_ <= Smi::kMaxValue; } void KeepOrder(); +#ifdef DEBUG void Verify() const; +#endif void StackUpon(Range* other) { Intersect(other); @@ -405,7 +407,6 @@ class HType { static HType TypeFromValue(Handle value); const char* ToString(); - const char* ToShortString(); private: enum Type { diff --git a/src/ia32/assembler-ia32.cc b/src/ia32/assembler-ia32.cc index 66a98841a2..c6030f9aaf 100644 --- a/src/ia32/assembler-ia32.cc +++ b/src/ia32/assembler-ia32.cc @@ -628,26 +628,6 @@ void Assembler::movzx_w(Register dst, const Operand& src) { } -void Assembler::cmov(Condition cc, Register dst, int32_t imm32) { - ASSERT(CpuFeatures::IsEnabled(CMOV)); - EnsureSpace ensure_space(this); - UNIMPLEMENTED(); - USE(cc); - USE(dst); - USE(imm32); -} - - -void Assembler::cmov(Condition cc, Register dst, Handle handle) { - ASSERT(CpuFeatures::IsEnabled(CMOV)); - EnsureSpace ensure_space(this); - UNIMPLEMENTED(); - USE(cc); - USE(dst); - USE(handle); -} - - void Assembler::cmov(Condition cc, Register dst, const Operand& src) { ASSERT(CpuFeatures::IsEnabled(CMOV)); EnsureSpace ensure_space(this); diff --git a/src/ia32/assembler-ia32.h b/src/ia32/assembler-ia32.h index 4dfde5f62f..fbd04bb712 100644 --- a/src/ia32/assembler-ia32.h +++ b/src/ia32/assembler-ia32.h @@ -713,8 +713,6 @@ class Assembler : public AssemblerBase { void movzx_w(Register dst, const Operand& src); // Conditional moves - void cmov(Condition cc, Register dst, int32_t imm32); - void cmov(Condition cc, Register dst, Handle handle); void cmov(Condition cc, Register dst, Register src) { cmov(cc, dst, Operand(src)); } diff --git a/src/ia32/lithium-ia32.cc b/src/ia32/lithium-ia32.cc index d8d3a7cecc..227d0b58bb 100644 --- a/src/ia32/lithium-ia32.cc +++ b/src/ia32/lithium-ia32.cc @@ -110,22 +110,17 @@ void LInstruction::PrintTo(StringStream* stream) { } -template -void LTemplateInstruction::PrintDataTo(StringStream* stream) { +void LInstruction::PrintDataTo(StringStream* stream) { stream->Add("= "); - for (int i = 0; i < inputs_.length(); i++) { + for (int i = 0; i < InputCount(); i++) { if (i > 0) stream->Add(" "); - inputs_[i]->PrintTo(stream); + InputAt(i)->PrintTo(stream); } } -template -void LTemplateInstruction::PrintOutputOperandTo(StringStream* stream) { - for (int i = 0; i < results_.length(); i++) { - if (i > 0) stream->Add(" "); - results_[i]->PrintTo(stream); - } +void LInstruction::PrintOutputOperandTo(StringStream* stream) { + if (HasResult()) result()->PrintTo(stream); } diff --git a/src/ia32/lithium-ia32.h b/src/ia32/lithium-ia32.h index 2380a5b917..98487b4630 100644 --- a/src/ia32/lithium-ia32.h +++ b/src/ia32/lithium-ia32.h @@ -192,8 +192,8 @@ class LInstruction: public ZoneObject { virtual void CompileToNative(LCodeGen* generator) = 0; virtual const char* Mnemonic() const = 0; virtual void PrintTo(StringStream* stream); - virtual void PrintDataTo(StringStream* stream) = 0; - virtual void PrintOutputOperandTo(StringStream* stream) = 0; + virtual void PrintDataTo(StringStream* stream); + virtual void PrintOutputOperandTo(StringStream* stream); enum Opcode { // Declare a unique enum value for each instruction. @@ -289,9 +289,6 @@ class LTemplateInstruction: public LInstruction { int TempCount() { return T; } LOperand* TempAt(int i) { return temps_[i]; } - virtual void PrintDataTo(StringStream* stream); - virtual void PrintOutputOperandTo(StringStream* stream); - protected: EmbeddedContainer results_; EmbeddedContainer inputs_; diff --git a/src/scopes.cc b/src/scopes.cc index 3167c4d092..a199da6b2b 100644 --- a/src/scopes.cc +++ b/src/scopes.cc @@ -76,9 +76,6 @@ static bool Match(void* key1, void* key2) { } -// Dummy constructor -VariableMap::VariableMap(bool gotta_love_static_overloading) : HashMap() {} - VariableMap::VariableMap() : HashMap(Match, &LocalsMapAllocator, 8) {} VariableMap::~VariableMap() {} @@ -112,21 +109,6 @@ Variable* VariableMap::Lookup(Handle name) { // ---------------------------------------------------------------------------- // Implementation of Scope - -// Dummy constructor -Scope::Scope(ScopeType type) - : isolate_(Isolate::Current()), - inner_scopes_(0), - variables_(false), - temps_(0), - params_(0), - unresolved_(0), - decls_(0), - already_resolved_(false) { - SetDefaults(type, NULL, Handle::null()); -} - - Scope::Scope(Scope* outer_scope, ScopeType type) : isolate_(Isolate::Current()), inner_scopes_(4), diff --git a/src/scopes.h b/src/scopes.h index a1418874e9..0cd3be5b12 100644 --- a/src/scopes.h +++ b/src/scopes.h @@ -42,10 +42,6 @@ class VariableMap: public HashMap { public: VariableMap(); - // Dummy constructor. This constructor doesn't set up the map - // properly so don't use it unless you have a good reason. - explicit VariableMap(bool gotta_love_static_overloading); - virtual ~VariableMap(); Variable* Declare(Scope* scope, @@ -373,8 +369,6 @@ class Scope: public ZoneObject { protected: friend class ParserFactory; - explicit Scope(ScopeType type); - Isolate* const isolate_; // Scope tree.