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

Side by Side Diff: src/heap.cc

Issue 243087: Recommit coderanges putting code objects within a 2 GB range, reserving only ... (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;
80 #elif defined(V8_TARGET_ARCH_X64) 81 #elif defined(V8_TARGET_ARCH_X64)
81 int Heap::semispace_size_ = 16*MB; 82 int Heap::semispace_size_ = 16*MB;
82 int Heap::old_generation_size_ = 1*GB; 83 int Heap::old_generation_size_ = 1*GB;
83 int Heap::initial_semispace_size_ = 1*MB; 84 int Heap::initial_semispace_size_ = 1*MB;
85 size_t Heap::code_range_size_ = 256*MB;
84 #else 86 #else
85 int Heap::semispace_size_ = 8*MB; 87 int Heap::semispace_size_ = 8*MB;
86 int Heap::old_generation_size_ = 512*MB; 88 int Heap::old_generation_size_ = 512*MB;
87 int Heap::initial_semispace_size_ = 512*KB; 89 int Heap::initial_semispace_size_ = 512*KB;
90 size_t Heap::code_range_size_ = 0;
88 #endif 91 #endif
89 92
90 GCCallback Heap::global_gc_prologue_callback_ = NULL; 93 GCCallback Heap::global_gc_prologue_callback_ = NULL;
91 GCCallback Heap::global_gc_epilogue_callback_ = NULL; 94 GCCallback Heap::global_gc_epilogue_callback_ = NULL;
92 95
93 // Variables set based on semispace_size_ and old_generation_size_ in 96 // Variables set based on semispace_size_ and old_generation_size_ in
94 // ConfigureHeap. 97 // ConfigureHeap.
95 int Heap::young_generation_size_ = 0; // Will be 2 * semispace_size_. 98 int Heap::young_generation_size_ = 0; // Will be 2 * semispace_size_.
96 int Heap::survived_since_last_expansion_ = 0; 99 int Heap::survived_since_last_expansion_ = 0;
97 int Heap::external_allocation_limit_ = 0; 100 int Heap::external_allocation_limit_ = 0;
(...skipping 1854 matching lines...) Expand 10 before | Expand all | Expand 10 after
1952 result = lo_space_->AllocateRawCode(obj_size); 1955 result = lo_space_->AllocateRawCode(obj_size);
1953 } else { 1956 } else {
1954 result = code_space_->AllocateRaw(obj_size); 1957 result = code_space_->AllocateRaw(obj_size);
1955 } 1958 }
1956 1959
1957 if (result->IsFailure()) return result; 1960 if (result->IsFailure()) return result;
1958 1961
1959 // Initialize the object 1962 // Initialize the object
1960 HeapObject::cast(result)->set_map(code_map()); 1963 HeapObject::cast(result)->set_map(code_map());
1961 Code* code = Code::cast(result); 1964 Code* code = Code::cast(result);
1965 ASSERT(!CodeRange::exists() || CodeRange::contains(code->address()));
1962 code->set_instruction_size(desc.instr_size); 1966 code->set_instruction_size(desc.instr_size);
1963 code->set_relocation_size(desc.reloc_size); 1967 code->set_relocation_size(desc.reloc_size);
1964 code->set_sinfo_size(sinfo_size); 1968 code->set_sinfo_size(sinfo_size);
1965 code->set_flags(flags); 1969 code->set_flags(flags);
1966 // Allow self references to created code object by patching the handle to 1970 // Allow self references to created code object by patching the handle to
1967 // point to the newly allocated Code object. 1971 // point to the newly allocated Code object.
1968 if (!self_reference.is_null()) { 1972 if (!self_reference.is_null()) {
1969 *(self_reference.location()) = code; 1973 *(self_reference.location()) = code;
1970 } 1974 }
1971 // Migrate generated code. 1975 // Migrate generated code.
(...skipping 24 matching lines...) Expand all
1996 if (result->IsFailure()) return result; 2000 if (result->IsFailure()) return result;
1997 2001
1998 // Copy code object. 2002 // Copy code object.
1999 Address old_addr = code->address(); 2003 Address old_addr = code->address();
2000 Address new_addr = reinterpret_cast<HeapObject*>(result)->address(); 2004 Address new_addr = reinterpret_cast<HeapObject*>(result)->address();
2001 CopyBlock(reinterpret_cast<Object**>(new_addr), 2005 CopyBlock(reinterpret_cast<Object**>(new_addr),
2002 reinterpret_cast<Object**>(old_addr), 2006 reinterpret_cast<Object**>(old_addr),
2003 obj_size); 2007 obj_size);
2004 // Relocate the copy. 2008 // Relocate the copy.
2005 Code* new_code = Code::cast(result); 2009 Code* new_code = Code::cast(result);
2010 ASSERT(!CodeRange::exists() || CodeRange::contains(code->address()));
2006 new_code->Relocate(new_addr - old_addr); 2011 new_code->Relocate(new_addr - old_addr);
2007 return new_code; 2012 return new_code;
2008 } 2013 }
2009 2014
2010 2015
2011 Object* Heap::Allocate(Map* map, AllocationSpace space) { 2016 Object* Heap::Allocate(Map* map, AllocationSpace space) {
2012 ASSERT(gc_state_ == NOT_IN_GC); 2017 ASSERT(gc_state_ == NOT_IN_GC);
2013 ASSERT(map->instance_type() != MAP_TYPE); 2018 ASSERT(map->instance_type() != MAP_TYPE);
2014 Object* result = AllocateRaw(map->instance_size(), 2019 Object* result = AllocateRaw(map->instance_size(),
2015 space, 2020 space,
(...skipping 1238 matching lines...) Expand 10 before | Expand all | Expand 10 after
3254 if (!old_pointer_space_->Setup(NULL, 0)) return false; 3259 if (!old_pointer_space_->Setup(NULL, 0)) return false;
3255 3260
3256 // Initialize old data space. 3261 // Initialize old data space.
3257 old_data_space_ = 3262 old_data_space_ =
3258 new OldSpace(old_generation_size_, OLD_DATA_SPACE, NOT_EXECUTABLE); 3263 new OldSpace(old_generation_size_, OLD_DATA_SPACE, NOT_EXECUTABLE);
3259 if (old_data_space_ == NULL) return false; 3264 if (old_data_space_ == NULL) return false;
3260 if (!old_data_space_->Setup(NULL, 0)) return false; 3265 if (!old_data_space_->Setup(NULL, 0)) return false;
3261 3266
3262 // Initialize the code space, set its maximum capacity to the old 3267 // Initialize the code space, set its maximum capacity to the old
3263 // generation size. It needs executable memory. 3268 // generation size. It needs executable memory.
3269 // On 64-bit platform(s), we put all code objects in a 2 GB range of
3270 // virtual address space, so that they can call each other with near calls.
3271 if (code_range_size_ > 0) {
3272 if (!CodeRange::Setup(code_range_size_)) {
3273 return false;
3274 }
3275 }
3276
3264 code_space_ = 3277 code_space_ =
3265 new OldSpace(old_generation_size_, CODE_SPACE, EXECUTABLE); 3278 new OldSpace(old_generation_size_, CODE_SPACE, EXECUTABLE);
3266 if (code_space_ == NULL) return false; 3279 if (code_space_ == NULL) return false;
3267 if (!code_space_->Setup(NULL, 0)) return false; 3280 if (!code_space_->Setup(NULL, 0)) return false;
3268 3281
3269 // Initialize map space. 3282 // Initialize map space.
3270 map_space_ = new MapSpace(kMaxMapSpaceSize, MAP_SPACE); 3283 map_space_ = new MapSpace(kMaxMapSpaceSize, MAP_SPACE);
3271 if (map_space_ == NULL) return false; 3284 if (map_space_ == NULL) return false;
3272 if (!map_space_->Setup(NULL, 0)) return false; 3285 if (!map_space_->Setup(NULL, 0)) return false;
3273 3286
(...skipping 600 matching lines...) Expand 10 before | Expand all | Expand 10 after
3874 for (int i = 0; i < kNumberOfCaches; i++) { 3887 for (int i = 0; i < kNumberOfCaches; i++) {
3875 if (caches_[i] != NULL) { 3888 if (caches_[i] != NULL) {
3876 delete caches_[i]; 3889 delete caches_[i];
3877 caches_[i] = NULL; 3890 caches_[i] = NULL;
3878 } 3891 }
3879 } 3892 }
3880 } 3893 }
3881 3894
3882 3895
3883 } } // namespace v8::internal 3896 } } // 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