| 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 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 SnapshotByteSink sink; |
| 96 StartupSerializer ser(internal_isolate, &sink); | 96 StartupSerializer ser(internal_isolate, &sink, |
| 97 v8::SnapshotCreator::FunctionCodeHandling::kClear); |
| 97 ser.SerializeStrongReferences(); | 98 ser.SerializeStrongReferences(); |
| 98 ser.SerializeWeakReferencesAndDeferred(); | 99 ser.SerializeWeakReferencesAndDeferred(); |
| 99 SnapshotData snapshot_data(ser); | 100 SnapshotData snapshot_data(ser); |
| 100 return WritePayload(snapshot_data.RawData()); | 101 return WritePayload(snapshot_data.RawData()); |
| 101 } | 102 } |
| 102 | 103 |
| 103 | 104 |
| 104 Vector<const uint8_t> ConstructSource(Vector<const uint8_t> head, | 105 Vector<const uint8_t> ConstructSource(Vector<const uint8_t> head, |
| 105 Vector<const uint8_t> body, | 106 Vector<const uint8_t> body, |
| 106 Vector<const uint8_t> tail, int repeats) { | 107 Vector<const uint8_t> tail, int repeats) { |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 275 raw_foo = *(v8::Utils::OpenHandle(*foo)); | 276 raw_foo = *(v8::Utils::OpenHandle(*foo)); |
| 276 } | 277 } |
| 277 | 278 |
| 278 { | 279 { |
| 279 v8::HandleScope handle_scope(v8_isolate); | 280 v8::HandleScope handle_scope(v8_isolate); |
| 280 v8::Local<v8::Context>::New(v8_isolate, env)->Exit(); | 281 v8::Local<v8::Context>::New(v8_isolate, env)->Exit(); |
| 281 } | 282 } |
| 282 env.Reset(); | 283 env.Reset(); |
| 283 | 284 |
| 284 SnapshotByteSink startup_sink; | 285 SnapshotByteSink startup_sink; |
| 285 StartupSerializer startup_serializer(isolate, &startup_sink); | 286 StartupSerializer startup_serializer( |
| 287 isolate, &startup_sink, |
| 288 v8::SnapshotCreator::FunctionCodeHandling::kClear); |
| 286 startup_serializer.SerializeStrongReferences(); | 289 startup_serializer.SerializeStrongReferences(); |
| 287 | 290 |
| 288 SnapshotByteSink partial_sink; | 291 SnapshotByteSink partial_sink; |
| 289 PartialSerializer partial_serializer(isolate, &startup_serializer, | 292 PartialSerializer partial_serializer(isolate, &startup_serializer, |
| 290 &partial_sink); | 293 &partial_sink); |
| 291 partial_serializer.Serialize(&raw_foo); | 294 partial_serializer.Serialize(&raw_foo); |
| 292 | 295 |
| 293 startup_serializer.SerializeWeakReferencesAndDeferred(); | 296 startup_serializer.SerializeWeakReferencesAndDeferred(); |
| 294 | 297 |
| 295 SnapshotData startup_snapshot(startup_serializer); | 298 SnapshotData startup_snapshot(startup_serializer); |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 374 { | 377 { |
| 375 v8::HandleScope handle_scope(v8_isolate); | 378 v8::HandleScope handle_scope(v8_isolate); |
| 376 v8::Local<v8::Context>::New(v8_isolate, env)->Exit(); | 379 v8::Local<v8::Context>::New(v8_isolate, env)->Exit(); |
| 377 } | 380 } |
| 378 | 381 |
| 379 i::Object* raw_context = *v8::Utils::OpenPersistent(env); | 382 i::Object* raw_context = *v8::Utils::OpenPersistent(env); |
| 380 | 383 |
| 381 env.Reset(); | 384 env.Reset(); |
| 382 | 385 |
| 383 SnapshotByteSink startup_sink; | 386 SnapshotByteSink startup_sink; |
| 384 StartupSerializer startup_serializer(isolate, &startup_sink); | 387 StartupSerializer startup_serializer( |
| 388 isolate, &startup_sink, |
| 389 v8::SnapshotCreator::FunctionCodeHandling::kClear); |
| 385 startup_serializer.SerializeStrongReferences(); | 390 startup_serializer.SerializeStrongReferences(); |
| 386 | 391 |
| 387 SnapshotByteSink partial_sink; | 392 SnapshotByteSink partial_sink; |
| 388 PartialSerializer partial_serializer(isolate, &startup_serializer, | 393 PartialSerializer partial_serializer(isolate, &startup_serializer, |
| 389 &partial_sink); | 394 &partial_sink); |
| 390 partial_serializer.Serialize(&raw_context); | 395 partial_serializer.Serialize(&raw_context); |
| 391 startup_serializer.SerializeWeakReferencesAndDeferred(); | 396 startup_serializer.SerializeWeakReferencesAndDeferred(); |
| 392 | 397 |
| 393 SnapshotData startup_snapshot(startup_serializer); | 398 SnapshotData startup_snapshot(startup_serializer); |
| 394 SnapshotData partial_snapshot(partial_serializer); | 399 SnapshotData partial_snapshot(partial_serializer); |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 492 { | 497 { |
| 493 v8::HandleScope handle_scope(v8_isolate); | 498 v8::HandleScope handle_scope(v8_isolate); |
| 494 v8::Local<v8::Context>::New(v8_isolate, env)->Exit(); | 499 v8::Local<v8::Context>::New(v8_isolate, env)->Exit(); |
| 495 } | 500 } |
| 496 | 501 |
| 497 i::Object* raw_context = *v8::Utils::OpenPersistent(env); | 502 i::Object* raw_context = *v8::Utils::OpenPersistent(env); |
| 498 | 503 |
| 499 env.Reset(); | 504 env.Reset(); |
| 500 | 505 |
| 501 SnapshotByteSink startup_sink; | 506 SnapshotByteSink startup_sink; |
| 502 StartupSerializer startup_serializer(isolate, &startup_sink); | 507 StartupSerializer startup_serializer( |
| 508 isolate, &startup_sink, |
| 509 v8::SnapshotCreator::FunctionCodeHandling::kClear); |
| 503 startup_serializer.SerializeStrongReferences(); | 510 startup_serializer.SerializeStrongReferences(); |
| 504 | 511 |
| 505 SnapshotByteSink partial_sink; | 512 SnapshotByteSink partial_sink; |
| 506 PartialSerializer partial_serializer(isolate, &startup_serializer, | 513 PartialSerializer partial_serializer(isolate, &startup_serializer, |
| 507 &partial_sink); | 514 &partial_sink); |
| 508 partial_serializer.Serialize(&raw_context); | 515 partial_serializer.Serialize(&raw_context); |
| 509 startup_serializer.SerializeWeakReferencesAndDeferred(); | 516 startup_serializer.SerializeWeakReferencesAndDeferred(); |
| 510 | 517 |
| 511 SnapshotData startup_snapshot(startup_serializer); | 518 SnapshotData startup_snapshot(startup_serializer); |
| 512 SnapshotData partial_snapshot(partial_serializer); | 519 SnapshotData partial_snapshot(partial_serializer); |
| (...skipping 1370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1883 delete script_data; | 1890 delete script_data; |
| 1884 } | 1891 } |
| 1885 #endif // V8_TARGET_ARCH_X64 | 1892 #endif // V8_TARGET_ARCH_X64 |
| 1886 | 1893 |
| 1887 TEST(SerializationMemoryStats) { | 1894 TEST(SerializationMemoryStats) { |
| 1888 FLAG_profile_deserialization = true; | 1895 FLAG_profile_deserialization = true; |
| 1889 FLAG_always_opt = false; | 1896 FLAG_always_opt = false; |
| 1890 v8::StartupData blob = v8::V8::CreateSnapshotDataBlob(); | 1897 v8::StartupData blob = v8::V8::CreateSnapshotDataBlob(); |
| 1891 delete[] blob.data; | 1898 delete[] blob.data; |
| 1892 } | 1899 } |
| OLD | NEW |