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

Side by Side Diff: src/objects.h

Issue 6685073: Remember and reuse derived map for external arrays (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: review feedback Created 9 years, 9 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/mirror-debugger.js ('k') | src/objects.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2010 the V8 project authors. All rights reserved. 1 // Copyright 2010 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 128
129 129
130 // PropertyDetails captures type and attributes for a property. 130 // PropertyDetails captures type and attributes for a property.
131 // They are used both in property dictionaries and instance descriptors. 131 // They are used both in property dictionaries and instance descriptors.
132 class PropertyDetails BASE_EMBEDDED { 132 class PropertyDetails BASE_EMBEDDED {
133 public: 133 public:
134 134
135 PropertyDetails(PropertyAttributes attributes, 135 PropertyDetails(PropertyAttributes attributes,
136 PropertyType type, 136 PropertyType type,
137 int index = 0) { 137 int index = 0) {
138 ASSERT(type != EXTERNAL_ARRAY_TRANSITION);
138 ASSERT(TypeField::is_valid(type)); 139 ASSERT(TypeField::is_valid(type));
139 ASSERT(AttributesField::is_valid(attributes)); 140 ASSERT(AttributesField::is_valid(attributes));
140 ASSERT(IndexField::is_valid(index)); 141 ASSERT(StorageField::is_valid(index));
141 142
142 value_ = TypeField::encode(type) 143 value_ = TypeField::encode(type)
143 | AttributesField::encode(attributes) 144 | AttributesField::encode(attributes)
144 | IndexField::encode(index); 145 | StorageField::encode(index);
145 146
146 ASSERT(type == this->type()); 147 ASSERT(type == this->type());
147 ASSERT(attributes == this->attributes()); 148 ASSERT(attributes == this->attributes());
148 ASSERT(index == this->index()); 149 ASSERT(index == this->index());
149 } 150 }
150 151
152 PropertyDetails(PropertyAttributes attributes,
153 PropertyType type,
154 ExternalArrayType array_type) {
155 ASSERT(type == EXTERNAL_ARRAY_TRANSITION);
156 ASSERT(TypeField::is_valid(type));
157 ASSERT(AttributesField::is_valid(attributes));
158 ASSERT(StorageField::is_valid(static_cast<int>(array_type)));
159
160 value_ = TypeField::encode(type)
161 | AttributesField::encode(attributes)
162 | StorageField::encode(static_cast<int>(array_type));
163
164 ASSERT(type == this->type());
165 ASSERT(attributes == this->attributes());
166 ASSERT(array_type == this->array_type());
167 }
168
151 // Conversion for storing details as Object*. 169 // Conversion for storing details as Object*.
152 inline PropertyDetails(Smi* smi); 170 inline PropertyDetails(Smi* smi);
153 inline Smi* AsSmi(); 171 inline Smi* AsSmi();
154 172
155 PropertyType type() { return TypeField::decode(value_); } 173 PropertyType type() { return TypeField::decode(value_); }
156 174
157 bool IsTransition() { 175 bool IsTransition() {
158 PropertyType t = type(); 176 PropertyType t = type();
159 ASSERT(t != INTERCEPTOR); 177 ASSERT(t != INTERCEPTOR);
160 return t == MAP_TRANSITION || t == CONSTANT_TRANSITION; 178 return t == MAP_TRANSITION || t == CONSTANT_TRANSITION ||
179 t == EXTERNAL_ARRAY_TRANSITION;
161 } 180 }
162 181
163 bool IsProperty() { 182 bool IsProperty() {
164 return type() < FIRST_PHANTOM_PROPERTY_TYPE; 183 return type() < FIRST_PHANTOM_PROPERTY_TYPE;
165 } 184 }
166 185
167 PropertyAttributes attributes() { return AttributesField::decode(value_); } 186 PropertyAttributes attributes() { return AttributesField::decode(value_); }
168 187
169 int index() { return IndexField::decode(value_); } 188 int index() { return StorageField::decode(value_); }
189
190 ExternalArrayType array_type() {
191 ASSERT(type() == EXTERNAL_ARRAY_TRANSITION);
192 return static_cast<ExternalArrayType>(StorageField::decode(value_));
193 }
170 194
171 inline PropertyDetails AsDeleted(); 195 inline PropertyDetails AsDeleted();
172 196
173 static bool IsValidIndex(int index) { return IndexField::is_valid(index); } 197 static bool IsValidIndex(int index) {
198 return StorageField::is_valid(index);
199 }
174 200
175 bool IsReadOnly() { return (attributes() & READ_ONLY) != 0; } 201 bool IsReadOnly() { return (attributes() & READ_ONLY) != 0; }
176 bool IsDontDelete() { return (attributes() & DONT_DELETE) != 0; } 202 bool IsDontDelete() { return (attributes() & DONT_DELETE) != 0; }
177 bool IsDontEnum() { return (attributes() & DONT_ENUM) != 0; } 203 bool IsDontEnum() { return (attributes() & DONT_ENUM) != 0; }
178 bool IsDeleted() { return DeletedField::decode(value_) != 0;} 204 bool IsDeleted() { return DeletedField::decode(value_) != 0;}
179 205
180 // Bit fields in value_ (type, shift, size). Must be public so the 206 // Bit fields in value_ (type, shift, size). Must be public so the
181 // constants can be embedded in generated code. 207 // constants can be embedded in generated code.
182 class TypeField: public BitField<PropertyType, 0, 3> {}; 208 class TypeField: public BitField<PropertyType, 0, 4> {};
183 class AttributesField: public BitField<PropertyAttributes, 3, 3> {}; 209 class AttributesField: public BitField<PropertyAttributes, 4, 3> {};
184 class DeletedField: public BitField<uint32_t, 6, 1> {}; 210 class DeletedField: public BitField<uint32_t, 7, 1> {};
185 class IndexField: public BitField<uint32_t, 7, 32-7> {}; 211 class StorageField: public BitField<uint32_t, 8, 32-8> {};
186 212
187 static const int kInitialIndex = 1; 213 static const int kInitialIndex = 1;
188 private: 214 private:
189 uint32_t value_; 215 uint32_t value_;
190 }; 216 };
191 217
192 218
193 // Setter that skips the write barrier if mode is SKIP_WRITE_BARRIER. 219 // Setter that skips the write barrier if mode is SKIP_WRITE_BARRIER.
194 enum WriteBarrierMode { SKIP_WRITE_BARRIER, UPDATE_WRITE_BARRIER }; 220 enum WriteBarrierMode { SKIP_WRITE_BARRIER, UPDATE_WRITE_BARRIER };
195 221
(...skipping 3299 matching lines...) Expand 10 before | Expand all | Expand 10 after
3495 static const int kAllowOSRAtLoopNestingLevelOffset = 3521 static const int kAllowOSRAtLoopNestingLevelOffset =
3496 kHasDeoptimizationSupportOffset + 1; 3522 kHasDeoptimizationSupportOffset + 1;
3497 3523
3498 static const int kSafepointTableOffsetOffset = kStackSlotsOffset + kIntSize; 3524 static const int kSafepointTableOffsetOffset = kStackSlotsOffset + kIntSize;
3499 static const int kStackCheckTableOffsetOffset = kStackSlotsOffset + kIntSize; 3525 static const int kStackCheckTableOffsetOffset = kStackSlotsOffset + kIntSize;
3500 3526
3501 // Flags layout. 3527 // Flags layout.
3502 static const int kFlagsICStateShift = 0; 3528 static const int kFlagsICStateShift = 0;
3503 static const int kFlagsICInLoopShift = 3; 3529 static const int kFlagsICInLoopShift = 3;
3504 static const int kFlagsTypeShift = 4; 3530 static const int kFlagsTypeShift = 4;
3505 static const int kFlagsKindShift = 7; 3531 static const int kFlagsKindShift = 8;
3506 static const int kFlagsICHolderShift = 11; 3532 static const int kFlagsICHolderShift = 12;
3507 static const int kFlagsExtraICStateShift = 12; 3533 static const int kFlagsExtraICStateShift = 13;
3508 static const int kFlagsArgumentsCountShift = 14; 3534 static const int kFlagsArgumentsCountShift = 15;
3509 3535
3510 static const int kFlagsICStateMask = 0x00000007; // 00000000111 3536 static const int kFlagsICStateMask = 0x00000007; // 00000000111
3511 static const int kFlagsICInLoopMask = 0x00000008; // 00000001000 3537 static const int kFlagsICInLoopMask = 0x00000008; // 00000001000
3512 static const int kFlagsTypeMask = 0x00000070; // 00001110000 3538 static const int kFlagsTypeMask = 0x000000F0; // 00001110000
3513 static const int kFlagsKindMask = 0x00000780; // 11110000000 3539 static const int kFlagsKindMask = 0x00000F00; // 11110000000
3514 static const int kFlagsCacheInPrototypeMapMask = 0x00000800; 3540 static const int kFlagsCacheInPrototypeMapMask = 0x00001000;
3515 static const int kFlagsExtraICStateMask = 0x00003000; 3541 static const int kFlagsExtraICStateMask = 0x00006000;
3516 static const int kFlagsArgumentsCountMask = 0xFFFFC000; 3542 static const int kFlagsArgumentsCountMask = 0xFFFF8000;
3517 3543
3518 static const int kFlagsNotUsedInLookup = 3544 static const int kFlagsNotUsedInLookup =
3519 (kFlagsICInLoopMask | kFlagsTypeMask | kFlagsCacheInPrototypeMapMask); 3545 (kFlagsICInLoopMask | kFlagsTypeMask | kFlagsCacheInPrototypeMapMask);
3520 3546
3521 private: 3547 private:
3522 DISALLOW_IMPLICIT_CONSTRUCTORS(Code); 3548 DISALLOW_IMPLICIT_CONSTRUCTORS(Code);
3523 }; 3549 };
3524 3550
3525 3551
3526 // All heap objects have a Map that describes their structure. 3552 // All heap objects have a Map that describes their structure.
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
3708 // descriptors and the fast elements bit set. 3734 // descriptors and the fast elements bit set.
3709 MUST_USE_RESULT inline MaybeObject* GetFastElementsMap(); 3735 MUST_USE_RESULT inline MaybeObject* GetFastElementsMap();
3710 3736
3711 // Returns this map if it has the fast elements bit cleared, 3737 // Returns this map if it has the fast elements bit cleared,
3712 // otherwise returns a copy of the map, with all transitions dropped 3738 // otherwise returns a copy of the map, with all transitions dropped
3713 // from the descriptors and the fast elements bit cleared. 3739 // from the descriptors and the fast elements bit cleared.
3714 MUST_USE_RESULT inline MaybeObject* GetSlowElementsMap(); 3740 MUST_USE_RESULT inline MaybeObject* GetSlowElementsMap();
3715 3741
3716 // Returns a new map with all transitions dropped from the descriptors and the 3742 // Returns a new map with all transitions dropped from the descriptors and the
3717 // external array elements bit set. 3743 // external array elements bit set.
3718 MUST_USE_RESULT inline MaybeObject* NewExternalArrayElementsMap(); 3744 MUST_USE_RESULT MaybeObject* GetExternalArrayElementsMap(
3745 ExternalArrayType array_type,
3746 bool safe_to_add_transition);
3719 3747
3720 // Returns the property index for name (only valid for FAST MODE). 3748 // Returns the property index for name (only valid for FAST MODE).
3721 int PropertyIndexFor(String* name); 3749 int PropertyIndexFor(String* name);
3722 3750
3723 // Returns the next free property index (only valid for FAST MODE). 3751 // Returns the next free property index (only valid for FAST MODE).
3724 int NextFreePropertyIndex(); 3752 int NextFreePropertyIndex();
3725 3753
3726 // Returns the number of properties described in instance_descriptors. 3754 // Returns the number of properties described in instance_descriptors.
3727 int NumberOfDescribedProperties(); 3755 int NumberOfDescribedProperties();
3728 3756
(...skipping 2889 matching lines...) Expand 10 before | Expand all | Expand 10 after
6618 } else { 6646 } else {
6619 value &= ~(1 << bit_position); 6647 value &= ~(1 << bit_position);
6620 } 6648 }
6621 return value; 6649 return value;
6622 } 6650 }
6623 }; 6651 };
6624 6652
6625 } } // namespace v8::internal 6653 } } // namespace v8::internal
6626 6654
6627 #endif // V8_OBJECTS_H_ 6655 #endif // V8_OBJECTS_H_
OLDNEW
« no previous file with comments | « src/mirror-debugger.js ('k') | src/objects.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698