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 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 exit(1); | 126 exit(1); |
127 } | 127 } |
128 fclose(file); | 128 fclose(file); |
129 } | 129 } |
130 | 130 |
131 | 131 |
132 static bool WriteToFile(Isolate* isolate, const char* snapshot_file) { | 132 static bool WriteToFile(Isolate* isolate, const char* snapshot_file) { |
133 SnapshotByteSink sink; | 133 SnapshotByteSink sink; |
134 StartupSerializer ser(isolate, &sink); | 134 StartupSerializer ser(isolate, &sink); |
135 ser.Serialize(); | 135 ser.Serialize(); |
136 SnapshotData snapshot_data(sink, ser); | 136 SnapshotData snapshot_data(ser); |
137 WritePayload(snapshot_data.RawData(), snapshot_file); | 137 WritePayload(snapshot_data.RawData(), snapshot_file); |
138 return true; | 138 return true; |
139 } | 139 } |
140 | 140 |
141 | 141 |
142 static void Serialize(v8::Isolate* isolate) { | 142 static void Serialize(v8::Isolate* isolate) { |
143 // We have to create one context. One reason for this is so that the builtins | 143 // We have to create one context. One reason for this is so that the builtins |
144 // can be loaded from v8natives.js and their addresses can be processed. This | 144 // can be loaded from v8natives.js and their addresses can be processed. This |
145 // will clear the pending fixups array, which would otherwise contain GC roots | 145 // will clear the pending fixups array, which would otherwise contain GC roots |
146 // that would confuse the serialization/deserialization process. | 146 // that would confuse the serialization/deserialization process. |
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
369 StartupSerializer startup_serializer(isolate, &startup_sink); | 369 StartupSerializer startup_serializer(isolate, &startup_sink); |
370 startup_serializer.SerializeStrongReferences(); | 370 startup_serializer.SerializeStrongReferences(); |
371 | 371 |
372 SnapshotByteSink partial_sink; | 372 SnapshotByteSink partial_sink; |
373 PartialSerializer partial_serializer(isolate, &startup_serializer, | 373 PartialSerializer partial_serializer(isolate, &startup_serializer, |
374 &partial_sink); | 374 &partial_sink); |
375 partial_serializer.Serialize(&raw_foo); | 375 partial_serializer.Serialize(&raw_foo); |
376 | 376 |
377 startup_serializer.SerializeWeakReferences(); | 377 startup_serializer.SerializeWeakReferences(); |
378 | 378 |
379 SnapshotData startup_snapshot(startup_sink, startup_serializer); | 379 SnapshotData startup_snapshot(startup_serializer); |
380 SnapshotData partial_snapshot(partial_sink, partial_serializer); | 380 SnapshotData partial_snapshot(partial_serializer); |
381 | 381 |
382 WritePayload(partial_snapshot.RawData(), FLAG_testing_serialization_file); | 382 WritePayload(partial_snapshot.RawData(), FLAG_testing_serialization_file); |
383 WritePayload(startup_snapshot.RawData(), startup_name.start()); | 383 WritePayload(startup_snapshot.RawData(), startup_name.start()); |
384 | 384 |
385 startup_name.Dispose(); | 385 startup_name.Dispose(); |
386 } | 386 } |
387 v8_isolate->Exit(); | 387 v8_isolate->Exit(); |
388 v8_isolate->Dispose(); | 388 v8_isolate->Dispose(); |
389 } | 389 } |
390 } | 390 } |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
487 SnapshotByteSink startup_sink; | 487 SnapshotByteSink startup_sink; |
488 StartupSerializer startup_serializer(isolate, &startup_sink); | 488 StartupSerializer startup_serializer(isolate, &startup_sink); |
489 startup_serializer.SerializeStrongReferences(); | 489 startup_serializer.SerializeStrongReferences(); |
490 | 490 |
491 SnapshotByteSink partial_sink; | 491 SnapshotByteSink partial_sink; |
492 PartialSerializer partial_serializer(isolate, &startup_serializer, | 492 PartialSerializer partial_serializer(isolate, &startup_serializer, |
493 &partial_sink); | 493 &partial_sink); |
494 partial_serializer.Serialize(&raw_context); | 494 partial_serializer.Serialize(&raw_context); |
495 startup_serializer.SerializeWeakReferences(); | 495 startup_serializer.SerializeWeakReferences(); |
496 | 496 |
497 SnapshotData startup_snapshot(startup_sink, startup_serializer); | 497 SnapshotData startup_snapshot(startup_serializer); |
498 SnapshotData partial_snapshot(partial_sink, partial_serializer); | 498 SnapshotData partial_snapshot(partial_serializer); |
499 | 499 |
500 WritePayload(partial_snapshot.RawData(), FLAG_testing_serialization_file); | 500 WritePayload(partial_snapshot.RawData(), FLAG_testing_serialization_file); |
501 WritePayload(startup_snapshot.RawData(), startup_name.start()); | 501 WritePayload(startup_snapshot.RawData(), startup_name.start()); |
502 | 502 |
503 startup_name.Dispose(); | 503 startup_name.Dispose(); |
504 } | 504 } |
505 v8_isolate->Dispose(); | 505 v8_isolate->Dispose(); |
506 } | 506 } |
507 } | 507 } |
508 | 508 |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
623 SnapshotByteSink startup_sink; | 623 SnapshotByteSink startup_sink; |
624 StartupSerializer startup_serializer(isolate, &startup_sink); | 624 StartupSerializer startup_serializer(isolate, &startup_sink); |
625 startup_serializer.SerializeStrongReferences(); | 625 startup_serializer.SerializeStrongReferences(); |
626 | 626 |
627 SnapshotByteSink partial_sink; | 627 SnapshotByteSink partial_sink; |
628 PartialSerializer partial_serializer(isolate, &startup_serializer, | 628 PartialSerializer partial_serializer(isolate, &startup_serializer, |
629 &partial_sink); | 629 &partial_sink); |
630 partial_serializer.Serialize(&raw_context); | 630 partial_serializer.Serialize(&raw_context); |
631 startup_serializer.SerializeWeakReferences(); | 631 startup_serializer.SerializeWeakReferences(); |
632 | 632 |
633 SnapshotData startup_snapshot(startup_sink, startup_serializer); | 633 SnapshotData startup_snapshot(startup_serializer); |
634 SnapshotData partial_snapshot(partial_sink, partial_serializer); | 634 SnapshotData partial_snapshot(partial_serializer); |
635 | 635 |
636 WritePayload(partial_snapshot.RawData(), FLAG_testing_serialization_file); | 636 WritePayload(partial_snapshot.RawData(), FLAG_testing_serialization_file); |
637 WritePayload(startup_snapshot.RawData(), startup_name.start()); | 637 WritePayload(startup_snapshot.RawData(), startup_name.start()); |
638 | 638 |
639 startup_name.Dispose(); | 639 startup_name.Dispose(); |
640 } | 640 } |
641 v8_isolate->Dispose(); | 641 v8_isolate->Dispose(); |
642 } | 642 } |
643 } | 643 } |
644 | 644 |
(...skipping 771 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1416 { | 1416 { |
1417 DisallowCompilation no_compile(reinterpret_cast<Isolate*>(isolate2)); | 1417 DisallowCompilation no_compile(reinterpret_cast<Isolate*>(isolate2)); |
1418 script = v8::ScriptCompiler::CompileUnbound( | 1418 script = v8::ScriptCompiler::CompileUnbound( |
1419 isolate2, &source, v8::ScriptCompiler::kConsumeCodeCache); | 1419 isolate2, &source, v8::ScriptCompiler::kConsumeCodeCache); |
1420 } | 1420 } |
1421 v8::Local<v8::Value> result = script->BindToCurrentContext()->Run(); | 1421 v8::Local<v8::Value> result = script->BindToCurrentContext()->Run(); |
1422 CHECK(result->ToString(isolate2)->Equals(v8_str("XY"))); | 1422 CHECK(result->ToString(isolate2)->Equals(v8_str("XY"))); |
1423 } | 1423 } |
1424 isolate2->Dispose(); | 1424 isolate2->Dispose(); |
1425 } | 1425 } |
OLD | NEW |