| 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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 #include "src/objects-inl.h" | 42 #include "src/objects-inl.h" |
| 43 #include "src/runtime/runtime.h" | 43 #include "src/runtime/runtime.h" |
| 44 #include "src/snapshot/code-serializer.h" | 44 #include "src/snapshot/code-serializer.h" |
| 45 #include "src/snapshot/deserializer.h" | 45 #include "src/snapshot/deserializer.h" |
| 46 #include "src/snapshot/natives.h" | 46 #include "src/snapshot/natives.h" |
| 47 #include "src/snapshot/partial-serializer.h" | 47 #include "src/snapshot/partial-serializer.h" |
| 48 #include "src/snapshot/snapshot.h" | 48 #include "src/snapshot/snapshot.h" |
| 49 #include "src/snapshot/startup-serializer.h" | 49 #include "src/snapshot/startup-serializer.h" |
| 50 #include "test/cctest/cctest.h" | 50 #include "test/cctest/cctest.h" |
| 51 #include "test/cctest/heap/heap-utils.h" | 51 #include "test/cctest/heap/heap-utils.h" |
| 52 #include "test/cctest/setup-builtins-for-tests.h" |
| 52 | 53 |
| 53 using namespace v8::internal; | 54 using namespace v8::internal; |
| 54 | 55 |
| 55 void DisableAlwaysOpt() { | 56 void DisableAlwaysOpt() { |
| 56 // Isolates prepared for serialization do not optimize. The only exception is | 57 // Isolates prepared for serialization do not optimize. The only exception is |
| 57 // with the flag --always-opt. | 58 // with the flag --always-opt. |
| 58 FLAG_always_opt = false; | 59 FLAG_always_opt = false; |
| 59 } | 60 } |
| 60 | 61 |
| 61 | 62 |
| 62 // TestIsolate is used for testing isolate serialization. | 63 // TestIsolate is used for testing isolate serialization. |
| 63 class TestIsolate : public Isolate { | 64 class TestIsolate : public Isolate { |
| 64 public: | 65 public: |
| 65 static v8::Isolate* NewInitialized(bool enable_serializer) { | 66 static v8::Isolate* NewInitialized(bool enable_serializer) { |
| 66 i::Isolate* isolate = new TestIsolate(enable_serializer); | 67 i::Isolate* isolate = new TestIsolate(enable_serializer); |
| 68 isolate->setup_builtins_delegate_ = new SetupBuiltinsDelegateForTests(); |
| 67 v8::Isolate* v8_isolate = reinterpret_cast<v8::Isolate*>(isolate); | 69 v8::Isolate* v8_isolate = reinterpret_cast<v8::Isolate*>(isolate); |
| 68 v8::Isolate::Scope isolate_scope(v8_isolate); | 70 v8::Isolate::Scope isolate_scope(v8_isolate); |
| 69 isolate->Init(NULL); | 71 isolate->Init(NULL); |
| 70 return v8_isolate; | 72 return v8_isolate; |
| 71 } | 73 } |
| 72 explicit TestIsolate(bool enable_serializer) : Isolate(enable_serializer) { | 74 explicit TestIsolate(bool enable_serializer) : Isolate(enable_serializer) { |
| 73 set_array_buffer_allocator(CcTest::array_buffer_allocator()); | 75 set_array_buffer_allocator(CcTest::array_buffer_allocator()); |
| 74 } | 76 } |
| 75 }; | 77 }; |
| 76 | 78 |
| (...skipping 2382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2459 } | 2461 } |
| 2460 delete[] blob.data; | 2462 delete[] blob.data; |
| 2461 } | 2463 } |
| 2462 | 2464 |
| 2463 TEST(SerializationMemoryStats) { | 2465 TEST(SerializationMemoryStats) { |
| 2464 FLAG_profile_deserialization = true; | 2466 FLAG_profile_deserialization = true; |
| 2465 FLAG_always_opt = false; | 2467 FLAG_always_opt = false; |
| 2466 v8::StartupData blob = v8::V8::CreateSnapshotDataBlob(); | 2468 v8::StartupData blob = v8::V8::CreateSnapshotDataBlob(); |
| 2467 delete[] blob.data; | 2469 delete[] blob.data; |
| 2468 } | 2470 } |
| OLD | NEW |