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 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
387 | 387 |
388 const char* file_name = FLAG_testing_serialization_file; | 388 const char* file_name = FLAG_testing_serialization_file; |
389 | 389 |
390 int snapshot_size = 0; | 390 int snapshot_size = 0; |
391 byte* snapshot = ReadBytes(file_name, &snapshot_size); | 391 byte* snapshot = ReadBytes(file_name, &snapshot_size); |
392 | 392 |
393 Isolate* isolate = reinterpret_cast<Isolate*>(v8_isolate); | 393 Isolate* isolate = reinterpret_cast<Isolate*>(v8_isolate); |
394 HandleScope handle_scope(isolate); | 394 HandleScope handle_scope(isolate); |
395 Handle<Object> root; | 395 Handle<Object> root; |
396 Handle<FixedArray> outdated_contexts; | 396 Handle<FixedArray> outdated_contexts; |
| 397 // Intentionally empty handle. The deserializer should not come across |
| 398 // any references to the global proxy in this test. |
| 399 Handle<JSGlobalProxy> global_proxy = Handle<JSGlobalProxy>::null(); |
397 { | 400 { |
398 SnapshotData snapshot_data(Vector<const byte>(snapshot, snapshot_size)); | 401 SnapshotData snapshot_data(Vector<const byte>(snapshot, snapshot_size)); |
399 Deserializer deserializer(&snapshot_data); | 402 Deserializer deserializer(&snapshot_data); |
400 root = deserializer.DeserializePartial(isolate, &outdated_contexts) | 403 root = deserializer.DeserializePartial(isolate, global_proxy, |
| 404 &outdated_contexts) |
401 .ToHandleChecked(); | 405 .ToHandleChecked(); |
402 CHECK_EQ(0, outdated_contexts->length()); | 406 CHECK_EQ(0, outdated_contexts->length()); |
403 CHECK(root->IsString()); | 407 CHECK(root->IsString()); |
404 } | 408 } |
405 | 409 |
406 Handle<Object> root2; | 410 Handle<Object> root2; |
407 { | 411 { |
408 SnapshotData snapshot_data(Vector<const byte>(snapshot, snapshot_size)); | 412 SnapshotData snapshot_data(Vector<const byte>(snapshot, snapshot_size)); |
409 Deserializer deserializer(&snapshot_data); | 413 Deserializer deserializer(&snapshot_data); |
410 root2 = deserializer.DeserializePartial(isolate, &outdated_contexts) | 414 root2 = deserializer.DeserializePartial(isolate, global_proxy, |
| 415 &outdated_contexts) |
411 .ToHandleChecked(); | 416 .ToHandleChecked(); |
412 CHECK(root2->IsString()); | 417 CHECK(root2->IsString()); |
413 CHECK(root.is_identical_to(root2)); | 418 CHECK(root.is_identical_to(root2)); |
414 } | 419 } |
415 } | 420 } |
416 v8_isolate->Dispose(); | 421 v8_isolate->Dispose(); |
417 } | 422 } |
418 } | 423 } |
419 | 424 |
420 | 425 |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
499 | 504 |
500 const char* file_name = FLAG_testing_serialization_file; | 505 const char* file_name = FLAG_testing_serialization_file; |
501 | 506 |
502 int snapshot_size = 0; | 507 int snapshot_size = 0; |
503 byte* snapshot = ReadBytes(file_name, &snapshot_size); | 508 byte* snapshot = ReadBytes(file_name, &snapshot_size); |
504 | 509 |
505 Isolate* isolate = reinterpret_cast<Isolate*>(v8_isolate); | 510 Isolate* isolate = reinterpret_cast<Isolate*>(v8_isolate); |
506 HandleScope handle_scope(isolate); | 511 HandleScope handle_scope(isolate); |
507 Handle<Object> root; | 512 Handle<Object> root; |
508 Handle<FixedArray> outdated_contexts; | 513 Handle<FixedArray> outdated_contexts; |
| 514 Handle<JSGlobalProxy> global_proxy = |
| 515 isolate->factory()->NewUninitializedJSGlobalProxy(); |
509 { | 516 { |
510 SnapshotData snapshot_data(Vector<const byte>(snapshot, snapshot_size)); | 517 SnapshotData snapshot_data(Vector<const byte>(snapshot, snapshot_size)); |
511 Deserializer deserializer(&snapshot_data); | 518 Deserializer deserializer(&snapshot_data); |
512 root = deserializer.DeserializePartial(isolate, &outdated_contexts) | 519 root = deserializer.DeserializePartial(isolate, global_proxy, |
| 520 &outdated_contexts) |
513 .ToHandleChecked(); | 521 .ToHandleChecked(); |
514 CHECK(root->IsContext()); | 522 CHECK(root->IsContext()); |
| 523 CHECK(Handle<Context>::cast(root)->global_proxy() == *global_proxy); |
515 CHECK_EQ(1, outdated_contexts->length()); | 524 CHECK_EQ(1, outdated_contexts->length()); |
516 } | 525 } |
517 | 526 |
518 Handle<Object> root2; | 527 Handle<Object> root2; |
519 { | 528 { |
520 SnapshotData snapshot_data(Vector<const byte>(snapshot, snapshot_size)); | 529 SnapshotData snapshot_data(Vector<const byte>(snapshot, snapshot_size)); |
521 Deserializer deserializer(&snapshot_data); | 530 Deserializer deserializer(&snapshot_data); |
522 root2 = deserializer.DeserializePartial(isolate, &outdated_contexts) | 531 root2 = deserializer.DeserializePartial(isolate, global_proxy, |
| 532 &outdated_contexts) |
523 .ToHandleChecked(); | 533 .ToHandleChecked(); |
524 CHECK(root2->IsContext()); | 534 CHECK(root2->IsContext()); |
525 CHECK(!root.is_identical_to(root2)); | 535 CHECK(!root.is_identical_to(root2)); |
526 } | 536 } |
527 } | 537 } |
528 v8_isolate->Dispose(); | 538 v8_isolate->Dispose(); |
529 } | 539 } |
530 } | 540 } |
531 | 541 |
532 | 542 |
(...skipping 14 matching lines...) Expand all Loading... |
547 } | 557 } |
548 DCHECK(!env.IsEmpty()); | 558 DCHECK(!env.IsEmpty()); |
549 { | 559 { |
550 v8::HandleScope handle_scope(v8_isolate); | 560 v8::HandleScope handle_scope(v8_isolate); |
551 v8::Local<v8::Context>::New(v8_isolate, env)->Enter(); | 561 v8::Local<v8::Context>::New(v8_isolate, env)->Enter(); |
552 // After execution, e's function context refers to the global object. | 562 // After execution, e's function context refers to the global object. |
553 CompileRun( | 563 CompileRun( |
554 "var e;" | 564 "var e;" |
555 "(function() {" | 565 "(function() {" |
556 " e = function(s) { eval (s); }" | 566 " e = function(s) { eval (s); }" |
557 "})();"); | 567 "})();" |
| 568 "var o = this;"); |
558 } | 569 } |
559 // Make sure all builtin scripts are cached. | 570 // Make sure all builtin scripts are cached. |
560 { | 571 { |
561 HandleScope scope(isolate); | 572 HandleScope scope(isolate); |
562 for (int i = 0; i < Natives::GetBuiltinsCount(); i++) { | 573 for (int i = 0; i < Natives::GetBuiltinsCount(); i++) { |
563 isolate->bootstrapper()->NativesSourceLookup(i); | 574 isolate->bootstrapper()->NativesSourceLookup(i); |
564 } | 575 } |
565 } | 576 } |
566 // If we don't do this then we end up with a stray root pointing at the | 577 // If we don't do this then we end up with a stray root pointing at the |
567 // context even after we have disposed of env. | 578 // context even after we have disposed of env. |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
618 | 629 |
619 const char* file_name = FLAG_testing_serialization_file; | 630 const char* file_name = FLAG_testing_serialization_file; |
620 | 631 |
621 int snapshot_size = 0; | 632 int snapshot_size = 0; |
622 byte* snapshot = ReadBytes(file_name, &snapshot_size); | 633 byte* snapshot = ReadBytes(file_name, &snapshot_size); |
623 | 634 |
624 Isolate* isolate = reinterpret_cast<Isolate*>(v8_isolate); | 635 Isolate* isolate = reinterpret_cast<Isolate*>(v8_isolate); |
625 HandleScope handle_scope(isolate); | 636 HandleScope handle_scope(isolate); |
626 Handle<Object> root; | 637 Handle<Object> root; |
627 Handle<FixedArray> outdated_contexts; | 638 Handle<FixedArray> outdated_contexts; |
| 639 Handle<JSGlobalProxy> global_proxy = |
| 640 isolate->factory()->NewUninitializedJSGlobalProxy(); |
628 { | 641 { |
629 SnapshotData snapshot_data(Vector<const byte>(snapshot, snapshot_size)); | 642 SnapshotData snapshot_data(Vector<const byte>(snapshot, snapshot_size)); |
630 Deserializer deserializer(&snapshot_data); | 643 Deserializer deserializer(&snapshot_data); |
631 root = deserializer.DeserializePartial(isolate, &outdated_contexts) | 644 root = deserializer.DeserializePartial(isolate, global_proxy, |
| 645 &outdated_contexts) |
632 .ToHandleChecked(); | 646 .ToHandleChecked(); |
633 CHECK_EQ(2, outdated_contexts->length()); | 647 CHECK_EQ(2, outdated_contexts->length()); |
634 CHECK(root->IsContext()); | 648 CHECK(root->IsContext()); |
| 649 Handle<Context> context = Handle<Context>::cast(root); |
| 650 CHECK(context->global_proxy() == *global_proxy); |
| 651 Handle<String> o = isolate->factory()->NewStringFromAsciiChecked("o"); |
| 652 Handle<JSObject> global_object(context->global_object(), isolate); |
| 653 Handle<Object> property = JSObject::GetDataProperty(global_object, o); |
| 654 CHECK(property.is_identical_to(global_proxy)); |
635 } | 655 } |
636 } | 656 } |
637 v8_isolate->Dispose(); | 657 v8_isolate->Dispose(); |
638 } | 658 } |
639 } | 659 } |
640 | 660 |
641 | 661 |
642 TEST(TestThatAlwaysSucceeds) { | 662 TEST(TestThatAlwaysSucceeds) { |
643 } | 663 } |
644 | 664 |
(...skipping 680 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1325 { | 1345 { |
1326 DisallowCompilation no_compile(reinterpret_cast<Isolate*>(isolate2)); | 1346 DisallowCompilation no_compile(reinterpret_cast<Isolate*>(isolate2)); |
1327 script = v8::ScriptCompiler::CompileUnbound( | 1347 script = v8::ScriptCompiler::CompileUnbound( |
1328 isolate2, &source, v8::ScriptCompiler::kConsumeCodeCache); | 1348 isolate2, &source, v8::ScriptCompiler::kConsumeCodeCache); |
1329 } | 1349 } |
1330 v8::Local<v8::Value> result = script->BindToCurrentContext()->Run(); | 1350 v8::Local<v8::Value> result = script->BindToCurrentContext()->Run(); |
1331 CHECK(result->ToString(isolate2)->Equals(v8_str("XY"))); | 1351 CHECK(result->ToString(isolate2)->Equals(v8_str("XY"))); |
1332 } | 1352 } |
1333 isolate2->Dispose(); | 1353 isolate2->Dispose(); |
1334 } | 1354 } |
OLD | NEW |