Revision: 22238
Author: [email protected]
Date: Mon Jul 7 11:35:17 2014 UTC
Log: Hydrogenized KeyedLoadGeneric stub: Fix
FieldIndex::GetLoadByFieldIndex()
[email protected]
Review URL: https://codereview.chromium.org/370573003
http://code.google.com/p/v8/source/detail?r=22238
Modified:
/branches/bleeding_edge/src/field-index-inl.h
/branches/bleeding_edge/src/field-index.h
=======================================
--- /branches/bleeding_edge/src/field-index-inl.h Thu Jun 12 09:58:10 2014
UTC
+++ /branches/bleeding_edge/src/field-index-inl.h Mon Jul 7 11:35:17 2014
UTC
@@ -45,6 +45,8 @@
}
+// 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 @@
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;
}
=======================================
--- /branches/bleeding_edge/src/field-index.h Fri Jun 20 08:40:11 2014 UTC
+++ /branches/bleeding_edge/src/field-index.h Mon Jul 7 11:35:17 2014 UTC
@@ -28,6 +28,8 @@
static FieldIndex ForLoadByFieldIndex(Map* map, int index);
static FieldIndex ForKeyedLookupCacheIndex(Map* map, int index);
+ int GetLoadByFieldIndex() const;
+
bool is_inobject() const {
return IsInObjectBits::decode(bit_field_);
}
@@ -40,6 +42,7 @@
return index() * kPointerSize;
}
+ // Zero-indexed from beginning of the object.
int index() const {
return IndexBits::decode(bit_field_);
}
@@ -49,6 +52,8 @@
return index() - first_inobject_property_offset() / kPointerSize;
}
+ // Zero-based from the first inobject property. Overflows to
out-of-object
+ // properties.
int property_index() const {
ASSERT(!IsHiddenField::decode(bit_field_));
int result = index() - first_inobject_property_offset() / kPointerSize;
@@ -57,21 +62,6 @@
}
return result;
}
-
- int 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() - first_inobject_property_offset() / kPointerSize;
- if (!is_inobject()) {
- result = -result - 1;
- }
- result <<= 1;
- return is_double() ? (result | 1) : result;
- }
int GetKeyedLookupCacheIndex() const;
@@ -100,11 +90,14 @@
static const int kIndexBitsSize = kDescriptorIndexBitCount + 1;
+ // Index from beginning of object.
class IndexBits: public BitField<int, 0, kIndexBitsSize> {};
class IsInObjectBits: public BitField<bool, IndexBits::kNext, 1> {};
class IsDoubleBits: public BitField<bool, IsInObjectBits::kNext, 1> {};
+ // Number of inobject properties.
class InObjectPropertyBits: public BitField<int, IsDoubleBits::kNext,
kDescriptorIndexBitCount> {};
+ // Offset of first inobject property from beginning of object.
class FirstInobjectPropertyOffsetBits:
public BitField<int, InObjectPropertyBits::kNext, 7> {};
class IsHiddenField:
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.