OLD | NEW |
1 // Copyright 2007-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2007-2008 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 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 static void Serialize() { | 150 static void Serialize() { |
151 #ifdef DEBUG | 151 #ifdef DEBUG |
152 FLAG_debug_serialization = true; | 152 FLAG_debug_serialization = true; |
153 #endif | 153 #endif |
154 StatsTable::SetCounterFunction(counter_function); | 154 StatsTable::SetCounterFunction(counter_function); |
155 | 155 |
156 v8::HandleScope scope; | 156 v8::HandleScope scope; |
157 const int kExtensionCount = 1; | 157 const int kExtensionCount = 1; |
158 const char* extension_list[kExtensionCount] = { "v8/gc" }; | 158 const char* extension_list[kExtensionCount] = { "v8/gc" }; |
159 v8::ExtensionConfiguration extensions(kExtensionCount, extension_list); | 159 v8::ExtensionConfiguration extensions(kExtensionCount, extension_list); |
| 160 Serializer::Enable(); |
160 v8::Persistent<v8::Context> env = v8::Context::New(&extensions); | 161 v8::Persistent<v8::Context> env = v8::Context::New(&extensions); |
161 env->Enter(); | 162 env->Enter(); |
162 | 163 |
163 Snapshot::WriteToFile(FLAG_testing_serialization_file); | 164 Snapshot::WriteToFile(FLAG_testing_serialization_file); |
164 } | 165 } |
165 | 166 |
166 | 167 |
167 // Test that the whole heap can be serialized when running from the | 168 // Test that the whole heap can be serialized when running from the |
168 // internal snapshot. | 169 // internal snapshot. |
169 // (Smoke test.) | 170 // (Smoke test.) |
(...skipping 10 matching lines...) Expand all Loading... |
180 if (Snapshot::IsEnabled()) return; | 181 if (Snapshot::IsEnabled()) return; |
181 Serialize(); | 182 Serialize(); |
182 } | 183 } |
183 | 184 |
184 | 185 |
185 // Test that the heap isn't destroyed after a serialization. | 186 // Test that the heap isn't destroyed after a serialization. |
186 TEST(SerializeNondestructive) { | 187 TEST(SerializeNondestructive) { |
187 if (Snapshot::IsEnabled()) return; | 188 if (Snapshot::IsEnabled()) return; |
188 StatsTable::SetCounterFunction(counter_function); | 189 StatsTable::SetCounterFunction(counter_function); |
189 v8::HandleScope scope; | 190 v8::HandleScope scope; |
| 191 Serializer::Enable(); |
190 v8::Persistent<v8::Context> env = v8::Context::New(); | 192 v8::Persistent<v8::Context> env = v8::Context::New(); |
191 v8::Context::Scope context_scope(env); | 193 v8::Context::Scope context_scope(env); |
192 Serializer().Serialize(); | 194 Serializer().Serialize(); |
193 const char* c_source = "\"abcd\".charAt(2) == 'c'"; | 195 const char* c_source = "\"abcd\".charAt(2) == 'c'"; |
194 v8::Local<v8::String> source = v8::String::New(c_source); | 196 v8::Local<v8::String> source = v8::String::New(c_source); |
195 v8::Local<v8::Script> script = v8::Script::Compile(source); | 197 v8::Local<v8::Script> script = v8::Script::Compile(source); |
196 v8::Local<v8::Value> value = script->Run(); | 198 v8::Local<v8::Value> value = script->Run(); |
197 CHECK(value->BooleanValue()); | 199 CHECK(value->BooleanValue()); |
198 } | 200 } |
199 | 201 |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
257 DEPENDENT_TEST(DeserializeExtensions, Serialize) { | 259 DEPENDENT_TEST(DeserializeExtensions, Serialize) { |
258 v8::HandleScope scope; | 260 v8::HandleScope scope; |
259 | 261 |
260 Deserialize(); | 262 Deserialize(); |
261 const char* c_source = "gc();"; | 263 const char* c_source = "gc();"; |
262 v8::Local<v8::String> source = v8::String::New(c_source); | 264 v8::Local<v8::String> source = v8::String::New(c_source); |
263 v8::Local<v8::Script> script = v8::Script::Compile(source); | 265 v8::Local<v8::Script> script = v8::Script::Compile(source); |
264 v8::Local<v8::Value> value = script->Run(); | 266 v8::Local<v8::Value> value = script->Run(); |
265 CHECK(value->IsUndefined()); | 267 CHECK(value->IsUndefined()); |
266 } | 268 } |
OLD | NEW |