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

Side by Side Diff: src/heap.cc

Issue 246064: Revert change r3004, issue http://codereview.chromium.org/244022, because Lin... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 11 years, 2 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/heap.h ('k') | src/spaces.h » ('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 2009 the V8 project authors. All rights reserved. 1 // Copyright 2009 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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 70
71 int Heap::amount_of_external_allocated_memory_ = 0; 71 int Heap::amount_of_external_allocated_memory_ = 0;
72 int Heap::amount_of_external_allocated_memory_at_last_global_gc_ = 0; 72 int Heap::amount_of_external_allocated_memory_at_last_global_gc_ = 0;
73 73
74 // semispace_size_ should be a power of 2 and old_generation_size_ should be 74 // semispace_size_ should be a power of 2 and old_generation_size_ should be
75 // a multiple of Page::kPageSize. 75 // a multiple of Page::kPageSize.
76 #if defined(ANDROID) 76 #if defined(ANDROID)
77 int Heap::semispace_size_ = 512*KB; 77 int Heap::semispace_size_ = 512*KB;
78 int Heap::old_generation_size_ = 128*MB; 78 int Heap::old_generation_size_ = 128*MB;
79 int Heap::initial_semispace_size_ = 128*KB; 79 int Heap::initial_semispace_size_ = 128*KB;
80 size_t Heap::code_range_size_ = 0;
81 #elif defined(V8_TARGET_ARCH_X64) 80 #elif defined(V8_TARGET_ARCH_X64)
82 int Heap::semispace_size_ = 16*MB; 81 int Heap::semispace_size_ = 16*MB;
83 int Heap::old_generation_size_ = 1*GB; 82 int Heap::old_generation_size_ = 1*GB;
84 int Heap::initial_semispace_size_ = 1*MB; 83 int Heap::initial_semispace_size_ = 1*MB;
85 size_t Heap::code_range_size_ = V8_UINT64_C(2)*GB;
86 #else 84 #else
87 int Heap::semispace_size_ = 8*MB; 85 int Heap::semispace_size_ = 8*MB;
88 int Heap::old_generation_size_ = 512*MB; 86 int Heap::old_generation_size_ = 512*MB;
89 int Heap::initial_semispace_size_ = 512*KB; 87 int Heap::initial_semispace_size_ = 512*KB;
90 size_t Heap::code_range_size_ = 0;
91 #endif 88 #endif
92 89
93 GCCallback Heap::global_gc_prologue_callback_ = NULL; 90 GCCallback Heap::global_gc_prologue_callback_ = NULL;
94 GCCallback Heap::global_gc_epilogue_callback_ = NULL; 91 GCCallback Heap::global_gc_epilogue_callback_ = NULL;
95 92
96 // Variables set based on semispace_size_ and old_generation_size_ in 93 // Variables set based on semispace_size_ and old_generation_size_ in
97 // ConfigureHeap. 94 // ConfigureHeap.
98 int Heap::young_generation_size_ = 0; // Will be 2 * semispace_size_. 95 int Heap::young_generation_size_ = 0; // Will be 2 * semispace_size_.
99 int Heap::survived_since_last_expansion_ = 0; 96 int Heap::survived_since_last_expansion_ = 0;
100 int Heap::external_allocation_limit_ = 0; 97 int Heap::external_allocation_limit_ = 0;
(...skipping 1818 matching lines...) Expand 10 before | Expand all | Expand 10 after
1919 result = lo_space_->AllocateRawCode(obj_size); 1916 result = lo_space_->AllocateRawCode(obj_size);
1920 } else { 1917 } else {
1921 result = code_space_->AllocateRaw(obj_size); 1918 result = code_space_->AllocateRaw(obj_size);
1922 } 1919 }
1923 1920
1924 if (result->IsFailure()) return result; 1921 if (result->IsFailure()) return result;
1925 1922
1926 // Initialize the object 1923 // Initialize the object
1927 HeapObject::cast(result)->set_map(code_map()); 1924 HeapObject::cast(result)->set_map(code_map());
1928 Code* code = Code::cast(result); 1925 Code* code = Code::cast(result);
1929 ASSERT(!CodeRange::exists() || CodeRange::contains(code->address()));
1930 code->set_instruction_size(desc.instr_size); 1926 code->set_instruction_size(desc.instr_size);
1931 code->set_relocation_size(desc.reloc_size); 1927 code->set_relocation_size(desc.reloc_size);
1932 code->set_sinfo_size(sinfo_size); 1928 code->set_sinfo_size(sinfo_size);
1933 code->set_flags(flags); 1929 code->set_flags(flags);
1934 // Allow self references to created code object by patching the handle to 1930 // Allow self references to created code object by patching the handle to
1935 // point to the newly allocated Code object. 1931 // point to the newly allocated Code object.
1936 if (!self_reference.is_null()) { 1932 if (!self_reference.is_null()) {
1937 *(self_reference.location()) = code; 1933 *(self_reference.location()) = code;
1938 } 1934 }
1939 // Migrate generated code. 1935 // Migrate generated code.
(...skipping 24 matching lines...) Expand all
1964 if (result->IsFailure()) return result; 1960 if (result->IsFailure()) return result;
1965 1961
1966 // Copy code object. 1962 // Copy code object.
1967 Address old_addr = code->address(); 1963 Address old_addr = code->address();
1968 Address new_addr = reinterpret_cast<HeapObject*>(result)->address(); 1964 Address new_addr = reinterpret_cast<HeapObject*>(result)->address();
1969 CopyBlock(reinterpret_cast<Object**>(new_addr), 1965 CopyBlock(reinterpret_cast<Object**>(new_addr),
1970 reinterpret_cast<Object**>(old_addr), 1966 reinterpret_cast<Object**>(old_addr),
1971 obj_size); 1967 obj_size);
1972 // Relocate the copy. 1968 // Relocate the copy.
1973 Code* new_code = Code::cast(result); 1969 Code* new_code = Code::cast(result);
1974 ASSERT(!CodeRange::exists() || CodeRange::contains(code->address()));
1975 new_code->Relocate(new_addr - old_addr); 1970 new_code->Relocate(new_addr - old_addr);
1976 return new_code; 1971 return new_code;
1977 } 1972 }
1978 1973
1979 1974
1980 Object* Heap::Allocate(Map* map, AllocationSpace space) { 1975 Object* Heap::Allocate(Map* map, AllocationSpace space) {
1981 ASSERT(gc_state_ == NOT_IN_GC); 1976 ASSERT(gc_state_ == NOT_IN_GC);
1982 ASSERT(map->instance_type() != MAP_TYPE); 1977 ASSERT(map->instance_type() != MAP_TYPE);
1983 Object* result = AllocateRaw(map->instance_size(), 1978 Object* result = AllocateRaw(map->instance_size(),
1984 space, 1979 space,
(...skipping 1227 matching lines...) Expand 10 before | Expand all | Expand 10 after
3212 if (!old_pointer_space_->Setup(NULL, 0)) return false; 3207 if (!old_pointer_space_->Setup(NULL, 0)) return false;
3213 3208
3214 // Initialize old data space. 3209 // Initialize old data space.
3215 old_data_space_ = 3210 old_data_space_ =
3216 new OldSpace(old_generation_size_, OLD_DATA_SPACE, NOT_EXECUTABLE); 3211 new OldSpace(old_generation_size_, OLD_DATA_SPACE, NOT_EXECUTABLE);
3217 if (old_data_space_ == NULL) return false; 3212 if (old_data_space_ == NULL) return false;
3218 if (!old_data_space_->Setup(NULL, 0)) return false; 3213 if (!old_data_space_->Setup(NULL, 0)) return false;
3219 3214
3220 // Initialize the code space, set its maximum capacity to the old 3215 // Initialize the code space, set its maximum capacity to the old
3221 // generation size. It needs executable memory. 3216 // generation size. It needs executable memory.
3222 // On 64-bit platform(s), we put all code objects in a 2 GB range of
3223 // virtual address space, so that they can call each other with near calls.
3224 if (code_range_size_ > 0) {
3225 if (!CodeRange::Setup(code_range_size_)) {
3226 return false;
3227 }
3228 }
3229
3230 code_space_ = 3217 code_space_ =
3231 new OldSpace(old_generation_size_, CODE_SPACE, EXECUTABLE); 3218 new OldSpace(old_generation_size_, CODE_SPACE, EXECUTABLE);
3232 if (code_space_ == NULL) return false; 3219 if (code_space_ == NULL) return false;
3233 if (!code_space_->Setup(NULL, 0)) return false; 3220 if (!code_space_->Setup(NULL, 0)) return false;
3234 3221
3235 // Initialize map space. 3222 // Initialize map space.
3236 map_space_ = new MapSpace(kMaxMapSpaceSize, MAP_SPACE); 3223 map_space_ = new MapSpace(kMaxMapSpaceSize, MAP_SPACE);
3237 if (map_space_ == NULL) return false; 3224 if (map_space_ == NULL) return false;
3238 if (!map_space_->Setup(NULL, 0)) return false; 3225 if (!map_space_->Setup(NULL, 0)) return false;
3239 3226
(...skipping 600 matching lines...) Expand 10 before | Expand all | Expand 10 after
3840 for (int i = 0; i < kNumberOfCaches; i++) { 3827 for (int i = 0; i < kNumberOfCaches; i++) {
3841 if (caches_[i] != NULL) { 3828 if (caches_[i] != NULL) {
3842 delete caches_[i]; 3829 delete caches_[i];
3843 caches_[i] = NULL; 3830 caches_[i] = NULL;
3844 } 3831 }
3845 } 3832 }
3846 } 3833 }
3847 3834
3848 3835
3849 } } // namespace v8::internal 3836 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/heap.h ('k') | src/spaces.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698