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

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: Some more refactoring. 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
« no previous file with comments | « src/factory.cc ('k') | src/objects.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 18 matching lines...) Expand all
3493 3473
3494 // Search the instance descriptors for given name. 3474 // Search the instance descriptors for given name.
3495 INLINE(int Search(Name* name, int number_of_own_descriptors)); 3475 INLINE(int Search(Name* name, int number_of_own_descriptors));
3496 3476
3497 // As the above, but uses DescriptorLookupCache and updates it when 3477 // As the above, but uses DescriptorLookupCache and updates it when
3498 // necessary. 3478 // necessary.
3499 INLINE(int SearchWithCache(Name* name, Map* map)); 3479 INLINE(int SearchWithCache(Name* name, Map* map));
3500 3480
3501 // Allocates a DescriptorArray, but returns the singleton 3481 // Allocates a DescriptorArray, but returns the singleton
3502 // empty descriptor array object if number_of_descriptors is 0. 3482 // empty descriptor array object if number_of_descriptors is 0.
3503 MUST_USE_RESULT static MaybeObject* Allocate(Isolate* isolate, 3483 static Handle<DescriptorArray> Allocate(Isolate* isolate,
3504 int number_of_descriptors, 3484 int number_of_descriptors,
3505 int slack = 0); 3485 int slack = 0);
3506 3486
3507 // Casting. 3487 // Casting.
3508 static inline DescriptorArray* cast(Object* obj); 3488 static inline DescriptorArray* cast(Object* obj);
3509 3489
3510 // Constant for denoting key was not found. 3490 // Constant for denoting key was not found.
3511 static const int kNotFound = -1; 3491 static const int kNotFound = -1;
3512 3492
3513 static const int kDescriptorLengthIndex = 0; 3493 static const int kDescriptorLengthIndex = 0;
3514 static const int kEnumCacheIndex = 1; 3494 static const int kEnumCacheIndex = 1;
3515 static const int kFirstIndex = 2; 3495 static const int kFirstIndex = 2;
(...skipping 33 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(DescriptorArray* array);
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 481 matching lines...) Expand 10 before | Expand all | Expand 10 after
4090 static inline NameDictionary* cast(Object* obj) { 4091 static inline NameDictionary* cast(Object* obj) {
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 MUST_USE_RESULT MaybeObject* TransformPropertiesToFastFor(
4102 JSObject* obj,
4103 int unused_property_fields);
4104
4105 // Find entry for key, otherwise return kNotFound. Optimized version of 4101 // Find entry for key, otherwise return kNotFound. Optimized version of
4106 // HashTable::FindEntry. 4102 // HashTable::FindEntry.
4107 int FindEntry(Name* key); 4103 int FindEntry(Name* key);
4108 }; 4104 };
4109 4105
4110 4106
4111 class NumberDictionaryShape : public BaseShape<uint32_t> { 4107 class NumberDictionaryShape : public BaseShape<uint32_t> {
4112 public: 4108 public:
4113 static inline bool IsMatch(uint32_t key, Object* other); 4109 static inline bool IsMatch(uint32_t key, Object* other);
4114 MUST_USE_RESULT static inline MaybeObject* AsObject(Heap* heap, 4110 MUST_USE_RESULT static inline MaybeObject* AsObject(Heap* heap,
(...skipping 2177 matching lines...) Expand 10 before | Expand all | Expand 10 after
6292 6288
6293 // [prototype transitions]: cache of prototype transitions. 6289 // [prototype transitions]: cache of prototype transitions.
6294 // Prototype transition is a transition that happens 6290 // Prototype transition is a transition that happens
6295 // when we change object's prototype to a new one. 6291 // when we change object's prototype to a new one.
6296 // Cache format: 6292 // Cache format:
6297 // 0: finger - index of the first free cell in the cache 6293 // 0: finger - index of the first free cell in the cache
6298 // 1: back pointer that overlaps with prototype transitions field. 6294 // 1: back pointer that overlaps with prototype transitions field.
6299 // 2 + 2 * i: prototype 6295 // 2 + 2 * i: prototype
6300 // 3 + 2 * i: target map 6296 // 3 + 2 * i: target map
6301 inline FixedArray* GetPrototypeTransitions(); 6297 inline FixedArray* GetPrototypeTransitions();
6302 MUST_USE_RESULT inline MaybeObject* SetPrototypeTransitions( 6298 static inline void SetPrototypeTransitions(
6303 FixedArray* prototype_transitions); 6299 Handle<Map> map, Handle<FixedArray> prototype_transitions);
6304 inline bool HasPrototypeTransitions(); 6300 inline bool HasPrototypeTransitions();
6305 6301
6306 static const int kProtoTransitionHeaderSize = 1; 6302 static const int kProtoTransitionHeaderSize = 1;
6307 static const int kProtoTransitionNumberOfEntriesOffset = 0; 6303 static const int kProtoTransitionNumberOfEntriesOffset = 0;
6308 static const int kProtoTransitionElementsPerEntry = 2; 6304 static const int kProtoTransitionElementsPerEntry = 2;
6309 static const int kProtoTransitionPrototypeOffset = 0; 6305 static const int kProtoTransitionPrototypeOffset = 0;
6310 static const int kProtoTransitionMapOffset = 1; 6306 static const int kProtoTransitionMapOffset = 1;
6311 6307
6312 inline int NumberOfProtoTransitions() { 6308 inline int NumberOfProtoTransitions() {
6313 FixedArray* cache = GetPrototypeTransitions(); 6309 FixedArray* cache = GetPrototypeTransitions();
(...skipping 74 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 6384 // 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. 6385 // 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. 6386 // This method also applies any pending migrations along the prototype chain.
6391 static Handle<Map> CurrentMapForDeprecated(Handle<Map> map); 6387 static Handle<Map> CurrentMapForDeprecated(Handle<Map> map);
6392 // Same as above, but does not touch the prototype chain. 6388 // Same as above, but does not touch the prototype chain.
6393 static Handle<Map> CurrentMapForDeprecatedInternal(Handle<Map> map); 6389 static Handle<Map> CurrentMapForDeprecatedInternal(Handle<Map> map);
6394 6390
6395 static Handle<Map> RawCopy(Handle<Map> map, int instance_size); 6391 static Handle<Map> RawCopy(Handle<Map> map, int instance_size);
6396 MUST_USE_RESULT MaybeObject* RawCopy(int instance_size); 6392 MUST_USE_RESULT MaybeObject* RawCopy(int instance_size);
6397 static Handle<Map> CopyDropDescriptors(Handle<Map> map); 6393 static Handle<Map> CopyDropDescriptors(Handle<Map> map);
6398 MUST_USE_RESULT MaybeObject* CopyDropDescriptors();
6399 static Handle<Map> CopyReplaceDescriptors( 6394 static Handle<Map> CopyReplaceDescriptors(
6400 Handle<Map> map, 6395 Handle<Map> map,
6401 Handle<DescriptorArray> descriptors, 6396 Handle<DescriptorArray> descriptors,
6402 TransitionFlag flag, 6397 TransitionFlag flag,
6403 Handle<Name> name, 6398 Handle<Name> name,
6404 SimpleTransitionFlag simple_flag = FULL_TRANSITION); 6399 SimpleTransitionFlag simple_flag = FULL_TRANSITION);
6405 static Handle<Map> CopyReplaceDescriptors( 6400 static Handle<Map> CopyReplaceDescriptors(
6406 Handle<Map> map, 6401 Handle<Map> map,
6407 Handle<DescriptorArray> descriptors, 6402 Handle<DescriptorArray> descriptors,
6408 TransitionFlag flag, 6403 TransitionFlag flag,
(...skipping 23 matching lines...) Expand all
6432 static Handle<Map> CopyAsElementsKind(Handle<Map> map, 6427 static Handle<Map> CopyAsElementsKind(Handle<Map> map,
6433 ElementsKind kind, 6428 ElementsKind kind,
6434 TransitionFlag flag); 6429 TransitionFlag flag);
6435 6430
6436 static Handle<Map> CopyForObserved(Handle<Map> map); 6431 static Handle<Map> CopyForObserved(Handle<Map> map);
6437 6432
6438 static Handle<Map> CopyNormalized(Handle<Map> map, 6433 static Handle<Map> CopyNormalized(Handle<Map> map,
6439 PropertyNormalizationMode mode, 6434 PropertyNormalizationMode mode,
6440 NormalizedMapSharingMode sharing); 6435 NormalizedMapSharingMode sharing);
6441 6436
6442 inline void AppendDescriptor(Descriptor* desc, 6437 inline void AppendDescriptor(Descriptor* desc);
6443 const DescriptorArray::WhitenessWitness&);
6444 6438
6445 // Returns a copy of the map, with all transitions dropped from the 6439 // Returns a copy of the map, with all transitions dropped from the
6446 // instance descriptors. 6440 // instance descriptors.
6447 static Handle<Map> Copy(Handle<Map> map); 6441 static Handle<Map> Copy(Handle<Map> map);
6448 static Handle<Map> Create(Handle<JSFunction> constructor, 6442 static Handle<Map> Create(Handle<JSFunction> constructor,
6449 int extra_inobject_properties); 6443 int extra_inobject_properties);
6450 6444
6451 // Returns the next free property index (only valid for FAST MODE). 6445 // Returns the next free property index (only valid for FAST MODE).
6452 int NextFreePropertyIndex(); 6446 int NextFreePropertyIndex();
6453 6447
(...skipping 4561 matching lines...) Expand 10 before | Expand all | Expand 10 after
11015 } else { 11009 } else {
11016 value &= ~(1 << bit_position); 11010 value &= ~(1 << bit_position);
11017 } 11011 }
11018 return value; 11012 return value;
11019 } 11013 }
11020 }; 11014 };
11021 11015
11022 } } // namespace v8::internal 11016 } } // namespace v8::internal
11023 11017
11024 #endif // V8_OBJECTS_H_ 11018 #endif // V8_OBJECTS_H_
OLDNEW
« no previous file with comments | « src/factory.cc ('k') | src/objects.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698