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

Side by Side Diff: src/objects.h

Issue 35413006: Correct handling of arrays with callbacks in the prototype chain. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Test fixes Created 7 years, 1 month 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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 2084 matching lines...) Expand 10 before | Expand all | Expand 10 after
2095 inline bool HasExternalByteElements(); 2095 inline bool HasExternalByteElements();
2096 inline bool HasExternalUnsignedByteElements(); 2096 inline bool HasExternalUnsignedByteElements();
2097 inline bool HasExternalShortElements(); 2097 inline bool HasExternalShortElements();
2098 inline bool HasExternalUnsignedShortElements(); 2098 inline bool HasExternalUnsignedShortElements();
2099 inline bool HasExternalIntElements(); 2099 inline bool HasExternalIntElements();
2100 inline bool HasExternalUnsignedIntElements(); 2100 inline bool HasExternalUnsignedIntElements();
2101 inline bool HasExternalFloatElements(); 2101 inline bool HasExternalFloatElements();
2102 inline bool HasExternalDoubleElements(); 2102 inline bool HasExternalDoubleElements();
2103 bool HasFastArgumentsElements(); 2103 bool HasFastArgumentsElements();
2104 bool HasDictionaryArgumentsElements(); 2104 bool HasDictionaryArgumentsElements();
2105 inline bool HasNonStrictArgumentsElementsMap();
2105 inline SeededNumberDictionary* element_dictionary(); // Gets slow elements. 2106 inline SeededNumberDictionary* element_dictionary(); // Gets slow elements.
2106 2107
2108 // Gets elements from the appropriate location if a normal object or a
2109 // non-strict arguments object.
2110 inline FixedArrayBase* GetElements();
danno 2013/10/30 12:17:45 Why is elements() not sufficient here?
2111
2107 inline bool ShouldTrackAllocationInfo(); 2112 inline bool ShouldTrackAllocationInfo();
2108 2113
2109 inline void set_map_and_elements( 2114 inline void set_map_and_elements(
2110 Map* map, 2115 Map* map,
2111 FixedArrayBase* value, 2116 FixedArrayBase* value,
2112 WriteBarrierMode mode = UPDATE_WRITE_BARRIER); 2117 WriteBarrierMode mode = UPDATE_WRITE_BARRIER);
2113 2118
2114 // Requires: HasFastElements(). 2119 // Requires: HasFastElements().
2115 MUST_USE_RESULT inline MaybeObject* EnsureWritableFastElements(); 2120 MUST_USE_RESULT inline MaybeObject* EnsureWritableFastElements();
2116 2121
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after
2490 PropertyNormalizationMode mode, 2495 PropertyNormalizationMode mode,
2491 int expected_additional_properties); 2496 int expected_additional_properties);
2492 2497
2493 // Convert and update the elements backing store to be a 2498 // Convert and update the elements backing store to be a
2494 // SeededNumberDictionary dictionary. Returns the backing after conversion. 2499 // SeededNumberDictionary dictionary. Returns the backing after conversion.
2495 static Handle<SeededNumberDictionary> NormalizeElements( 2500 static Handle<SeededNumberDictionary> NormalizeElements(
2496 Handle<JSObject> object); 2501 Handle<JSObject> object);
2497 2502
2498 MUST_USE_RESULT MaybeObject* NormalizeElements(); 2503 MUST_USE_RESULT MaybeObject* NormalizeElements();
2499 2504
2505 // Convert the elements backing store as a SeededNumberDictionary dictionary.
2506 // Precondition: the elements aren't already a dictionary.
2507 // Does not set the new elements in the object.
2508 static Handle<SeededNumberDictionary> CreateNormalizedElements(
2509 Handle<JSObject> object);
2510
2511 MUST_USE_RESULT MaybeObject* CreateNormalizedElements();
2512
2500 // Transform slow named properties to fast variants. 2513 // Transform slow named properties to fast variants.
2501 static void TransformToFastProperties(Handle<JSObject> object, 2514 static void TransformToFastProperties(Handle<JSObject> object,
2502 int unused_property_fields); 2515 int unused_property_fields);
2503 2516
2504 // Access fast-case object properties at index. 2517 // Access fast-case object properties at index.
2505 MUST_USE_RESULT inline MaybeObject* FastPropertyAt( 2518 MUST_USE_RESULT inline MaybeObject* FastPropertyAt(
2506 Representation representation, 2519 Representation representation,
2507 int index); 2520 int index);
2508 inline Object* RawFastPropertyAt(int index); 2521 inline Object* RawFastPropertyAt(int index);
2509 inline void FastPropertyAtPut(int index, Object* value); 2522 inline void FastPropertyAtPut(int index, Object* value);
(...skipping 2781 matching lines...) Expand 10 before | Expand all | Expand 10 after
5291 int CodeSize() { return SizeFor(body_size()); } 5304 int CodeSize() { return SizeFor(body_size()); }
5292 inline void CodeIterateBody(ObjectVisitor* v); 5305 inline void CodeIterateBody(ObjectVisitor* v);
5293 5306
5294 template<typename StaticVisitor> 5307 template<typename StaticVisitor>
5295 inline void CodeIterateBody(Heap* heap); 5308 inline void CodeIterateBody(Heap* heap);
5296 5309
5297 DECLARE_PRINTER(Code) 5310 DECLARE_PRINTER(Code)
5298 DECLARE_VERIFIER(Code) 5311 DECLARE_VERIFIER(Code)
5299 5312
5300 void ClearInlineCaches(); 5313 void ClearInlineCaches();
5314 void ClearInlineCaches(Kind* kind);
danno 2013/10/30 12:17:45 Shouldn't this one be private?
mvstanton 2013/10/30 18:22:28 Done.
5315 void ClearInlineCaches(Kind kind);
5316
5301 void ClearTypeFeedbackCells(Heap* heap); 5317 void ClearTypeFeedbackCells(Heap* heap);
5302 5318
5303 BailoutId TranslatePcOffsetToAstId(uint32_t pc_offset); 5319 BailoutId TranslatePcOffsetToAstId(uint32_t pc_offset);
5304 5320
5305 #define DECLARE_CODE_AGE_ENUM(X) k##X##CodeAge, 5321 #define DECLARE_CODE_AGE_ENUM(X) k##X##CodeAge,
5306 enum Age { 5322 enum Age {
5307 kNotExecutedCodeAge = -2, 5323 kNotExecutedCodeAge = -2,
5308 kExecutedOnceCodeAge = -1, 5324 kExecutedOnceCodeAge = -1,
5309 kNoAgeCodeAge = 0, 5325 kNoAgeCodeAge = 0,
5310 CODE_AGE_LIST(DECLARE_CODE_AGE_ENUM) 5326 CODE_AGE_LIST(DECLARE_CODE_AGE_ENUM)
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after
5623 class IsShared: public BitField<bool, 22, 1> {}; 5639 class IsShared: public BitField<bool, 22, 1> {};
5624 class FunctionWithPrototype: public BitField<bool, 23, 1> {}; 5640 class FunctionWithPrototype: public BitField<bool, 23, 1> {};
5625 class DictionaryMap: public BitField<bool, 24, 1> {}; 5641 class DictionaryMap: public BitField<bool, 24, 1> {};
5626 class OwnsDescriptors: public BitField<bool, 25, 1> {}; 5642 class OwnsDescriptors: public BitField<bool, 25, 1> {};
5627 class IsObserved: public BitField<bool, 26, 1> {}; 5643 class IsObserved: public BitField<bool, 26, 1> {};
5628 class Deprecated: public BitField<bool, 27, 1> {}; 5644 class Deprecated: public BitField<bool, 27, 1> {};
5629 class IsFrozen: public BitField<bool, 28, 1> {}; 5645 class IsFrozen: public BitField<bool, 28, 1> {};
5630 class IsUnstable: public BitField<bool, 29, 1> {}; 5646 class IsUnstable: public BitField<bool, 29, 1> {};
5631 class IsMigrationTarget: public BitField<bool, 30, 1> {}; 5647 class IsMigrationTarget: public BitField<bool, 30, 1> {};
5632 5648
5649 // Bit field 4.
5650 inline uint32_t bit_field4();
5651 inline void set_bit_field4(uint32_t bits);
5652
5653 class HasElementCallbacks: public BitField<int, 0, 1> {};
5654
5655 inline void set_has_element_callbacks(bool value);
5656 inline bool has_element_callbacks();
5657
5633 // Tells whether the object in the prototype property will be used 5658 // Tells whether the object in the prototype property will be used
5634 // for instances created from this function. If the prototype 5659 // for instances created from this function. If the prototype
5635 // property is set to a value that is not a JSObject, the prototype 5660 // property is set to a value that is not a JSObject, the prototype
5636 // property will not be used to create instances of the function. 5661 // property will not be used to create instances of the function.
5637 // See ECMA-262, 13.2.2. 5662 // See ECMA-262, 13.2.2.
5638 inline void set_non_instance_prototype(bool value); 5663 inline void set_non_instance_prototype(bool value);
5639 inline bool has_non_instance_prototype(); 5664 inline bool has_non_instance_prototype();
5640 5665
5641 // Tells whether function has special prototype property. If not, prototype 5666 // Tells whether function has special prototype property. If not, prototype
5642 // property will not be created when accessed (will return undefined), 5667 // property will not be created when accessed (will return undefined),
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
5757 static bool IsValidElementsTransition(ElementsKind from_kind, 5782 static bool IsValidElementsTransition(ElementsKind from_kind,
5758 ElementsKind to_kind); 5783 ElementsKind to_kind);
5759 5784
5760 inline bool HasTransitionArray(); 5785 inline bool HasTransitionArray();
5761 inline bool HasElementsTransition(); 5786 inline bool HasElementsTransition();
5762 inline Map* elements_transition_map(); 5787 inline Map* elements_transition_map();
5763 MUST_USE_RESULT inline MaybeObject* set_elements_transition_map( 5788 MUST_USE_RESULT inline MaybeObject* set_elements_transition_map(
5764 Map* transitioned_map); 5789 Map* transitioned_map);
5765 inline void SetTransition(int transition_index, Map* target); 5790 inline void SetTransition(int transition_index, Map* target);
5766 inline Map* GetTransition(int transition_index); 5791 inline Map* GetTransition(int transition_index);
5767
5768 static Handle<TransitionArray> AddTransition(Handle<Map> map, 5792 static Handle<TransitionArray> AddTransition(Handle<Map> map,
5769 Handle<Name> key, 5793 Handle<Name> key,
5770 Handle<Map> target, 5794 Handle<Map> target,
5771 SimpleTransitionFlag flag); 5795 SimpleTransitionFlag flag);
5772 5796
5773 MUST_USE_RESULT inline MaybeObject* AddTransition(Name* key, 5797 MUST_USE_RESULT inline MaybeObject* AddTransition(Name* key,
5774 Map* target, 5798 Map* target,
5775 SimpleTransitionFlag flag); 5799 SimpleTransitionFlag flag);
5800 inline bool HasElementCallbacksTransition();
5801 inline Map* element_callbacks_map();
5802 MUST_USE_RESULT inline MaybeObject* set_element_callbacks_map(
5803 Map* callbacks_map);
5804
5776 DECL_ACCESSORS(transitions, TransitionArray) 5805 DECL_ACCESSORS(transitions, TransitionArray)
5777 inline void ClearTransitions(Heap* heap, 5806 inline void ClearTransitions(Heap* heap,
5778 WriteBarrierMode mode = UPDATE_WRITE_BARRIER); 5807 WriteBarrierMode mode = UPDATE_WRITE_BARRIER);
5779 5808
5780 void DeprecateTransitionTree(); 5809 void DeprecateTransitionTree();
5781 void DeprecateTarget(Name* key, DescriptorArray* new_descriptors); 5810 void DeprecateTarget(Name* key, DescriptorArray* new_descriptors);
5782 5811
5783 Map* FindRootMap(); 5812 Map* FindRootMap();
5784 Map* FindUpdatedMap(int verbatim, int length, DescriptorArray* descriptors); 5813 Map* FindUpdatedMap(int verbatim, int length, DescriptorArray* descriptors);
5785 Map* FindLastMatchMap(int verbatim, int length, DescriptorArray* descriptors); 5814 Map* FindLastMatchMap(int verbatim, int length, DescriptorArray* descriptors);
5786 5815
5787 int NumberOfFields(); 5816 int NumberOfFields();
5788 5817
5818 bool MayHaveIndexedCallbacksInPrototypeChain();
5819
5789 bool InstancesNeedRewriting(Map* target, 5820 bool InstancesNeedRewriting(Map* target,
5790 int target_number_of_fields, 5821 int target_number_of_fields,
5791 int target_inobject, 5822 int target_inobject,
5792 int target_unused); 5823 int target_unused);
5793 static Handle<Map> GeneralizeAllFieldRepresentations( 5824 static Handle<Map> GeneralizeAllFieldRepresentations(
5794 Handle<Map> map, 5825 Handle<Map> map,
5795 Representation new_representation); 5826 Representation new_representation);
5796 static Handle<Map> GeneralizeRepresentation( 5827 static Handle<Map> GeneralizeRepresentation(
5797 Handle<Map> map, 5828 Handle<Map> map,
5798 int modify_index, 5829 int modify_index,
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
5996 TransitionFlag flag); 6027 TransitionFlag flag);
5997 MUST_USE_RESULT MaybeObject* CopyReplaceDescriptor( 6028 MUST_USE_RESULT MaybeObject* CopyReplaceDescriptor(
5998 DescriptorArray* descriptors, 6029 DescriptorArray* descriptors,
5999 Descriptor* descriptor, 6030 Descriptor* descriptor,
6000 int index, 6031 int index,
6001 TransitionFlag flag); 6032 TransitionFlag flag);
6002 MUST_USE_RESULT MaybeObject* AsElementsKind(ElementsKind kind); 6033 MUST_USE_RESULT MaybeObject* AsElementsKind(ElementsKind kind);
6003 6034
6004 MUST_USE_RESULT MaybeObject* CopyAsElementsKind(ElementsKind kind, 6035 MUST_USE_RESULT MaybeObject* CopyAsElementsKind(ElementsKind kind,
6005 TransitionFlag flag); 6036 TransitionFlag flag);
6037 MUST_USE_RESULT MaybeObject* CopyAsElementCallbacksTransition(
6038 bool with_dictionary_elements);
6039 static Handle<Map> CopyAsElementCallbacksTransition(
6040 Handle<Map> map, bool with_dictionary_elements);
6006 6041
6007 static Handle<Map> CopyForObserved(Handle<Map> map); 6042 static Handle<Map> CopyForObserved(Handle<Map> map);
6008 6043
6009 static Handle<Map> CopyNormalized(Handle<Map> map, 6044 static Handle<Map> CopyNormalized(Handle<Map> map,
6010 PropertyNormalizationMode mode, 6045 PropertyNormalizationMode mode,
6011 NormalizedMapSharingMode sharing); 6046 NormalizedMapSharingMode sharing);
6012 6047
6013 inline void AppendDescriptor(Descriptor* desc, 6048 inline void AppendDescriptor(Descriptor* desc,
6014 const DescriptorArray::WhitenessWitness&); 6049 const DescriptorArray::WhitenessWitness&);
6015 6050
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
6173 // pointer if unused. When the map has transitions, the back pointer is 6208 // pointer if unused. When the map has transitions, the back pointer is
6174 // transferred to the transition array and accessed through an extra 6209 // transferred to the transition array and accessed through an extra
6175 // indirection. 6210 // indirection.
6176 static const int kTransitionsOrBackPointerOffset = 6211 static const int kTransitionsOrBackPointerOffset =
6177 kConstructorOffset + kPointerSize; 6212 kConstructorOffset + kPointerSize;
6178 static const int kDescriptorsOffset = 6213 static const int kDescriptorsOffset =
6179 kTransitionsOrBackPointerOffset + kPointerSize; 6214 kTransitionsOrBackPointerOffset + kPointerSize;
6180 static const int kCodeCacheOffset = kDescriptorsOffset + kPointerSize; 6215 static const int kCodeCacheOffset = kDescriptorsOffset + kPointerSize;
6181 static const int kDependentCodeOffset = kCodeCacheOffset + kPointerSize; 6216 static const int kDependentCodeOffset = kCodeCacheOffset + kPointerSize;
6182 static const int kBitField3Offset = kDependentCodeOffset + kPointerSize; 6217 static const int kBitField3Offset = kDependentCodeOffset + kPointerSize;
6183 static const int kSize = kBitField3Offset + kPointerSize; 6218 static const int kBitField4Offset = kBitField3Offset + kPointerSize;
6219 static const int kSize = kBitField4Offset + kPointerSize;
6184 6220
6185 // Layout of pointer fields. Heap iteration code relies on them 6221 // Layout of pointer fields. Heap iteration code relies on them
6186 // being continuously allocated. 6222 // being continuously allocated.
6187 static const int kPointerFieldsBeginOffset = Map::kPrototypeOffset; 6223 static const int kPointerFieldsBeginOffset = Map::kPrototypeOffset;
6188 static const int kPointerFieldsEndOffset = kBitField3Offset + kPointerSize; 6224 static const int kPointerFieldsEndOffset = kBitField3Offset + kPointerSize;
6189 6225
6190 // Byte offsets within kInstanceSizesOffset. 6226 // Byte offsets within kInstanceSizesOffset.
6191 static const int kInstanceSizeOffset = kInstanceSizesOffset + 0; 6227 static const int kInstanceSizeOffset = kInstanceSizesOffset + 0;
6192 static const int kInObjectPropertiesByte = 1; 6228 static const int kInObjectPropertiesByte = 1;
6193 static const int kInObjectPropertiesOffset = 6229 static const int kInObjectPropertiesOffset =
(...skipping 4238 matching lines...) Expand 10 before | Expand all | Expand 10 after
10432 } else { 10468 } else {
10433 value &= ~(1 << bit_position); 10469 value &= ~(1 << bit_position);
10434 } 10470 }
10435 return value; 10471 return value;
10436 } 10472 }
10437 }; 10473 };
10438 10474
10439 } } // namespace v8::internal 10475 } } // namespace v8::internal
10440 10476
10441 #endif // V8_OBJECTS_H_ 10477 #endif // V8_OBJECTS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698