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

Unified Diff: src/property.h

Issue 11365221: Allow property indexes to refer to slots inside the object header. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years, 1 month 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 | « src/objects.cc ('k') | src/property.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/property.h
diff --git a/src/property.h b/src/property.h
index 3faa28b85ed08ae6dedd0b68ce43e0caf8a9d9e3..14e3d006767d1ef924df445d8731a066a6ed206d 100644
--- a/src/property.h
+++ b/src/property.h
@@ -132,6 +132,44 @@ class CallbacksDescriptor: public Descriptor {
};
+// Hold a property index value distinguishing if it is a field index or an
Jakob Kummerow 2012/11/13 10:44:43 nit: s/Hold/Holds/
+// index inside the object header.
+class PropertyIndex {
+ public:
+ static PropertyIndex NewFieldIndex(int index) {
+ return PropertyIndex(index, false);
+ }
+ static PropertyIndex NewHeaderIndex(int index) {
+ return PropertyIndex(index, true);
+ }
+
+ bool IsFieldIndex() { return (index_ & kHeaderIndexBit) == 0; }
Jakob Kummerow 2012/11/13 10:44:43 nit: I think for this and the next three methods,
+ bool IsHeaderIndex() { return (index_ & kHeaderIndexBit) != 0; }
+
+ int FieldIndex() {
+ ASSERT(IsFieldIndex());
+ return value();
+ }
+ int HeaderIndex() {
+ ASSERT(IsHeaderIndex());
+ return value();
+ }
+
+ int RawIndex() { return index_; }
Jakob Kummerow 2012/11/13 10:44:43 I don't see this ever getting called.
+
+ private:
+ static const int kHeaderIndexBit = 1 << 31;
+ static const int kIndexMask = ~kHeaderIndexBit;
+
+ int value() { return index_ & kIndexMask; }
+
+ int index_;
+ PropertyIndex(int index, bool isHeaderBased) :
Jakob Kummerow 2012/11/13 10:44:43 nit1: ':' should be on the second line (see e.g. t
+ index_(index | (isHeaderBased ? kHeaderIndexBit : 0)) {
+ ASSERT(index <= kIndexMask);
+ }
+};
+
Jakob Kummerow 2012/11/13 10:44:43 nit: two lines of whitespace between top-level def
class LookupResult BASE_EMBEDDED {
public:
explicit LookupResult(Isolate* isolate)
@@ -278,7 +316,7 @@ class LookupResult BASE_EMBEDDED {
Object* GetLazyValue() {
switch (type()) {
case FIELD:
- return holder()->FastPropertyAt(GetFieldIndex());
+ return holder()->FastPropertyAt(GetFieldIndex().FieldIndex());
case NORMAL: {
Object* value;
value = holder()->property_dictionary()->ValueAt(GetDictionaryEntry());
@@ -334,10 +372,11 @@ class LookupResult BASE_EMBEDDED {
return number_;
}
- int GetFieldIndex() {
+ PropertyIndex GetFieldIndex() {
ASSERT(lookup_type_ == DESCRIPTOR_TYPE);
ASSERT(IsField());
- return Descriptor::IndexFromValue(GetValue());
+ return PropertyIndex::NewFieldIndex(
+ Descriptor::IndexFromValue(GetValue()));
}
int GetLocalFieldIndexFromMap(Map* map) {
« no previous file with comments | « src/objects.cc ('k') | src/property.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698