| OLD | NEW |
| 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 2357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2368 // object, the prefix of this array is sorted. | 2368 // object, the prefix of this array is sorted. |
| 2369 void SortPairs(FixedArray* numbers, uint32_t len); | 2369 void SortPairs(FixedArray* numbers, uint32_t len); |
| 2370 | 2370 |
| 2371 class BodyDescriptor : public FlexibleBodyDescriptor<kHeaderSize> { | 2371 class BodyDescriptor : public FlexibleBodyDescriptor<kHeaderSize> { |
| 2372 public: | 2372 public: |
| 2373 static inline int SizeOf(Map* map, HeapObject* object) { | 2373 static inline int SizeOf(Map* map, HeapObject* object) { |
| 2374 return SizeFor(reinterpret_cast<FixedArray*>(object)->length()); | 2374 return SizeFor(reinterpret_cast<FixedArray*>(object)->length()); |
| 2375 } | 2375 } |
| 2376 }; | 2376 }; |
| 2377 | 2377 |
| 2378 // WhitenessWitness is used to prove that a descriptor array is white | |
| 2379 // (unmarked), so incremental write barriers can be skipped because the | |
| 2380 // marking invariant cannot be broken and slots pointing into evacuation | |
| 2381 // candidates will be discovered when the object is scanned. A witness is | |
| 2382 // always stack-allocated right after creating an array. By allocating a | |
| 2383 // witness, incremental marking is globally disabled. The witness is then | |
| 2384 // passed along wherever needed to statically prove that the array is known to | |
| 2385 // be white. | |
| 2386 class WhitenessWitness { | |
| 2387 public: | |
| 2388 inline explicit WhitenessWitness(FixedArray* array); | |
| 2389 inline ~WhitenessWitness(); | |
| 2390 | |
| 2391 private: | |
| 2392 IncrementalMarking* marking_; | |
| 2393 }; | |
| 2394 | |
| 2395 protected: | 2378 protected: |
| 2396 // Set operation on FixedArray without using write barriers. Can | 2379 // Set operation on FixedArray without using write barriers. Can |
| 2397 // only be used for storing old space objects or smis. | 2380 // only be used for storing old space objects or smis. |
| 2398 static inline void NoWriteBarrierSet(FixedArray* array, | 2381 static inline void NoWriteBarrierSet(FixedArray* array, |
| 2399 int index, | 2382 int index, |
| 2400 Object* value); | 2383 Object* value); |
| 2401 | 2384 |
| 2402 // Set operation on FixedArray without incremental write barrier. Can | 2385 // Set operation on FixedArray without incremental write barrier. Can |
| 2403 // only be used if the object is guaranteed to be white (whiteness witness | 2386 // only be used if the object is guaranteed to be white (whiteness witness |
| 2404 // is present). | 2387 // is present). |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2468 | 2451 |
| 2469 // DescriptorArrays are fixed arrays used to hold instance descriptors. | 2452 // DescriptorArrays are fixed arrays used to hold instance descriptors. |
| 2470 // The format of the these objects is: | 2453 // The format of the these objects is: |
| 2471 // [0]: Either Smi(0) if uninitialized, or a pointer to small fixed array: | 2454 // [0]: Either Smi(0) if uninitialized, or a pointer to small fixed array: |
| 2472 // [0]: pointer to fixed array with enum cache | 2455 // [0]: pointer to fixed array with enum cache |
| 2473 // [1]: either Smi(0) or pointer to fixed array with indices | 2456 // [1]: either Smi(0) or pointer to fixed array with indices |
| 2474 // [1]: first key | 2457 // [1]: first key |
| 2475 // [length() - kDescriptorSize]: last key | 2458 // [length() - kDescriptorSize]: last key |
| 2476 class DescriptorArray: public FixedArray { | 2459 class DescriptorArray: public FixedArray { |
| 2477 public: | 2460 public: |
| 2461 // WhitenessWitness is used to prove that a descriptor array is white |
| 2462 // (unmarked), so incremental write barriers can be skipped because the |
| 2463 // marking invariant cannot be broken and slots pointing into evacuation |
| 2464 // candidates will be discovered when the object is scanned. A witness is |
| 2465 // always stack-allocated right after creating an array. By allocating a |
| 2466 // witness, incremental marking is globally disabled. The witness is then |
| 2467 // passed along wherever needed to statically prove that the array is known to |
| 2468 // be white. |
| 2469 class WhitenessWitness { |
| 2470 public: |
| 2471 inline explicit WhitenessWitness(FixedArray* array); |
| 2472 inline ~WhitenessWitness(); |
| 2473 |
| 2474 private: |
| 2475 IncrementalMarking* marking_; |
| 2476 }; |
| 2477 |
| 2478 // Returns true for both shared empty_descriptor_array and for smis, which the | 2478 // Returns true for both shared empty_descriptor_array and for smis, which the |
| 2479 // map uses to encode additional bit fields when the descriptor array is not | 2479 // map uses to encode additional bit fields when the descriptor array is not |
| 2480 // yet used. | 2480 // yet used. |
| 2481 inline bool IsEmpty(); | 2481 inline bool IsEmpty(); |
| 2482 | 2482 |
| 2483 // Returns the number of descriptors in the array. | 2483 // Returns the number of descriptors in the array. |
| 2484 int number_of_descriptors() { | 2484 int number_of_descriptors() { |
| 2485 ASSERT(length() >= kFirstIndex || IsEmpty()); | 2485 ASSERT(length() >= kFirstIndex || IsEmpty()); |
| 2486 int len = length(); | 2486 int len = length(); |
| 2487 return len <= kFirstIndex ? 0 : (len - kFirstIndex) / kDescriptorSize; | 2487 return len <= kFirstIndex ? 0 : (len - kFirstIndex) / kDescriptorSize; |
| (...skipping 6486 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8974 } else { | 8974 } else { |
| 8975 value &= ~(1 << bit_position); | 8975 value &= ~(1 << bit_position); |
| 8976 } | 8976 } |
| 8977 return value; | 8977 return value; |
| 8978 } | 8978 } |
| 8979 }; | 8979 }; |
| 8980 | 8980 |
| 8981 } } // namespace v8::internal | 8981 } } // namespace v8::internal |
| 8982 | 8982 |
| 8983 #endif // V8_OBJECTS_H_ | 8983 #endif // V8_OBJECTS_H_ |
| OLD | NEW |