Merged FeedbackSlotInterface into AstNode, removing the need for a 2nd vtable.

This tiny change shaves off 112MB from the peak memory usage in the
bug mentioned below, more to come...

BUG=417697
LOG=y
R=mvstanton@chromium.org

Review URL: https://codereview.chromium.org/611393004

git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@24390 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 6482fb3e
...@@ -11,7 +11,6 @@ ...@@ -11,7 +11,6 @@
#include "src/ast-value-factory.h" #include "src/ast-value-factory.h"
#include "src/bailout-reason.h" #include "src/bailout-reason.h"
#include "src/factory.h" #include "src/factory.h"
#include "src/feedback-slots.h"
#include "src/interface.h" #include "src/interface.h"
#include "src/isolate.h" #include "src/isolate.h"
#include "src/jsregexp.h" #include "src/jsregexp.h"
...@@ -233,6 +232,17 @@ class AstNode: public ZoneObject { ...@@ -233,6 +232,17 @@ class AstNode: public ZoneObject {
virtual IterationStatement* AsIterationStatement() { return NULL; } virtual IterationStatement* AsIterationStatement() { return NULL; }
virtual MaterializedLiteral* AsMaterializedLiteral() { 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.
static const int kInvalidFeedbackSlot = -1;
virtual int ComputeFeedbackSlotCount() {
UNREACHABLE();
return 0;
}
virtual void SetFirstFeedbackSlot(int slot) { UNREACHABLE(); }
protected: protected:
// Some nodes re-use bailout IDs for type feedback. // Some nodes re-use bailout IDs for type feedback.
static TypeFeedbackId reuse(BailoutId id) { static TypeFeedbackId reuse(BailoutId id) {
...@@ -914,8 +924,7 @@ class ForEachStatement : public IterationStatement { ...@@ -914,8 +924,7 @@ class ForEachStatement : public IterationStatement {
}; };
class ForInStatement FINAL : public ForEachStatement, class ForInStatement FINAL : public ForEachStatement {
public FeedbackSlotInterface {
public: public:
DECLARE_NODE_TYPE(ForInStatement) DECLARE_NODE_TYPE(ForInStatement)
...@@ -1628,7 +1637,7 @@ class ArrayLiteral FINAL : public MaterializedLiteral { ...@@ -1628,7 +1637,7 @@ class ArrayLiteral FINAL : public MaterializedLiteral {
}; };
class VariableProxy FINAL : public Expression, public FeedbackSlotInterface { class VariableProxy FINAL : public Expression {
public: public:
DECLARE_NODE_TYPE(VariableProxy) DECLARE_NODE_TYPE(VariableProxy)
...@@ -1672,7 +1681,7 @@ class VariableProxy FINAL : public Expression, public FeedbackSlotInterface { ...@@ -1672,7 +1681,7 @@ class VariableProxy FINAL : public Expression, public FeedbackSlotInterface {
}; };
class Property FINAL : public Expression, public FeedbackSlotInterface { class Property FINAL : public Expression {
public: public:
DECLARE_NODE_TYPE(Property) DECLARE_NODE_TYPE(Property)
...@@ -1741,7 +1750,7 @@ class Property FINAL : public Expression, public FeedbackSlotInterface { ...@@ -1741,7 +1750,7 @@ class Property FINAL : public Expression, public FeedbackSlotInterface {
}; };
class Call FINAL : public Expression, public FeedbackSlotInterface { class Call FINAL : public Expression {
public: public:
DECLARE_NODE_TYPE(Call) DECLARE_NODE_TYPE(Call)
...@@ -1844,7 +1853,7 @@ class Call FINAL : public Expression, public FeedbackSlotInterface { ...@@ -1844,7 +1853,7 @@ class Call FINAL : public Expression, public FeedbackSlotInterface {
}; };
class CallNew FINAL : public Expression, public FeedbackSlotInterface { class CallNew FINAL : public Expression {
public: public:
DECLARE_NODE_TYPE(CallNew) DECLARE_NODE_TYPE(CallNew)
...@@ -1907,7 +1916,7 @@ class CallNew FINAL : public Expression, public FeedbackSlotInterface { ...@@ -1907,7 +1916,7 @@ class CallNew FINAL : public Expression, public FeedbackSlotInterface {
// language construct. Instead it is used to call a C or JS function // language construct. Instead it is used to call a C or JS function
// with a set of arguments. This is used from the builtins that are // with a set of arguments. This is used from the builtins that are
// implemented in JavaScript (see "v8natives.js"). // implemented in JavaScript (see "v8natives.js").
class CallRuntime FINAL : public Expression, public FeedbackSlotInterface { class CallRuntime FINAL : public Expression {
public: public:
DECLARE_NODE_TYPE(CallRuntime) DECLARE_NODE_TYPE(CallRuntime)
...@@ -2223,7 +2232,7 @@ class Assignment FINAL : public Expression { ...@@ -2223,7 +2232,7 @@ class Assignment FINAL : public Expression {
}; };
class Yield FINAL : public Expression, public FeedbackSlotInterface { class Yield FINAL : public Expression {
public: public:
DECLARE_NODE_TYPE(Yield) DECLARE_NODE_TYPE(Yield)
...@@ -3038,7 +3047,7 @@ class AstConstructionVisitor BASE_EMBEDDED { ...@@ -3038,7 +3047,7 @@ class AstConstructionVisitor BASE_EMBEDDED {
dont_turbofan_reason_ = reason; dont_turbofan_reason_ = reason;
} }
void add_slot_node(FeedbackSlotInterface* slot_node) { void add_slot_node(AstNode* slot_node) {
int count = slot_node->ComputeFeedbackSlotCount(); int count = slot_node->ComputeFeedbackSlotCount();
if (count > 0) { if (count > 0) {
slot_node->SetFirstFeedbackSlot(properties_.feedback_slots()); slot_node->SetFirstFeedbackSlot(properties_.feedback_slots());
......
// Copyright 2014 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef V8_FEEDBACK_SLOTS_H_
#define V8_FEEDBACK_SLOTS_H_
#include "src/v8.h"
#include "src/isolate.h"
namespace v8 {
namespace internal {
class FeedbackSlotInterface {
public:
static const int kInvalidFeedbackSlot = -1;
virtual ~FeedbackSlotInterface() {}
virtual int ComputeFeedbackSlotCount() = 0;
virtual void SetFirstFeedbackSlot(int slot) = 0;
};
} } // namespace v8::internal
#endif // V8_FEEDBACK_SLOTS_H_
...@@ -15,7 +15,6 @@ ...@@ -15,7 +15,6 @@
#include "src/conversions.h" #include "src/conversions.h"
#include "src/data-flow.h" #include "src/data-flow.h"
#include "src/deoptimizer.h" #include "src/deoptimizer.h"
#include "src/feedback-slots.h"
#include "src/hydrogen-types.h" #include "src/hydrogen-types.h"
#include "src/small-pointer-list.h" #include "src/small-pointer-list.h"
#include "src/unique.h" #include "src/unique.h"
...@@ -5475,8 +5474,7 @@ class HLoadGlobalGeneric FINAL : public HTemplateInstruction<2> { ...@@ -5475,8 +5474,7 @@ class HLoadGlobalGeneric FINAL : public HTemplateInstruction<2> {
Handle<String> name() const { return name_; } Handle<String> name() const { return name_; }
bool for_typeof() const { return for_typeof_; } bool for_typeof() const { return for_typeof_; }
int slot() const { int slot() const {
DCHECK(FLAG_vector_ics && DCHECK(FLAG_vector_ics && slot_ != AstNode::kInvalidFeedbackSlot);
slot_ != FeedbackSlotInterface::kInvalidFeedbackSlot);
return slot_; return slot_;
} }
Handle<FixedArray> feedback_vector() const { return feedback_vector_; } Handle<FixedArray> feedback_vector() const { return feedback_vector_; }
...@@ -5497,8 +5495,9 @@ class HLoadGlobalGeneric FINAL : public HTemplateInstruction<2> { ...@@ -5497,8 +5495,9 @@ class HLoadGlobalGeneric FINAL : public HTemplateInstruction<2> {
private: private:
HLoadGlobalGeneric(HValue* context, HValue* global_object, HLoadGlobalGeneric(HValue* context, HValue* global_object,
Handle<String> name, bool for_typeof) Handle<String> name, bool for_typeof)
: name_(name), for_typeof_(for_typeof), : name_(name),
slot_(FeedbackSlotInterface::kInvalidFeedbackSlot) { for_typeof_(for_typeof),
slot_(AstNode::kInvalidFeedbackSlot) {
SetOperandAt(0, context); SetOperandAt(0, context);
SetOperandAt(1, global_object); SetOperandAt(1, global_object);
set_representation(Representation::Tagged()); set_representation(Representation::Tagged());
...@@ -6478,8 +6477,7 @@ class HLoadNamedGeneric FINAL : public HTemplateInstruction<2> { ...@@ -6478,8 +6477,7 @@ class HLoadNamedGeneric FINAL : public HTemplateInstruction<2> {
Handle<Object> name() const { return name_; } Handle<Object> name() const { return name_; }
int slot() const { int slot() const {
DCHECK(FLAG_vector_ics && DCHECK(FLAG_vector_ics && slot_ != AstNode::kInvalidFeedbackSlot);
slot_ != FeedbackSlotInterface::kInvalidFeedbackSlot);
return slot_; return slot_;
} }
Handle<FixedArray> feedback_vector() const { return feedback_vector_; } Handle<FixedArray> feedback_vector() const { return feedback_vector_; }
...@@ -6499,8 +6497,7 @@ class HLoadNamedGeneric FINAL : public HTemplateInstruction<2> { ...@@ -6499,8 +6497,7 @@ class HLoadNamedGeneric FINAL : public HTemplateInstruction<2> {
private: private:
HLoadNamedGeneric(HValue* context, HValue* object, Handle<Object> name) HLoadNamedGeneric(HValue* context, HValue* object, Handle<Object> name)
: name_(name), : name_(name), slot_(AstNode::kInvalidFeedbackSlot) {
slot_(FeedbackSlotInterface::kInvalidFeedbackSlot) {
SetOperandAt(0, context); SetOperandAt(0, context);
SetOperandAt(1, object); SetOperandAt(1, object);
set_representation(Representation::Tagged()); set_representation(Representation::Tagged());
...@@ -6756,8 +6753,7 @@ class HLoadKeyedGeneric FINAL : public HTemplateInstruction<3> { ...@@ -6756,8 +6753,7 @@ class HLoadKeyedGeneric FINAL : public HTemplateInstruction<3> {
HValue* key() const { return OperandAt(1); } HValue* key() const { return OperandAt(1); }
HValue* context() const { return OperandAt(2); } HValue* context() const { return OperandAt(2); }
int slot() const { int slot() const {
DCHECK(FLAG_vector_ics && DCHECK(FLAG_vector_ics && slot_ != AstNode::kInvalidFeedbackSlot);
slot_ != FeedbackSlotInterface::kInvalidFeedbackSlot);
return slot_; return slot_;
} }
Handle<FixedArray> feedback_vector() const { return feedback_vector_; } Handle<FixedArray> feedback_vector() const { return feedback_vector_; }
...@@ -6780,7 +6776,7 @@ class HLoadKeyedGeneric FINAL : public HTemplateInstruction<3> { ...@@ -6780,7 +6776,7 @@ class HLoadKeyedGeneric FINAL : public HTemplateInstruction<3> {
private: private:
HLoadKeyedGeneric(HValue* context, HValue* obj, HValue* key) HLoadKeyedGeneric(HValue* context, HValue* obj, HValue* key)
: slot_(FeedbackSlotInterface::kInvalidFeedbackSlot) { : slot_(AstNode::kInvalidFeedbackSlot) {
set_representation(Representation::Tagged()); set_representation(Representation::Tagged());
SetOperandAt(0, obj); SetOperandAt(0, obj);
SetOperandAt(1, key); SetOperandAt(1, key);
......
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