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

Side by Side Diff: src/heap.h

Issue 467037: External string table. (Closed)
Patch Set: Created 11 years 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
« no previous file with comments | « src/globals.h ('k') | src/heap.cc » ('j') | src/heap.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 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 548 matching lines...) Expand 10 before | Expand all | Expand 10 after
559 // Allocate a new external string object, which is backed by a string 559 // Allocate a new external string object, which is backed by a string
560 // resource that resides outside the V8 heap. 560 // resource that resides outside the V8 heap.
561 // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation 561 // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation
562 // failed. 562 // failed.
563 // Please note this does not perform a garbage collection. 563 // Please note this does not perform a garbage collection.
564 static Object* AllocateExternalStringFromAscii( 564 static Object* AllocateExternalStringFromAscii(
565 ExternalAsciiString::Resource* resource); 565 ExternalAsciiString::Resource* resource);
566 static Object* AllocateExternalStringFromTwoByte( 566 static Object* AllocateExternalStringFromTwoByte(
567 ExternalTwoByteString::Resource* resource); 567 ExternalTwoByteString::Resource* resource);
568 568
569 // Finalizes an external string by deleting the associated external
570 // data and clearing the resource pointer.
571 static inline void FinalizeExternalString(String* string);
572
569 // Allocates an uninitialized object. The memory is non-executable if the 573 // Allocates an uninitialized object. The memory is non-executable if the
570 // hardware and OS allow. 574 // hardware and OS allow.
571 // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation 575 // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation
572 // failed. 576 // failed.
573 // Please note this function does not perform a garbage collection. 577 // Please note this function does not perform a garbage collection.
574 static inline Object* AllocateRaw(int size_in_bytes, 578 static inline Object* AllocateRaw(int size_in_bytes,
575 AllocationSpace space, 579 AllocationSpace space,
576 AllocationSpace retry_space); 580 AllocationSpace retry_space);
577 581
578 // Initialize a filler object to keep the ability to iterate over the heap 582 // Initialize a filler object to keep the ability to iterate over the heap
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
771 static inline HeapState gc_state() { return gc_state_; } 775 static inline HeapState gc_state() { return gc_state_; }
772 776
773 #ifdef DEBUG 777 #ifdef DEBUG
774 static bool IsAllocationAllowed() { return allocation_allowed_; } 778 static bool IsAllocationAllowed() { return allocation_allowed_; }
775 static inline bool allow_allocation(bool enable); 779 static inline bool allow_allocation(bool enable);
776 780
777 static bool disallow_allocation_failure() { 781 static bool disallow_allocation_failure() {
778 return disallow_allocation_failure_; 782 return disallow_allocation_failure_;
779 } 783 }
780 784
781 static void TracePathToObject(); 785 static void TracePathToObject(Object* target);
782 static void TracePathToGlobal(); 786 static void TracePathToGlobal();
783 #endif 787 #endif
784 788
785 // Callback function passed to Heap::Iterate etc. Copies an object if 789 // Callback function passed to Heap::Iterate etc. Copies an object if
786 // necessary, the object might be promoted to an old space. The caller must 790 // necessary, the object might be promoted to an old space. The caller must
787 // ensure the precondition that the object is (a) a heap object and (b) in 791 // ensure the precondition that the object is (a) a heap object and (b) in
788 // the heap's from space. 792 // the heap's from space.
789 static void ScavengePointer(HeapObject** p); 793 static void ScavengePointer(HeapObject** p);
790 static inline void ScavengeObject(HeapObject** p, HeapObject* object); 794 static inline void ScavengeObject(HeapObject** p, HeapObject* object);
791 795
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
1032 1036
1033 static Object* CreateOddball(Map* map, 1037 static Object* CreateOddball(Map* map,
1034 const char* to_string, 1038 const char* to_string,
1035 Object* to_number); 1039 Object* to_number);
1036 1040
1037 // Allocate empty fixed array. 1041 // Allocate empty fixed array.
1038 static Object* AllocateEmptyFixedArray(); 1042 static Object* AllocateEmptyFixedArray();
1039 1043
1040 // Performs a minor collection in new generation. 1044 // Performs a minor collection in new generation.
1041 static void Scavenge(); 1045 static void Scavenge();
1046 static void ScavengeExternalStringTable();
1047 static Address DoScavenge(ObjectVisitor* scavenge_visitor,
1048 Address new_space_front);
1042 1049
1043 // Performs a major collection in the whole heap. 1050 // Performs a major collection in the whole heap.
1044 static void MarkCompact(GCTracer* tracer); 1051 static void MarkCompact(GCTracer* tracer);
1045 1052
1046 // Code to be run before and after mark-compact. 1053 // Code to be run before and after mark-compact.
1047 static void MarkCompactPrologue(bool is_compacting); 1054 static void MarkCompactPrologue(bool is_compacting);
1048 static void MarkCompactEpilogue(bool is_compacting); 1055 static void MarkCompactEpilogue(bool is_compacting);
1049 1056
1050 // Helper function used by CopyObject to copy a source object to an 1057 // Helper function used by CopyObject to copy a source object to an
1051 // allocated target object and update the forwarding pointer in the source 1058 // allocated target object and update the forwarding pointer in the source
(...skipping 564 matching lines...) Expand 10 before | Expand all | Expand 10 after
1616 hash ^= hash >> 16; 1623 hash ^= hash >> 16;
1617 hash ^= hash >> 8; 1624 hash ^= hash >> 8;
1618 return (hash & (kCacheSize - 1)); 1625 return (hash & (kCacheSize - 1));
1619 } 1626 }
1620 static TranscendentalCache* caches_[kNumberOfCaches]; 1627 static TranscendentalCache* caches_[kNumberOfCaches];
1621 Element elements_[kCacheSize]; 1628 Element elements_[kCacheSize];
1622 Type type_; 1629 Type type_;
1623 }; 1630 };
1624 1631
1625 1632
1633 // External strings table is a place where all external strings are
1634 // registered. We need to keep track of such strings to properly
1635 // finalize them.
1636 class ExternalStringTable : public AllStatic {
1637 public:
1638 // Registers an external string.
1639 inline static void AddString(String* string);
1640
1641 inline static void Iterate(ObjectVisitor* v);
1642
1643 // Restores internal invariant and gets rid of collected strings.
1644 // Must be called after each Iterate() that modified the strings.
1645 static void CleanUp();
1646
1647 // Destroys all allocated memory.
1648 static void TearDown();
1649
1650 private:
1651 friend class Heap;
1652
1653 inline static void Verify();
1654
1655 inline static void AddOldString(String* string);
1656
1657 // Notifies the table that only a prefix of the new list is valid.
1658 inline static void ShrinkNewStrings(int position);
1659
1660 // Cleans up either the new or old list moving string that shouldn't
1661 // be in the list to the other list and removing nulls.
1662 static void CleanUpList(bool new_to_old);
1663
1664 // To speed up scavenge collections new space string are kept
1665 // separate from old space strings.
1666 static List<Object*> new_space_strings_;
1667 static List<Object*> old_space_strings_;
1668 };
1669
1626 } } // namespace v8::internal 1670 } } // namespace v8::internal
1627 1671
1628 #endif // V8_HEAP_H_ 1672 #endif // V8_HEAP_H_
OLDNEW
« no previous file with comments | « src/globals.h ('k') | src/heap.cc » ('j') | src/heap.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698