From a5020673cccad404bcd58e4325145a7a79e4b05a Mon Sep 17 00:00:00 2001 From: verwaest Date: Thu, 7 Jul 2016 04:25:55 -0700 Subject: [PATCH] Devirtualize AssignFeedbackVectorSlots In AstNumberingVisitor we always know what node we're dealing with, so there's no reason for this method to be virtual. This additionally deletes 3 calls to AssignFeedbackVectorSlots that would always end up in the empty version. BUG= Review-Url: https://codereview.chromium.org/2128613003 Cr-Commit-Position: refs/heads/master@{#37582} --- src/ast/ast-numbering.cc | 3 --- src/ast/ast.h | 28 ++++++++++------------------ 2 files changed, 10 insertions(+), 21 deletions(-) diff --git a/src/ast/ast-numbering.cc b/src/ast/ast-numbering.cc index 34ce96c135..b7b52a3b79 100644 --- a/src/ast/ast-numbering.cc +++ b/src/ast/ast-numbering.cc @@ -213,7 +213,6 @@ void AstNumberingVisitor::VisitYield(Yield* node) { node->set_yield_id(yield_count_); yield_count_++; IncrementNodeCount(); - ReserveFeedbackSlots(node); node->set_base_id(ReserveIdRange(Yield::num_ids())); Visit(node->generator_object()); Visit(node->expression()); @@ -259,7 +258,6 @@ void AstNumberingVisitor::VisitFunctionDeclaration(FunctionDeclaration* node) { void AstNumberingVisitor::VisitCallRuntime(CallRuntime* node) { IncrementNodeCount(); - ReserveFeedbackSlots(node); node->set_base_id(ReserveIdRange(CallRuntime::num_ids())); VisitArguments(node->arguments()); } @@ -395,7 +393,6 @@ void AstNumberingVisitor::VisitForOfStatement(ForOfStatement* node) { Visit(node->assign_each()); Visit(node->body()); node->set_yield_count(yield_count_ - node->first_yield_id()); - ReserveFeedbackSlots(node); } diff --git a/src/ast/ast.h b/src/ast/ast.h index 0ae2b6fd34..54e776017c 100644 --- a/src/ast/ast.h +++ b/src/ast/ast.h @@ -213,14 +213,6 @@ class AstNode: public ZoneObject { virtual IterationStatement* AsIterationStatement() { return NULL; } virtual MaterializedLiteral* AsMaterializedLiteral() { return NULL; } - // The interface for feedback slots, with default no-op implementations for - // node types which don't actually have this. Note that this is conceptually - // not really nice, but multiple inheritance would introduce yet another - // vtable entry per node, something we don't want for space reasons. - virtual void AssignFeedbackVectorSlots(Isolate* isolate, - FeedbackVectorSpec* spec, - FeedbackVectorSlotCache* cache) {} - private: // Hidden to prevent accidental usage. It would have to load the // current zone from the TLS. @@ -802,7 +794,7 @@ class ForInStatement final : public ForEachStatement { // Type feedback information. void AssignFeedbackVectorSlots(Isolate* isolate, FeedbackVectorSpec* spec, - FeedbackVectorSlotCache* cache) override; + FeedbackVectorSlotCache* cache); FeedbackVectorSlot EachFeedbackSlot() const { return each_slot_; } FeedbackVectorSlot ForInFeedbackSlot() { DCHECK(!for_in_feedback_slot_.IsInvalid()); @@ -1509,7 +1501,7 @@ class ObjectLiteral final : public MaterializedLiteral { // Object literals need one feedback slot for each non-trivial value, as well // as some slots for home objects. void AssignFeedbackVectorSlots(Isolate* isolate, FeedbackVectorSpec* spec, - FeedbackVectorSlotCache* cache) override; + FeedbackVectorSlotCache* cache); protected: ObjectLiteral(Zone* zone, ZoneList* properties, int literal_index, @@ -1635,7 +1627,7 @@ class ArrayLiteral final : public MaterializedLiteral { }; void AssignFeedbackVectorSlots(Isolate* isolate, FeedbackVectorSpec* spec, - FeedbackVectorSlotCache* cache) override; + FeedbackVectorSlotCache* cache); FeedbackVectorSlot LiteralFeedbackSlot() const { return literal_slot_; } protected: @@ -1708,7 +1700,7 @@ class VariableProxy final : public Expression { } void AssignFeedbackVectorSlots(Isolate* isolate, FeedbackVectorSpec* spec, - FeedbackVectorSlotCache* cache) override; + FeedbackVectorSlotCache* cache); FeedbackVectorSlot VariableFeedbackSlot() { return variable_feedback_slot_; } @@ -1808,7 +1800,7 @@ class Property final : public Expression { bool IsSuperAccess() { return obj()->IsSuperPropertyReference(); } void AssignFeedbackVectorSlots(Isolate* isolate, FeedbackVectorSpec* spec, - FeedbackVectorSlotCache* cache) override { + FeedbackVectorSlotCache* cache) { FeedbackVectorSlotKind kind = key()->IsPropertyName() ? FeedbackVectorSlotKind::LOAD_IC : FeedbackVectorSlotKind::KEYED_LOAD_IC; @@ -1863,7 +1855,7 @@ class Call final : public Expression { // Type feedback information. void AssignFeedbackVectorSlots(Isolate* isolate, FeedbackVectorSpec* spec, - FeedbackVectorSlotCache* cache) override; + FeedbackVectorSlotCache* cache); FeedbackVectorSlot CallFeedbackSlot() const { return stub_slot_; } @@ -1987,7 +1979,7 @@ class CallNew final : public Expression { // Type feedback information. void AssignFeedbackVectorSlots(Isolate* isolate, FeedbackVectorSpec* spec, - FeedbackVectorSlotCache* cache) override { + FeedbackVectorSlotCache* cache) { callnew_feedback_slot_ = spec->AddGeneralSlot(); // Construct calls have two slots, one right after the other. // The second slot stores the call count for monomorphic calls. @@ -2235,7 +2227,7 @@ class CountOperation final : public Expression { } void AssignFeedbackVectorSlots(Isolate* isolate, FeedbackVectorSpec* spec, - FeedbackVectorSlotCache* cache) override; + FeedbackVectorSlotCache* cache); FeedbackVectorSlot CountSlot() const { return slot_; } protected: @@ -2427,7 +2419,7 @@ class Assignment final : public Expression { } void AssignFeedbackVectorSlots(Isolate* isolate, FeedbackVectorSpec* spec, - FeedbackVectorSlotCache* cache) override; + FeedbackVectorSlotCache* cache); FeedbackVectorSlot AssignmentSlot() const { return slot_; } protected: @@ -2775,7 +2767,7 @@ class ClassLiteral final : public Expression { // Object literals need one feedback slot for each non-trivial value, as well // as some slots for home objects. void AssignFeedbackVectorSlots(Isolate* isolate, FeedbackVectorSpec* spec, - FeedbackVectorSlotCache* cache) override; + FeedbackVectorSlotCache* cache); bool NeedsProxySlot() const { return class_variable_proxy() != nullptr &&