OLD | NEW |
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 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 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
305 Persistent<Context> context = v8::Context::New(); | 305 Persistent<Context> context = v8::Context::New(); |
306 ASSERT(!context.IsEmpty()); | 306 ASSERT(!context.IsEmpty()); |
307 // Make sure all builtin scripts are cached. | 307 // Make sure all builtin scripts are cached. |
308 { HandleScope scope; | 308 { HandleScope scope; |
309 for (int i = 0; i < i::Natives::GetBuiltinsCount(); i++) { | 309 for (int i = 0; i < i::Natives::GetBuiltinsCount(); i++) { |
310 i::Isolate::Current()->bootstrapper()->NativesSourceLookup(i); | 310 i::Isolate::Current()->bootstrapper()->NativesSourceLookup(i); |
311 } | 311 } |
312 } | 312 } |
313 // If we don't do this then we end up with a stray root pointing at the | 313 // If we don't do this then we end up with a stray root pointing at the |
314 // context even after we have disposed of the context. | 314 // context even after we have disposed of the context. |
315 HEAP->CollectAllGarbage(true); | 315 // TODO(gc): request full compaction? |
| 316 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); |
316 i::Object* raw_context = *(v8::Utils::OpenHandle(*context)); | 317 i::Object* raw_context = *(v8::Utils::OpenHandle(*context)); |
317 context.Dispose(); | 318 context.Dispose(); |
318 CppByteSink sink(argv[1]); | 319 CppByteSink sink(argv[1]); |
319 // This results in a somewhat smaller snapshot, probably because it gets rid | 320 // This results in a somewhat smaller snapshot, probably because it gets rid |
320 // of some things that are cached between garbage collections. | 321 // of some things that are cached between garbage collections. |
321 i::StartupSerializer ser(&sink); | 322 i::StartupSerializer ser(&sink); |
322 ser.SerializeStrongReferences(); | 323 ser.SerializeStrongReferences(); |
323 | 324 |
324 i::PartialSerializer partial_ser(&ser, sink.partial_sink()); | 325 i::PartialSerializer partial_ser(&ser, sink.partial_sink()); |
325 partial_ser.Serialize(&raw_context); | 326 partial_ser.Serialize(&raw_context); |
(...skipping 13 matching lines...) Expand all Loading... |
339 sink.WriteSpaceUsed( | 340 sink.WriteSpaceUsed( |
340 partial_ser.CurrentAllocationAddress(i::NEW_SPACE), | 341 partial_ser.CurrentAllocationAddress(i::NEW_SPACE), |
341 partial_ser.CurrentAllocationAddress(i::OLD_POINTER_SPACE), | 342 partial_ser.CurrentAllocationAddress(i::OLD_POINTER_SPACE), |
342 partial_ser.CurrentAllocationAddress(i::OLD_DATA_SPACE), | 343 partial_ser.CurrentAllocationAddress(i::OLD_DATA_SPACE), |
343 partial_ser.CurrentAllocationAddress(i::CODE_SPACE), | 344 partial_ser.CurrentAllocationAddress(i::CODE_SPACE), |
344 partial_ser.CurrentAllocationAddress(i::MAP_SPACE), | 345 partial_ser.CurrentAllocationAddress(i::MAP_SPACE), |
345 partial_ser.CurrentAllocationAddress(i::CELL_SPACE), | 346 partial_ser.CurrentAllocationAddress(i::CELL_SPACE), |
346 partial_ser.CurrentAllocationAddress(i::LO_SPACE)); | 347 partial_ser.CurrentAllocationAddress(i::LO_SPACE)); |
347 return 0; | 348 return 0; |
348 } | 349 } |
OLD | NEW |