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

Side by Side Diff: src/objects.h

Issue 234783002: Handlify Map::CopyDropDescriptors(). (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Made WhitenessWitness private. Created 6 years, 8 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 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 3329 matching lines...) Expand 10 before | Expand all | Expand 10 after
3340 // DescriptorArrays are fixed arrays used to hold instance descriptors. 3340 // DescriptorArrays are fixed arrays used to hold instance descriptors.
3341 // The format of the these objects is: 3341 // The format of the these objects is:
3342 // [0]: Number of descriptors 3342 // [0]: Number of descriptors
3343 // [1]: Either Smi(0) if uninitialized, or a pointer to small fixed array: 3343 // [1]: Either Smi(0) if uninitialized, or a pointer to small fixed array:
3344 // [0]: pointer to fixed array with enum cache 3344 // [0]: pointer to fixed array with enum cache
3345 // [1]: either Smi(0) or pointer to fixed array with indices 3345 // [1]: either Smi(0) or pointer to fixed array with indices
3346 // [2]: first key 3346 // [2]: first key
3347 // [2 + number of descriptors * kDescriptorSize]: start of slack 3347 // [2 + number of descriptors * kDescriptorSize]: start of slack
3348 class DescriptorArray: public FixedArray { 3348 class DescriptorArray: public FixedArray {
3349 public: 3349 public:
3350 // WhitenessWitness is used to prove that a descriptor array is white
3351 // (unmarked), so incremental write barriers can be skipped because the
3352 // marking invariant cannot be broken and slots pointing into evacuation
3353 // candidates will be discovered when the object is scanned. A witness is
3354 // always stack-allocated right after creating an array. By allocating a
3355 // witness, incremental marking is globally disabled. The witness is then
3356 // passed along wherever needed to statically prove that the array is known to
3357 // be white.
3358 class WhitenessWitness {
3359 public:
3360 inline explicit WhitenessWitness(FixedArray* array);
3361 inline ~WhitenessWitness();
3362
3363 private:
3364 IncrementalMarking* marking_;
3365 };
3366
3367 // Returns true for both shared empty_descriptor_array and for smis, which the 3350 // Returns true for both shared empty_descriptor_array and for smis, which the
3368 // map uses to encode additional bit fields when the descriptor array is not 3351 // map uses to encode additional bit fields when the descriptor array is not
3369 // yet used. 3352 // yet used.
3370 inline bool IsEmpty(); 3353 inline bool IsEmpty();
3371 3354
3372 // Returns the number of descriptors in the array. 3355 // Returns the number of descriptors in the array.
3373 int number_of_descriptors() { 3356 int number_of_descriptors() {
3374 ASSERT(length() >= kFirstIndex || IsEmpty()); 3357 ASSERT(length() >= kFirstIndex || IsEmpty());
3375 int len = length(); 3358 int len = length();
3376 return len == 0 ? 0 : Smi::cast(get(kDescriptorLengthIndex))->value(); 3359 return len == 0 ? 0 : Smi::cast(get(kDescriptorLengthIndex))->value();
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
3446 3429
3447 inline Name* GetSortedKey(int descriptor_number); 3430 inline Name* GetSortedKey(int descriptor_number);
3448 inline int GetSortedKeyIndex(int descriptor_number); 3431 inline int GetSortedKeyIndex(int descriptor_number);
3449 inline void SetSortedKey(int pointer, int descriptor_number); 3432 inline void SetSortedKey(int pointer, int descriptor_number);
3450 inline void InitializeRepresentations(Representation representation); 3433 inline void InitializeRepresentations(Representation representation);
3451 inline void SetRepresentation(int descriptor_number, 3434 inline void SetRepresentation(int descriptor_number,
3452 Representation representation); 3435 Representation representation);
3453 3436
3454 // Accessor for complete descriptor. 3437 // Accessor for complete descriptor.
3455 inline void Get(int descriptor_number, Descriptor* desc); 3438 inline void Get(int descriptor_number, Descriptor* desc);
3456 inline void Set(int descriptor_number, 3439 inline void Set(int descriptor_number, Descriptor* desc);
3457 Descriptor* desc,
3458 const WhitenessWitness&);
3459 void Replace(int descriptor_number, Descriptor* descriptor); 3440 void Replace(int descriptor_number, Descriptor* descriptor);
3460 3441
3461 // Append automatically sets the enumeration index. This should only be used 3442 // Append automatically sets the enumeration index. This should only be used
3462 // to add descriptors in bulk at the end, followed by sorting the descriptor 3443 // to add descriptors in bulk at the end, followed by sorting the descriptor
3463 // array. 3444 // array.
3464 inline void Append(Descriptor* desc, const WhitenessWitness&);
3465 inline void Append(Descriptor* desc); 3445 inline void Append(Descriptor* desc);
3466 3446
3467 static Handle<DescriptorArray> Merge(Handle<Map> left_map, 3447 static Handle<DescriptorArray> Merge(Handle<Map> left_map,
3468 int verbatim, 3448 int verbatim,
3469 int valid, 3449 int valid,
3470 int new_size, 3450 int new_size,
3471 int modify_index, 3451 int modify_index,
3472 StoreMode store_mode, 3452 StoreMode store_mode,
3473 Handle<Map> right_map) 3453 Handle<Map> right_map)
3474 V8_WARN_UNUSED_RESULT; 3454 V8_WARN_UNUSED_RESULT;
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
3549 bool IsEqualTo(DescriptorArray* other); 3529 bool IsEqualTo(DescriptorArray* other);
3550 #endif 3530 #endif
3551 3531
3552 // Returns the fixed array length required to hold number_of_descriptors 3532 // Returns the fixed array length required to hold number_of_descriptors
3553 // descriptors. 3533 // descriptors.
3554 static int LengthFor(int number_of_descriptors) { 3534 static int LengthFor(int number_of_descriptors) {
3555 return ToKeyIndex(number_of_descriptors); 3535 return ToKeyIndex(number_of_descriptors);
3556 } 3536 }
3557 3537
3558 private: 3538 private:
3539 // WhitenessWitness is used to prove that a descriptor array is white
3540 // (unmarked), so incremental write barriers can be skipped because the
3541 // marking invariant cannot be broken and slots pointing into evacuation
3542 // candidates will be discovered when the object is scanned. A witness is
3543 // always stack-allocated right after creating an array. By allocating a
3544 // witness, incremental marking is globally disabled. The witness is then
3545 // passed along wherever needed to statically prove that the array is known to
3546 // be white.
3547 class WhitenessWitness {
3548 public:
3549 inline explicit WhitenessWitness(FixedArray* array);
Toon Verwaest 2014/04/11 10:37:59 DescriptorArray* descriptors?
mvstanton 2014/04/11 11:25:20 Sure.
3550 inline ~WhitenessWitness();
3551
3552 private:
3553 IncrementalMarking* marking_;
3554 };
3555
3559 // An entry in a DescriptorArray, represented as an (array, index) pair. 3556 // An entry in a DescriptorArray, represented as an (array, index) pair.
3560 class Entry { 3557 class Entry {
3561 public: 3558 public:
3562 inline explicit Entry(DescriptorArray* descs, int index) : 3559 inline explicit Entry(DescriptorArray* descs, int index) :
3563 descs_(descs), index_(index) { } 3560 descs_(descs), index_(index) { }
3564 3561
3565 inline PropertyType type() { return descs_->GetType(index_); } 3562 inline PropertyType type() { return descs_->GetType(index_); }
3566 inline Object* GetCallbackObject() { return descs_->GetValue(index_); } 3563 inline Object* GetCallbackObject() { return descs_->GetValue(index_); }
3567 3564
3568 private: 3565 private:
(...skipping 19 matching lines...) Expand all
3588 (descriptor_number * kDescriptorSize) + 3585 (descriptor_number * kDescriptorSize) +
3589 kDescriptorValue; 3586 kDescriptorValue;
3590 } 3587 }
3591 3588
3592 // Transfer a complete descriptor from the src descriptor array to this 3589 // Transfer a complete descriptor from the src descriptor array to this
3593 // descriptor array. 3590 // descriptor array.
3594 void CopyFrom(int index, 3591 void CopyFrom(int index,
3595 DescriptorArray* src, 3592 DescriptorArray* src,
3596 const WhitenessWitness&); 3593 const WhitenessWitness&);
3597 3594
3598 inline void Set(int descriptor_number, Descriptor* desc); 3595 inline void Set(int descriptor_number,
3596 Descriptor* desc,
3597 const WhitenessWitness&);
3598
3599 inline void Append(Descriptor* desc, const WhitenessWitness&);
3599 3600
3600 // Swap first and second descriptor. 3601 // Swap first and second descriptor.
3601 inline void SwapSortedKeys(int first, int second); 3602 inline void SwapSortedKeys(int first, int second);
3602 3603
3603 DISALLOW_IMPLICIT_CONSTRUCTORS(DescriptorArray); 3604 DISALLOW_IMPLICIT_CONSTRUCTORS(DescriptorArray);
3604 }; 3605 };
3605 3606
3606 3607
3607 enum SearchMode { ALL_ENTRIES, VALID_ENTRIES }; 3608 enum SearchMode { ALL_ENTRIES, VALID_ENTRIES };
3608 3609
(...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after
4091 ASSERT(obj->IsDictionary()); 4092 ASSERT(obj->IsDictionary());
4092 return reinterpret_cast<NameDictionary*>(obj); 4093 return reinterpret_cast<NameDictionary*>(obj);
4093 } 4094 }
4094 4095
4095 // Copies enumerable keys to preallocated fixed array. 4096 // Copies enumerable keys to preallocated fixed array.
4096 void CopyEnumKeysTo(FixedArray* storage); 4097 void CopyEnumKeysTo(FixedArray* storage);
4097 static void DoGenerateNewEnumerationIndices( 4098 static void DoGenerateNewEnumerationIndices(
4098 Handle<NameDictionary> dictionary); 4099 Handle<NameDictionary> dictionary);
4099 4100
4100 // For transforming properties of a JSObject. 4101 // For transforming properties of a JSObject.
4101 MUST_USE_RESULT MaybeObject* TransformPropertiesToFastFor( 4102 static void TransformPropertiesToFastFor(Handle<NameDictionary> dictionary,
4102 JSObject* obj, 4103 Handle<JSObject> obj,
4103 int unused_property_fields); 4104 int unused_property_fields);
4104 4105
4105 // Find entry for key, otherwise return kNotFound. Optimized version of 4106 // Find entry for key, otherwise return kNotFound. Optimized version of
4106 // HashTable::FindEntry. 4107 // HashTable::FindEntry.
4107 int FindEntry(Name* key); 4108 int FindEntry(Name* key);
4108 }; 4109 };
4109 4110
4110 4111
4111 class NumberDictionaryShape : public BaseShape<uint32_t> { 4112 class NumberDictionaryShape : public BaseShape<uint32_t> {
4112 public: 4113 public:
4113 static inline bool IsMatch(uint32_t key, Object* other); 4114 static inline bool IsMatch(uint32_t key, Object* other);
(...skipping 2274 matching lines...) Expand 10 before | Expand all | Expand 10 after
6388 // is found by re-transitioning from the root of the transition tree using the 6389 // is found by re-transitioning from the root of the transition tree using the
6389 // descriptor array of the map. Returns NULL if no updated map is found. 6390 // descriptor array of the map. Returns NULL if no updated map is found.
6390 // This method also applies any pending migrations along the prototype chain. 6391 // This method also applies any pending migrations along the prototype chain.
6391 static Handle<Map> CurrentMapForDeprecated(Handle<Map> map); 6392 static Handle<Map> CurrentMapForDeprecated(Handle<Map> map);
6392 // Same as above, but does not touch the prototype chain. 6393 // Same as above, but does not touch the prototype chain.
6393 static Handle<Map> CurrentMapForDeprecatedInternal(Handle<Map> map); 6394 static Handle<Map> CurrentMapForDeprecatedInternal(Handle<Map> map);
6394 6395
6395 static Handle<Map> RawCopy(Handle<Map> map, int instance_size); 6396 static Handle<Map> RawCopy(Handle<Map> map, int instance_size);
6396 MUST_USE_RESULT MaybeObject* RawCopy(int instance_size); 6397 MUST_USE_RESULT MaybeObject* RawCopy(int instance_size);
6397 static Handle<Map> CopyDropDescriptors(Handle<Map> map); 6398 static Handle<Map> CopyDropDescriptors(Handle<Map> map);
6398 MUST_USE_RESULT MaybeObject* CopyDropDescriptors();
6399 static Handle<Map> CopyReplaceDescriptors( 6399 static Handle<Map> CopyReplaceDescriptors(
6400 Handle<Map> map, 6400 Handle<Map> map,
6401 Handle<DescriptorArray> descriptors, 6401 Handle<DescriptorArray> descriptors,
6402 TransitionFlag flag, 6402 TransitionFlag flag,
6403 Handle<Name> name, 6403 Handle<Name> name,
6404 SimpleTransitionFlag simple_flag = FULL_TRANSITION); 6404 SimpleTransitionFlag simple_flag = FULL_TRANSITION);
6405 static Handle<Map> CopyReplaceDescriptors( 6405 static Handle<Map> CopyReplaceDescriptors(
6406 Handle<Map> map, 6406 Handle<Map> map,
6407 Handle<DescriptorArray> descriptors, 6407 Handle<DescriptorArray> descriptors,
6408 TransitionFlag flag, 6408 TransitionFlag flag,
(...skipping 23 matching lines...) Expand all
6432 static Handle<Map> CopyAsElementsKind(Handle<Map> map, 6432 static Handle<Map> CopyAsElementsKind(Handle<Map> map,
6433 ElementsKind kind, 6433 ElementsKind kind,
6434 TransitionFlag flag); 6434 TransitionFlag flag);
6435 6435
6436 static Handle<Map> CopyForObserved(Handle<Map> map); 6436 static Handle<Map> CopyForObserved(Handle<Map> map);
6437 6437
6438 static Handle<Map> CopyNormalized(Handle<Map> map, 6438 static Handle<Map> CopyNormalized(Handle<Map> map,
6439 PropertyNormalizationMode mode, 6439 PropertyNormalizationMode mode,
6440 NormalizedMapSharingMode sharing); 6440 NormalizedMapSharingMode sharing);
6441 6441
6442 inline void AppendDescriptor(Descriptor* desc, 6442 inline void AppendDescriptor(Descriptor* desc);
6443 const DescriptorArray::WhitenessWitness&);
6444 6443
6445 // Returns a copy of the map, with all transitions dropped from the 6444 // Returns a copy of the map, with all transitions dropped from the
6446 // instance descriptors. 6445 // instance descriptors.
6447 static Handle<Map> Copy(Handle<Map> map); 6446 static Handle<Map> Copy(Handle<Map> map);
6448 static Handle<Map> Create(Handle<JSFunction> constructor, 6447 static Handle<Map> Create(Handle<JSFunction> constructor,
6449 int extra_inobject_properties); 6448 int extra_inobject_properties);
6450 6449
6451 // Returns the next free property index (only valid for FAST MODE). 6450 // Returns the next free property index (only valid for FAST MODE).
6452 int NextFreePropertyIndex(); 6451 int NextFreePropertyIndex();
6453 6452
(...skipping 4561 matching lines...) Expand 10 before | Expand all | Expand 10 after
11015 } else { 11014 } else {
11016 value &= ~(1 << bit_position); 11015 value &= ~(1 << bit_position);
11017 } 11016 }
11018 return value; 11017 return value;
11019 } 11018 }
11020 }; 11019 };
11021 11020
11022 } } // namespace v8::internal 11021 } } // namespace v8::internal
11023 11022
11024 #endif // V8_OBJECTS_H_ 11023 #endif // V8_OBJECTS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698