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

Side by Side Diff: src/field-index-inl.h

Issue 329463005: Revert 21720: "Introduce FieldIndex to unify and abstract property/field offset" (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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/field-index.cc ('k') | src/heap-snapshot-generator.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2014 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef V8_FIELD_INDEX_INL_H_
6 #define V8_FIELD_INDEX_INL_H_
7
8 #include "src/field-index.h"
9
10 namespace v8 {
11 namespace internal {
12
13
14 inline FieldIndex FieldIndex::ForInObjectOffset(int offset, Map* map) {
15 ASSERT((offset % kPointerSize) == 0);
16 int index = offset / kPointerSize;
17 if (map == NULL) {
18 return FieldIndex(true, index, false, index + 1, 0, true);
19 }
20 int first_inobject_offset = map->GetInObjectPropertyOffset(0);
21 if (offset < first_inobject_offset) {
22 return FieldIndex(true, index, false, 0, 0, true);
23 } else {
24 return FieldIndex::ForPropertyIndex(map, offset / kPointerSize);
25 }
26 }
27
28
29 inline FieldIndex FieldIndex::ForPropertyIndex(Map* map,
30 int property_index,
31 bool is_double) {
32 ASSERT(map->instance_type() >= FIRST_NONSTRING_TYPE);
33 int inobject_properties = map->inobject_properties();
34 bool is_inobject = property_index < inobject_properties;
35 int first_inobject_offset;
36 if (is_inobject) {
37 first_inobject_offset = map->GetInObjectPropertyOffset(0);
38 } else {
39 first_inobject_offset = FixedArray::kHeaderSize;
40 property_index -= inobject_properties;
41 }
42 return FieldIndex(is_inobject,
43 property_index + first_inobject_offset / kPointerSize,
44 is_double, inobject_properties, first_inobject_offset);
45 }
46
47
48 inline FieldIndex FieldIndex::ForLoadByFieldIndex(Map* map, int orig_index) {
49 int field_index = orig_index;
50 int is_inobject = true;
51 bool is_double = field_index & 1;
52 int first_inobject_offset = 0;
53 field_index >>= 1;
54 if (field_index < 0) {
55 field_index = -(field_index + 1);
56 is_inobject = false;
57 first_inobject_offset = FixedArray::kHeaderSize;
58 field_index += FixedArray::kHeaderSize / kPointerSize;
59 } else {
60 first_inobject_offset = map->GetInObjectPropertyOffset(0);
61 field_index += JSObject::kHeaderSize / kPointerSize;
62 }
63 return FieldIndex(is_inobject, field_index, is_double,
64 map->inobject_properties(), first_inobject_offset);
65 }
66
67
68 inline FieldIndex FieldIndex::ForDescriptor(Map* map, int descriptor_index) {
69 PropertyDetails details =
70 map->instance_descriptors()->GetDetails(descriptor_index);
71 int field_index =
72 map->instance_descriptors()->GetFieldIndex(descriptor_index);
73 return ForPropertyIndex(map, field_index,
74 details.representation().IsDouble());
75 }
76
77
78 } } // namespace v8::internal
79
80 #endif
OLDNEW
« no previous file with comments | « src/field-index.cc ('k') | src/heap-snapshot-generator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698