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 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
325 chars[size] = '\0'; | 325 chars[size] = '\0'; |
326 for (int i = 0; i < size;) { | 326 for (int i = 0; i < size;) { |
327 int read = static_cast<int>(fread(&chars[i], 1, size - i, file)); | 327 int read = static_cast<int>(fread(&chars[i], 1, size - i, file)); |
328 if (read < 0) { | 328 if (read < 0) { |
329 fprintf(stderr, "Failed to read '%s': errno %d\n", name, errno); | 329 fprintf(stderr, "Failed to read '%s': errno %d\n", name, errno); |
330 exit(1); | 330 exit(1); |
331 } | 331 } |
332 i += read; | 332 i += read; |
333 } | 333 } |
334 fclose(file); | 334 fclose(file); |
335 Local<String> source = String::New(chars); | 335 Local<String> source = String::NewFromUtf8(isolate, chars); |
336 TryCatch try_catch; | 336 TryCatch try_catch; |
337 Local<Script> script = Script::Compile(source); | 337 Local<Script> script = Script::Compile(source); |
338 if (try_catch.HasCaught()) { | 338 if (try_catch.HasCaught()) { |
339 fprintf(stderr, "Failure compiling '%s'\n", name); | 339 fprintf(stderr, "Failure compiling '%s'\n", name); |
340 DumpException(try_catch.Message()); | 340 DumpException(try_catch.Message()); |
341 exit(1); | 341 exit(1); |
342 } | 342 } |
343 script->Run(); | 343 script->Run(); |
344 if (try_catch.HasCaught()) { | 344 if (try_catch.HasCaught()) { |
345 fprintf(stderr, "Failure running '%s'\n", name); | 345 fprintf(stderr, "Failure running '%s'\n", name); |
346 DumpException(try_catch.Message()); | 346 DumpException(try_catch.Message()); |
347 exit(1); | 347 exit(1); |
348 } | 348 } |
349 } | 349 } |
350 // Make sure all builtin scripts are cached. | 350 // Make sure all builtin scripts are cached. |
351 { HandleScope scope(isolate); | 351 { HandleScope scope(isolate); |
352 for (int i = 0; i < i::Natives::GetBuiltinsCount(); i++) { | 352 for (int i = 0; i < i::Natives::GetBuiltinsCount(); i++) { |
353 internal_isolate->bootstrapper()->NativesSourceLookup(i); | 353 internal_isolate->bootstrapper()->NativesSourceLookup(i); |
354 } | 354 } |
355 } | 355 } |
356 // If we don't do this then we end up with a stray root pointing at the | 356 // If we don't do this then we end up with a stray root pointing at the |
357 // context even after we have disposed of the context. | 357 // context even after we have disposed of the context. |
358 internal_isolate->heap()->CollectAllGarbage( | 358 internal_isolate->heap()->CollectAllGarbage( |
359 i::Heap::kNoGCFlags, "mksnapshot"); | 359 i::Heap::kNoGCFlags, "mksnapshot"); |
360 i::Object* raw_context = *v8::Utils::OpenPersistent(context); | 360 i::Object* raw_context = *v8::Utils::OpenPersistent(context); |
361 context.Dispose(); | 361 context.Reset(); |
362 CppByteSink sink(argv[1]); | 362 CppByteSink sink(argv[1]); |
363 // This results in a somewhat smaller snapshot, probably because it gets rid | 363 // This results in a somewhat smaller snapshot, probably because it gets rid |
364 // of some things that are cached between garbage collections. | 364 // of some things that are cached between garbage collections. |
365 i::StartupSerializer ser(internal_isolate, &sink); | 365 i::StartupSerializer ser(internal_isolate, &sink); |
366 ser.SerializeStrongReferences(); | 366 ser.SerializeStrongReferences(); |
367 | 367 |
368 i::PartialSerializer partial_ser( | 368 i::PartialSerializer partial_ser( |
369 internal_isolate, &ser, sink.partial_sink()); | 369 internal_isolate, &ser, sink.partial_sink()); |
370 partial_ser.Serialize(&raw_context); | 370 partial_ser.Serialize(&raw_context); |
371 | 371 |
(...skipping 22 matching lines...) Expand all Loading... |
394 "", | 394 "", |
395 ser.CurrentAllocationAddress(i::NEW_SPACE), | 395 ser.CurrentAllocationAddress(i::NEW_SPACE), |
396 ser.CurrentAllocationAddress(i::OLD_POINTER_SPACE), | 396 ser.CurrentAllocationAddress(i::OLD_POINTER_SPACE), |
397 ser.CurrentAllocationAddress(i::OLD_DATA_SPACE), | 397 ser.CurrentAllocationAddress(i::OLD_DATA_SPACE), |
398 ser.CurrentAllocationAddress(i::CODE_SPACE), | 398 ser.CurrentAllocationAddress(i::CODE_SPACE), |
399 ser.CurrentAllocationAddress(i::MAP_SPACE), | 399 ser.CurrentAllocationAddress(i::MAP_SPACE), |
400 ser.CurrentAllocationAddress(i::CELL_SPACE), | 400 ser.CurrentAllocationAddress(i::CELL_SPACE), |
401 ser.CurrentAllocationAddress(i::PROPERTY_CELL_SPACE)); | 401 ser.CurrentAllocationAddress(i::PROPERTY_CELL_SPACE)); |
402 return 0; | 402 return 0; |
403 } | 403 } |
OLD | NEW |