OLD | NEW |
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 Loading... |
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_ = V8_UINT64_C(2)*GB; |
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 1818 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1916 result = lo_space_->AllocateRawCode(obj_size); | 1919 result = lo_space_->AllocateRawCode(obj_size); |
1917 } else { | 1920 } else { |
1918 result = code_space_->AllocateRaw(obj_size); | 1921 result = code_space_->AllocateRaw(obj_size); |
1919 } | 1922 } |
1920 | 1923 |
1921 if (result->IsFailure()) return result; | 1924 if (result->IsFailure()) return result; |
1922 | 1925 |
1923 // Initialize the object | 1926 // Initialize the object |
1924 HeapObject::cast(result)->set_map(code_map()); | 1927 HeapObject::cast(result)->set_map(code_map()); |
1925 Code* code = Code::cast(result); | 1928 Code* code = Code::cast(result); |
| 1929 ASSERT(!CodeRange::exists() || CodeRange::contains(code->address())); |
1926 code->set_instruction_size(desc.instr_size); | 1930 code->set_instruction_size(desc.instr_size); |
1927 code->set_relocation_size(desc.reloc_size); | 1931 code->set_relocation_size(desc.reloc_size); |
1928 code->set_sinfo_size(sinfo_size); | 1932 code->set_sinfo_size(sinfo_size); |
1929 code->set_flags(flags); | 1933 code->set_flags(flags); |
1930 // Allow self references to created code object by patching the handle to | 1934 // Allow self references to created code object by patching the handle to |
1931 // point to the newly allocated Code object. | 1935 // point to the newly allocated Code object. |
1932 if (!self_reference.is_null()) { | 1936 if (!self_reference.is_null()) { |
1933 *(self_reference.location()) = code; | 1937 *(self_reference.location()) = code; |
1934 } | 1938 } |
1935 // Migrate generated code. | 1939 // Migrate generated code. |
(...skipping 24 matching lines...) Expand all Loading... |
1960 if (result->IsFailure()) return result; | 1964 if (result->IsFailure()) return result; |
1961 | 1965 |
1962 // Copy code object. | 1966 // Copy code object. |
1963 Address old_addr = code->address(); | 1967 Address old_addr = code->address(); |
1964 Address new_addr = reinterpret_cast<HeapObject*>(result)->address(); | 1968 Address new_addr = reinterpret_cast<HeapObject*>(result)->address(); |
1965 CopyBlock(reinterpret_cast<Object**>(new_addr), | 1969 CopyBlock(reinterpret_cast<Object**>(new_addr), |
1966 reinterpret_cast<Object**>(old_addr), | 1970 reinterpret_cast<Object**>(old_addr), |
1967 obj_size); | 1971 obj_size); |
1968 // Relocate the copy. | 1972 // Relocate the copy. |
1969 Code* new_code = Code::cast(result); | 1973 Code* new_code = Code::cast(result); |
| 1974 ASSERT(!CodeRange::exists() || CodeRange::contains(code->address())); |
1970 new_code->Relocate(new_addr - old_addr); | 1975 new_code->Relocate(new_addr - old_addr); |
1971 return new_code; | 1976 return new_code; |
1972 } | 1977 } |
1973 | 1978 |
1974 | 1979 |
1975 Object* Heap::Allocate(Map* map, AllocationSpace space) { | 1980 Object* Heap::Allocate(Map* map, AllocationSpace space) { |
1976 ASSERT(gc_state_ == NOT_IN_GC); | 1981 ASSERT(gc_state_ == NOT_IN_GC); |
1977 ASSERT(map->instance_type() != MAP_TYPE); | 1982 ASSERT(map->instance_type() != MAP_TYPE); |
1978 Object* result = AllocateRaw(map->instance_size(), | 1983 Object* result = AllocateRaw(map->instance_size(), |
1979 space, | 1984 space, |
(...skipping 1227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3207 if (!old_pointer_space_->Setup(NULL, 0)) return false; | 3212 if (!old_pointer_space_->Setup(NULL, 0)) return false; |
3208 | 3213 |
3209 // Initialize old data space. | 3214 // Initialize old data space. |
3210 old_data_space_ = | 3215 old_data_space_ = |
3211 new OldSpace(old_generation_size_, OLD_DATA_SPACE, NOT_EXECUTABLE); | 3216 new OldSpace(old_generation_size_, OLD_DATA_SPACE, NOT_EXECUTABLE); |
3212 if (old_data_space_ == NULL) return false; | 3217 if (old_data_space_ == NULL) return false; |
3213 if (!old_data_space_->Setup(NULL, 0)) return false; | 3218 if (!old_data_space_->Setup(NULL, 0)) return false; |
3214 | 3219 |
3215 // Initialize the code space, set its maximum capacity to the old | 3220 // Initialize the code space, set its maximum capacity to the old |
3216 // generation size. It needs executable memory. | 3221 // 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 |
3217 code_space_ = | 3230 code_space_ = |
3218 new OldSpace(old_generation_size_, CODE_SPACE, EXECUTABLE); | 3231 new OldSpace(old_generation_size_, CODE_SPACE, EXECUTABLE); |
3219 if (code_space_ == NULL) return false; | 3232 if (code_space_ == NULL) return false; |
3220 if (!code_space_->Setup(NULL, 0)) return false; | 3233 if (!code_space_->Setup(NULL, 0)) return false; |
3221 | 3234 |
3222 // Initialize map space. | 3235 // Initialize map space. |
3223 map_space_ = new MapSpace(kMaxMapSpaceSize, MAP_SPACE); | 3236 map_space_ = new MapSpace(kMaxMapSpaceSize, MAP_SPACE); |
3224 if (map_space_ == NULL) return false; | 3237 if (map_space_ == NULL) return false; |
3225 if (!map_space_->Setup(NULL, 0)) return false; | 3238 if (!map_space_->Setup(NULL, 0)) return false; |
3226 | 3239 |
(...skipping 600 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3827 for (int i = 0; i < kNumberOfCaches; i++) { | 3840 for (int i = 0; i < kNumberOfCaches; i++) { |
3828 if (caches_[i] != NULL) { | 3841 if (caches_[i] != NULL) { |
3829 delete caches_[i]; | 3842 delete caches_[i]; |
3830 caches_[i] = NULL; | 3843 caches_[i] = NULL; |
3831 } | 3844 } |
3832 } | 3845 } |
3833 } | 3846 } |
3834 | 3847 |
3835 | 3848 |
3836 } } // namespace v8::internal | 3849 } } // namespace v8::internal |
OLD | NEW |