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

Unified Diff: src/ast.h

Issue 7655017: Improve memory usage of receiver type feedback. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: ReceiverTypeList -> SmallMapList Created 9 years, 4 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
« no previous file with comments | « no previous file | src/ast.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/ast.h
diff --git a/src/ast.h b/src/ast.h
index fccf1aa1cc2f4b235afb3a0836390805bbe65818..f31fa1d0def171d5e844f35438528d98a87466b2 100644
--- a/src/ast.h
+++ b/src/ast.h
@@ -33,6 +33,7 @@
#include "factory.h"
#include "jsregexp.h"
#include "runtime.h"
+#include "small-pointer-list.h"
#include "token.h"
#include "variables.h"
@@ -207,6 +208,35 @@ class Statement: public AstNode {
};
+class SmallMapList {
+ public:
+ SmallMapList() {}
+ explicit SmallMapList(int capacity) : list_(capacity) {}
+
+ void Reserve(int capacty) { list_.Reserve(capacty); }
fschneider 2011/08/22 13:38:06 capacty -> capacity
+ void Clear() { list_.Clear(); }
+
+ bool is_empty() const { return list_.is_empty(); }
+ int length() const { return list_.length(); }
+
+ void Add(Handle<Map> handle) {
+ list_.Add(handle.location());
+ }
+
+ Handle<Map> at(int i) const {
+ return Handle<Map>(list_.at(i));
+ }
+
+ Handle<Map> first() const { return at(0); }
+ Handle<Map> last() const { return at(length() - 1); }
+
+ private:
+ SmallPointerList<Map*> list_;
+
+ DISALLOW_COPY_AND_ASSIGN(SmallMapList);
+};
+
+
class Expression: public AstNode {
public:
enum Context {
@@ -265,13 +295,15 @@ class Expression: public AstNode {
UNREACHABLE();
return false;
}
- virtual ZoneMapList* GetReceiverTypes() {
+ virtual SmallMapList* GetReceiverTypes() {
UNREACHABLE();
return NULL;
}
- virtual Handle<Map> GetMonomorphicReceiverType() {
- UNREACHABLE();
- return Handle<Map>();
+ Handle<Map> GetMonomorphicReceiverType() {
+ ASSERT(IsMonomorphic());
+ SmallMapList* types = GetReceiverTypes();
+ ASSERT(types != NULL && types->length() == 1);
+ return types->at(0);
}
unsigned id() const { return id_; }
@@ -1211,7 +1243,6 @@ class Property: public Expression {
key_(key),
pos_(pos),
type_(type),
- receiver_types_(NULL),
is_monomorphic_(false),
is_array_length_(false),
is_string_length_(false),
@@ -1235,11 +1266,8 @@ class Property: public Expression {
// Type feedback information.
void RecordTypeFeedback(TypeFeedbackOracle* oracle);
virtual bool IsMonomorphic() { return is_monomorphic_; }
- virtual ZoneMapList* GetReceiverTypes() { return receiver_types_; }
+ virtual SmallMapList* GetReceiverTypes() { return &receiver_types_; }
virtual bool IsArrayLength() { return is_array_length_; }
- virtual Handle<Map> GetMonomorphicReceiverType() {
- return monomorphic_receiver_type_;
- }
private:
Expression* obj_;
@@ -1247,13 +1275,12 @@ class Property: public Expression {
int pos_;
Type type_;
- ZoneMapList* receiver_types_;
+ SmallMapList receiver_types_;
bool is_monomorphic_ : 1;
bool is_array_length_ : 1;
bool is_string_length_ : 1;
bool is_string_access_ : 1;
bool is_function_prototype_ : 1;
- Handle<Map> monomorphic_receiver_type_;
};
@@ -1269,7 +1296,6 @@ class Call: public Expression {
pos_(pos),
is_monomorphic_(false),
check_type_(RECEIVER_MAP_CHECK),
- receiver_types_(NULL),
return_id_(GetNextId(isolate)) {
}
@@ -1283,7 +1309,7 @@ class Call: public Expression {
void RecordTypeFeedback(TypeFeedbackOracle* oracle,
CallKind call_kind);
- virtual ZoneMapList* GetReceiverTypes() { return receiver_types_; }
+ virtual SmallMapList* GetReceiverTypes() { return &receiver_types_; }
virtual bool IsMonomorphic() { return is_monomorphic_; }
CheckType check_type() const { return check_type_; }
Handle<JSFunction> target() { return target_; }
@@ -1308,7 +1334,7 @@ class Call: public Expression {
bool is_monomorphic_;
CheckType check_type_;
- ZoneMapList* receiver_types_;
+ SmallMapList receiver_types_;
Handle<JSFunction> target_;
Handle<JSObject> holder_;
Handle<JSGlobalPropertyCell> cell_;
@@ -1483,8 +1509,7 @@ class CountOperation: public Expression {
expression_(expr),
pos_(pos),
assignment_id_(GetNextId(isolate)),
- count_id_(GetNextId(isolate)),
- receiver_types_(NULL) { }
+ count_id_(GetNextId(isolate)) {}
DECLARE_NODE_TYPE(CountOperation)
@@ -1505,10 +1530,7 @@ class CountOperation: public Expression {
void RecordTypeFeedback(TypeFeedbackOracle* oracle);
virtual bool IsMonomorphic() { return is_monomorphic_; }
- virtual Handle<Map> GetMonomorphicReceiverType() {
- return monomorphic_receiver_type_;
- }
- virtual ZoneMapList* GetReceiverTypes() { return receiver_types_; }
+ virtual SmallMapList* GetReceiverTypes() { return &receiver_types_; }
// Bailout support.
int AssignmentId() const { return assignment_id_; }
@@ -1522,8 +1544,7 @@ class CountOperation: public Expression {
int pos_;
int assignment_id_;
int count_id_;
- Handle<Map> monomorphic_receiver_type_;
- ZoneMapList* receiver_types_;
+ SmallMapList receiver_types_;
};
@@ -1671,10 +1692,7 @@ class Assignment: public Expression {
// Type feedback information.
void RecordTypeFeedback(TypeFeedbackOracle* oracle);
virtual bool IsMonomorphic() { return is_monomorphic_; }
- virtual ZoneMapList* GetReceiverTypes() { return receiver_types_; }
- virtual Handle<Map> GetMonomorphicReceiverType() {
- return monomorphic_receiver_type_;
- }
+ virtual SmallMapList* GetReceiverTypes() { return &receiver_types_; }
// Bailout support.
int CompoundLoadId() const { return compound_load_id_; }
@@ -1693,8 +1711,7 @@ class Assignment: public Expression {
bool block_end_;
bool is_monomorphic_;
- ZoneMapList* receiver_types_;
- Handle<Map> monomorphic_receiver_type_;
+ SmallMapList receiver_types_;
};
« no previous file with comments | « no previous file | src/ast.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698