diff options
author | Ryan Dahl <ry@tinyclouds.org> | 2012-01-16 14:37:57 -0800 |
---|---|---|
committer | Ryan Dahl <ry@tinyclouds.org> | 2012-01-16 14:37:57 -0800 |
commit | 60040a4f366d436d759729530f4d19e7e1958e51 (patch) | |
tree | 953a40adf24a0826836cc69843ea80d197a12dab /deps/v8/src/heap.cc | |
parent | 1afd0b52fe9bb4642a44b48dabf9d7b26d00e4ab (diff) | |
download | node-60040a4f366d436d759729530f4d19e7e1958e51.tar.gz |
Upgrade V8 to 3.8.6
Diffstat (limited to 'deps/v8/src/heap.cc')
-rw-r--r-- | deps/v8/src/heap.cc | 103 |
1 files changed, 69 insertions, 34 deletions
diff --git a/deps/v8/src/heap.cc b/deps/v8/src/heap.cc index 31cd889cb..3c871e270 100644 --- a/deps/v8/src/heap.cc +++ b/deps/v8/src/heap.cc @@ -176,7 +176,7 @@ Heap::Heap() intptr_t Heap::Capacity() { - if (!HasBeenSetup()) return 0; + if (!HasBeenSetUp()) return 0; return new_space_.Capacity() + old_pointer_space_->Capacity() + @@ -188,7 +188,7 @@ intptr_t Heap::Capacity() { intptr_t Heap::CommittedMemory() { - if (!HasBeenSetup()) return 0; + if (!HasBeenSetUp()) return 0; return new_space_.CommittedMemory() + old_pointer_space_->CommittedMemory() + @@ -200,14 +200,14 @@ intptr_t Heap::CommittedMemory() { } intptr_t Heap::CommittedMemoryExecutable() { - if (!HasBeenSetup()) return 0; + if (!HasBeenSetUp()) return 0; return isolate()->memory_allocator()->SizeExecutable(); } intptr_t Heap::Available() { - if (!HasBeenSetup()) return 0; + if (!HasBeenSetUp()) return 0; return new_space_.Available() + old_pointer_space_->Available() + @@ -218,7 +218,7 @@ intptr_t Heap::Available() { } -bool Heap::HasBeenSetup() { +bool Heap::HasBeenSetUp() { return old_pointer_space_ != NULL && old_data_space_ != NULL && code_space_ != NULL && @@ -1354,6 +1354,28 @@ void Heap::ProcessWeakReferences(WeakObjectRetainer* retainer) { } +void Heap::VisitExternalResources(v8::ExternalResourceVisitor* visitor) { + AssertNoAllocation no_allocation; + + class VisitorAdapter : public ObjectVisitor { + public: + explicit VisitorAdapter(v8::ExternalResourceVisitor* visitor) + : visitor_(visitor) {} + virtual void VisitPointers(Object** start, Object** end) { + for (Object** p = start; p < end; p++) { + if ((*p)->IsExternalString()) { + visitor_->VisitExternalString(Utils::ToLocal( + Handle<String>(String::cast(*p)))); + } + } + } + private: + v8::ExternalResourceVisitor* visitor_; + } visitor_adapter(visitor); + external_string_table_.Iterate(&visitor_adapter); +} + + class NewSpaceScavenger : public StaticNewSpaceVisitor<NewSpaceScavenger> { public: static inline void VisitPointer(Heap* heap, Object** p) { @@ -1869,6 +1891,19 @@ MaybeObject* Heap::AllocatePolymorphicCodeCache() { } +MaybeObject* Heap::AllocateAccessorPair() { + Object* result; + { MaybeObject* maybe_result = AllocateStruct(ACCESSOR_PAIR_TYPE); + if (!maybe_result->ToObject(&result)) return maybe_result; + } + AccessorPair* accessors = AccessorPair::cast(result); + // Later we will have to distinguish between undefined and the hole... + // accessors->set_getter(the_hole_value(), SKIP_WRITE_BARRIER); + // accessors->set_setter(the_hole_value(), SKIP_WRITE_BARRIER); + return accessors; +} + + const Heap::StringTypeTable Heap::string_type_table[] = { #define STRING_TYPE_ELEMENT(type, size, name, camel_name) \ {type, size, k##camel_name##MapRootIndex}, @@ -2428,18 +2463,18 @@ bool Heap::CreateInitialObjects() { // Allocate the code_stubs dictionary. The initial size is set to avoid // expanding the dictionary during bootstrapping. - { MaybeObject* maybe_obj = NumberDictionary::Allocate(128); + { MaybeObject* maybe_obj = UnseededNumberDictionary::Allocate(128); if (!maybe_obj->ToObject(&obj)) return false; } - set_code_stubs(NumberDictionary::cast(obj)); + set_code_stubs(UnseededNumberDictionary::cast(obj)); // Allocate the non_monomorphic_cache used in stub-cache.cc. The initial size // is set to avoid expanding the dictionary during bootstrapping. - { MaybeObject* maybe_obj = NumberDictionary::Allocate(64); + { MaybeObject* maybe_obj = UnseededNumberDictionary::Allocate(64); if (!maybe_obj->ToObject(&obj)) return false; } - set_non_monomorphic_cache(NumberDictionary::cast(obj)); + set_non_monomorphic_cache(UnseededNumberDictionary::cast(obj)); { MaybeObject* maybe_obj = AllocatePolymorphicCodeCache(); if (!maybe_obj->ToObject(&obj)) return false; @@ -3794,7 +3829,7 @@ MaybeObject* Heap::AllocateGlobalObject(JSFunction* constructor) { } Map* new_map = Map::cast(obj); - // Setup the global object as a normalized object. + // Set up the global object as a normalized object. global->set_map(new_map); global->map()->clear_instance_descriptors(); global->set_properties(dictionary); @@ -4727,7 +4762,7 @@ bool Heap::IdleGlobalGC() { #ifdef DEBUG void Heap::Print() { - if (!HasBeenSetup()) return; + if (!HasBeenSetUp()) return; isolate()->PrintStack(); AllSpaces spaces; for (Space* space = spaces.next(); space != NULL; space = spaces.next()) @@ -4792,7 +4827,7 @@ bool Heap::Contains(HeapObject* value) { bool Heap::Contains(Address addr) { if (OS::IsOutsideAllocatedSpace(addr)) return false; - return HasBeenSetup() && + return HasBeenSetUp() && (new_space_.ToSpaceContains(addr) || old_pointer_space_->Contains(addr) || old_data_space_->Contains(addr) || @@ -4810,7 +4845,7 @@ bool Heap::InSpace(HeapObject* value, AllocationSpace space) { bool Heap::InSpace(Address addr, AllocationSpace space) { if (OS::IsOutsideAllocatedSpace(addr)) return false; - if (!HasBeenSetup()) return false; + if (!HasBeenSetUp()) return false; switch (space) { case NEW_SPACE: @@ -4835,7 +4870,7 @@ bool Heap::InSpace(Address addr, AllocationSpace space) { #ifdef DEBUG void Heap::Verify() { - ASSERT(HasBeenSetup()); + ASSERT(HasBeenSetUp()); store_buffer()->Verify(); @@ -5262,7 +5297,7 @@ void Heap::IterateStrongRoots(ObjectVisitor* v, VisitMode mode) { bool Heap::ConfigureHeap(int max_semispace_size, intptr_t max_old_gen_size, intptr_t max_executable_size) { - if (HasBeenSetup()) return false; + if (HasBeenSetUp()) return false; if (max_semispace_size > 0) { if (max_semispace_size < Page::kPageSize) { @@ -5551,7 +5586,7 @@ class HeapDebugUtils { #endif -bool Heap::Setup(bool create_heap_objects) { +bool Heap::SetUp(bool create_heap_objects) { #ifdef DEBUG allocation_timeout_ = FLAG_gc_interval; debug_utils_ = new HeapDebugUtils(this); @@ -5581,12 +5616,12 @@ bool Heap::Setup(bool create_heap_objects) { MarkMapPointersAsEncoded(false); - // Setup memory allocator. - if (!isolate_->memory_allocator()->Setup(MaxReserved(), MaxExecutableSize())) + // Set up memory allocator. + if (!isolate_->memory_allocator()->SetUp(MaxReserved(), MaxExecutableSize())) return false; - // Setup new space. - if (!new_space_.Setup(reserved_semispace_size_, max_semispace_size_)) { + // Set up new space. + if (!new_space_.SetUp(reserved_semispace_size_, max_semispace_size_)) { return false; } @@ -5597,7 +5632,7 @@ bool Heap::Setup(bool create_heap_objects) { OLD_POINTER_SPACE, NOT_EXECUTABLE); if (old_pointer_space_ == NULL) return false; - if (!old_pointer_space_->Setup()) return false; + if (!old_pointer_space_->SetUp()) return false; // Initialize old data space. old_data_space_ = @@ -5606,14 +5641,14 @@ bool Heap::Setup(bool create_heap_objects) { OLD_DATA_SPACE, NOT_EXECUTABLE); if (old_data_space_ == NULL) return false; - if (!old_data_space_->Setup()) return false; + if (!old_data_space_->SetUp()) return false; // Initialize the code space, set its maximum capacity to the old // generation size. It needs executable memory. // On 64-bit platform(s), we put all code objects in a 2 GB range of // virtual address space, so that they can call each other with near calls. if (code_range_size_ > 0) { - if (!isolate_->code_range()->Setup(code_range_size_)) { + if (!isolate_->code_range()->SetUp(code_range_size_)) { return false; } } @@ -5621,7 +5656,7 @@ bool Heap::Setup(bool create_heap_objects) { code_space_ = new OldSpace(this, max_old_generation_size_, CODE_SPACE, EXECUTABLE); if (code_space_ == NULL) return false; - if (!code_space_->Setup()) return false; + if (!code_space_->SetUp()) return false; // Initialize map space. map_space_ = new MapSpace(this, @@ -5629,28 +5664,28 @@ bool Heap::Setup(bool create_heap_objects) { FLAG_max_map_space_pages, MAP_SPACE); if (map_space_ == NULL) return false; - if (!map_space_->Setup()) return false; + if (!map_space_->SetUp()) return false; // Initialize global property cell space. cell_space_ = new CellSpace(this, max_old_generation_size_, CELL_SPACE); if (cell_space_ == NULL) return false; - if (!cell_space_->Setup()) return false; + if (!cell_space_->SetUp()) return false; // The large object code space may contain code or data. We set the memory // to be non-executable here for safety, but this means we need to enable it // explicitly when allocating large code objects. lo_space_ = new LargeObjectSpace(this, max_old_generation_size_, LO_SPACE); if (lo_space_ == NULL) return false; - if (!lo_space_->Setup()) return false; + if (!lo_space_->SetUp()) return false; - // Setup the seed that is used to randomize the string hash function. - ASSERT(string_hash_seed() == 0); - if (FLAG_randomize_string_hashes) { - if (FLAG_string_hash_seed == 0) { - set_string_hash_seed( + // Set up the seed that is used to randomize the string hash function. + ASSERT(hash_seed() == 0); + if (FLAG_randomize_hashes) { + if (FLAG_hash_seed == 0) { + set_hash_seed( Smi::FromInt(V8::RandomPrivate(isolate()) & 0x3fffffff)); } else { - set_string_hash_seed(Smi::FromInt(FLAG_string_hash_seed)); + set_hash_seed(Smi::FromInt(FLAG_hash_seed)); } } @@ -5668,7 +5703,7 @@ bool Heap::Setup(bool create_heap_objects) { LOG(isolate_, IntPtrTEvent("heap-capacity", Capacity())); LOG(isolate_, IntPtrTEvent("heap-available", Available())); - store_buffer()->Setup(); + store_buffer()->SetUp(); return true; } |