| 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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 #include "test/cctest/cctest.h" | 44 #include "test/cctest/cctest.h" |
| 45 | 45 |
| 46 using namespace v8::internal; | 46 using namespace v8::internal; |
| 47 | 47 |
| 48 | 48 |
| 49 bool DefaultSnapshotAvailable() { | 49 bool DefaultSnapshotAvailable() { |
| 50 return i::Snapshot::DefaultSnapshotBlob() != NULL; | 50 return i::Snapshot::DefaultSnapshotBlob() != NULL; |
| 51 } | 51 } |
| 52 | 52 |
| 53 | 53 |
| 54 void DisableTurbofan() { |
| 55 const char* flag = "--turbo-filter=\"\""; |
| 56 FlagList::SetFlagsFromString(flag, StrLength(flag)); |
| 57 } |
| 58 |
| 59 |
| 54 // TestIsolate is used for testing isolate serialization. | 60 // TestIsolate is used for testing isolate serialization. |
| 55 class TestIsolate : public Isolate { | 61 class TestIsolate : public Isolate { |
| 56 public: | 62 public: |
| 57 static v8::Isolate* NewInitialized(bool enable_serializer) { | 63 static v8::Isolate* NewInitialized(bool enable_serializer) { |
| 58 i::Isolate* isolate = new TestIsolate(enable_serializer); | 64 i::Isolate* isolate = new TestIsolate(enable_serializer); |
| 59 v8::Isolate* v8_isolate = reinterpret_cast<v8::Isolate*>(isolate); | 65 v8::Isolate* v8_isolate = reinterpret_cast<v8::Isolate*>(isolate); |
| 60 v8::Isolate::Scope isolate_scope(v8_isolate); | 66 v8::Isolate::Scope isolate_scope(v8_isolate); |
| 61 isolate->Init(NULL); | 67 isolate->Init(NULL); |
| 62 return v8_isolate; | 68 return v8_isolate; |
| 63 } | 69 } |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 187 } | 193 } |
| 188 CopyChars(source + head.length() + repeats * body.length(), tail.start(), | 194 CopyChars(source + head.length() + repeats * body.length(), tail.start(), |
| 189 tail.length()); | 195 tail.length()); |
| 190 return Vector<const uint8_t>(const_cast<const uint8_t*>(source), | 196 return Vector<const uint8_t>(const_cast<const uint8_t*>(source), |
| 191 source_length); | 197 source_length); |
| 192 } | 198 } |
| 193 | 199 |
| 194 | 200 |
| 195 // Test that the whole heap can be serialized. | 201 // Test that the whole heap can be serialized. |
| 196 UNINITIALIZED_TEST(Serialize) { | 202 UNINITIALIZED_TEST(Serialize) { |
| 203 DisableTurbofan(); |
| 197 if (DefaultSnapshotAvailable()) return; | 204 if (DefaultSnapshotAvailable()) return; |
| 198 v8::Isolate* isolate = TestIsolate::NewInitialized(true); | 205 v8::Isolate* isolate = TestIsolate::NewInitialized(true); |
| 199 Serialize(isolate); | 206 Serialize(isolate); |
| 200 } | 207 } |
| 201 | 208 |
| 202 | 209 |
| 203 // Test that heap serialization is non-destructive. | 210 // Test that heap serialization is non-destructive. |
| 204 UNINITIALIZED_TEST(SerializeTwice) { | 211 UNINITIALIZED_TEST(SerializeTwice) { |
| 212 DisableTurbofan(); |
| 205 if (DefaultSnapshotAvailable()) return; | 213 if (DefaultSnapshotAvailable()) return; |
| 206 v8::Isolate* isolate = TestIsolate::NewInitialized(true); | 214 v8::Isolate* isolate = TestIsolate::NewInitialized(true); |
| 207 Serialize(isolate); | 215 Serialize(isolate); |
| 208 Serialize(isolate); | 216 Serialize(isolate); |
| 209 } | 217 } |
| 210 | 218 |
| 211 | 219 |
| 212 //---------------------------------------------------------------------------- | 220 //---------------------------------------------------------------------------- |
| 213 // Tests that the heap can be deserialized. | 221 // Tests that the heap can be deserialized. |
| 214 | 222 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 247 CHECK(isolate->native_context()->IsContext()); | 255 CHECK(isolate->native_context()->IsContext()); |
| 248 CHECK(isolate->heap()->string_table()->IsStringTable()); | 256 CHECK(isolate->heap()->string_table()->IsStringTable()); |
| 249 isolate->factory()->InternalizeOneByteString(STATIC_CHAR_VECTOR("Empty")); | 257 isolate->factory()->InternalizeOneByteString(STATIC_CHAR_VECTOR("Empty")); |
| 250 } | 258 } |
| 251 | 259 |
| 252 | 260 |
| 253 UNINITIALIZED_DEPENDENT_TEST(Deserialize, Serialize) { | 261 UNINITIALIZED_DEPENDENT_TEST(Deserialize, Serialize) { |
| 254 // The serialize-deserialize tests only work if the VM is built without | 262 // The serialize-deserialize tests only work if the VM is built without |
| 255 // serialization. That doesn't matter. We don't need to be able to | 263 // serialization. That doesn't matter. We don't need to be able to |
| 256 // serialize a snapshot in a VM that is booted from a snapshot. | 264 // serialize a snapshot in a VM that is booted from a snapshot. |
| 265 DisableTurbofan(); |
| 257 if (DefaultSnapshotAvailable()) return; | 266 if (DefaultSnapshotAvailable()) return; |
| 258 v8::Isolate* isolate = Deserialize(); | 267 v8::Isolate* isolate = Deserialize(); |
| 259 { | 268 { |
| 260 v8::HandleScope handle_scope(isolate); | 269 v8::HandleScope handle_scope(isolate); |
| 261 v8::Isolate::Scope isolate_scope(isolate); | 270 v8::Isolate::Scope isolate_scope(isolate); |
| 262 | 271 |
| 263 v8::Local<v8::Context> env = v8::Context::New(isolate); | 272 v8::Local<v8::Context> env = v8::Context::New(isolate); |
| 264 env->Enter(); | 273 env->Enter(); |
| 265 | 274 |
| 266 SanityCheck(isolate); | 275 SanityCheck(isolate); |
| 267 } | 276 } |
| 268 isolate->Dispose(); | 277 isolate->Dispose(); |
| 269 } | 278 } |
| 270 | 279 |
| 271 | 280 |
| 272 UNINITIALIZED_DEPENDENT_TEST(DeserializeFromSecondSerialization, | 281 UNINITIALIZED_DEPENDENT_TEST(DeserializeFromSecondSerialization, |
| 273 SerializeTwice) { | 282 SerializeTwice) { |
| 283 DisableTurbofan(); |
| 274 if (DefaultSnapshotAvailable()) return; | 284 if (DefaultSnapshotAvailable()) return; |
| 275 v8::Isolate* isolate = Deserialize(); | 285 v8::Isolate* isolate = Deserialize(); |
| 276 { | 286 { |
| 277 v8::Isolate::Scope isolate_scope(isolate); | 287 v8::Isolate::Scope isolate_scope(isolate); |
| 278 v8::HandleScope handle_scope(isolate); | 288 v8::HandleScope handle_scope(isolate); |
| 279 | 289 |
| 280 v8::Local<v8::Context> env = v8::Context::New(isolate); | 290 v8::Local<v8::Context> env = v8::Context::New(isolate); |
| 281 env->Enter(); | 291 env->Enter(); |
| 282 | 292 |
| 283 SanityCheck(isolate); | 293 SanityCheck(isolate); |
| 284 } | 294 } |
| 285 isolate->Dispose(); | 295 isolate->Dispose(); |
| 286 } | 296 } |
| 287 | 297 |
| 288 | 298 |
| 289 UNINITIALIZED_DEPENDENT_TEST(DeserializeAndRunScript2, Serialize) { | 299 UNINITIALIZED_DEPENDENT_TEST(DeserializeAndRunScript2, Serialize) { |
| 300 DisableTurbofan(); |
| 290 if (DefaultSnapshotAvailable()) return; | 301 if (DefaultSnapshotAvailable()) return; |
| 291 v8::Isolate* isolate = Deserialize(); | 302 v8::Isolate* isolate = Deserialize(); |
| 292 { | 303 { |
| 293 v8::Isolate::Scope isolate_scope(isolate); | 304 v8::Isolate::Scope isolate_scope(isolate); |
| 294 v8::HandleScope handle_scope(isolate); | 305 v8::HandleScope handle_scope(isolate); |
| 295 | 306 |
| 296 | 307 |
| 297 v8::Local<v8::Context> env = v8::Context::New(isolate); | 308 v8::Local<v8::Context> env = v8::Context::New(isolate); |
| 298 env->Enter(); | 309 env->Enter(); |
| 299 | 310 |
| 300 const char* c_source = "\"1234\".length"; | 311 const char* c_source = "\"1234\".length"; |
| 301 v8::Local<v8::String> source = v8::String::NewFromUtf8(isolate, c_source); | 312 v8::Local<v8::String> source = v8::String::NewFromUtf8(isolate, c_source); |
| 302 v8::Local<v8::Script> script = v8::Script::Compile(source); | 313 v8::Local<v8::Script> script = v8::Script::Compile(source); |
| 303 CHECK_EQ(4, script->Run()->Int32Value()); | 314 CHECK_EQ(4, script->Run()->Int32Value()); |
| 304 } | 315 } |
| 305 isolate->Dispose(); | 316 isolate->Dispose(); |
| 306 } | 317 } |
| 307 | 318 |
| 308 | 319 |
| 309 UNINITIALIZED_DEPENDENT_TEST(DeserializeFromSecondSerializationAndRunScript2, | 320 UNINITIALIZED_DEPENDENT_TEST(DeserializeFromSecondSerializationAndRunScript2, |
| 310 SerializeTwice) { | 321 SerializeTwice) { |
| 322 DisableTurbofan(); |
| 311 if (DefaultSnapshotAvailable()) return; | 323 if (DefaultSnapshotAvailable()) return; |
| 312 v8::Isolate* isolate = Deserialize(); | 324 v8::Isolate* isolate = Deserialize(); |
| 313 { | 325 { |
| 314 v8::Isolate::Scope isolate_scope(isolate); | 326 v8::Isolate::Scope isolate_scope(isolate); |
| 315 v8::HandleScope handle_scope(isolate); | 327 v8::HandleScope handle_scope(isolate); |
| 316 | 328 |
| 317 v8::Local<v8::Context> env = v8::Context::New(isolate); | 329 v8::Local<v8::Context> env = v8::Context::New(isolate); |
| 318 env->Enter(); | 330 env->Enter(); |
| 319 | 331 |
| 320 const char* c_source = "\"1234\".length"; | 332 const char* c_source = "\"1234\".length"; |
| 321 v8::Local<v8::String> source = v8::String::NewFromUtf8(isolate, c_source); | 333 v8::Local<v8::String> source = v8::String::NewFromUtf8(isolate, c_source); |
| 322 v8::Local<v8::Script> script = v8::Script::Compile(source); | 334 v8::Local<v8::Script> script = v8::Script::Compile(source); |
| 323 CHECK_EQ(4, script->Run()->Int32Value()); | 335 CHECK_EQ(4, script->Run()->Int32Value()); |
| 324 } | 336 } |
| 325 isolate->Dispose(); | 337 isolate->Dispose(); |
| 326 } | 338 } |
| 327 | 339 |
| 328 | 340 |
| 329 UNINITIALIZED_TEST(PartialSerialization) { | 341 UNINITIALIZED_TEST(PartialSerialization) { |
| 342 DisableTurbofan(); |
| 330 if (DefaultSnapshotAvailable()) return; | 343 if (DefaultSnapshotAvailable()) return; |
| 331 v8::Isolate* v8_isolate = TestIsolate::NewInitialized(true); | 344 v8::Isolate* v8_isolate = TestIsolate::NewInitialized(true); |
| 332 Isolate* isolate = reinterpret_cast<Isolate*>(v8_isolate); | 345 Isolate* isolate = reinterpret_cast<Isolate*>(v8_isolate); |
| 333 v8_isolate->Enter(); | 346 v8_isolate->Enter(); |
| 334 { | 347 { |
| 335 Heap* heap = isolate->heap(); | 348 Heap* heap = isolate->heap(); |
| 336 | 349 |
| 337 v8::Persistent<v8::Context> env; | 350 v8::Persistent<v8::Context> env; |
| 338 { | 351 { |
| 339 HandleScope scope(isolate); | 352 HandleScope scope(isolate); |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 390 WritePayload(startup_snapshot.RawData(), startup_name.start()); | 403 WritePayload(startup_snapshot.RawData(), startup_name.start()); |
| 391 | 404 |
| 392 startup_name.Dispose(); | 405 startup_name.Dispose(); |
| 393 } | 406 } |
| 394 v8_isolate->Exit(); | 407 v8_isolate->Exit(); |
| 395 v8_isolate->Dispose(); | 408 v8_isolate->Dispose(); |
| 396 } | 409 } |
| 397 | 410 |
| 398 | 411 |
| 399 UNINITIALIZED_DEPENDENT_TEST(PartialDeserialization, PartialSerialization) { | 412 UNINITIALIZED_DEPENDENT_TEST(PartialDeserialization, PartialSerialization) { |
| 413 DisableTurbofan(); |
| 400 if (DefaultSnapshotAvailable()) return; | 414 if (DefaultSnapshotAvailable()) return; |
| 401 int file_name_length = StrLength(FLAG_testing_serialization_file) + 10; | 415 int file_name_length = StrLength(FLAG_testing_serialization_file) + 10; |
| 402 Vector<char> startup_name = Vector<char>::New(file_name_length + 1); | 416 Vector<char> startup_name = Vector<char>::New(file_name_length + 1); |
| 403 SNPrintF(startup_name, "%s.startup", FLAG_testing_serialization_file); | 417 SNPrintF(startup_name, "%s.startup", FLAG_testing_serialization_file); |
| 404 | 418 |
| 405 v8::Isolate* v8_isolate = InitializeFromFile(startup_name.start()); | 419 v8::Isolate* v8_isolate = InitializeFromFile(startup_name.start()); |
| 406 CHECK(v8_isolate); | 420 CHECK(v8_isolate); |
| 407 startup_name.Dispose(); | 421 startup_name.Dispose(); |
| 408 { | 422 { |
| 409 v8::Isolate::Scope isolate_scope(v8_isolate); | 423 v8::Isolate::Scope isolate_scope(v8_isolate); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 441 CHECK(root.is_identical_to(root2)); | 455 CHECK(root.is_identical_to(root2)); |
| 442 } | 456 } |
| 443 | 457 |
| 444 DeleteArray(snapshot); | 458 DeleteArray(snapshot); |
| 445 } | 459 } |
| 446 v8_isolate->Dispose(); | 460 v8_isolate->Dispose(); |
| 447 } | 461 } |
| 448 | 462 |
| 449 | 463 |
| 450 UNINITIALIZED_TEST(ContextSerialization) { | 464 UNINITIALIZED_TEST(ContextSerialization) { |
| 465 DisableTurbofan(); |
| 451 if (DefaultSnapshotAvailable()) return; | 466 if (DefaultSnapshotAvailable()) return; |
| 452 v8::Isolate* v8_isolate = TestIsolate::NewInitialized(true); | 467 v8::Isolate* v8_isolate = TestIsolate::NewInitialized(true); |
| 453 Isolate* isolate = reinterpret_cast<Isolate*>(v8_isolate); | 468 Isolate* isolate = reinterpret_cast<Isolate*>(v8_isolate); |
| 454 Heap* heap = isolate->heap(); | 469 Heap* heap = isolate->heap(); |
| 455 { | 470 { |
| 456 v8::Isolate::Scope isolate_scope(v8_isolate); | 471 v8::Isolate::Scope isolate_scope(v8_isolate); |
| 457 | 472 |
| 458 v8::Persistent<v8::Context> env; | 473 v8::Persistent<v8::Context> env; |
| 459 { | 474 { |
| 460 HandleScope scope(isolate); | 475 HandleScope scope(isolate); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 505 WritePayload(partial_snapshot.RawData(), FLAG_testing_serialization_file); | 520 WritePayload(partial_snapshot.RawData(), FLAG_testing_serialization_file); |
| 506 WritePayload(startup_snapshot.RawData(), startup_name.start()); | 521 WritePayload(startup_snapshot.RawData(), startup_name.start()); |
| 507 | 522 |
| 508 startup_name.Dispose(); | 523 startup_name.Dispose(); |
| 509 } | 524 } |
| 510 v8_isolate->Dispose(); | 525 v8_isolate->Dispose(); |
| 511 } | 526 } |
| 512 | 527 |
| 513 | 528 |
| 514 UNINITIALIZED_DEPENDENT_TEST(ContextDeserialization, ContextSerialization) { | 529 UNINITIALIZED_DEPENDENT_TEST(ContextDeserialization, ContextSerialization) { |
| 530 DisableTurbofan(); |
| 515 if (DefaultSnapshotAvailable()) return; | 531 if (DefaultSnapshotAvailable()) return; |
| 516 int file_name_length = StrLength(FLAG_testing_serialization_file) + 10; | 532 int file_name_length = StrLength(FLAG_testing_serialization_file) + 10; |
| 517 Vector<char> startup_name = Vector<char>::New(file_name_length + 1); | 533 Vector<char> startup_name = Vector<char>::New(file_name_length + 1); |
| 518 SNPrintF(startup_name, "%s.startup", FLAG_testing_serialization_file); | 534 SNPrintF(startup_name, "%s.startup", FLAG_testing_serialization_file); |
| 519 | 535 |
| 520 v8::Isolate* v8_isolate = InitializeFromFile(startup_name.start()); | 536 v8::Isolate* v8_isolate = InitializeFromFile(startup_name.start()); |
| 521 CHECK(v8_isolate); | 537 CHECK(v8_isolate); |
| 522 startup_name.Dispose(); | 538 startup_name.Dispose(); |
| 523 { | 539 { |
| 524 v8::Isolate::Scope isolate_scope(v8_isolate); | 540 v8::Isolate::Scope isolate_scope(v8_isolate); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 555 CHECK(root2->IsContext()); | 571 CHECK(root2->IsContext()); |
| 556 CHECK(!root.is_identical_to(root2)); | 572 CHECK(!root.is_identical_to(root2)); |
| 557 } | 573 } |
| 558 DeleteArray(snapshot); | 574 DeleteArray(snapshot); |
| 559 } | 575 } |
| 560 v8_isolate->Dispose(); | 576 v8_isolate->Dispose(); |
| 561 } | 577 } |
| 562 | 578 |
| 563 | 579 |
| 564 UNINITIALIZED_TEST(CustomContextSerialization) { | 580 UNINITIALIZED_TEST(CustomContextSerialization) { |
| 581 DisableTurbofan(); |
| 565 if (DefaultSnapshotAvailable()) return; | 582 if (DefaultSnapshotAvailable()) return; |
| 566 v8::Isolate* v8_isolate = TestIsolate::NewInitialized(true); | 583 v8::Isolate* v8_isolate = TestIsolate::NewInitialized(true); |
| 567 Isolate* isolate = reinterpret_cast<Isolate*>(v8_isolate); | 584 Isolate* isolate = reinterpret_cast<Isolate*>(v8_isolate); |
| 568 { | 585 { |
| 569 v8::Isolate::Scope isolate_scope(v8_isolate); | 586 v8::Isolate::Scope isolate_scope(v8_isolate); |
| 570 | 587 |
| 571 v8::Persistent<v8::Context> env; | 588 v8::Persistent<v8::Context> env; |
| 572 { | 589 { |
| 573 HandleScope scope(isolate); | 590 HandleScope scope(isolate); |
| 574 env.Reset(v8_isolate, v8::Context::New(v8_isolate)); | 591 env.Reset(v8_isolate, v8::Context::New(v8_isolate)); |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 639 WritePayload(startup_snapshot.RawData(), startup_name.start()); | 656 WritePayload(startup_snapshot.RawData(), startup_name.start()); |
| 640 | 657 |
| 641 startup_name.Dispose(); | 658 startup_name.Dispose(); |
| 642 } | 659 } |
| 643 v8_isolate->Dispose(); | 660 v8_isolate->Dispose(); |
| 644 } | 661 } |
| 645 | 662 |
| 646 | 663 |
| 647 UNINITIALIZED_DEPENDENT_TEST(CustomContextDeserialization, | 664 UNINITIALIZED_DEPENDENT_TEST(CustomContextDeserialization, |
| 648 CustomContextSerialization) { | 665 CustomContextSerialization) { |
| 666 DisableTurbofan(); |
| 649 FLAG_crankshaft = false; | 667 FLAG_crankshaft = false; |
| 650 if (DefaultSnapshotAvailable()) return; | 668 if (DefaultSnapshotAvailable()) return; |
| 651 int file_name_length = StrLength(FLAG_testing_serialization_file) + 10; | 669 int file_name_length = StrLength(FLAG_testing_serialization_file) + 10; |
| 652 Vector<char> startup_name = Vector<char>::New(file_name_length + 1); | 670 Vector<char> startup_name = Vector<char>::New(file_name_length + 1); |
| 653 SNPrintF(startup_name, "%s.startup", FLAG_testing_serialization_file); | 671 SNPrintF(startup_name, "%s.startup", FLAG_testing_serialization_file); |
| 654 | 672 |
| 655 v8::Isolate* v8_isolate = InitializeFromFile(startup_name.start()); | 673 v8::Isolate* v8_isolate = InitializeFromFile(startup_name.start()); |
| 656 CHECK(v8_isolate); | 674 CHECK(v8_isolate); |
| 657 startup_name.Dispose(); | 675 startup_name.Dispose(); |
| 658 { | 676 { |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 699 int b = CompileRun("b.length")->ToNumber(v8_isolate)->Int32Value(); | 717 int b = CompileRun("b.length")->ToNumber(v8_isolate)->Int32Value(); |
| 700 CHECK_EQ(100002, b); | 718 CHECK_EQ(100002, b); |
| 701 } | 719 } |
| 702 DeleteArray(snapshot); | 720 DeleteArray(snapshot); |
| 703 } | 721 } |
| 704 v8_isolate->Dispose(); | 722 v8_isolate->Dispose(); |
| 705 } | 723 } |
| 706 | 724 |
| 707 | 725 |
| 708 TEST(PerIsolateSnapshotBlobs) { | 726 TEST(PerIsolateSnapshotBlobs) { |
| 709 const char* flag = "--turbo-filter=\"\""; | 727 DisableTurbofan(); |
| 710 FlagList::SetFlagsFromString(flag, StrLength(flag)); | |
| 711 | |
| 712 const char* source1 = "function f() { return 42; }"; | 728 const char* source1 = "function f() { return 42; }"; |
| 713 const char* source2 = | 729 const char* source2 = |
| 714 "function f() { return g() * 2; }" | 730 "function f() { return g() * 2; }" |
| 715 "function g() { return 43; }" | 731 "function g() { return 43; }" |
| 716 "/./.test('a')"; | 732 "/./.test('a')"; |
| 717 | 733 |
| 718 v8::StartupData data1 = v8::V8::CreateSnapshotDataBlob(source1); | 734 v8::StartupData data1 = v8::V8::CreateSnapshotDataBlob(source1); |
| 719 v8::StartupData data2 = v8::V8::CreateSnapshotDataBlob(source2); | 735 v8::StartupData data2 = v8::V8::CreateSnapshotDataBlob(source2); |
| 720 | 736 |
| 721 v8::Isolate::CreateParams params1; | 737 v8::Isolate::CreateParams params1; |
| (...skipping 20 matching lines...) Expand all Loading... |
| 742 delete[] data2.data; // We can dispose of the snapshot blob now. | 758 delete[] data2.data; // We can dispose of the snapshot blob now. |
| 743 v8::Context::Scope c_scope(context); | 759 v8::Context::Scope c_scope(context); |
| 744 CHECK_EQ(86, CompileRun("f()")->ToInt32(isolate2)->Int32Value()); | 760 CHECK_EQ(86, CompileRun("f()")->ToInt32(isolate2)->Int32Value()); |
| 745 CHECK_EQ(43, CompileRun("g()")->ToInt32(isolate2)->Int32Value()); | 761 CHECK_EQ(43, CompileRun("g()")->ToInt32(isolate2)->Int32Value()); |
| 746 } | 762 } |
| 747 isolate2->Dispose(); | 763 isolate2->Dispose(); |
| 748 } | 764 } |
| 749 | 765 |
| 750 | 766 |
| 751 TEST(PerIsolateSnapshotBlobsWithLocker) { | 767 TEST(PerIsolateSnapshotBlobsWithLocker) { |
| 768 DisableTurbofan(); |
| 752 v8::Isolate* isolate0 = v8::Isolate::New(); | 769 v8::Isolate* isolate0 = v8::Isolate::New(); |
| 753 { | 770 { |
| 754 v8::Locker locker(isolate0); | 771 v8::Locker locker(isolate0); |
| 755 v8::Isolate::Scope i_scope(isolate0); | 772 v8::Isolate::Scope i_scope(isolate0); |
| 756 v8::HandleScope h_scope(isolate0); | 773 v8::HandleScope h_scope(isolate0); |
| 757 v8::Local<v8::Context> context = v8::Context::New(isolate0); | 774 v8::Local<v8::Context> context = v8::Context::New(isolate0); |
| 758 v8::Context::Scope c_scope(context); | 775 v8::Context::Scope c_scope(context); |
| 759 CHECK_EQ(1, CompileRun("Math.cos(0)")->ToInt32(isolate0)->Int32Value()); | 776 CHECK_EQ(1, CompileRun("Math.cos(0)")->ToInt32(isolate0)->Int32Value()); |
| 760 } | 777 } |
| 761 isolate0->Dispose(); | 778 isolate0->Dispose(); |
| (...skipping 779 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1541 v8::Local<v8::Context> context = v8::Context::New(isolate); | 1558 v8::Local<v8::Context> context = v8::Context::New(isolate); |
| 1542 delete[] data.data; // We can dispose of the snapshot blob now. | 1559 delete[] data.data; // We can dispose of the snapshot blob now. |
| 1543 v8::Context::Scope c_scope(context); | 1560 v8::Context::Scope c_scope(context); |
| 1544 v8::Handle<v8::Function> foo = | 1561 v8::Handle<v8::Function> foo = |
| 1545 v8::Handle<v8::Function>::Cast(CompileRun("foo")); | 1562 v8::Handle<v8::Function>::Cast(CompileRun("foo")); |
| 1546 CHECK(v8::Utils::OpenHandle(*foo)->code()->is_turbofanned()); | 1563 CHECK(v8::Utils::OpenHandle(*foo)->code()->is_turbofanned()); |
| 1547 CHECK_EQ(3, CompileRun("foo(4)")->ToInt32(isolate)->Int32Value()); | 1564 CHECK_EQ(3, CompileRun("foo(4)")->ToInt32(isolate)->Int32Value()); |
| 1548 } | 1565 } |
| 1549 isolate->Dispose(); | 1566 isolate->Dispose(); |
| 1550 } | 1567 } |
| OLD | NEW |