| 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 22 matching lines...) Expand all Loading... |
| 33 #include "v8.h" | 33 #include "v8.h" |
| 34 | 34 |
| 35 #include "debug.h" | 35 #include "debug.h" |
| 36 #include "ic-inl.h" | 36 #include "ic-inl.h" |
| 37 #include "runtime.h" | 37 #include "runtime.h" |
| 38 #include "serialize.h" | 38 #include "serialize.h" |
| 39 #include "scopeinfo.h" | 39 #include "scopeinfo.h" |
| 40 #include "snapshot.h" | 40 #include "snapshot.h" |
| 41 #include "cctest.h" | 41 #include "cctest.h" |
| 42 | 42 |
| 43 namespace v8 { namespace internal { | |
| 44 | |
| 45 #ifdef WIN32 | |
| 46 DEFINE_string(serialization_file, "C:\\Windows\\Temp\\serdes", | |
| 47 "file in which to serialize heap"); | |
| 48 #else | |
| 49 DEFINE_string(serialization_file, "/tmp/serdes", | |
| 50 "file in which to serialize heap"); | |
| 51 #endif | |
| 52 DECLARE_bool(debug_serialization); | |
| 53 }} // namespace v8::internal | |
| 54 | |
| 55 using namespace v8::internal; | 43 using namespace v8::internal; |
| 56 | 44 |
| 57 | |
| 58 static int local_counters[256]; | 45 static int local_counters[256]; |
| 59 static int counter_count = 0; | 46 static int counter_count = 0; |
| 60 static std::map<std::wstring, int> counter_table; | 47 static std::map<std::wstring, int> counter_table; |
| 61 | 48 |
| 62 | 49 |
| 63 // Callback receiver to track counters in test. | 50 // Callback receiver to track counters in test. |
| 64 static int* counter_function(const wchar_t* name) { | 51 static int* counter_function(const wchar_t* name) { |
| 65 std::wstring counter(name); | 52 std::wstring counter(name); |
| 66 if (counter_table.find(counter) == counter_table.end()) { | 53 if (counter_table.find(counter) == counter_table.end()) { |
| 67 local_counters[counter_count] = 0; | 54 local_counters[counter_count] = 0; |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 StatsTable::SetCounterFunction(counter_function); | 154 StatsTable::SetCounterFunction(counter_function); |
| 168 | 155 |
| 169 v8::HandleScope scope; | 156 v8::HandleScope scope; |
| 170 const int kExtensionCount = 5; | 157 const int kExtensionCount = 5; |
| 171 const char* extension_list[kExtensionCount] = | 158 const char* extension_list[kExtensionCount] = |
| 172 { "v8/print", "v8/load", "v8/quit", "v8/version", "v8/gc" }; | 159 { "v8/print", "v8/load", "v8/quit", "v8/version", "v8/gc" }; |
| 173 v8::ExtensionConfiguration extensions(kExtensionCount, extension_list); | 160 v8::ExtensionConfiguration extensions(kExtensionCount, extension_list); |
| 174 v8::Persistent<v8::Context> env = v8::Context::New(&extensions); | 161 v8::Persistent<v8::Context> env = v8::Context::New(&extensions); |
| 175 env->Enter(); | 162 env->Enter(); |
| 176 | 163 |
| 177 Snapshot::WriteToFile(FLAG_serialization_file); | 164 Snapshot::WriteToFile(FLAG_testing_serialization_file); |
| 178 } | 165 } |
| 179 | 166 |
| 180 | 167 |
| 181 // 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 |
| 182 // internal snapshot. | 169 // internal snapshot. |
| 183 // (Smoke test.) | 170 // (Smoke test.) |
| 184 TEST(SerializeInternal) { | 171 TEST(SerializeInternal) { |
| 185 Snapshot::Initialize(NULL); | 172 Snapshot::Initialize(NULL); |
| 186 Serialize(); | 173 Serialize(); |
| 187 } | 174 } |
| (...skipping 23 matching lines...) Expand all Loading... |
| 211 CHECK(value->BooleanValue()); | 198 CHECK(value->BooleanValue()); |
| 212 } | 199 } |
| 213 | 200 |
| 214 //---------------------------------------------------------------------------- | 201 //---------------------------------------------------------------------------- |
| 215 // Tests that the heap can be deserialized. | 202 // Tests that the heap can be deserialized. |
| 216 | 203 |
| 217 static void Deserialize() { | 204 static void Deserialize() { |
| 218 #ifdef DEBUG | 205 #ifdef DEBUG |
| 219 FLAG_debug_serialization = true; | 206 FLAG_debug_serialization = true; |
| 220 #endif | 207 #endif |
| 221 CHECK(Snapshot::Initialize(FLAG_serialization_file)); | 208 CHECK(Snapshot::Initialize(FLAG_testing_serialization_file)); |
| 222 } | 209 } |
| 223 | 210 |
| 224 | 211 |
| 225 static void SanityCheck() { | 212 static void SanityCheck() { |
| 226 v8::HandleScope scope; | 213 v8::HandleScope scope; |
| 227 #ifdef DEBUG | 214 #ifdef DEBUG |
| 228 Heap::Verify(); | 215 Heap::Verify(); |
| 229 #endif | 216 #endif |
| 230 CHECK(Top::global()->IsJSObject()); | 217 CHECK(Top::global()->IsJSObject()); |
| 231 CHECK(Top::global_context()->IsContext()); | 218 CHECK(Top::global_context()->IsContext()); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 271 TEST(DeserializeExtensions) { | 258 TEST(DeserializeExtensions) { |
| 272 v8::HandleScope scope; | 259 v8::HandleScope scope; |
| 273 | 260 |
| 274 Deserialize(); | 261 Deserialize(); |
| 275 const char* c_source = "print(\"abcd\");"; | 262 const char* c_source = "print(\"abcd\");"; |
| 276 v8::Local<v8::String> source = v8::String::New(c_source); | 263 v8::Local<v8::String> source = v8::String::New(c_source); |
| 277 v8::Local<v8::Script> script = v8::Script::Compile(source); | 264 v8::Local<v8::Script> script = v8::Script::Compile(source); |
| 278 v8::Local<v8::Value> value = script->Run(); | 265 v8::Local<v8::Value> value = script->Run(); |
| 279 CHECK(value->IsUndefined()); | 266 CHECK(value->IsUndefined()); |
| 280 } | 267 } |
| OLD | NEW |