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

Side by Side Diff: src/heap.cc

Issue 9976003: Minimize uses of lazy initialization by adding explicit initialization functions. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Address Daniel's comments. Created 8 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/frames.cc ('k') | src/lazy-instance.h » ('j') | src/v8.cc » ('J')
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 24 matching lines...) Expand all
35 #include "debug.h" 35 #include "debug.h"
36 #include "deoptimizer.h" 36 #include "deoptimizer.h"
37 #include "global-handles.h" 37 #include "global-handles.h"
38 #include "heap-profiler.h" 38 #include "heap-profiler.h"
39 #include "incremental-marking.h" 39 #include "incremental-marking.h"
40 #include "liveobjectlist-inl.h" 40 #include "liveobjectlist-inl.h"
41 #include "mark-compact.h" 41 #include "mark-compact.h"
42 #include "natives.h" 42 #include "natives.h"
43 #include "objects-visiting.h" 43 #include "objects-visiting.h"
44 #include "objects-visiting-inl.h" 44 #include "objects-visiting-inl.h"
45 #include "once.h"
45 #include "runtime-profiler.h" 46 #include "runtime-profiler.h"
46 #include "scopeinfo.h" 47 #include "scopeinfo.h"
47 #include "snapshot.h" 48 #include "snapshot.h"
48 #include "store-buffer.h" 49 #include "store-buffer.h"
49 #include "v8threads.h" 50 #include "v8threads.h"
50 #include "vm-state-inl.h" 51 #include "vm-state-inl.h"
51 #if V8_TARGET_ARCH_ARM && !V8_INTERPRETED_REGEXP 52 #if V8_TARGET_ARCH_ARM && !V8_INTERPRETED_REGEXP
52 #include "regexp-macro-assembler.h" 53 #include "regexp-macro-assembler.h"
53 #include "arm/regexp-macro-assembler-arm.h" 54 #include "arm/regexp-macro-assembler-arm.h"
54 #endif 55 #endif
55 #if V8_TARGET_ARCH_MIPS && !V8_INTERPRETED_REGEXP 56 #if V8_TARGET_ARCH_MIPS && !V8_INTERPRETED_REGEXP
56 #include "regexp-macro-assembler.h" 57 #include "regexp-macro-assembler.h"
57 #include "mips/regexp-macro-assembler-mips.h" 58 #include "mips/regexp-macro-assembler-mips.h"
58 #endif 59 #endif
59 60
60 namespace v8 { 61 namespace v8 {
61 namespace internal { 62 namespace internal {
62 63
63 static LazyMutex gc_initializer_mutex = LAZY_MUTEX_INITIALIZER;
64
65 64
66 Heap::Heap() 65 Heap::Heap()
67 : isolate_(NULL), 66 : isolate_(NULL),
68 // semispace_size_ should be a power of 2 and old_generation_size_ should be 67 // semispace_size_ should be a power of 2 and old_generation_size_ should be
69 // a multiple of Page::kPageSize. 68 // a multiple of Page::kPageSize.
70 #if defined(ANDROID) 69 #if defined(ANDROID)
71 #define LUMP_OF_MEMORY (128 * KB) 70 #define LUMP_OF_MEMORY (128 * KB)
72 code_range_size_(0), 71 code_range_size_(0),
73 #elif defined(V8_TARGET_ARCH_X64) 72 #elif defined(V8_TARGET_ARCH_X64)
74 #define LUMP_OF_MEMORY (2 * MB) 73 #define LUMP_OF_MEMORY (2 * MB)
(...skipping 5768 matching lines...) Expand 10 before | Expand all | Expand 10 after
5843 Object* search_target_; 5842 Object* search_target_;
5844 bool found_target_; 5843 bool found_target_;
5845 List<Object*> object_stack_; 5844 List<Object*> object_stack_;
5846 Heap* heap_; 5845 Heap* heap_;
5847 5846
5848 friend class Heap; 5847 friend class Heap;
5849 }; 5848 };
5850 5849
5851 #endif 5850 #endif
5852 5851
5852
5853 V8_DECLARE_ONCE(initialize_gc_once);
5854
5855 static void InitializeGCOnce() {
5856 InitializeScavengingVisitorsTables();
5857 NewSpaceScavenger::Initialize();
5858 MarkCompactCollector::Initialize();
5859 }
5860
5853 bool Heap::SetUp(bool create_heap_objects) { 5861 bool Heap::SetUp(bool create_heap_objects) {
5854 #ifdef DEBUG 5862 #ifdef DEBUG
5855 allocation_timeout_ = FLAG_gc_interval; 5863 allocation_timeout_ = FLAG_gc_interval;
5856 debug_utils_ = new HeapDebugUtils(this); 5864 debug_utils_ = new HeapDebugUtils(this);
5857 #endif 5865 #endif
5858 5866
5859 // Initialize heap spaces and initial maps and objects. Whenever something 5867 // Initialize heap spaces and initial maps and objects. Whenever something
5860 // goes wrong, just return false. The caller should check the results and 5868 // goes wrong, just return false. The caller should check the results and
5861 // call Heap::TearDown() to release allocated memory. 5869 // call Heap::TearDown() to release allocated memory.
5862 // 5870 //
5863 // If the heap is not yet configured (e.g. through the API), configure it. 5871 // If the heap is not yet configured (e.g. through the API), configure it.
5864 // Configuration is based on the flags new-space-size (really the semispace 5872 // Configuration is based on the flags new-space-size (really the semispace
5865 // size) and old-space-size if set or the initial values of semispace_size_ 5873 // size) and old-space-size if set or the initial values of semispace_size_
5866 // and old_generation_size_ otherwise. 5874 // and old_generation_size_ otherwise.
5867 if (!configured_) { 5875 if (!configured_) {
5868 if (!ConfigureHeapDefault()) return false; 5876 if (!ConfigureHeapDefault()) return false;
5869 } 5877 }
5870 5878
5871 gc_initializer_mutex.Pointer()->Lock(); 5879 CallOnce(&initialize_gc_once, &InitializeGCOnce);
5872 static bool initialized_gc = false;
5873 if (!initialized_gc) {
5874 initialized_gc = true;
5875 InitializeScavengingVisitorsTables();
5876 NewSpaceScavenger::Initialize();
5877 MarkCompactCollector::Initialize();
5878 }
5879 gc_initializer_mutex.Pointer()->Unlock();
5880 5880
5881 MarkMapPointersAsEncoded(false); 5881 MarkMapPointersAsEncoded(false);
5882 5882
5883 // Set up memory allocator. 5883 // Set up memory allocator.
5884 if (!isolate_->memory_allocator()->SetUp(MaxReserved(), MaxExecutableSize())) 5884 if (!isolate_->memory_allocator()->SetUp(MaxReserved(), MaxExecutableSize()))
5885 return false; 5885 return false;
5886 5886
5887 // Set up new space. 5887 // Set up new space.
5888 if (!new_space_.SetUp(reserved_semispace_size_, max_semispace_size_)) { 5888 if (!new_space_.SetUp(reserved_semispace_size_, max_semispace_size_)) {
5889 return false; 5889 return false;
(...skipping 1090 matching lines...) Expand 10 before | Expand all | Expand 10 after
6980 } else { 6980 } else {
6981 p ^= 0x1d1ed & (Page::kPageSize - 1); // I died. 6981 p ^= 0x1d1ed & (Page::kPageSize - 1); // I died.
6982 } 6982 }
6983 remembered_unmapped_pages_[remembered_unmapped_pages_index_] = 6983 remembered_unmapped_pages_[remembered_unmapped_pages_index_] =
6984 reinterpret_cast<Address>(p); 6984 reinterpret_cast<Address>(p);
6985 remembered_unmapped_pages_index_++; 6985 remembered_unmapped_pages_index_++;
6986 remembered_unmapped_pages_index_ %= kRememberedUnmappedPages; 6986 remembered_unmapped_pages_index_ %= kRememberedUnmappedPages;
6987 } 6987 }
6988 6988
6989 } } // namespace v8::internal 6989 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/frames.cc ('k') | src/lazy-instance.h » ('j') | src/v8.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698