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

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

Issue 2182103002: [KeyedLoadIC] Support Smi "handlers" for simple field loads (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: rebased Created 4 years, 5 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') | src/full-codegen/full-codegen.cc » ('j') | 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 6811891d4852a9d5785076a9fbbfe950724c083b..f79394824fbbc9187ce68d24560b89e83d9ebec3 100644
--- a/src/field-index-inl.h
+++ b/src/field-index-inl.h
@@ -86,18 +86,18 @@ inline int FieldIndex::GetLoadByFieldIndex() const {
// Takes an offset as computed by GetLoadByFieldOffset and reconstructs a
// FieldIndex object from it.
+// static
inline FieldIndex FieldIndex::ForLoadByFieldOffset(Map* map, int offset) {
- bool is_double = offset & 1;
- int field_index = (offset >> 1) / kPointerSize;
- int is_inobject = true;
+ DCHECK(offset & 1); // Property marker (as opposed to element).
+ bool is_inobject = FieldOffsetIsInobject::decode(offset);
+ bool is_double = FieldOffsetIsDouble::decode(offset);
+ int field_index = FieldOffsetOffset::decode(offset) >> kPointerSizeLog2;
int first_inobject_offset = 0;
- if (field_index < 0) {
- field_index = -field_index;
- is_inobject = false;
- first_inobject_offset = FixedArray::kHeaderSize;
- } else {
+ if (is_inobject) {
first_inobject_offset =
map->IsJSObjectMap() ? map->GetInObjectPropertyOffset(0) : 0;
+ } else {
+ first_inobject_offset = FixedArray::kHeaderSize;
}
int inobject_properties =
map->IsJSObjectMap() ? map->GetInObjectProperties() : 0;
@@ -108,17 +108,13 @@ inline FieldIndex FieldIndex::ForLoadByFieldOffset(Map* map, int offset) {
}
// Returns the offset format consumed by TurboFan stubs:
-// In-object: zero-based from object start,
-// out-of-object: zero-based from FixedArray start.
+// (offset << 3) | (is_double << 2) | (is_inobject << 1) | is_property
+// Where |offset| is relative to object start or FixedArray start, respectively.
inline int FieldIndex::GetLoadByFieldOffset() const {
- // For efficiency, stubs consume an offset that is optimized for quick
- // access. If the property is in-object, the offset is positive.
- // If it's out-of-object, the encoded offset is -raw_offset.
- // In either case, the offset 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() << kPointerSizeLog2;
- if (!is_inobject()) result = -result;
- return (result << 1) | (is_double() ? 1 : 0);
+ return FieldOffsetIsInobject::encode(is_inobject()) |
+ FieldOffsetIsDouble::encode(is_double()) |
+ FieldOffsetOffset::encode(index() << kPointerSizeLog2) |
+ 1; // Property marker (as opposed to element).
}
inline FieldIndex FieldIndex::ForDescriptor(Map* map, int descriptor_index) {
« no previous file with comments | « src/field-index.h ('k') | src/full-codegen/full-codegen.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698