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

Unified Diff: src/field-index-inl.h

Issue 370573003: Hydrogenized KeyedLoadGeneric stub: Fix FieldIndex::GetLoadByFieldIndex() (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 6 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 | « src/field-index.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/field-index-inl.h
diff --git a/src/field-index-inl.h b/src/field-index-inl.h
index d3bf94aec8e726d5d79ec05ed21a449c1d46944d..f1591af50967f0b46b70e201cf74f79f4ab0ac56 100644
--- a/src/field-index-inl.h
+++ b/src/field-index-inl.h
@@ -45,6 +45,8 @@ inline FieldIndex FieldIndex::ForPropertyIndex(Map* map,
}
+// Takes an index as computed by GetLoadFieldByIndex and reconstructs a
+// FieldIndex object from it.
inline FieldIndex FieldIndex::ForLoadByFieldIndex(Map* map, int orig_index) {
int field_index = orig_index;
int is_inobject = true;
@@ -60,8 +62,32 @@ inline FieldIndex FieldIndex::ForLoadByFieldIndex(Map* map, int orig_index) {
first_inobject_offset = map->GetInObjectPropertyOffset(0);
field_index += JSObject::kHeaderSize / kPointerSize;
}
- return FieldIndex(is_inobject, field_index, is_double,
+ FieldIndex result(is_inobject, field_index, is_double,
map->inobject_properties(), first_inobject_offset);
+ ASSERT(result.GetLoadByFieldIndex() == orig_index);
+ return result;
+}
+
+
+// Returns the index format accepted by the HLoadFieldByIndex instruction.
+// (In-object: zero-based from (object start + JSObject::kHeaderSize),
+// out-of-object: zero-based from FixedArray::kHeaderSize.)
+inline int FieldIndex::GetLoadByFieldIndex() const {
+ // For efficiency, the LoadByFieldIndex instruction takes an index that is
+ // optimized for quick access. If the property is inline, the index is
+ // positive. If it's out-of-line, the encoded index is -raw_index - 1 to
+ // disambiguate the zero out-of-line index from the zero inobject case.
+ // The index itself is shifted up by one bit, the lower-most bit
+ // signifying if the field is a mutable double box (1) or not (0).
+ int result = index();
+ if (is_inobject()) {
+ result -= JSObject::kHeaderSize / kPointerSize;
+ } else {
+ result -= FixedArray::kHeaderSize / kPointerSize;
+ result = -result - 1;
+ }
+ result <<= 1;
+ return is_double() ? (result | 1) : result;
}
« no previous file with comments | « src/field-index.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698