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

Unified Diff: src/objects-inl.h

Issue 300283002: Introduce FieldIndex to unify and abstract property/field offset (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Fix nit 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
Index: src/objects-inl.h
diff --git a/src/objects-inl.h b/src/objects-inl.h
index 36d1aa1d84eeb91cb133d63eab5e4959e7e74187..8abd80229c559929989a8fb55505ac9d2ceb1040 100644
--- a/src/objects-inl.h
+++ b/src/objects-inl.h
@@ -16,6 +16,7 @@
#include "src/objects.h"
#include "src/contexts.h"
#include "src/conversions-inl.h"
+#include "src/field-index-inl.h"
#include "src/heap.h"
#include "src/isolate.h"
#include "src/heap-inl.h"
@@ -1941,29 +1942,24 @@ void JSObject::SetInternalField(int index, Smi* value) {
// Access fast-case object properties at index. The use of these routines
// is needed to correctly distinguish between properties stored in-object and
// properties stored in the properties array.
-Object* JSObject::RawFastPropertyAt(int index) {
+Object* JSObject::RawFastPropertyAt(FieldIndex index) {
// Adjust for the number of properties stored in the object.
Toon Verwaest 2014/06/06 12:00:33 Remove leftover comment
danno 2014/06/06 14:09:57 Done.
- index -= map()->inobject_properties();
- if (index < 0) {
- int offset = map()->instance_size() + (index * kPointerSize);
- return READ_FIELD(this, offset);
+ if (index.is_inobject()) {
+ return READ_FIELD(this, index.offset());
} else {
- ASSERT(index < properties()->length());
- return properties()->get(index);
+ return properties()->get(index.property_index());
}
}
-void JSObject::FastPropertyAtPut(int index, Object* value) {
+void JSObject::FastPropertyAtPut(FieldIndex index, Object* value) {
// Adjust for the number of properties stored in the object.
Toon Verwaest 2014/06/06 12:00:33 Same as above
danno 2014/06/06 14:09:57 Done.
- index -= map()->inobject_properties();
- if (index < 0) {
- int offset = map()->instance_size() + (index * kPointerSize);
+ if (index.is_inobject()) {
+ int offset = index.offset();
WRITE_FIELD(this, offset, value);
WRITE_BARRIER(GetHeap(), this, offset, value);
} else {
- ASSERT(index < properties()->length());
- properties()->set(index, value);
+ properties()->set(index.property_index(), value);
}
}

Powered by Google App Engine
This is Rietveld 408576698