Index: src/objects-inl.h |
diff --git a/src/objects-inl.h b/src/objects-inl.h |
index 3f178c0abac12075a204d05e98b7877321b7e97b..1e4c94b58bb5d2f05f8d2b68cf4530920083d50b 100644 |
--- a/src/objects-inl.h |
+++ b/src/objects-inl.h |
@@ -1968,18 +1968,12 @@ void JSObject::FastPropertyAtPut(int index, Object* value) { |
int JSObject::GetInObjectPropertyOffset(int index) { |
- // Adjust for the number of properties stored in the object. |
- index -= map()->inobject_properties(); |
- ASSERT(index < 0); |
- return map()->instance_size() + (index * kPointerSize); |
+ return map()->GetInObjectPropertyOffset(index); |
} |
Object* JSObject::InObjectPropertyAt(int index) { |
- // Adjust for the number of properties stored in the object. |
- index -= map()->inobject_properties(); |
- ASSERT(index < 0); |
- int offset = map()->instance_size() + (index * kPointerSize); |
+ int offset = GetInObjectPropertyOffset(index); |
return READ_FIELD(this, offset); |
} |
@@ -1988,9 +1982,7 @@ Object* JSObject::InObjectPropertyAtPut(int index, |
Object* value, |
WriteBarrierMode mode) { |
// Adjust for the number of properties stored in the object. |
- index -= map()->inobject_properties(); |
- ASSERT(index < 0); |
- int offset = map()->instance_size() + (index * kPointerSize); |
+ int offset = GetInObjectPropertyOffset(index); |
WRITE_FIELD(this, offset, value); |
CONDITIONAL_WRITE_BARRIER(GetHeap(), this, offset, value, mode); |
return value; |
@@ -3791,6 +3783,20 @@ int Map::pre_allocated_property_fields() { |
} |
+int Map::GetInObjectPropertyOffset(int index) { |
+ // Adjust for the number of properties stored in the object. |
+ index -= inobject_properties(); |
+ ASSERT(index < 0); |
+ return instance_size() + (index * kPointerSize); |
+} |
+ |
+ |
+int Map::GetInObjectPropertyIndex(int offset) { |
+ ASSERT(offset >= 0); |
+ return (offset - instance_size()) / kPointerSize + inobject_properties(); |
+} |
+ |
+ |
int HeapObject::SizeFromMap(Map* map) { |
int instance_size = map->instance_size(); |
if (instance_size != kVariableSizeSentinel) return instance_size; |