| 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 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 // will clear the pending fixups array, which would otherwise contain GC roots | 85 // will clear the pending fixups array, which would otherwise contain GC roots |
| 86 // that would confuse the serialization/deserialization process. | 86 // that would confuse the serialization/deserialization process. |
| 87 v8::Isolate::Scope isolate_scope(isolate); | 87 v8::Isolate::Scope isolate_scope(isolate); |
| 88 { | 88 { |
| 89 v8::HandleScope scope(isolate); | 89 v8::HandleScope scope(isolate); |
| 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 StartupSerializer ser(internal_isolate, |
| 96 StartupSerializer ser(internal_isolate, &sink, | |
| 97 v8::SnapshotCreator::FunctionCodeHandling::kClear); | 96 v8::SnapshotCreator::FunctionCodeHandling::kClear); |
| 98 ser.SerializeStrongReferences(); | 97 ser.SerializeStrongReferences(); |
| 99 ser.SerializeWeakReferencesAndDeferred(); | 98 ser.SerializeWeakReferencesAndDeferred(); |
| 100 SnapshotData snapshot_data(&ser); | 99 SnapshotData snapshot_data(&ser); |
| 101 return WritePayload(snapshot_data.RawData()); | 100 return WritePayload(snapshot_data.RawData()); |
| 102 } | 101 } |
| 103 | 102 |
| 104 | 103 |
| 105 Vector<const uint8_t> ConstructSource(Vector<const uint8_t> head, | 104 Vector<const uint8_t> ConstructSource(Vector<const uint8_t> head, |
| 106 Vector<const uint8_t> body, | 105 Vector<const uint8_t> body, |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 275 CHECK(!foo.IsEmpty()); | 274 CHECK(!foo.IsEmpty()); |
| 276 raw_foo = *(v8::Utils::OpenHandle(*foo)); | 275 raw_foo = *(v8::Utils::OpenHandle(*foo)); |
| 277 } | 276 } |
| 278 | 277 |
| 279 { | 278 { |
| 280 v8::HandleScope handle_scope(v8_isolate); | 279 v8::HandleScope handle_scope(v8_isolate); |
| 281 v8::Local<v8::Context>::New(v8_isolate, env)->Exit(); | 280 v8::Local<v8::Context>::New(v8_isolate, env)->Exit(); |
| 282 } | 281 } |
| 283 env.Reset(); | 282 env.Reset(); |
| 284 | 283 |
| 285 SnapshotByteSink startup_sink; | |
| 286 StartupSerializer startup_serializer( | 284 StartupSerializer startup_serializer( |
| 287 isolate, &startup_sink, | 285 isolate, v8::SnapshotCreator::FunctionCodeHandling::kClear); |
| 288 v8::SnapshotCreator::FunctionCodeHandling::kClear); | |
| 289 startup_serializer.SerializeStrongReferences(); | 286 startup_serializer.SerializeStrongReferences(); |
| 290 | 287 |
| 291 SnapshotByteSink partial_sink; | 288 PartialSerializer partial_serializer(isolate, &startup_serializer); |
| 292 PartialSerializer partial_serializer(isolate, &startup_serializer, | |
| 293 &partial_sink); | |
| 294 partial_serializer.Serialize(&raw_foo); | 289 partial_serializer.Serialize(&raw_foo); |
| 295 | 290 |
| 296 startup_serializer.SerializeWeakReferencesAndDeferred(); | 291 startup_serializer.SerializeWeakReferencesAndDeferred(); |
| 297 | 292 |
| 298 SnapshotData startup_snapshot(&startup_serializer); | 293 SnapshotData startup_snapshot(&startup_serializer); |
| 299 SnapshotData partial_snapshot(&partial_serializer); | 294 SnapshotData partial_snapshot(&partial_serializer); |
| 300 | 295 |
| 301 *partial_blob_out = WritePayload(partial_snapshot.RawData()); | 296 *partial_blob_out = WritePayload(partial_snapshot.RawData()); |
| 302 *startup_blob_out = WritePayload(startup_snapshot.RawData()); | 297 *startup_blob_out = WritePayload(startup_snapshot.RawData()); |
| 303 } | 298 } |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 378 v8::HandleScope handle_scope(v8_isolate); | 373 v8::HandleScope handle_scope(v8_isolate); |
| 379 v8::Local<v8::Context>::New(v8_isolate, env)->Exit(); | 374 v8::Local<v8::Context>::New(v8_isolate, env)->Exit(); |
| 380 } | 375 } |
| 381 | 376 |
| 382 i::Object* raw_context = *v8::Utils::OpenPersistent(env); | 377 i::Object* raw_context = *v8::Utils::OpenPersistent(env); |
| 383 | 378 |
| 384 env.Reset(); | 379 env.Reset(); |
| 385 | 380 |
| 386 SnapshotByteSink startup_sink; | 381 SnapshotByteSink startup_sink; |
| 387 StartupSerializer startup_serializer( | 382 StartupSerializer startup_serializer( |
| 388 isolate, &startup_sink, | 383 isolate, v8::SnapshotCreator::FunctionCodeHandling::kClear); |
| 389 v8::SnapshotCreator::FunctionCodeHandling::kClear); | |
| 390 startup_serializer.SerializeStrongReferences(); | 384 startup_serializer.SerializeStrongReferences(); |
| 391 | 385 |
| 392 SnapshotByteSink partial_sink; | 386 SnapshotByteSink partial_sink; |
| 393 PartialSerializer partial_serializer(isolate, &startup_serializer, | 387 PartialSerializer partial_serializer(isolate, &startup_serializer); |
| 394 &partial_sink); | |
| 395 partial_serializer.Serialize(&raw_context); | 388 partial_serializer.Serialize(&raw_context); |
| 396 startup_serializer.SerializeWeakReferencesAndDeferred(); | 389 startup_serializer.SerializeWeakReferencesAndDeferred(); |
| 397 | 390 |
| 398 SnapshotData startup_snapshot(&startup_serializer); | 391 SnapshotData startup_snapshot(&startup_serializer); |
| 399 SnapshotData partial_snapshot(&partial_serializer); | 392 SnapshotData partial_snapshot(&partial_serializer); |
| 400 | 393 |
| 401 *partial_blob_out = WritePayload(partial_snapshot.RawData()); | 394 *partial_blob_out = WritePayload(partial_snapshot.RawData()); |
| 402 *startup_blob_out = WritePayload(startup_snapshot.RawData()); | 395 *startup_blob_out = WritePayload(startup_snapshot.RawData()); |
| 403 } | 396 } |
| 404 v8_isolate->Dispose(); | 397 v8_isolate->Dispose(); |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 498 v8::HandleScope handle_scope(v8_isolate); | 491 v8::HandleScope handle_scope(v8_isolate); |
| 499 v8::Local<v8::Context>::New(v8_isolate, env)->Exit(); | 492 v8::Local<v8::Context>::New(v8_isolate, env)->Exit(); |
| 500 } | 493 } |
| 501 | 494 |
| 502 i::Object* raw_context = *v8::Utils::OpenPersistent(env); | 495 i::Object* raw_context = *v8::Utils::OpenPersistent(env); |
| 503 | 496 |
| 504 env.Reset(); | 497 env.Reset(); |
| 505 | 498 |
| 506 SnapshotByteSink startup_sink; | 499 SnapshotByteSink startup_sink; |
| 507 StartupSerializer startup_serializer( | 500 StartupSerializer startup_serializer( |
| 508 isolate, &startup_sink, | 501 isolate, v8::SnapshotCreator::FunctionCodeHandling::kClear); |
| 509 v8::SnapshotCreator::FunctionCodeHandling::kClear); | |
| 510 startup_serializer.SerializeStrongReferences(); | 502 startup_serializer.SerializeStrongReferences(); |
| 511 | 503 |
| 512 SnapshotByteSink partial_sink; | 504 SnapshotByteSink partial_sink; |
| 513 PartialSerializer partial_serializer(isolate, &startup_serializer, | 505 PartialSerializer partial_serializer(isolate, &startup_serializer); |
| 514 &partial_sink); | |
| 515 partial_serializer.Serialize(&raw_context); | 506 partial_serializer.Serialize(&raw_context); |
| 516 startup_serializer.SerializeWeakReferencesAndDeferred(); | 507 startup_serializer.SerializeWeakReferencesAndDeferred(); |
| 517 | 508 |
| 518 SnapshotData startup_snapshot(&startup_serializer); | 509 SnapshotData startup_snapshot(&startup_serializer); |
| 519 SnapshotData partial_snapshot(&partial_serializer); | 510 SnapshotData partial_snapshot(&partial_serializer); |
| 520 | 511 |
| 521 *partial_blob_out = WritePayload(partial_snapshot.RawData()); | 512 *partial_blob_out = WritePayload(partial_snapshot.RawData()); |
| 522 *startup_blob_out = WritePayload(startup_snapshot.RawData()); | 513 *startup_blob_out = WritePayload(startup_snapshot.RawData()); |
| 523 } | 514 } |
| 524 v8_isolate->Dispose(); | 515 v8_isolate->Dispose(); |
| (...skipping 1365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1890 delete script_data; | 1881 delete script_data; |
| 1891 } | 1882 } |
| 1892 #endif // V8_TARGET_ARCH_X64 | 1883 #endif // V8_TARGET_ARCH_X64 |
| 1893 | 1884 |
| 1894 TEST(SerializationMemoryStats) { | 1885 TEST(SerializationMemoryStats) { |
| 1895 FLAG_profile_deserialization = true; | 1886 FLAG_profile_deserialization = true; |
| 1896 FLAG_always_opt = false; | 1887 FLAG_always_opt = false; |
| 1897 v8::StartupData blob = v8::V8::CreateSnapshotDataBlob(); | 1888 v8::StartupData blob = v8::V8::CreateSnapshotDataBlob(); |
| 1898 delete[] blob.data; | 1889 delete[] blob.data; |
| 1899 } | 1890 } |
| OLD | NEW |