Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(148)

Unified Diff: src/feedbackslots.h

Issue 137403009: Adding a type vector to replace type cells. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Seperate file for feedback slot allocation. Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/feedbackslots.h
diff --git a/src/rewriter.h b/src/feedbackslots.h
similarity index 65%
copy from src/rewriter.h
copy to src/feedbackslots.h
index 59914d97f9155cbdbc785e9a4272f0698f1c3a6a..1e73afc36396cc5c8c7b04f9fb6569fc538857b8 100644
--- a/src/rewriter.h
+++ b/src/feedbackslots.h
@@ -1,4 +1,4 @@
-// Copyright 2011 the V8 project authors. All rights reserved.
+// Copyright 2014 the V8 project authors. All rights reserved.
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
@@ -25,23 +25,41 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#ifndef V8_REWRITER_H_
-#define V8_REWRITER_H_
+#ifndef V8_FEEDBACKSLOTS_H_
+#define V8_FEEDBACKSLOTS_H_
+#include "ast.h"
namespace v8 {
namespace internal {
-class CompilationInfo;
-
-class Rewriter {
+class FeedbackSlotAllocator: public AstVisitor {
public:
- // Rewrite top-level code (ECMA 262 "programs") so as to conservatively
- // include an assignment of the value of the last statement in the code to
- // a compiler-generated temporary variable wherever needed.
+ // Allocate feedback slots for ast nodes that require them.
//
// Assumes code has been parsed and scopes have been analyzed. Mutates the
// AST, so the AST should not continue to be used in the case of failure.
- static bool Rewrite(CompilationInfo* info);
+ static bool Run(CompilationInfo* info);
+
+ private:
+ explicit FeedbackSlotAllocator(Zone* zone) : used_(0) {
danno 2014/01/28 08:27:17 I worry that the additional pass over the AST migh
mvstanton 2014/01/30 15:13:41 Although it didn't appear to cost much (nodes in t
+ InitializeAstVisitor(zone);
+ }
+
+ int slot_count() const { return used_; }
+
+ // AST node visit functions.
+#define DECLARE_VISIT(type) virtual void Visit##type(type* node) { \
+ used_ = node->ConsumeFeedbackSlots(isolate(), used_); \
+ DoVisit##type(node); \
+ } \
+ void DoVisit##type(type* node);
+ AST_NODE_LIST(DECLARE_VISIT)
+#undef DECLARE_VISIT
+
+ int used_;
+
+ DEFINE_AST_VISITOR_SUBCLASS_MEMBERS();
+ DISALLOW_COPY_AND_ASSIGN(FeedbackSlotAllocator);
};

Powered by Google App Engine
This is Rietveld 408576698