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 // TODO(gc): request full compaction? | |
316 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); | 315 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); |
317 i::Object* raw_context = *(v8::Utils::OpenHandle(*context)); | 316 i::Object* raw_context = *(v8::Utils::OpenHandle(*context)); |
318 context.Dispose(); | 317 context.Dispose(); |
319 CppByteSink sink(argv[1]); | 318 CppByteSink sink(argv[1]); |
320 // This results in a somewhat smaller snapshot, probably because it gets rid | 319 // This results in a somewhat smaller snapshot, probably because it gets rid |
321 // of some things that are cached between garbage collections. | 320 // of some things that are cached between garbage collections. |
322 i::StartupSerializer ser(&sink); | 321 i::StartupSerializer ser(&sink); |
323 ser.SerializeStrongReferences(); | 322 ser.SerializeStrongReferences(); |
324 | 323 |
325 i::PartialSerializer partial_ser(&ser, sink.partial_sink()); | 324 i::PartialSerializer partial_ser(&ser, sink.partial_sink()); |
(...skipping 14 matching lines...) Expand all Loading... |
340 sink.WriteSpaceUsed( | 339 sink.WriteSpaceUsed( |
341 partial_ser.CurrentAllocationAddress(i::NEW_SPACE), | 340 partial_ser.CurrentAllocationAddress(i::NEW_SPACE), |
342 partial_ser.CurrentAllocationAddress(i::OLD_POINTER_SPACE), | 341 partial_ser.CurrentAllocationAddress(i::OLD_POINTER_SPACE), |
343 partial_ser.CurrentAllocationAddress(i::OLD_DATA_SPACE), | 342 partial_ser.CurrentAllocationAddress(i::OLD_DATA_SPACE), |
344 partial_ser.CurrentAllocationAddress(i::CODE_SPACE), | 343 partial_ser.CurrentAllocationAddress(i::CODE_SPACE), |
345 partial_ser.CurrentAllocationAddress(i::MAP_SPACE), | 344 partial_ser.CurrentAllocationAddress(i::MAP_SPACE), |
346 partial_ser.CurrentAllocationAddress(i::CELL_SPACE), | 345 partial_ser.CurrentAllocationAddress(i::CELL_SPACE), |
347 partial_ser.CurrentAllocationAddress(i::LO_SPACE)); | 346 partial_ser.CurrentAllocationAddress(i::LO_SPACE)); |
348 return 0; | 347 return 0; |
349 } | 348 } |
OLD | NEW |