| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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_OBJECTS_H_ | 5 #ifndef V8_OBJECTS_H_ |
| 6 #define V8_OBJECTS_H_ | 6 #define V8_OBJECTS_H_ |
| 7 | 7 |
| 8 #include "allocation.h" | 8 #include "allocation.h" |
| 9 #include "assert-scope.h" | 9 #include "assert-scope.h" |
| 10 #include "builtins.h" | 10 #include "builtins.h" |
| (...skipping 4599 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4610 class ContextLocalMode: public BitField<VariableMode, 0, 3> {}; | 4610 class ContextLocalMode: public BitField<VariableMode, 0, 3> {}; |
| 4611 class ContextLocalInitFlag: public BitField<InitializationFlag, 3, 1> {}; | 4611 class ContextLocalInitFlag: public BitField<InitializationFlag, 3, 1> {}; |
| 4612 }; | 4612 }; |
| 4613 | 4613 |
| 4614 | 4614 |
| 4615 // The cache for maps used by normalized (dictionary mode) objects. | 4615 // The cache for maps used by normalized (dictionary mode) objects. |
| 4616 // Such maps do not have property descriptors, so a typical program | 4616 // Such maps do not have property descriptors, so a typical program |
| 4617 // needs very limited number of distinct normalized maps. | 4617 // needs very limited number of distinct normalized maps. |
| 4618 class NormalizedMapCache: public FixedArray { | 4618 class NormalizedMapCache: public FixedArray { |
| 4619 public: | 4619 public: |
| 4620 static const int kEntries = 64; | 4620 static Handle<NormalizedMapCache> New(Isolate* isolate); |
| 4621 | 4621 |
| 4622 static Handle<Map> Get(Handle<NormalizedMapCache> cache, | 4622 MUST_USE_RESULT MaybeHandle<Map> Get(Handle<Map> fast_map); |
| 4623 Handle<Map> fast_map, | 4623 void Set(Handle<Map> fast_map, Handle<Map> normalized_map); |
| 4624 PropertyNormalizationMode mode); | |
| 4625 | 4624 |
| 4626 void Clear(); | 4625 void Clear(); |
| 4627 | 4626 |
| 4628 // Casting | 4627 // Casting |
| 4629 static inline NormalizedMapCache* cast(Object* obj); | 4628 static inline NormalizedMapCache* cast(Object* obj); |
| 4629 static inline bool IsNormalizedMapCache(Object* obj); |
| 4630 | 4630 |
| 4631 DECLARE_VERIFIER(NormalizedMapCache) | 4631 DECLARE_VERIFIER(NormalizedMapCache) |
| 4632 private: |
| 4633 static const int kEntries = 64; |
| 4634 |
| 4635 static inline int GetIndex(Handle<Map> map); |
| 4636 |
| 4637 // The following declarations hide base class methods. |
| 4638 Object* get(int index); |
| 4639 void set(int index, Object* value); |
| 4632 }; | 4640 }; |
| 4633 | 4641 |
| 4634 | 4642 |
| 4635 // ByteArray represents fixed sized byte arrays. Used for the relocation info | 4643 // ByteArray represents fixed sized byte arrays. Used for the relocation info |
| 4636 // that is attached to code objects. | 4644 // that is attached to code objects. |
| 4637 class ByteArray: public FixedArrayBase { | 4645 class ByteArray: public FixedArrayBase { |
| 4638 public: | 4646 public: |
| 4639 inline int Size() { return RoundUp(length() + kHeaderSize, kPointerSize); } | 4647 inline int Size() { return RoundUp(length() + kHeaderSize, kPointerSize); } |
| 4640 | 4648 |
| 4641 // Setter and getter. | 4649 // Setter and getter. |
| (...skipping 1472 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6114 Representation new_representation, | 6122 Representation new_representation, |
| 6115 Handle<HeapType> new_field_type, | 6123 Handle<HeapType> new_field_type, |
| 6116 StoreMode store_mode); | 6124 StoreMode store_mode); |
| 6117 static Handle<Map> CopyGeneralizeAllRepresentations( | 6125 static Handle<Map> CopyGeneralizeAllRepresentations( |
| 6118 Handle<Map> map, | 6126 Handle<Map> map, |
| 6119 int modify_index, | 6127 int modify_index, |
| 6120 StoreMode store_mode, | 6128 StoreMode store_mode, |
| 6121 PropertyAttributes attributes, | 6129 PropertyAttributes attributes, |
| 6122 const char* reason); | 6130 const char* reason); |
| 6123 | 6131 |
| 6132 static Handle<Map> Normalize(Handle<Map> map, PropertyNormalizationMode mode); |
| 6133 |
| 6124 // Returns the constructor name (the name (possibly, inferred name) of the | 6134 // Returns the constructor name (the name (possibly, inferred name) of the |
| 6125 // function that was used to instantiate the object). | 6135 // function that was used to instantiate the object). |
| 6126 String* constructor_name(); | 6136 String* constructor_name(); |
| 6127 | 6137 |
| 6128 // Tells whether the map is attached to SharedFunctionInfo | 6138 // Tells whether the map is attached to SharedFunctionInfo |
| 6129 // (for inobject slack tracking). | 6139 // (for inobject slack tracking). |
| 6130 inline void set_attached_to_shared_function_info(bool value); | 6140 inline void set_attached_to_shared_function_info(bool value); |
| 6131 | 6141 |
| 6132 inline bool attached_to_shared_function_info(); | 6142 inline bool attached_to_shared_function_info(); |
| 6133 | 6143 |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6307 static Handle<Map> AsElementsKind(Handle<Map> map, ElementsKind kind); | 6317 static Handle<Map> AsElementsKind(Handle<Map> map, ElementsKind kind); |
| 6308 | 6318 |
| 6309 static Handle<Map> CopyAsElementsKind(Handle<Map> map, | 6319 static Handle<Map> CopyAsElementsKind(Handle<Map> map, |
| 6310 ElementsKind kind, | 6320 ElementsKind kind, |
| 6311 TransitionFlag flag); | 6321 TransitionFlag flag); |
| 6312 | 6322 |
| 6313 static Handle<Map> CopyForObserved(Handle<Map> map); | 6323 static Handle<Map> CopyForObserved(Handle<Map> map); |
| 6314 | 6324 |
| 6315 static Handle<Map> CopyForFreeze(Handle<Map> map); | 6325 static Handle<Map> CopyForFreeze(Handle<Map> map); |
| 6316 | 6326 |
| 6317 static Handle<Map> CopyNormalized(Handle<Map> map, | |
| 6318 PropertyNormalizationMode mode, | |
| 6319 NormalizedMapSharingMode sharing); | |
| 6320 | |
| 6321 inline void AppendDescriptor(Descriptor* desc); | 6327 inline void AppendDescriptor(Descriptor* desc); |
| 6322 | 6328 |
| 6323 // Returns a copy of the map, with all transitions dropped from the | 6329 // Returns a copy of the map, with all transitions dropped from the |
| 6324 // instance descriptors. | 6330 // instance descriptors. |
| 6325 static Handle<Map> Copy(Handle<Map> map); | 6331 static Handle<Map> Copy(Handle<Map> map); |
| 6326 static Handle<Map> Create(Handle<JSFunction> constructor, | 6332 static Handle<Map> Create(Handle<JSFunction> constructor, |
| 6327 int extra_inobject_properties); | 6333 int extra_inobject_properties); |
| 6328 | 6334 |
| 6329 // Returns the next free property index (only valid for FAST MODE). | 6335 // Returns the next free property index (only valid for FAST MODE). |
| 6330 int NextFreePropertyIndex(); | 6336 int NextFreePropertyIndex(); |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6404 return instance_type() == JS_GLOBAL_PROXY_TYPE; | 6410 return instance_type() == JS_GLOBAL_PROXY_TYPE; |
| 6405 } | 6411 } |
| 6406 bool IsJSGlobalObjectMap() { | 6412 bool IsJSGlobalObjectMap() { |
| 6407 return instance_type() == JS_GLOBAL_OBJECT_TYPE; | 6413 return instance_type() == JS_GLOBAL_OBJECT_TYPE; |
| 6408 } | 6414 } |
| 6409 bool IsGlobalObjectMap() { | 6415 bool IsGlobalObjectMap() { |
| 6410 const InstanceType type = instance_type(); | 6416 const InstanceType type = instance_type(); |
| 6411 return type == JS_GLOBAL_OBJECT_TYPE || type == JS_BUILTINS_OBJECT_TYPE; | 6417 return type == JS_GLOBAL_OBJECT_TYPE || type == JS_BUILTINS_OBJECT_TYPE; |
| 6412 } | 6418 } |
| 6413 | 6419 |
| 6414 // Fires when the layout of an object with a leaf map changes. | |
| 6415 // This includes adding transitions to the leaf map or changing | |
| 6416 // the descriptor array. | |
| 6417 inline void NotifyLeafMapLayoutChange(); | |
| 6418 | |
| 6419 inline bool CanOmitMapChecks(); | 6420 inline bool CanOmitMapChecks(); |
| 6420 | 6421 |
| 6421 static void AddDependentCompilationInfo(Handle<Map> map, | 6422 static void AddDependentCompilationInfo(Handle<Map> map, |
| 6422 DependentCode::DependencyGroup group, | 6423 DependentCode::DependencyGroup group, |
| 6423 CompilationInfo* info); | 6424 CompilationInfo* info); |
| 6424 | 6425 |
| 6425 static void AddDependentCode(Handle<Map> map, | 6426 static void AddDependentCode(Handle<Map> map, |
| 6426 DependentCode::DependencyGroup group, | 6427 DependentCode::DependencyGroup group, |
| 6427 Handle<Code> code); | 6428 Handle<Code> code); |
| 6428 static void AddDependentIC(Handle<Map> map, | 6429 static void AddDependentIC(Handle<Map> map, |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6558 static Handle<Map> CopyAddDescriptor(Handle<Map> map, | 6559 static Handle<Map> CopyAddDescriptor(Handle<Map> map, |
| 6559 Descriptor* descriptor, | 6560 Descriptor* descriptor, |
| 6560 TransitionFlag flag); | 6561 TransitionFlag flag); |
| 6561 static Handle<Map> CopyReplaceDescriptors( | 6562 static Handle<Map> CopyReplaceDescriptors( |
| 6562 Handle<Map> map, | 6563 Handle<Map> map, |
| 6563 Handle<DescriptorArray> descriptors, | 6564 Handle<DescriptorArray> descriptors, |
| 6564 TransitionFlag flag, | 6565 TransitionFlag flag, |
| 6565 MaybeHandle<Name> maybe_name, | 6566 MaybeHandle<Name> maybe_name, |
| 6566 SimpleTransitionFlag simple_flag = FULL_TRANSITION); | 6567 SimpleTransitionFlag simple_flag = FULL_TRANSITION); |
| 6567 | 6568 |
| 6569 static Handle<Map> CopyNormalized(Handle<Map> map, |
| 6570 PropertyNormalizationMode mode, |
| 6571 NormalizedMapSharingMode sharing); |
| 6572 |
| 6573 // Fires when the layout of an object with a leaf map changes. |
| 6574 // This includes adding transitions to the leaf map or changing |
| 6575 // the descriptor array. |
| 6576 inline void NotifyLeafMapLayoutChange(); |
| 6577 |
| 6568 // Zaps the contents of backing data structures. Note that the | 6578 // Zaps the contents of backing data structures. Note that the |
| 6569 // heap verifier (i.e. VerifyMarkingVisitor) relies on zapping of objects | 6579 // heap verifier (i.e. VerifyMarkingVisitor) relies on zapping of objects |
| 6570 // holding weak references when incremental marking is used, because it also | 6580 // holding weak references when incremental marking is used, because it also |
| 6571 // iterates over objects that are otherwise unreachable. | 6581 // iterates over objects that are otherwise unreachable. |
| 6572 // In general we only want to call these functions in release mode when | 6582 // In general we only want to call these functions in release mode when |
| 6573 // heap verification is turned on. | 6583 // heap verification is turned on. |
| 6574 void ZapPrototypeTransitions(); | 6584 void ZapPrototypeTransitions(); |
| 6575 void ZapTransitions(); | 6585 void ZapTransitions(); |
| 6576 | 6586 |
| 6577 void DeprecateTransitionTree(); | 6587 void DeprecateTransitionTree(); |
| (...skipping 4505 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11083 } else { | 11093 } else { |
| 11084 value &= ~(1 << bit_position); | 11094 value &= ~(1 << bit_position); |
| 11085 } | 11095 } |
| 11086 return value; | 11096 return value; |
| 11087 } | 11097 } |
| 11088 }; | 11098 }; |
| 11089 | 11099 |
| 11090 } } // namespace v8::internal | 11100 } } // namespace v8::internal |
| 11091 | 11101 |
| 11092 #endif // V8_OBJECTS_H_ | 11102 #endif // V8_OBJECTS_H_ |
| OLD | NEW |