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

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

Issue 391693002: In-object double fields unboxing (for 64-bit only). (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef V8_FIELD_INDEX_H_ 5 #ifndef V8_FIELD_INDEX_H_
6 #define V8_FIELD_INDEX_H_ 6 #define V8_FIELD_INDEX_H_
7 7
8 #include "src/property-details.h" 8 #include "src/property-details.h"
9 #include "src/utils.h" 9 #include "src/utils.h"
10 10
(...skipping 16 matching lines...) Expand all
27 static FieldIndex ForDescriptor(Map* map, int descriptor_index); 27 static FieldIndex ForDescriptor(Map* map, int descriptor_index);
28 static FieldIndex ForLoadByFieldIndex(Map* map, int index); 28 static FieldIndex ForLoadByFieldIndex(Map* map, int index);
29 static FieldIndex ForKeyedLookupCacheIndex(Map* map, int index); 29 static FieldIndex ForKeyedLookupCacheIndex(Map* map, int index);
30 30
31 int GetLoadByFieldIndex() const; 31 int GetLoadByFieldIndex() const;
32 32
33 bool is_inobject() const { 33 bool is_inobject() const {
34 return IsInObjectBits::decode(bit_field_); 34 return IsInObjectBits::decode(bit_field_);
35 } 35 }
36 36
37 bool is_hidden_field() const { return IsHiddenField::decode(bit_field_); }
38
37 bool is_double() const { 39 bool is_double() const {
38 return IsDoubleBits::decode(bit_field_); 40 return IsDoubleBits::decode(bit_field_);
39 } 41 }
40 42
41 int offset() const { 43 int offset() const {
42 return index() * kPointerSize; 44 return index() * kPointerSize;
43 } 45 }
44 46
45 // Zero-indexed from beginning of the object. 47 // Zero-indexed from beginning of the object.
46 int index() const { 48 int index() const {
47 return IndexBits::decode(bit_field_); 49 return IndexBits::decode(bit_field_);
48 } 50 }
49 51
50 int outobject_array_index() const { 52 int outobject_array_index() const {
51 ASSERT(!is_inobject()); 53 ASSERT(!is_inobject());
52 return index() - first_inobject_property_offset() / kPointerSize; 54 return index() - first_inobject_property_offset() / kPointerSize;
53 } 55 }
54 56
55 // Zero-based from the first inobject property. Overflows to out-of-object 57 // Zero-based from the first inobject property. Overflows to out-of-object
56 // properties. 58 // properties.
57 int property_index() const { 59 int property_index() const {
58 ASSERT(!IsHiddenField::decode(bit_field_)); 60 ASSERT(!is_hidden_field());
59 int result = index() - first_inobject_property_offset() / kPointerSize; 61 int result = index() - first_inobject_property_offset() / kPointerSize;
60 if (!is_inobject()) { 62 if (!is_inobject()) {
61 result += InObjectPropertyBits::decode(bit_field_); 63 result += InObjectPropertyBits::decode(bit_field_);
62 } 64 }
63 return result; 65 return result;
64 } 66 }
65 67
66 int GetKeyedLookupCacheIndex() const; 68 int GetKeyedLookupCacheIndex() const;
67 69
68 int GetLoadFieldStubKey() const { 70 int GetLoadFieldStubKey() const {
69 return bit_field_ & 71 return bit_field_ &
70 (IsInObjectBits::kMask | IsDoubleBits::kMask | IndexBits::kMask); 72 (IsInObjectBits::kMask | IsDoubleBits::kMask | IndexBits::kMask);
71 } 73 }
72 74
73 private: 75 private:
74 FieldIndex(bool is_inobject, int local_index, bool is_double, 76 FieldIndex(bool is_inobject, int local_index, bool is_double,
75 int inobject_properties, int first_inobject_property_offset, 77 int inobject_properties, int first_inobject_property_offset,
76 bool is_hidden = false) { 78 bool is_hidden = false) {
77 ASSERT((first_inobject_property_offset & (kPointerSize - 1)) == 0); 79 ASSERT((first_inobject_property_offset & (kPointerSize - 1)) == 0);
78 bit_field_ = IsInObjectBits::encode(is_inobject) | 80 bit_field_ = IsInObjectBits::encode(is_inobject) |
79 IsDoubleBits::encode(is_double) | 81 IsDoubleBits::encode(is_double) |
80 FirstInobjectPropertyOffsetBits::encode(first_inobject_property_offset) | 82 FirstInobjectPropertyOffsetBits::encode(first_inobject_property_offset) |
81 IsHiddenField::encode(is_hidden) | 83 IsHiddenField::encode(is_hidden) |
82 IndexBits::encode(local_index) | 84 IndexBits::encode(local_index) |
83 InObjectPropertyBits::encode(inobject_properties); 85 InObjectPropertyBits::encode(inobject_properties);
84 } 86 }
85 87
86 int first_inobject_property_offset() const { 88 int first_inobject_property_offset() const {
87 ASSERT(!IsHiddenField::decode(bit_field_)); 89 ASSERT(!is_hidden_field());
88 return FirstInobjectPropertyOffsetBits::decode(bit_field_); 90 return FirstInobjectPropertyOffsetBits::decode(bit_field_);
89 } 91 }
90 92
91 static const int kIndexBitsSize = kDescriptorIndexBitCount + 1; 93 static const int kIndexBitsSize = kDescriptorIndexBitCount + 1;
92 94
93 // Index from beginning of object. 95 // Index from beginning of object.
94 class IndexBits: public BitField<int, 0, kIndexBitsSize> {}; 96 class IndexBits: public BitField<int, 0, kIndexBitsSize> {};
95 class IsInObjectBits: public BitField<bool, IndexBits::kNext, 1> {}; 97 class IsInObjectBits: public BitField<bool, IndexBits::kNext, 1> {};
96 class IsDoubleBits: public BitField<bool, IsInObjectBits::kNext, 1> {}; 98 class IsDoubleBits: public BitField<bool, IsInObjectBits::kNext, 1> {};
97 // Number of inobject properties. 99 // Number of inobject properties.
98 class InObjectPropertyBits: public BitField<int, IsDoubleBits::kNext, 100 class InObjectPropertyBits: public BitField<int, IsDoubleBits::kNext,
99 kDescriptorIndexBitCount> {}; 101 kDescriptorIndexBitCount> {};
100 // Offset of first inobject property from beginning of object. 102 // Offset of first inobject property from beginning of object.
101 class FirstInobjectPropertyOffsetBits: 103 class FirstInobjectPropertyOffsetBits:
102 public BitField<int, InObjectPropertyBits::kNext, 7> {}; 104 public BitField<int, InObjectPropertyBits::kNext, 7> {};
103 class IsHiddenField: 105 class IsHiddenField:
104 public BitField<bool, FirstInobjectPropertyOffsetBits::kNext, 1> {}; 106 public BitField<bool, FirstInobjectPropertyOffsetBits::kNext, 1> {};
105 STATIC_ASSERT(IsHiddenField::kNext <= 32); 107 STATIC_ASSERT(IsHiddenField::kNext <= 32);
106 108
107 int bit_field_; 109 int bit_field_;
108 }; 110 };
109 111
110 } } // namespace v8::internal 112 } } // namespace v8::internal
111 113
112 #endif 114 #endif
OLDNEW
« no previous file with comments | « src/code-stubs-hydrogen.cc ('k') | src/flag-definitions.h » ('j') | src/heap.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698