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

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: fix formatting 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
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 3280 matching lines...) Expand 10 before | Expand all | Expand 10 after
3476 static const int kAllowOSRAtLoopNestingLevelOffset = 3502 static const int kAllowOSRAtLoopNestingLevelOffset =
3477 kHasDeoptimizationSupportOffset + 1; 3503 kHasDeoptimizationSupportOffset + 1;
3478 3504
3479 static const int kSafepointTableOffsetOffset = kStackSlotsOffset + kIntSize; 3505 static const int kSafepointTableOffsetOffset = kStackSlotsOffset + kIntSize;
3480 static const int kStackCheckTableOffsetOffset = kStackSlotsOffset + kIntSize; 3506 static const int kStackCheckTableOffsetOffset = kStackSlotsOffset + kIntSize;
3481 3507
3482 // Flags layout. 3508 // Flags layout.
3483 static const int kFlagsICStateShift = 0; 3509 static const int kFlagsICStateShift = 0;
3484 static const int kFlagsICInLoopShift = 3; 3510 static const int kFlagsICInLoopShift = 3;
3485 static const int kFlagsTypeShift = 4; 3511 static const int kFlagsTypeShift = 4;
3486 static const int kFlagsKindShift = 7; 3512 static const int kFlagsKindShift = 8;
3487 static const int kFlagsICHolderShift = 11; 3513 static const int kFlagsICHolderShift = 12;
3488 static const int kFlagsExtraICStateShift = 12; 3514 static const int kFlagsExtraICStateShift = 13;
3489 static const int kFlagsArgumentsCountShift = 14; 3515 static const int kFlagsArgumentsCountShift = 15;
3490 3516
3491 static const int kFlagsICStateMask = 0x00000007; // 00000000111 3517 static const int kFlagsICStateMask = 0x00000007; // 00000000111
3492 static const int kFlagsICInLoopMask = 0x00000008; // 00000001000 3518 static const int kFlagsICInLoopMask = 0x00000008; // 00000001000
3493 static const int kFlagsTypeMask = 0x00000070; // 00001110000 3519 static const int kFlagsTypeMask = 0x000000F0; // 00001110000
3494 static const int kFlagsKindMask = 0x00000780; // 11110000000 3520 static const int kFlagsKindMask = 0x00000F00; // 11110000000
3495 static const int kFlagsCacheInPrototypeMapMask = 0x00000800; 3521 static const int kFlagsCacheInPrototypeMapMask = 0x00001000;
3496 static const int kFlagsExtraICStateMask = 0x00003000; 3522 static const int kFlagsExtraICStateMask = 0x00006000;
3497 static const int kFlagsArgumentsCountMask = 0xFFFFC000; 3523 static const int kFlagsArgumentsCountMask = 0xFFFF8000;
3498 3524
3499 static const int kFlagsNotUsedInLookup = 3525 static const int kFlagsNotUsedInLookup =
3500 (kFlagsICInLoopMask | kFlagsTypeMask | kFlagsCacheInPrototypeMapMask); 3526 (kFlagsICInLoopMask | kFlagsTypeMask | kFlagsCacheInPrototypeMapMask);
3501 3527
3502 private: 3528 private:
3503 DISALLOW_IMPLICIT_CONSTRUCTORS(Code); 3529 DISALLOW_IMPLICIT_CONSTRUCTORS(Code);
3504 }; 3530 };
3505 3531
3506 3532
3507 // All heap objects have a Map that describes their structure. 3533 // All heap objects have a Map that describes their structure.
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
3689 // descriptors and the fast elements bit set. 3715 // descriptors and the fast elements bit set.
3690 MUST_USE_RESULT inline MaybeObject* GetFastElementsMap(); 3716 MUST_USE_RESULT inline MaybeObject* GetFastElementsMap();
3691 3717
3692 // Returns this map if it has the fast elements bit cleared, 3718 // Returns this map if it has the fast elements bit cleared,
3693 // otherwise returns a copy of the map, with all transitions dropped 3719 // otherwise returns a copy of the map, with all transitions dropped
3694 // from the descriptors and the fast elements bit cleared. 3720 // from the descriptors and the fast elements bit cleared.
3695 MUST_USE_RESULT inline MaybeObject* GetSlowElementsMap(); 3721 MUST_USE_RESULT inline MaybeObject* GetSlowElementsMap();
3696 3722
3697 // Returns a new map with all transitions dropped from the descriptors and the 3723 // Returns a new map with all transitions dropped from the descriptors and the
3698 // external array elements bit set. 3724 // external array elements bit set.
3699 MUST_USE_RESULT inline MaybeObject* NewExternalArrayElementsMap(); 3725 MUST_USE_RESULT MaybeObject* GetExternalArrayElementsMap(
3726 ExternalArrayType array_type);
3700 3727
3701 // Returns the property index for name (only valid for FAST MODE). 3728 // Returns the property index for name (only valid for FAST MODE).
3702 int PropertyIndexFor(String* name); 3729 int PropertyIndexFor(String* name);
3703 3730
3704 // Returns the next free property index (only valid for FAST MODE). 3731 // Returns the next free property index (only valid for FAST MODE).
3705 int NextFreePropertyIndex(); 3732 int NextFreePropertyIndex();
3706 3733
3707 // Returns the number of properties described in instance_descriptors. 3734 // Returns the number of properties described in instance_descriptors.
3708 int NumberOfDescribedProperties(); 3735 int NumberOfDescribedProperties();
3709 3736
(...skipping 2874 matching lines...) Expand 10 before | Expand all | Expand 10 after
6584 } else { 6611 } else {
6585 value &= ~(1 << bit_position); 6612 value &= ~(1 << bit_position);
6586 } 6613 }
6587 return value; 6614 return value;
6588 } 6615 }
6589 }; 6616 };
6590 6617
6591 } } // namespace v8::internal 6618 } } // namespace v8::internal
6592 6619
6593 #endif // V8_OBJECTS_H_ 6620 #endif // V8_OBJECTS_H_
OLDNEW
« no previous file with comments | « src/mirror-debugger.js ('k') | src/objects.cc » ('j') | src/objects.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698