| OLD | NEW |
| 1 // Copyright 2007-2010 the V8 project authors. All rights reserved. | 1 // Copyright 2007-2010 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 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 v8::Context::New(isolate); | 90 v8::Context::New(isolate); |
| 91 } | 91 } |
| 92 | 92 |
| 93 Isolate* internal_isolate = reinterpret_cast<Isolate*>(isolate); | 93 Isolate* internal_isolate = reinterpret_cast<Isolate*>(isolate); |
| 94 internal_isolate->heap()->CollectAllAvailableGarbage("serialize"); | 94 internal_isolate->heap()->CollectAllAvailableGarbage("serialize"); |
| 95 SnapshotByteSink sink; | 95 SnapshotByteSink sink; |
| 96 StartupSerializer ser(internal_isolate, &sink, | 96 StartupSerializer ser(internal_isolate, &sink, |
| 97 v8::SnapshotCreator::FunctionCodeHandling::kClear); | 97 v8::SnapshotCreator::FunctionCodeHandling::kClear); |
| 98 ser.SerializeStrongReferences(); | 98 ser.SerializeStrongReferences(); |
| 99 ser.SerializeWeakReferencesAndDeferred(); | 99 ser.SerializeWeakReferencesAndDeferred(); |
| 100 SnapshotData snapshot_data(ser); | 100 SnapshotData snapshot_data(&ser); |
| 101 return WritePayload(snapshot_data.RawData()); | 101 return WritePayload(snapshot_data.RawData()); |
| 102 } | 102 } |
| 103 | 103 |
| 104 | 104 |
| 105 Vector<const uint8_t> ConstructSource(Vector<const uint8_t> head, | 105 Vector<const uint8_t> ConstructSource(Vector<const uint8_t> head, |
| 106 Vector<const uint8_t> body, | 106 Vector<const uint8_t> body, |
| 107 Vector<const uint8_t> tail, int repeats) { | 107 Vector<const uint8_t> tail, int repeats) { |
| 108 int source_length = head.length() + body.length() * repeats + tail.length(); | 108 int source_length = head.length() + body.length() * repeats + tail.length(); |
| 109 uint8_t* source = NewArray<uint8_t>(static_cast<size_t>(source_length)); | 109 uint8_t* source = NewArray<uint8_t>(static_cast<size_t>(source_length)); |
| 110 CopyChars(source, head.start(), head.length()); | 110 CopyChars(source, head.start(), head.length()); |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 288 v8::SnapshotCreator::FunctionCodeHandling::kClear); | 288 v8::SnapshotCreator::FunctionCodeHandling::kClear); |
| 289 startup_serializer.SerializeStrongReferences(); | 289 startup_serializer.SerializeStrongReferences(); |
| 290 | 290 |
| 291 SnapshotByteSink partial_sink; | 291 SnapshotByteSink partial_sink; |
| 292 PartialSerializer partial_serializer(isolate, &startup_serializer, | 292 PartialSerializer partial_serializer(isolate, &startup_serializer, |
| 293 &partial_sink); | 293 &partial_sink); |
| 294 partial_serializer.Serialize(&raw_foo); | 294 partial_serializer.Serialize(&raw_foo); |
| 295 | 295 |
| 296 startup_serializer.SerializeWeakReferencesAndDeferred(); | 296 startup_serializer.SerializeWeakReferencesAndDeferred(); |
| 297 | 297 |
| 298 SnapshotData startup_snapshot(startup_serializer); | 298 SnapshotData startup_snapshot(&startup_serializer); |
| 299 SnapshotData partial_snapshot(partial_serializer); | 299 SnapshotData partial_snapshot(&partial_serializer); |
| 300 | 300 |
| 301 *partial_blob_out = WritePayload(partial_snapshot.RawData()); | 301 *partial_blob_out = WritePayload(partial_snapshot.RawData()); |
| 302 *startup_blob_out = WritePayload(startup_snapshot.RawData()); | 302 *startup_blob_out = WritePayload(startup_snapshot.RawData()); |
| 303 } | 303 } |
| 304 v8_isolate->Exit(); | 304 v8_isolate->Exit(); |
| 305 v8_isolate->Dispose(); | 305 v8_isolate->Dispose(); |
| 306 } | 306 } |
| 307 | 307 |
| 308 UNINITIALIZED_TEST(PartialSerializerObject) { | 308 UNINITIALIZED_TEST(PartialSerializerObject) { |
| 309 DisableTurbofan(); | 309 DisableTurbofan(); |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 388 isolate, &startup_sink, | 388 isolate, &startup_sink, |
| 389 v8::SnapshotCreator::FunctionCodeHandling::kClear); | 389 v8::SnapshotCreator::FunctionCodeHandling::kClear); |
| 390 startup_serializer.SerializeStrongReferences(); | 390 startup_serializer.SerializeStrongReferences(); |
| 391 | 391 |
| 392 SnapshotByteSink partial_sink; | 392 SnapshotByteSink partial_sink; |
| 393 PartialSerializer partial_serializer(isolate, &startup_serializer, | 393 PartialSerializer partial_serializer(isolate, &startup_serializer, |
| 394 &partial_sink); | 394 &partial_sink); |
| 395 partial_serializer.Serialize(&raw_context); | 395 partial_serializer.Serialize(&raw_context); |
| 396 startup_serializer.SerializeWeakReferencesAndDeferred(); | 396 startup_serializer.SerializeWeakReferencesAndDeferred(); |
| 397 | 397 |
| 398 SnapshotData startup_snapshot(startup_serializer); | 398 SnapshotData startup_snapshot(&startup_serializer); |
| 399 SnapshotData partial_snapshot(partial_serializer); | 399 SnapshotData partial_snapshot(&partial_serializer); |
| 400 | 400 |
| 401 *partial_blob_out = WritePayload(partial_snapshot.RawData()); | 401 *partial_blob_out = WritePayload(partial_snapshot.RawData()); |
| 402 *startup_blob_out = WritePayload(startup_snapshot.RawData()); | 402 *startup_blob_out = WritePayload(startup_snapshot.RawData()); |
| 403 } | 403 } |
| 404 v8_isolate->Dispose(); | 404 v8_isolate->Dispose(); |
| 405 } | 405 } |
| 406 | 406 |
| 407 UNINITIALIZED_TEST(PartialSerializerContext) { | 407 UNINITIALIZED_TEST(PartialSerializerContext) { |
| 408 DisableTurbofan(); | 408 DisableTurbofan(); |
| 409 Vector<const byte> startup_blob; | 409 Vector<const byte> startup_blob; |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 508 isolate, &startup_sink, | 508 isolate, &startup_sink, |
| 509 v8::SnapshotCreator::FunctionCodeHandling::kClear); | 509 v8::SnapshotCreator::FunctionCodeHandling::kClear); |
| 510 startup_serializer.SerializeStrongReferences(); | 510 startup_serializer.SerializeStrongReferences(); |
| 511 | 511 |
| 512 SnapshotByteSink partial_sink; | 512 SnapshotByteSink partial_sink; |
| 513 PartialSerializer partial_serializer(isolate, &startup_serializer, | 513 PartialSerializer partial_serializer(isolate, &startup_serializer, |
| 514 &partial_sink); | 514 &partial_sink); |
| 515 partial_serializer.Serialize(&raw_context); | 515 partial_serializer.Serialize(&raw_context); |
| 516 startup_serializer.SerializeWeakReferencesAndDeferred(); | 516 startup_serializer.SerializeWeakReferencesAndDeferred(); |
| 517 | 517 |
| 518 SnapshotData startup_snapshot(startup_serializer); | 518 SnapshotData startup_snapshot(&startup_serializer); |
| 519 SnapshotData partial_snapshot(partial_serializer); | 519 SnapshotData partial_snapshot(&partial_serializer); |
| 520 | 520 |
| 521 *partial_blob_out = WritePayload(partial_snapshot.RawData()); | 521 *partial_blob_out = WritePayload(partial_snapshot.RawData()); |
| 522 *startup_blob_out = WritePayload(startup_snapshot.RawData()); | 522 *startup_blob_out = WritePayload(startup_snapshot.RawData()); |
| 523 } | 523 } |
| 524 v8_isolate->Dispose(); | 524 v8_isolate->Dispose(); |
| 525 } | 525 } |
| 526 | 526 |
| 527 UNINITIALIZED_TEST(PartialSerializerCustomContext) { | 527 UNINITIALIZED_TEST(PartialSerializerCustomContext) { |
| 528 DisableTurbofan(); | 528 DisableTurbofan(); |
| 529 Vector<const byte> startup_blob; | 529 Vector<const byte> startup_blob; |
| (...skipping 1360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1890 delete script_data; | 1890 delete script_data; |
| 1891 } | 1891 } |
| 1892 #endif // V8_TARGET_ARCH_X64 | 1892 #endif // V8_TARGET_ARCH_X64 |
| 1893 | 1893 |
| 1894 TEST(SerializationMemoryStats) { | 1894 TEST(SerializationMemoryStats) { |
| 1895 FLAG_profile_deserialization = true; | 1895 FLAG_profile_deserialization = true; |
| 1896 FLAG_always_opt = false; | 1896 FLAG_always_opt = false; |
| 1897 v8::StartupData blob = v8::V8::CreateSnapshotDataBlob(); | 1897 v8::StartupData blob = v8::V8::CreateSnapshotDataBlob(); |
| 1898 delete[] blob.data; | 1898 delete[] blob.data; |
| 1899 } | 1899 } |
| OLD | NEW |