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 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
216 ::printf("Usage: %s [flag] ... outfile\n", argv[0]); | 216 ::printf("Usage: %s [flag] ... outfile\n", argv[0]); |
217 i::FlagList::PrintHelp(); | 217 i::FlagList::PrintHelp(); |
218 return !i::FLAG_help; | 218 return !i::FLAG_help; |
219 } | 219 } |
220 i::Serializer::Enable(); | 220 i::Serializer::Enable(); |
221 Persistent<Context> context = v8::Context::New(); | 221 Persistent<Context> context = v8::Context::New(); |
222 ASSERT(!context.IsEmpty()); | 222 ASSERT(!context.IsEmpty()); |
223 // Make sure all builtin scripts are cached. | 223 // Make sure all builtin scripts are cached. |
224 { HandleScope scope; | 224 { HandleScope scope; |
225 for (int i = 0; i < i::Natives::GetBuiltinsCount(); i++) { | 225 for (int i = 0; i < i::Natives::GetBuiltinsCount(); i++) { |
226 i::Bootstrapper::NativesSourceLookup(i); | 226 i::Isolate::Current()->bootstrapper()->NativesSourceLookup(i); |
227 } | 227 } |
228 } | 228 } |
229 // If we don't do this then we end up with a stray root pointing at the | 229 // If we don't do this then we end up with a stray root pointing at the |
230 // context even after we have disposed of the context. | 230 // context even after we have disposed of the context. |
231 i::Heap::CollectAllGarbage(true); | 231 HEAP->CollectAllGarbage(true); |
232 i::Object* raw_context = *(v8::Utils::OpenHandle(*context)); | 232 i::Object* raw_context = *(v8::Utils::OpenHandle(*context)); |
233 context.Dispose(); | 233 context.Dispose(); |
234 CppByteSink sink(argv[1]); | 234 CppByteSink sink(argv[1]); |
235 // This results in a somewhat smaller snapshot, probably because it gets rid | 235 // This results in a somewhat smaller snapshot, probably because it gets rid |
236 // of some things that are cached between garbage collections. | 236 // of some things that are cached between garbage collections. |
237 i::StartupSerializer ser(&sink); | 237 i::StartupSerializer ser(&sink); |
238 ser.SerializeStrongReferences(); | 238 ser.SerializeStrongReferences(); |
239 | 239 |
240 i::PartialSerializer partial_ser(&ser, sink.partial_sink()); | 240 i::PartialSerializer partial_ser(&ser, sink.partial_sink()); |
241 partial_ser.Serialize(&raw_context); | 241 partial_ser.Serialize(&raw_context); |
242 | 242 |
243 ser.SerializeWeakReferences(); | 243 ser.SerializeWeakReferences(); |
244 | 244 |
245 sink.WritePartialSnapshot(); | 245 sink.WritePartialSnapshot(); |
246 | 246 |
247 sink.WriteSpaceUsed( | 247 sink.WriteSpaceUsed( |
248 partial_ser.CurrentAllocationAddress(i::NEW_SPACE), | 248 partial_ser.CurrentAllocationAddress(i::NEW_SPACE), |
249 partial_ser.CurrentAllocationAddress(i::OLD_POINTER_SPACE), | 249 partial_ser.CurrentAllocationAddress(i::OLD_POINTER_SPACE), |
250 partial_ser.CurrentAllocationAddress(i::OLD_DATA_SPACE), | 250 partial_ser.CurrentAllocationAddress(i::OLD_DATA_SPACE), |
251 partial_ser.CurrentAllocationAddress(i::CODE_SPACE), | 251 partial_ser.CurrentAllocationAddress(i::CODE_SPACE), |
252 partial_ser.CurrentAllocationAddress(i::MAP_SPACE), | 252 partial_ser.CurrentAllocationAddress(i::MAP_SPACE), |
253 partial_ser.CurrentAllocationAddress(i::CELL_SPACE), | 253 partial_ser.CurrentAllocationAddress(i::CELL_SPACE), |
254 partial_ser.CurrentAllocationAddress(i::LO_SPACE)); | 254 partial_ser.CurrentAllocationAddress(i::LO_SPACE)); |
255 return 0; | 255 return 0; |
256 } | 256 } |
OLD | NEW |