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 545 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
556 env.Reset(v8_isolate, v8::Context::New(v8_isolate)); | 556 env.Reset(v8_isolate, v8::Context::New(v8_isolate)); |
557 } | 557 } |
558 DCHECK(!env.IsEmpty()); | 558 DCHECK(!env.IsEmpty()); |
559 { | 559 { |
560 v8::HandleScope handle_scope(v8_isolate); | 560 v8::HandleScope handle_scope(v8_isolate); |
561 v8::Local<v8::Context>::New(v8_isolate, env)->Enter(); | 561 v8::Local<v8::Context>::New(v8_isolate, env)->Enter(); |
562 // After execution, e's function context refers to the global object. | 562 // After execution, e's function context refers to the global object. |
563 CompileRun( | 563 CompileRun( |
564 "var e;" | 564 "var e;" |
565 "(function() {" | 565 "(function() {" |
566 " e = function(s) { eval (s); }" | 566 " e = function(s) { return eval (s); }" |
567 "})();" | 567 "})();" |
568 "var o = this;" | 568 "var o = this;" |
569 "var r = Math.random();" | 569 "var r = Math.random() + Math.cos(0);" |
570 "var f = (function(a, b) {}).bind(1, 2, 3);"); | 570 "var f = (function(a, b) { return a + b; }).bind(1, 2, 3);" |
| 571 "var s = parseInt('12345');"); |
571 } | 572 } |
572 // Make sure all builtin scripts are cached. | 573 // Make sure all builtin scripts are cached. |
573 { | 574 { |
574 HandleScope scope(isolate); | 575 HandleScope scope(isolate); |
575 for (int i = 0; i < Natives::GetBuiltinsCount(); i++) { | 576 for (int i = 0; i < Natives::GetBuiltinsCount(); i++) { |
576 isolate->bootstrapper()->NativesSourceLookup(i); | 577 isolate->bootstrapper()->NativesSourceLookup(i); |
577 } | 578 } |
578 } | 579 } |
579 // If we don't do this then we end up with a stray root pointing at the | 580 // If we don't do this then we end up with a stray root pointing at the |
580 // context even after we have disposed of env. | 581 // context even after we have disposed of env. |
(...skipping 28 matching lines...) Expand all Loading... |
609 WritePayload(partial_snapshot.RawData(), FLAG_testing_serialization_file); | 610 WritePayload(partial_snapshot.RawData(), FLAG_testing_serialization_file); |
610 WritePayload(startup_snapshot.RawData(), startup_name.start()); | 611 WritePayload(startup_snapshot.RawData(), startup_name.start()); |
611 | 612 |
612 startup_name.Dispose(); | 613 startup_name.Dispose(); |
613 } | 614 } |
614 v8_isolate->Dispose(); | 615 v8_isolate->Dispose(); |
615 } | 616 } |
616 } | 617 } |
617 | 618 |
618 | 619 |
619 UNINITIALIZED_DEPENDENT_TEST(CustomContextDeSerialization, | 620 UNINITIALIZED_DEPENDENT_TEST(CustomContextDeserialization, |
620 CustomContextSerialization) { | 621 CustomContextSerialization) { |
| 622 FLAG_crankshaft = false; |
621 if (!Snapshot::HaveASnapshotToStartFrom()) { | 623 if (!Snapshot::HaveASnapshotToStartFrom()) { |
622 int file_name_length = StrLength(FLAG_testing_serialization_file) + 10; | 624 int file_name_length = StrLength(FLAG_testing_serialization_file) + 10; |
623 Vector<char> startup_name = Vector<char>::New(file_name_length + 1); | 625 Vector<char> startup_name = Vector<char>::New(file_name_length + 1); |
624 SNPrintF(startup_name, "%s.startup", FLAG_testing_serialization_file); | 626 SNPrintF(startup_name, "%s.startup", FLAG_testing_serialization_file); |
625 | 627 |
626 v8::Isolate* v8_isolate = InitializeFromFile(startup_name.start()); | 628 v8::Isolate* v8_isolate = InitializeFromFile(startup_name.start()); |
627 CHECK(v8_isolate); | 629 CHECK(v8_isolate); |
628 startup_name.Dispose(); | 630 startup_name.Dispose(); |
629 { | 631 { |
630 v8::Isolate::Scope isolate_scope(v8_isolate); | 632 v8::Isolate::Scope isolate_scope(v8_isolate); |
(...skipping 16 matching lines...) Expand all Loading... |
647 &outdated_contexts) | 649 &outdated_contexts) |
648 .ToHandleChecked(); | 650 .ToHandleChecked(); |
649 CHECK_EQ(2, outdated_contexts->length()); | 651 CHECK_EQ(2, outdated_contexts->length()); |
650 CHECK(root->IsContext()); | 652 CHECK(root->IsContext()); |
651 Handle<Context> context = Handle<Context>::cast(root); | 653 Handle<Context> context = Handle<Context>::cast(root); |
652 CHECK(context->global_proxy() == *global_proxy); | 654 CHECK(context->global_proxy() == *global_proxy); |
653 Handle<String> o = isolate->factory()->NewStringFromAsciiChecked("o"); | 655 Handle<String> o = isolate->factory()->NewStringFromAsciiChecked("o"); |
654 Handle<JSObject> global_object(context->global_object(), isolate); | 656 Handle<JSObject> global_object(context->global_object(), isolate); |
655 Handle<Object> property = JSObject::GetDataProperty(global_object, o); | 657 Handle<Object> property = JSObject::GetDataProperty(global_object, o); |
656 CHECK(property.is_identical_to(global_proxy)); | 658 CHECK(property.is_identical_to(global_proxy)); |
| 659 |
| 660 v8::Handle<v8::Context> v8_context = v8::Utils::ToLocal(context); |
| 661 v8::Context::Scope context_scope(v8_context); |
| 662 double r = CompileRun("r")->ToNumber(v8_isolate)->Value(); |
| 663 CHECK(r >= 1 && r <= 2); |
| 664 int f = CompileRun("f()")->ToNumber(v8_isolate)->Int32Value(); |
| 665 CHECK_EQ(5, f); |
| 666 f = CompileRun("e('f()')")->ToNumber(v8_isolate)->Int32Value(); |
| 667 CHECK_EQ(5, f); |
| 668 v8::Handle<v8::String> s = CompileRun("s")->ToString(v8_isolate); |
| 669 CHECK(s->Equals(v8_str("12345"))); |
657 } | 670 } |
658 } | 671 } |
659 v8_isolate->Dispose(); | 672 v8_isolate->Dispose(); |
660 } | 673 } |
661 } | 674 } |
662 | 675 |
663 | 676 |
664 TEST(TestThatAlwaysSucceeds) { | 677 TEST(TestThatAlwaysSucceeds) { |
665 } | 678 } |
666 | 679 |
(...skipping 680 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1347 { | 1360 { |
1348 DisallowCompilation no_compile(reinterpret_cast<Isolate*>(isolate2)); | 1361 DisallowCompilation no_compile(reinterpret_cast<Isolate*>(isolate2)); |
1349 script = v8::ScriptCompiler::CompileUnbound( | 1362 script = v8::ScriptCompiler::CompileUnbound( |
1350 isolate2, &source, v8::ScriptCompiler::kConsumeCodeCache); | 1363 isolate2, &source, v8::ScriptCompiler::kConsumeCodeCache); |
1351 } | 1364 } |
1352 v8::Local<v8::Value> result = script->BindToCurrentContext()->Run(); | 1365 v8::Local<v8::Value> result = script->BindToCurrentContext()->Run(); |
1353 CHECK(result->ToString(isolate2)->Equals(v8_str("XY"))); | 1366 CHECK(result->ToString(isolate2)->Equals(v8_str("XY"))); |
1354 } | 1367 } |
1355 isolate2->Dispose(); | 1368 isolate2->Dispose(); |
1356 } | 1369 } |
OLD | NEW |