| 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 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 326 return !i::FLAG_help; | 326 return !i::FLAG_help; |
| 327 } | 327 } |
| 328 #ifdef COMPRESS_STARTUP_DATA_BZ2 | 328 #ifdef COMPRESS_STARTUP_DATA_BZ2 |
| 329 BZip2Decompressor natives_decompressor; | 329 BZip2Decompressor natives_decompressor; |
| 330 int bz2_result = natives_decompressor.Decompress(); | 330 int bz2_result = natives_decompressor.Decompress(); |
| 331 if (bz2_result != BZ_OK) { | 331 if (bz2_result != BZ_OK) { |
| 332 fprintf(stderr, "bzip error code: %d\n", bz2_result); | 332 fprintf(stderr, "bzip error code: %d\n", bz2_result); |
| 333 exit(1); | 333 exit(1); |
| 334 } | 334 } |
| 335 #endif | 335 #endif |
| 336 i::Serializer::Enable(); | |
| 337 Isolate* isolate = Isolate::GetCurrent(); | 336 Isolate* isolate = Isolate::GetCurrent(); |
| 337 i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(isolate); |
| 338 i::Serializer::Enable(internal_isolate); |
| 338 Persistent<Context> context; | 339 Persistent<Context> context; |
| 339 { | 340 { |
| 340 HandleScope handle_scope(isolate); | 341 HandleScope handle_scope(isolate); |
| 341 context.Reset(isolate, Context::New(isolate)); | 342 context.Reset(isolate, Context::New(isolate)); |
| 342 } | 343 } |
| 343 | 344 |
| 344 if (context.IsEmpty()) { | 345 if (context.IsEmpty()) { |
| 345 fprintf(stderr, | 346 fprintf(stderr, |
| 346 "\nException thrown while compiling natives - see above.\n\n"); | 347 "\nException thrown while compiling natives - see above.\n\n"); |
| 347 exit(1); | 348 exit(1); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 384 script->Run(); | 385 script->Run(); |
| 385 if (try_catch.HasCaught()) { | 386 if (try_catch.HasCaught()) { |
| 386 fprintf(stderr, "Failure running '%s'\n", name); | 387 fprintf(stderr, "Failure running '%s'\n", name); |
| 387 DumpException(try_catch.Message()); | 388 DumpException(try_catch.Message()); |
| 388 exit(1); | 389 exit(1); |
| 389 } | 390 } |
| 390 } | 391 } |
| 391 // Make sure all builtin scripts are cached. | 392 // Make sure all builtin scripts are cached. |
| 392 { HandleScope scope(isolate); | 393 { HandleScope scope(isolate); |
| 393 for (int i = 0; i < i::Natives::GetBuiltinsCount(); i++) { | 394 for (int i = 0; i < i::Natives::GetBuiltinsCount(); i++) { |
| 394 i::Isolate::Current()->bootstrapper()->NativesSourceLookup(i); | 395 internal_isolate->bootstrapper()->NativesSourceLookup(i); |
| 395 } | 396 } |
| 396 } | 397 } |
| 397 // If we don't do this then we end up with a stray root pointing at the | 398 // If we don't do this then we end up with a stray root pointing at the |
| 398 // context even after we have disposed of the context. | 399 // context even after we have disposed of the context. |
| 399 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags, "mksnapshot"); | 400 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags, "mksnapshot"); |
| 400 i::Object* raw_context = *v8::Utils::OpenPersistent(context); | 401 i::Object* raw_context = *v8::Utils::OpenPersistent(context); |
| 401 context.Dispose(); | 402 context.Dispose(); |
| 402 CppByteSink sink(argv[1]); | 403 CppByteSink sink(argv[1]); |
| 403 // This results in a somewhat smaller snapshot, probably because it gets rid | 404 // This results in a somewhat smaller snapshot, probably because it gets rid |
| 404 // of some things that are cached between garbage collections. | 405 // of some things that are cached between garbage collections. |
| 405 i::StartupSerializer ser(&sink); | 406 i::StartupSerializer ser(internal_isolate, &sink); |
| 406 ser.SerializeStrongReferences(); | 407 ser.SerializeStrongReferences(); |
| 407 | 408 |
| 408 i::PartialSerializer partial_ser(&ser, sink.partial_sink()); | 409 i::PartialSerializer partial_ser( |
| 410 internal_isolate, &ser, sink.partial_sink()); |
| 409 partial_ser.Serialize(&raw_context); | 411 partial_ser.Serialize(&raw_context); |
| 410 | 412 |
| 411 ser.SerializeWeakReferences(); | 413 ser.SerializeWeakReferences(); |
| 412 | 414 |
| 413 #ifdef COMPRESS_STARTUP_DATA_BZ2 | 415 #ifdef COMPRESS_STARTUP_DATA_BZ2 |
| 414 BZip2Compressor compressor; | 416 BZip2Compressor compressor; |
| 415 if (!sink.Compress(&compressor)) | 417 if (!sink.Compress(&compressor)) |
| 416 return 1; | 418 return 1; |
| 417 if (!sink.partial_sink()->Compress(&compressor)) | 419 if (!sink.partial_sink()->Compress(&compressor)) |
| 418 return 1; | 420 return 1; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 433 "", | 435 "", |
| 434 ser.CurrentAllocationAddress(i::NEW_SPACE), | 436 ser.CurrentAllocationAddress(i::NEW_SPACE), |
| 435 ser.CurrentAllocationAddress(i::OLD_POINTER_SPACE), | 437 ser.CurrentAllocationAddress(i::OLD_POINTER_SPACE), |
| 436 ser.CurrentAllocationAddress(i::OLD_DATA_SPACE), | 438 ser.CurrentAllocationAddress(i::OLD_DATA_SPACE), |
| 437 ser.CurrentAllocationAddress(i::CODE_SPACE), | 439 ser.CurrentAllocationAddress(i::CODE_SPACE), |
| 438 ser.CurrentAllocationAddress(i::MAP_SPACE), | 440 ser.CurrentAllocationAddress(i::MAP_SPACE), |
| 439 ser.CurrentAllocationAddress(i::CELL_SPACE), | 441 ser.CurrentAllocationAddress(i::CELL_SPACE), |
| 440 ser.CurrentAllocationAddress(i::PROPERTY_CELL_SPACE)); | 442 ser.CurrentAllocationAddress(i::PROPERTY_CELL_SPACE)); |
| 441 return 0; | 443 return 0; |
| 442 } | 444 } |
| OLD | NEW |