From c5b7b9f72f302d7a207769bf523e8a3476f0f322 Mon Sep 17 00:00:00 2001 From: mvstanton Date: Fri, 22 May 2015 07:32:31 -0700 Subject: [PATCH] Remove unnecessary TypeFeedbackIds, saves memory and simplifies TurboFan. Consequence of going whole-hog for vector-based Load/KeyedLoad ICs. BUG= Review URL: https://codereview.chromium.org/1152063003 Cr-Commit-Position: refs/heads/master@{#28596} --- src/ast.h | 15 ++------- src/compiler/ast-graph-builder.cc | 56 ++++++++++++++----------------- src/compiler/ast-graph-builder.h | 4 +-- 3 files changed, 31 insertions(+), 44 deletions(-) diff --git a/src/ast.h b/src/ast.h index 9300330370..44339c7c9f 100644 --- a/src/ast.h +++ b/src/ast.h @@ -1663,9 +1663,8 @@ class Property final : public Expression { Expression* obj() const { return obj_; } Expression* key() const { return key_; } - static int num_ids() { return parent_num_ids() + 2; } + static int num_ids() { return parent_num_ids() + 1; } BailoutId LoadId() const { return BailoutId(local_id(0)); } - TypeFeedbackId PropertyFeedbackId() { return TypeFeedbackId(local_id(1)); } bool IsStringAccess() const { return IsStringAccessField::decode(bit_field_); @@ -1972,10 +1971,7 @@ class CallRuntime final : public Expression { return callruntime_feedback_slot_; } - static int num_ids() { return parent_num_ids() + 1; } - TypeFeedbackId CallRuntimeFeedbackId() const { - return TypeFeedbackId(local_id(0)); - } + static int num_ids() { return parent_num_ids(); } protected: CallRuntime(Zone* zone, const AstRawString* name, @@ -1989,8 +1985,6 @@ class CallRuntime final : public Expression { static int parent_num_ids() { return Expression::num_ids(); } private: - int local_id(int n) const { return base_id() + parent_num_ids() + n; } - const AstRawString* raw_name_; const Runtime::Function* function_; ZoneList* arguments_; @@ -2697,8 +2691,7 @@ class SuperReference final : public Expression { VariableProxy* this_var() const { return this_var_; } - static int num_ids() { return parent_num_ids() + 1; } - TypeFeedbackId HomeObjectFeedbackId() { return TypeFeedbackId(local_id(0)); } + static int num_ids() { return parent_num_ids(); } // Type feedback information. virtual FeedbackVectorRequirements ComputeFeedbackRequirements( @@ -2726,8 +2719,6 @@ class SuperReference final : public Expression { static int parent_num_ids() { return Expression::num_ids(); } private: - int local_id(int n) const { return base_id() + parent_num_ids() + n; } - VariableProxy* this_var_; FeedbackVectorICSlot homeobject_feedback_slot_; }; diff --git a/src/compiler/ast-graph-builder.cc b/src/compiler/ast-graph-builder.cc index 0d01a5a08b..fccc55dd7e 100644 --- a/src/compiler/ast-graph-builder.cc +++ b/src/compiler/ast-graph-builder.cc @@ -2129,8 +2129,7 @@ void AstGraphBuilder::VisitAssignment(Assignment* expr) { VectorSlotPair pair = CreateVectorSlotPair(property->PropertyFeedbackSlot()); FrameStateBeforeAndAfter states(this, property->obj()->id()); - old_value = - BuildNamedLoad(object, name, pair, property->PropertyFeedbackId()); + old_value = BuildNamedLoad(object, name, pair); states.AddToNode(old_value, property->LoadId(), OutputFrameStateCombine::Push()); break; @@ -2141,8 +2140,7 @@ void AstGraphBuilder::VisitAssignment(Assignment* expr) { VectorSlotPair pair = CreateVectorSlotPair(property->PropertyFeedbackSlot()); FrameStateBeforeAndAfter states(this, property->key()->id()); - old_value = - BuildKeyedLoad(object, key, pair, property->PropertyFeedbackId()); + old_value = BuildKeyedLoad(object, key, pair); states.AddToNode(old_value, property->LoadId(), OutputFrameStateCombine::Push()); break; @@ -2227,7 +2225,7 @@ void AstGraphBuilder::VisitProperty(Property* expr) { FrameStateBeforeAndAfter states(this, expr->obj()->id()); Node* object = environment()->Pop(); Handle name = expr->key()->AsLiteral()->AsPropertyName(); - value = BuildNamedLoad(object, name, pair, expr->PropertyFeedbackId()); + value = BuildNamedLoad(object, name, pair); states.AddToNode(value, expr->id(), ast_context()->GetStateCombine()); } else { VisitForValue(expr->obj()); @@ -2235,7 +2233,7 @@ void AstGraphBuilder::VisitProperty(Property* expr) { FrameStateBeforeAndAfter states(this, expr->key()->id()); Node* key = environment()->Pop(); Node* object = environment()->Pop(); - value = BuildKeyedLoad(object, key, pair, expr->PropertyFeedbackId()); + value = BuildKeyedLoad(object, key, pair); states.AddToNode(value, expr->id(), ast_context()->GetStateCombine()); } ast_context()->ProduceValue(value); @@ -2286,16 +2284,14 @@ void AstGraphBuilder::VisitCall(Call* expr) { if (property->key()->IsPropertyName()) { FrameStateBeforeAndAfter states(this, property->obj()->id()); Handle name = property->key()->AsLiteral()->AsPropertyName(); - callee_value = - BuildNamedLoad(object, name, pair, property->PropertyFeedbackId()); + callee_value = BuildNamedLoad(object, name, pair); states.AddToNode(callee_value, property->LoadId(), OutputFrameStateCombine::Push()); } else { VisitForValue(property->key()); FrameStateBeforeAndAfter states(this, property->key()->id()); Node* key = environment()->Pop(); - callee_value = - BuildKeyedLoad(object, key, pair, property->PropertyFeedbackId()); + callee_value = BuildKeyedLoad(object, key, pair); states.AddToNode(callee_value, property->LoadId(), OutputFrameStateCombine::Push()); } @@ -2410,8 +2406,7 @@ void AstGraphBuilder::VisitCallJSRuntime(CallRuntime* expr) { VectorSlotPair pair = CreateVectorSlotPair(expr->CallRuntimeFeedbackSlot()); // TODO(jarin): bailout ids for runtime calls. FrameStateBeforeAndAfter states(this, BailoutId::None()); - Node* callee_value = - BuildNamedLoad(receiver_value, name, pair, expr->CallRuntimeFeedbackId()); + Node* callee_value = BuildNamedLoad(receiver_value, name, pair); states.AddToNode(callee_value, BailoutId::None(), OutputFrameStateCombine::Push()); environment()->Push(callee_value); @@ -2501,8 +2496,7 @@ void AstGraphBuilder::VisitCountOperation(CountOperation* expr) { Handle name = property->key()->AsLiteral()->AsPropertyName(); VectorSlotPair pair = CreateVectorSlotPair(property->PropertyFeedbackSlot()); - old_value = - BuildNamedLoad(object, name, pair, property->PropertyFeedbackId()); + old_value = BuildNamedLoad(object, name, pair); states.AddToNode(old_value, property->LoadId(), OutputFrameStateCombine::Push()); stack_depth = 1; @@ -2516,8 +2510,7 @@ void AstGraphBuilder::VisitCountOperation(CountOperation* expr) { Node* object = environment()->Peek(1); VectorSlotPair pair = CreateVectorSlotPair(property->PropertyFeedbackSlot()); - old_value = - BuildKeyedLoad(object, key, pair, property->PropertyFeedbackId()); + old_value = BuildKeyedLoad(object, key, pair); states.AddToNode(old_value, property->LoadId(), OutputFrameStateCombine::Push()); stack_depth = 2; @@ -3012,8 +3005,7 @@ Node* AstGraphBuilder::BuildVariableLoad(FrameStateBeforeAndAfter& states, // Global var, const, or let variable. Node* global = BuildLoadGlobalObject(); Handle name = variable->name(); - Node* node = BuildNamedLoad(global, name, feedback, - TypeFeedbackId::None(), contextual_mode); + Node* node = BuildNamedLoad(global, name, feedback, contextual_mode); states.AddToNode(node, bailout_id, combine); return node; } @@ -3218,38 +3210,43 @@ Node* AstGraphBuilder::BuildVariableAssignment( static inline Node* Record(JSTypeFeedbackTable* js_type_feedback, Node* node, - TypeFeedbackId id, FeedbackVectorICSlot slot) { + FeedbackVectorICSlot slot) { if (js_type_feedback) { - js_type_feedback->Record(node, id); js_type_feedback->Record(node, slot); } return node; } +static inline Node* Record(JSTypeFeedbackTable* js_type_feedback, Node* node, + TypeFeedbackId id) { + if (js_type_feedback) { + js_type_feedback->Record(node, id); + } + return node; +} + + Node* AstGraphBuilder::BuildKeyedLoad(Node* object, Node* key, - const VectorSlotPair& feedback, - TypeFeedbackId id) { + const VectorSlotPair& feedback) { const Operator* op = javascript()->LoadProperty(feedback); - return Record(js_type_feedback_, NewNode(op, object, key), id, - feedback.slot()); + return Record(js_type_feedback_, NewNode(op, object, key), feedback.slot()); } Node* AstGraphBuilder::BuildNamedLoad(Node* object, Handle name, const VectorSlotPair& feedback, - TypeFeedbackId id, ContextualMode mode) { + ContextualMode mode) { const Operator* op = javascript()->LoadNamed(MakeUnique(name), feedback, mode); - return Record(js_type_feedback_, NewNode(op, object), id, feedback.slot()); + return Record(js_type_feedback_, NewNode(op, object), feedback.slot()); } Node* AstGraphBuilder::BuildKeyedStore(Node* object, Node* key, Node* value, TypeFeedbackId id) { const Operator* op = javascript()->StoreProperty(language_mode()); - return Record(js_type_feedback_, NewNode(op, object, key, value), id, - FeedbackVectorICSlot::Invalid()); + return Record(js_type_feedback_, NewNode(op, object, key, value), id); } @@ -3257,8 +3254,7 @@ Node* AstGraphBuilder::BuildNamedStore(Node* object, Handle name, Node* value, TypeFeedbackId id) { const Operator* op = javascript()->StoreNamed(language_mode(), MakeUnique(name)); - return Record(js_type_feedback_, NewNode(op, object, value), id, - FeedbackVectorICSlot::Invalid()); + return Record(js_type_feedback_, NewNode(op, object, value), id); } diff --git a/src/compiler/ast-graph-builder.h b/src/compiler/ast-graph-builder.h index c7d604cada..40b7732fcb 100644 --- a/src/compiler/ast-graph-builder.h +++ b/src/compiler/ast-graph-builder.h @@ -268,9 +268,9 @@ class AstGraphBuilder : public AstVisitor { // Builders for property loads and stores. Node* BuildKeyedLoad(Node* receiver, Node* key, - const VectorSlotPair& feedback, TypeFeedbackId id); + const VectorSlotPair& feedback); Node* BuildNamedLoad(Node* receiver, Handle name, - const VectorSlotPair& feedback, TypeFeedbackId id, + const VectorSlotPair& feedback, ContextualMode mode = NOT_CONTEXTUAL); Node* BuildKeyedStore(Node* receiver, Node* key, Node* value, TypeFeedbackId id);