Chromium Code Reviews| Index: src/objects.h |
| diff --git a/src/objects.h b/src/objects.h |
| index adaa9cfb793f92e4f99bb1cc51324c0cff347c8c..e75c2790e20690bd8058d362d33143f7f3fcd146 100644 |
| --- a/src/objects.h |
| +++ b/src/objects.h |
| @@ -386,6 +386,7 @@ const int kStubMinorKeyBits = kBitsPerInt - kSmiTagSize - kStubMajorKeyBits; |
| V(SIGNATURE_INFO_TYPE) \ |
| V(TYPE_SWITCH_INFO_TYPE) \ |
| V(ALLOCATION_SITE_INFO_TYPE) \ |
| + V(ALLOCATION_SITE_TYPE) \ |
| V(SCRIPT_TYPE) \ |
| V(CODE_CACHE_TYPE) \ |
| V(POLYMORPHIC_CODE_CACHE_TYPE) \ |
| @@ -549,6 +550,7 @@ const int kStubMinorKeyBits = kBitsPerInt - kSmiTagSize - kStubMajorKeyBits; |
| V(SIGNATURE_INFO, SignatureInfo, signature_info) \ |
| V(TYPE_SWITCH_INFO, TypeSwitchInfo, type_switch_info) \ |
| V(SCRIPT, Script, script) \ |
| + V(ALLOCATION_SITE, AllocationSite, allocation_site) \ |
| V(ALLOCATION_SITE_INFO, AllocationSiteInfo, allocation_site_info) \ |
| V(CODE_CACHE, CodeCache, code_cache) \ |
| V(POLYMORPHIC_CODE_CACHE, PolymorphicCodeCache, polymorphic_code_cache) \ |
| @@ -708,6 +710,7 @@ enum InstanceType { |
| OBJECT_TEMPLATE_INFO_TYPE, |
| SIGNATURE_INFO_TYPE, |
| TYPE_SWITCH_INFO_TYPE, |
| + ALLOCATION_SITE_TYPE, |
| ALLOCATION_SITE_INFO_TYPE, |
| SCRIPT_TYPE, |
| CODE_CACHE_TYPE, |
| @@ -2217,8 +2220,7 @@ class JSObject: public JSReceiver { |
| ElementsKind to_kind); |
| MUST_USE_RESULT MaybeObject* TransitionElementsKind(ElementsKind to_kind); |
| - MUST_USE_RESULT MaybeObject* UpdateAllocationSiteInfo( |
| - ElementsKind to_kind); |
| + MUST_USE_RESULT MaybeObject* UpdateAllocationSite(ElementsKind to_kind); |
| // Replaces an existing transition with a transition to a map with a FIELD. |
| MUST_USE_RESULT MaybeObject* ConvertTransitionToMapTransition( |
| @@ -7456,26 +7458,68 @@ enum AllocationSiteMode { |
| }; |
| -class AllocationSiteInfo: public Struct { |
| +class AllocationSite: public Struct { |
| public: |
| + static const int kPayloadOffset = HeapObject::kHeaderSize; |
| + static const int kSize = kPayloadOffset + kPointerSize; |
| + static const uint32_t kMaximumArrayBytesToPretransition = 8 * 1024; |
| + |
| + // TODO(mvstanton): rename payload to transition_info. |
| DECL_ACCESSORS(payload, Object) |
| - static inline AllocationSiteInfo* cast(Object* obj); |
| + void Initialize() { |
| + SetElementsKindPayload(GetInitialFastElementsKind()); |
| + } |
| - DECLARE_PRINTER(AllocationSiteInfo) |
| - DECLARE_VERIFIER(AllocationSiteInfo) |
| + ElementsKind GetElementsKindPayload() { |
| + ASSERT(!IsLiteralSite()); |
| + return static_cast<ElementsKind>(Smi::cast(payload())->value()); |
| + } |
| - // Returns NULL if no AllocationSiteInfo is available for object. |
| - static AllocationSiteInfo* FindForJSObject(JSObject* object); |
| + void SetElementsKindPayload(ElementsKind kind) { |
| + set_payload(Smi::FromInt(static_cast<int>(kind))); |
| + } |
| + |
| + bool IsLiteralSite() { |
| + // If the payload is a smi, then it represents an ElementsKind |
| + // for a constructed array. Otherwise, it must be a boilerplate |
| + // for an array literal |
| + return payload()->IsJSArray(); |
| + } |
| + |
| + DECLARE_PRINTER(AllocationSite) |
| + DECLARE_VERIFIER(AllocationSite) |
| + |
| + static inline AllocationSite* cast(Object* obj); |
| static inline AllocationSiteMode GetMode( |
| ElementsKind boilerplate_elements_kind); |
| static inline AllocationSiteMode GetMode(ElementsKind from, ElementsKind to); |
| - static const int kPayloadOffset = HeapObject::kHeaderSize; |
| - static const int kSize = kPayloadOffset + kPointerSize; |
| - static const uint32_t kMaximumArrayBytesToPretransition = 8 * 1024; |
| + private: |
| + DISALLOW_IMPLICIT_CONSTRUCTORS(AllocationSite); |
| +}; |
| + |
| + |
| +class AllocationSiteInfo: public Struct { |
| + public: |
| + static const int kAllocationSiteOffset = HeapObject::kHeaderSize; |
| + static const int kSize = kAllocationSiteOffset + kPointerSize; |
| + |
| + DECL_ACCESSORS(allocation_site, Object) |
| + |
| + bool site_is_valid() { return allocation_site()->IsAllocationSite(); } |
|
Hannes Payer (out of office)
2013/07/03 15:34:02
this is not a real getter.
mvstanton
2013/07/05 07:56:14
Done.
|
| + AllocationSite* allocation_site_casted() { |
|
Hannes Payer (out of office)
2013/07/03 15:34:02
This is also not a real getter. Moreover can we ca
mvstanton
2013/07/05 07:56:14
Done.
|
| + ASSERT(site_is_valid()); |
| + return AllocationSite::cast(allocation_site()); |
| + } |
| + |
| + DECLARE_PRINTER(AllocationSiteInfo) |
| + DECLARE_VERIFIER(AllocationSiteInfo) |
| + |
| + // Returns NULL if no AllocationSiteInfo is available for object. |
| + static AllocationSiteInfo* FindForJSObject(JSObject* object); |
| + static inline AllocationSiteInfo* cast(Object* obj); |
| - bool GetElementsKindPayload(ElementsKind* kind); |
| private: |
| DISALLOW_IMPLICIT_CONSTRUCTORS(AllocationSiteInfo); |
| }; |