OLD | NEW |
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 6191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6202 | 6202 |
6203 | 6203 |
6204 V8_DECLARE_ONCE(initialize_gc_once); | 6204 V8_DECLARE_ONCE(initialize_gc_once); |
6205 | 6205 |
6206 static void InitializeGCOnce() { | 6206 static void InitializeGCOnce() { |
6207 InitializeScavengingVisitorsTables(); | 6207 InitializeScavengingVisitorsTables(); |
6208 NewSpaceScavenger::Initialize(); | 6208 NewSpaceScavenger::Initialize(); |
6209 MarkCompactCollector::Initialize(); | 6209 MarkCompactCollector::Initialize(); |
6210 } | 6210 } |
6211 | 6211 |
6212 bool Heap::SetUp(bool create_heap_objects) { | 6212 bool Heap::SetUp() { |
6213 #ifdef DEBUG | 6213 #ifdef DEBUG |
6214 allocation_timeout_ = FLAG_gc_interval; | 6214 allocation_timeout_ = FLAG_gc_interval; |
6215 #endif | 6215 #endif |
6216 | 6216 |
6217 // Initialize heap spaces and initial maps and objects. Whenever something | 6217 // Initialize heap spaces and initial maps and objects. Whenever something |
6218 // goes wrong, just return false. The caller should check the results and | 6218 // goes wrong, just return false. The caller should check the results and |
6219 // call Heap::TearDown() to release allocated memory. | 6219 // call Heap::TearDown() to release allocated memory. |
6220 // | 6220 // |
6221 // If the heap is not yet configured (e.g. through the API), configure it. | 6221 // If the heap is not yet configured (e.g. through the API), configure it. |
6222 // Configuration is based on the flags new-space-size (really the semispace | 6222 // Configuration is based on the flags new-space-size (really the semispace |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6293 ASSERT(hash_seed() == 0); | 6293 ASSERT(hash_seed() == 0); |
6294 if (FLAG_randomize_hashes) { | 6294 if (FLAG_randomize_hashes) { |
6295 if (FLAG_hash_seed == 0) { | 6295 if (FLAG_hash_seed == 0) { |
6296 set_hash_seed( | 6296 set_hash_seed( |
6297 Smi::FromInt(V8::RandomPrivate(isolate()) & 0x3fffffff)); | 6297 Smi::FromInt(V8::RandomPrivate(isolate()) & 0x3fffffff)); |
6298 } else { | 6298 } else { |
6299 set_hash_seed(Smi::FromInt(FLAG_hash_seed)); | 6299 set_hash_seed(Smi::FromInt(FLAG_hash_seed)); |
6300 } | 6300 } |
6301 } | 6301 } |
6302 | 6302 |
6303 if (create_heap_objects) { | |
6304 // Create initial maps. | |
6305 if (!CreateInitialMaps()) return false; | |
6306 if (!CreateApiObjects()) return false; | |
6307 | |
6308 // Create initial objects | |
6309 if (!CreateInitialObjects()) return false; | |
6310 | |
6311 native_contexts_list_ = undefined_value(); | |
6312 } | |
6313 | |
6314 LOG(isolate_, IntPtrTEvent("heap-capacity", Capacity())); | 6303 LOG(isolate_, IntPtrTEvent("heap-capacity", Capacity())); |
6315 LOG(isolate_, IntPtrTEvent("heap-available", Available())); | 6304 LOG(isolate_, IntPtrTEvent("heap-available", Available())); |
6316 | 6305 |
6317 store_buffer()->SetUp(); | 6306 store_buffer()->SetUp(); |
6318 | 6307 |
6319 if (FLAG_parallel_recompilation) relocation_mutex_ = OS::CreateMutex(); | 6308 if (FLAG_parallel_recompilation) relocation_mutex_ = OS::CreateMutex(); |
6320 | 6309 |
6321 return true; | 6310 return true; |
6322 } | 6311 } |
6323 | 6312 |
| 6313 bool Heap::CreateHeapObjects() { |
| 6314 // Create initial maps. |
| 6315 if (!CreateInitialMaps()) return false; |
| 6316 if (!CreateApiObjects()) return false; |
| 6317 |
| 6318 // Create initial objects |
| 6319 if (!CreateInitialObjects()) return false; |
| 6320 |
| 6321 native_contexts_list_ = undefined_value(); |
| 6322 return true; |
| 6323 } |
| 6324 |
6324 | 6325 |
6325 void Heap::SetStackLimits() { | 6326 void Heap::SetStackLimits() { |
6326 ASSERT(isolate_ != NULL); | 6327 ASSERT(isolate_ != NULL); |
6327 ASSERT(isolate_ == isolate()); | 6328 ASSERT(isolate_ == isolate()); |
6328 // On 64 bit machines, pointers are generally out of range of Smis. We write | 6329 // On 64 bit machines, pointers are generally out of range of Smis. We write |
6329 // something that looks like an out of range Smi to the GC. | 6330 // something that looks like an out of range Smi to the GC. |
6330 | 6331 |
6331 // Set up the special root array entries containing the stack limits. | 6332 // Set up the special root array entries containing the stack limits. |
6332 // These are actually addresses, but the tag makes the GC ignore it. | 6333 // These are actually addresses, but the tag makes the GC ignore it. |
6333 roots_[kStackLimitRootIndex] = | 6334 roots_[kStackLimitRootIndex] = |
(...skipping 1201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7535 static_cast<int>(object_sizes_last_time_[index])); | 7536 static_cast<int>(object_sizes_last_time_[index])); |
7536 FIXED_ARRAY_SUB_INSTANCE_TYPE_LIST(ADJUST_LAST_TIME_OBJECT_COUNT) | 7537 FIXED_ARRAY_SUB_INSTANCE_TYPE_LIST(ADJUST_LAST_TIME_OBJECT_COUNT) |
7537 #undef ADJUST_LAST_TIME_OBJECT_COUNT | 7538 #undef ADJUST_LAST_TIME_OBJECT_COUNT |
7538 | 7539 |
7539 memcpy(object_counts_last_time_, object_counts_, sizeof(object_counts_)); | 7540 memcpy(object_counts_last_time_, object_counts_, sizeof(object_counts_)); |
7540 memcpy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_)); | 7541 memcpy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_)); |
7541 ClearObjectStats(); | 7542 ClearObjectStats(); |
7542 } | 7543 } |
7543 | 7544 |
7544 } } // namespace v8::internal | 7545 } } // namespace v8::internal |
OLD | NEW |