| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 2555 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2566 "function g () { f(mkbar()); }" | 2566 "function g () { f(mkbar()); }" |
| 2567 "f(new foo()); f(new foo());" | 2567 "f(new foo()); f(new foo());" |
| 2568 "%OptimizeFunctionOnNextCall(f);" | 2568 "%OptimizeFunctionOnNextCall(f);" |
| 2569 "f(new foo()); g();"); | 2569 "f(new foo()); g();"); |
| 2570 } | 2570 } |
| 2571 | 2571 |
| 2572 IncrementalMarking* marking = CcTest::heap()->incremental_marking(); | 2572 IncrementalMarking* marking = CcTest::heap()->incremental_marking(); |
| 2573 marking->Stop(); | 2573 marking->Stop(); |
| 2574 CcTest::heap()->StartIncrementalMarking(); | 2574 CcTest::heap()->StartIncrementalMarking(); |
| 2575 | 2575 |
| 2576 Handle<JSFunction> f = | 2576 Handle<JSFunction> f = Handle<JSFunction>::cast(v8::Utils::OpenHandle( |
| 2577 v8::Utils::OpenHandle( | 2577 *v8::Handle<v8::Function>::Cast(CcTest::global()->Get(v8_str("f"))))); |
| 2578 *v8::Handle<v8::Function>::Cast( | |
| 2579 CcTest::global()->Get(v8_str("f")))); | |
| 2580 | 2578 |
| 2581 CHECK(f->IsOptimized()); | 2579 CHECK(f->IsOptimized()); |
| 2582 | 2580 |
| 2583 while (!Marking::IsBlack(Marking::MarkBitFrom(f->code())) && | 2581 while (!Marking::IsBlack(Marking::MarkBitFrom(f->code())) && |
| 2584 !marking->IsStopped()) { | 2582 !marking->IsStopped()) { |
| 2585 // Discard any pending GC requests otherwise we will get GC when we enter | 2583 // Discard any pending GC requests otherwise we will get GC when we enter |
| 2586 // code below. | 2584 // code below. |
| 2587 marking->Step(MB, IncrementalMarking::NO_GC_VIA_STACK_GUARD); | 2585 marking->Step(MB, IncrementalMarking::NO_GC_VIA_STACK_GUARD); |
| 2588 } | 2586 } |
| 2589 | 2587 |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2684 CompileRun( | 2682 CompileRun( |
| 2685 "function f () {" | 2683 "function f () {" |
| 2686 " var s = 0;" | 2684 " var s = 0;" |
| 2687 " for (var i = 0; i < 100; i++) s += i;" | 2685 " for (var i = 0; i < 100; i++) s += i;" |
| 2688 " return s;" | 2686 " return s;" |
| 2689 "}" | 2687 "}" |
| 2690 "f(); f();" | 2688 "f(); f();" |
| 2691 "%OptimizeFunctionOnNextCall(f);" | 2689 "%OptimizeFunctionOnNextCall(f);" |
| 2692 "f();"); | 2690 "f();"); |
| 2693 } | 2691 } |
| 2694 Handle<JSFunction> f = | 2692 Handle<JSFunction> f = Handle<JSFunction>::cast(v8::Utils::OpenHandle( |
| 2695 v8::Utils::OpenHandle( | 2693 *v8::Handle<v8::Function>::Cast(CcTest::global()->Get(v8_str("f"))))); |
| 2696 *v8::Handle<v8::Function>::Cast( | |
| 2697 CcTest::global()->Get(v8_str("f")))); | |
| 2698 CHECK(f->IsOptimized()); | 2694 CHECK(f->IsOptimized()); |
| 2699 | 2695 |
| 2700 IncrementalMarking* marking = CcTest::heap()->incremental_marking(); | 2696 IncrementalMarking* marking = CcTest::heap()->incremental_marking(); |
| 2701 marking->Stop(); | 2697 marking->Stop(); |
| 2702 CcTest::heap()->StartIncrementalMarking(); | 2698 CcTest::heap()->StartIncrementalMarking(); |
| 2703 // The following calls will increment CcTest::heap()->global_ic_age(). | 2699 // The following calls will increment CcTest::heap()->global_ic_age(). |
| 2704 CcTest::isolate()->ContextDisposedNotification(); | 2700 CcTest::isolate()->ContextDisposedNotification(); |
| 2705 SimulateIncrementalMarking(CcTest::heap()); | 2701 SimulateIncrementalMarking(CcTest::heap()); |
| 2706 CcTest::heap()->CollectAllGarbage(); | 2702 CcTest::heap()->CollectAllGarbage(); |
| 2707 CHECK_EQ(CcTest::heap()->global_ic_age(), f->shared()->ic_age()); | 2703 CHECK_EQ(CcTest::heap()->global_ic_age(), f->shared()->ic_age()); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 2726 CompileRun( | 2722 CompileRun( |
| 2727 "function f () {" | 2723 "function f () {" |
| 2728 " var s = 0;" | 2724 " var s = 0;" |
| 2729 " for (var i = 0; i < 100; i++) s += i;" | 2725 " for (var i = 0; i < 100; i++) s += i;" |
| 2730 " return s;" | 2726 " return s;" |
| 2731 "}" | 2727 "}" |
| 2732 "f(); f();" | 2728 "f(); f();" |
| 2733 "%OptimizeFunctionOnNextCall(f);" | 2729 "%OptimizeFunctionOnNextCall(f);" |
| 2734 "f();"); | 2730 "f();"); |
| 2735 } | 2731 } |
| 2736 Handle<JSFunction> f = | 2732 Handle<JSFunction> f = Handle<JSFunction>::cast(v8::Utils::OpenHandle( |
| 2737 v8::Utils::OpenHandle( | 2733 *v8::Handle<v8::Function>::Cast(CcTest::global()->Get(v8_str("f"))))); |
| 2738 *v8::Handle<v8::Function>::Cast( | |
| 2739 CcTest::global()->Get(v8_str("f")))); | |
| 2740 CHECK(f->IsOptimized()); | 2734 CHECK(f->IsOptimized()); |
| 2741 | 2735 |
| 2742 CcTest::heap()->incremental_marking()->Stop(); | 2736 CcTest::heap()->incremental_marking()->Stop(); |
| 2743 | 2737 |
| 2744 // The following two calls will increment CcTest::heap()->global_ic_age(). | 2738 // The following two calls will increment CcTest::heap()->global_ic_age(). |
| 2745 CcTest::isolate()->ContextDisposedNotification(); | 2739 CcTest::isolate()->ContextDisposedNotification(); |
| 2746 CcTest::heap()->CollectAllGarbage(); | 2740 CcTest::heap()->CollectAllGarbage(); |
| 2747 | 2741 |
| 2748 CHECK_EQ(CcTest::heap()->global_ic_age(), f->shared()->ic_age()); | 2742 CHECK_EQ(CcTest::heap()->global_ic_age(), f->shared()->ic_age()); |
| 2749 CHECK_EQ(0, f->shared()->opt_count()); | 2743 CHECK_EQ(0, f->shared()->opt_count()); |
| (...skipping 863 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3613 } | 3607 } |
| 3614 | 3608 |
| 3615 | 3609 |
| 3616 #ifdef OBJECT_PRINT | 3610 #ifdef OBJECT_PRINT |
| 3617 TEST(PrintSharedFunctionInfo) { | 3611 TEST(PrintSharedFunctionInfo) { |
| 3618 CcTest::InitializeVM(); | 3612 CcTest::InitializeVM(); |
| 3619 v8::HandleScope scope(CcTest::isolate()); | 3613 v8::HandleScope scope(CcTest::isolate()); |
| 3620 const char* source = "f = function() { return 987654321; }\n" | 3614 const char* source = "f = function() { return 987654321; }\n" |
| 3621 "g = function() { return 123456789; }\n"; | 3615 "g = function() { return 123456789; }\n"; |
| 3622 CompileRun(source); | 3616 CompileRun(source); |
| 3623 Handle<JSFunction> g = | 3617 Handle<JSFunction> g = Handle<JSFunction>::cast(v8::Utils::OpenHandle( |
| 3624 v8::Utils::OpenHandle( | 3618 *v8::Handle<v8::Function>::Cast(CcTest::global()->Get(v8_str("g"))))); |
| 3625 *v8::Handle<v8::Function>::Cast( | |
| 3626 CcTest::global()->Get(v8_str("g")))); | |
| 3627 | 3619 |
| 3628 OFStream os(stdout); | 3620 OFStream os(stdout); |
| 3629 g->shared()->Print(os); | 3621 g->shared()->Print(os); |
| 3630 os << std::endl; | 3622 os << std::endl; |
| 3631 } | 3623 } |
| 3632 #endif // OBJECT_PRINT | 3624 #endif // OBJECT_PRINT |
| 3633 | 3625 |
| 3634 | 3626 |
| 3635 TEST(IncrementalMarkingPreservesMonomorphicCallIC) { | 3627 TEST(IncrementalMarkingPreservesMonomorphicCallIC) { |
| 3636 if (i::FLAG_always_opt) return; | 3628 if (i::FLAG_always_opt) return; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 3649 CompileRun("function fun() {};"); | 3641 CompileRun("function fun() {};"); |
| 3650 fun2 = env->Global()->Get(v8_str("fun")); | 3642 fun2 = env->Global()->Get(v8_str("fun")); |
| 3651 } | 3643 } |
| 3652 | 3644 |
| 3653 // Prepare function f that contains type feedback for closures | 3645 // Prepare function f that contains type feedback for closures |
| 3654 // originating from two different native contexts. | 3646 // originating from two different native contexts. |
| 3655 CcTest::global()->Set(v8_str("fun1"), fun1); | 3647 CcTest::global()->Set(v8_str("fun1"), fun1); |
| 3656 CcTest::global()->Set(v8_str("fun2"), fun2); | 3648 CcTest::global()->Set(v8_str("fun2"), fun2); |
| 3657 CompileRun("function f(a, b) { a(); b(); } f(fun1, fun2);"); | 3649 CompileRun("function f(a, b) { a(); b(); } f(fun1, fun2);"); |
| 3658 | 3650 |
| 3659 Handle<JSFunction> f = | 3651 Handle<JSFunction> f = Handle<JSFunction>::cast(v8::Utils::OpenHandle( |
| 3660 v8::Utils::OpenHandle( | 3652 *v8::Handle<v8::Function>::Cast(CcTest::global()->Get(v8_str("f"))))); |
| 3661 *v8::Handle<v8::Function>::Cast( | |
| 3662 CcTest::global()->Get(v8_str("f")))); | |
| 3663 | 3653 |
| 3664 Handle<TypeFeedbackVector> feedback_vector(f->shared()->feedback_vector()); | 3654 Handle<TypeFeedbackVector> feedback_vector(f->shared()->feedback_vector()); |
| 3665 FeedbackVectorHelper feedback_helper(feedback_vector); | 3655 FeedbackVectorHelper feedback_helper(feedback_vector); |
| 3666 | 3656 |
| 3667 int expected_slots = 2; | 3657 int expected_slots = 2; |
| 3668 CHECK_EQ(expected_slots, feedback_helper.slot_count()); | 3658 CHECK_EQ(expected_slots, feedback_helper.slot_count()); |
| 3669 int slot1 = 0; | 3659 int slot1 = 0; |
| 3670 int slot2 = 1; | 3660 int slot2 = 1; |
| 3671 CHECK(feedback_vector->Get(feedback_helper.slot(slot1))->IsWeakCell()); | 3661 CHECK(feedback_vector->Get(feedback_helper.slot(slot1))->IsWeakCell()); |
| 3672 CHECK(feedback_vector->Get(feedback_helper.slot(slot2))->IsWeakCell()); | 3662 CHECK(feedback_vector->Get(feedback_helper.slot(slot2))->IsWeakCell()); |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3758 TEST(IncrementalMarkingPreservesMonomorphicConstructor) { | 3748 TEST(IncrementalMarkingPreservesMonomorphicConstructor) { |
| 3759 if (i::FLAG_always_opt) return; | 3749 if (i::FLAG_always_opt) return; |
| 3760 CcTest::InitializeVM(); | 3750 CcTest::InitializeVM(); |
| 3761 v8::HandleScope scope(CcTest::isolate()); | 3751 v8::HandleScope scope(CcTest::isolate()); |
| 3762 | 3752 |
| 3763 // Prepare function f that contains a monomorphic IC for object | 3753 // Prepare function f that contains a monomorphic IC for object |
| 3764 // originating from the same native context. | 3754 // originating from the same native context. |
| 3765 CompileRun( | 3755 CompileRun( |
| 3766 "function fun() { this.x = 1; };" | 3756 "function fun() { this.x = 1; };" |
| 3767 "function f(o) { return new o(); } f(fun); f(fun);"); | 3757 "function f(o) { return new o(); } f(fun); f(fun);"); |
| 3768 Handle<JSFunction> f = v8::Utils::OpenHandle( | 3758 Handle<JSFunction> f = Handle<JSFunction>::cast(v8::Utils::OpenHandle( |
| 3769 *v8::Handle<v8::Function>::Cast(CcTest::global()->Get(v8_str("f")))); | 3759 *v8::Handle<v8::Function>::Cast(CcTest::global()->Get(v8_str("f"))))); |
| 3770 | 3760 |
| 3771 | 3761 |
| 3772 Handle<TypeFeedbackVector> vector(f->shared()->feedback_vector()); | 3762 Handle<TypeFeedbackVector> vector(f->shared()->feedback_vector()); |
| 3773 CHECK(vector->Get(FeedbackVectorSlot(0))->IsWeakCell()); | 3763 CHECK(vector->Get(FeedbackVectorSlot(0))->IsWeakCell()); |
| 3774 | 3764 |
| 3775 SimulateIncrementalMarking(CcTest::heap()); | 3765 SimulateIncrementalMarking(CcTest::heap()); |
| 3776 CcTest::heap()->CollectAllGarbage(); | 3766 CcTest::heap()->CollectAllGarbage(); |
| 3777 | 3767 |
| 3778 CHECK(vector->Get(FeedbackVectorSlot(0))->IsWeakCell()); | 3768 CHECK(vector->Get(FeedbackVectorSlot(0))->IsWeakCell()); |
| 3779 } | 3769 } |
| (...skipping 11 matching lines...) Expand all Loading... |
| 3791 CompileRun("function fun() { this.x = 1; };"); | 3781 CompileRun("function fun() { this.x = 1; };"); |
| 3792 fun1 = env->Global()->Get(v8_str("fun")); | 3782 fun1 = env->Global()->Get(v8_str("fun")); |
| 3793 } | 3783 } |
| 3794 | 3784 |
| 3795 // Prepare function f that contains a monomorphic constructor for object | 3785 // Prepare function f that contains a monomorphic constructor for object |
| 3796 // originating from a different native context. | 3786 // originating from a different native context. |
| 3797 CcTest::global()->Set(v8_str("fun1"), fun1); | 3787 CcTest::global()->Set(v8_str("fun1"), fun1); |
| 3798 CompileRun( | 3788 CompileRun( |
| 3799 "function fun() { this.x = 1; };" | 3789 "function fun() { this.x = 1; };" |
| 3800 "function f(o) { return new o(); } f(fun1); f(fun1);"); | 3790 "function f(o) { return new o(); } f(fun1); f(fun1);"); |
| 3801 Handle<JSFunction> f = v8::Utils::OpenHandle( | 3791 Handle<JSFunction> f = Handle<JSFunction>::cast(v8::Utils::OpenHandle( |
| 3802 *v8::Handle<v8::Function>::Cast(CcTest::global()->Get(v8_str("f")))); | 3792 *v8::Handle<v8::Function>::Cast(CcTest::global()->Get(v8_str("f"))))); |
| 3803 | 3793 |
| 3804 | 3794 |
| 3805 Handle<TypeFeedbackVector> vector(f->shared()->feedback_vector()); | 3795 Handle<TypeFeedbackVector> vector(f->shared()->feedback_vector()); |
| 3806 CHECK(vector->Get(FeedbackVectorSlot(0))->IsWeakCell()); | 3796 CHECK(vector->Get(FeedbackVectorSlot(0))->IsWeakCell()); |
| 3807 | 3797 |
| 3808 // Fire context dispose notification. | 3798 // Fire context dispose notification. |
| 3809 CcTest::isolate()->ContextDisposedNotification(); | 3799 CcTest::isolate()->ContextDisposedNotification(); |
| 3810 SimulateIncrementalMarking(CcTest::heap()); | 3800 SimulateIncrementalMarking(CcTest::heap()); |
| 3811 CcTest::heap()->CollectAllGarbage(); | 3801 CcTest::heap()->CollectAllGarbage(); |
| 3812 | 3802 |
| 3813 CHECK_EQ(*TypeFeedbackVector::UninitializedSentinel(isolate), | 3803 CHECK_EQ(*TypeFeedbackVector::UninitializedSentinel(isolate), |
| 3814 vector->Get(FeedbackVectorSlot(0))); | 3804 vector->Get(FeedbackVectorSlot(0))); |
| 3815 } | 3805 } |
| 3816 | 3806 |
| 3817 | 3807 |
| 3818 TEST(IncrementalMarkingPreservesMonomorphicIC) { | 3808 TEST(IncrementalMarkingPreservesMonomorphicIC) { |
| 3819 if (i::FLAG_always_opt) return; | 3809 if (i::FLAG_always_opt) return; |
| 3820 CcTest::InitializeVM(); | 3810 CcTest::InitializeVM(); |
| 3821 v8::HandleScope scope(CcTest::isolate()); | 3811 v8::HandleScope scope(CcTest::isolate()); |
| 3822 | 3812 |
| 3823 // Prepare function f that contains a monomorphic IC for object | 3813 // Prepare function f that contains a monomorphic IC for object |
| 3824 // originating from the same native context. | 3814 // originating from the same native context. |
| 3825 CompileRun("function fun() { this.x = 1; }; var obj = new fun();" | 3815 CompileRun("function fun() { this.x = 1; }; var obj = new fun();" |
| 3826 "function f(o) { return o.x; } f(obj); f(obj);"); | 3816 "function f(o) { return o.x; } f(obj); f(obj);"); |
| 3827 Handle<JSFunction> f = | 3817 Handle<JSFunction> f = Handle<JSFunction>::cast(v8::Utils::OpenHandle( |
| 3828 v8::Utils::OpenHandle( | 3818 *v8::Handle<v8::Function>::Cast(CcTest::global()->Get(v8_str("f"))))); |
| 3829 *v8::Handle<v8::Function>::Cast( | |
| 3830 CcTest::global()->Get(v8_str("f")))); | |
| 3831 | 3819 |
| 3832 Code* ic_before = FindFirstIC(f->shared()->code(), Code::LOAD_IC); | 3820 Code* ic_before = FindFirstIC(f->shared()->code(), Code::LOAD_IC); |
| 3833 CheckVectorIC(f, 0, MONOMORPHIC); | 3821 CheckVectorIC(f, 0, MONOMORPHIC); |
| 3834 CHECK(ic_before->ic_state() == DEFAULT); | 3822 CHECK(ic_before->ic_state() == DEFAULT); |
| 3835 | 3823 |
| 3836 SimulateIncrementalMarking(CcTest::heap()); | 3824 SimulateIncrementalMarking(CcTest::heap()); |
| 3837 CcTest::heap()->CollectAllGarbage(); | 3825 CcTest::heap()->CollectAllGarbage(); |
| 3838 | 3826 |
| 3839 Code* ic_after = FindFirstIC(f->shared()->code(), Code::LOAD_IC); | 3827 Code* ic_after = FindFirstIC(f->shared()->code(), Code::LOAD_IC); |
| 3840 CheckVectorIC(f, 0, MONOMORPHIC); | 3828 CheckVectorIC(f, 0, MONOMORPHIC); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 3851 { | 3839 { |
| 3852 LocalContext env; | 3840 LocalContext env; |
| 3853 CompileRun("function fun() { this.x = 1; }; var obj = new fun();"); | 3841 CompileRun("function fun() { this.x = 1; }; var obj = new fun();"); |
| 3854 obj1 = env->Global()->Get(v8_str("obj")); | 3842 obj1 = env->Global()->Get(v8_str("obj")); |
| 3855 } | 3843 } |
| 3856 | 3844 |
| 3857 // Prepare function f that contains a monomorphic IC for object | 3845 // Prepare function f that contains a monomorphic IC for object |
| 3858 // originating from a different native context. | 3846 // originating from a different native context. |
| 3859 CcTest::global()->Set(v8_str("obj1"), obj1); | 3847 CcTest::global()->Set(v8_str("obj1"), obj1); |
| 3860 CompileRun("function f(o) { return o.x; } f(obj1); f(obj1);"); | 3848 CompileRun("function f(o) { return o.x; } f(obj1); f(obj1);"); |
| 3861 Handle<JSFunction> f = v8::Utils::OpenHandle( | 3849 Handle<JSFunction> f = Handle<JSFunction>::cast(v8::Utils::OpenHandle( |
| 3862 *v8::Handle<v8::Function>::Cast(CcTest::global()->Get(v8_str("f")))); | 3850 *v8::Handle<v8::Function>::Cast(CcTest::global()->Get(v8_str("f"))))); |
| 3863 | 3851 |
| 3864 Code* ic_before = FindFirstIC(f->shared()->code(), Code::LOAD_IC); | 3852 Code* ic_before = FindFirstIC(f->shared()->code(), Code::LOAD_IC); |
| 3865 CheckVectorIC(f, 0, MONOMORPHIC); | 3853 CheckVectorIC(f, 0, MONOMORPHIC); |
| 3866 CHECK(ic_before->ic_state() == DEFAULT); | 3854 CHECK(ic_before->ic_state() == DEFAULT); |
| 3867 | 3855 |
| 3868 // Fire context dispose notification. | 3856 // Fire context dispose notification. |
| 3869 CcTest::isolate()->ContextDisposedNotification(); | 3857 CcTest::isolate()->ContextDisposedNotification(); |
| 3870 SimulateIncrementalMarking(CcTest::heap()); | 3858 SimulateIncrementalMarking(CcTest::heap()); |
| 3871 CcTest::heap()->CollectAllGarbage(); | 3859 CcTest::heap()->CollectAllGarbage(); |
| 3872 | 3860 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 3892 LocalContext env; | 3880 LocalContext env; |
| 3893 CompileRun("function fun() { this.x = 2; }; var obj = new fun();"); | 3881 CompileRun("function fun() { this.x = 2; }; var obj = new fun();"); |
| 3894 obj2 = env->Global()->Get(v8_str("obj")); | 3882 obj2 = env->Global()->Get(v8_str("obj")); |
| 3895 } | 3883 } |
| 3896 | 3884 |
| 3897 // Prepare function f that contains a polymorphic IC for objects | 3885 // Prepare function f that contains a polymorphic IC for objects |
| 3898 // originating from two different native contexts. | 3886 // originating from two different native contexts. |
| 3899 CcTest::global()->Set(v8_str("obj1"), obj1); | 3887 CcTest::global()->Set(v8_str("obj1"), obj1); |
| 3900 CcTest::global()->Set(v8_str("obj2"), obj2); | 3888 CcTest::global()->Set(v8_str("obj2"), obj2); |
| 3901 CompileRun("function f(o) { return o.x; } f(obj1); f(obj1); f(obj2);"); | 3889 CompileRun("function f(o) { return o.x; } f(obj1); f(obj1); f(obj2);"); |
| 3902 Handle<JSFunction> f = v8::Utils::OpenHandle( | 3890 Handle<JSFunction> f = Handle<JSFunction>::cast(v8::Utils::OpenHandle( |
| 3903 *v8::Handle<v8::Function>::Cast(CcTest::global()->Get(v8_str("f")))); | 3891 *v8::Handle<v8::Function>::Cast(CcTest::global()->Get(v8_str("f"))))); |
| 3904 | 3892 |
| 3905 Code* ic_before = FindFirstIC(f->shared()->code(), Code::LOAD_IC); | 3893 Code* ic_before = FindFirstIC(f->shared()->code(), Code::LOAD_IC); |
| 3906 CheckVectorIC(f, 0, POLYMORPHIC); | 3894 CheckVectorIC(f, 0, POLYMORPHIC); |
| 3907 CHECK(ic_before->ic_state() == DEFAULT); | 3895 CHECK(ic_before->ic_state() == DEFAULT); |
| 3908 | 3896 |
| 3909 // Fire context dispose notification. | 3897 // Fire context dispose notification. |
| 3910 SimulateIncrementalMarking(CcTest::heap()); | 3898 SimulateIncrementalMarking(CcTest::heap()); |
| 3911 CcTest::heap()->CollectAllGarbage(); | 3899 CcTest::heap()->CollectAllGarbage(); |
| 3912 | 3900 |
| 3913 Code* ic_after = FindFirstIC(f->shared()->code(), Code::LOAD_IC); | 3901 Code* ic_after = FindFirstIC(f->shared()->code(), Code::LOAD_IC); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 3932 LocalContext env; | 3920 LocalContext env; |
| 3933 CompileRun("function fun() { this.x = 2; }; var obj = new fun();"); | 3921 CompileRun("function fun() { this.x = 2; }; var obj = new fun();"); |
| 3934 obj2 = env->Global()->Get(v8_str("obj")); | 3922 obj2 = env->Global()->Get(v8_str("obj")); |
| 3935 } | 3923 } |
| 3936 | 3924 |
| 3937 // Prepare function f that contains a polymorphic IC for objects | 3925 // Prepare function f that contains a polymorphic IC for objects |
| 3938 // originating from two different native contexts. | 3926 // originating from two different native contexts. |
| 3939 CcTest::global()->Set(v8_str("obj1"), obj1); | 3927 CcTest::global()->Set(v8_str("obj1"), obj1); |
| 3940 CcTest::global()->Set(v8_str("obj2"), obj2); | 3928 CcTest::global()->Set(v8_str("obj2"), obj2); |
| 3941 CompileRun("function f(o) { return o.x; } f(obj1); f(obj1); f(obj2);"); | 3929 CompileRun("function f(o) { return o.x; } f(obj1); f(obj1); f(obj2);"); |
| 3942 Handle<JSFunction> f = v8::Utils::OpenHandle( | 3930 Handle<JSFunction> f = Handle<JSFunction>::cast(v8::Utils::OpenHandle( |
| 3943 *v8::Handle<v8::Function>::Cast(CcTest::global()->Get(v8_str("f")))); | 3931 *v8::Handle<v8::Function>::Cast(CcTest::global()->Get(v8_str("f"))))); |
| 3944 | 3932 |
| 3945 Code* ic_before = FindFirstIC(f->shared()->code(), Code::LOAD_IC); | 3933 Code* ic_before = FindFirstIC(f->shared()->code(), Code::LOAD_IC); |
| 3946 CheckVectorIC(f, 0, POLYMORPHIC); | 3934 CheckVectorIC(f, 0, POLYMORPHIC); |
| 3947 CHECK(ic_before->ic_state() == DEFAULT); | 3935 CHECK(ic_before->ic_state() == DEFAULT); |
| 3948 | 3936 |
| 3949 // Fire context dispose notification. | 3937 // Fire context dispose notification. |
| 3950 CcTest::isolate()->ContextDisposedNotification(); | 3938 CcTest::isolate()->ContextDisposedNotification(); |
| 3951 SimulateIncrementalMarking(CcTest::heap()); | 3939 SimulateIncrementalMarking(CcTest::heap()); |
| 3952 CcTest::heap()->CollectAllGarbage(); | 3940 CcTest::heap()->CollectAllGarbage(); |
| 3953 | 3941 |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4088 " return function(x) { return x + 1; };" | 4076 " return function(x) { return x + 1; };" |
| 4089 "}" | 4077 "}" |
| 4090 "var f = mkClosure();" | 4078 "var f = mkClosure();" |
| 4091 "var g = mkClosure();" | 4079 "var g = mkClosure();" |
| 4092 "f(1); f(2);" | 4080 "f(1); f(2);" |
| 4093 "g(1); g(2);" | 4081 "g(1); g(2);" |
| 4094 "h(1); h(2);" | 4082 "h(1); h(2);" |
| 4095 "%OptimizeFunctionOnNextCall(f); f(3);" | 4083 "%OptimizeFunctionOnNextCall(f); f(3);" |
| 4096 "%OptimizeFunctionOnNextCall(h); h(3);"); | 4084 "%OptimizeFunctionOnNextCall(h); h(3);"); |
| 4097 | 4085 |
| 4098 Handle<JSFunction> f = | 4086 Handle<JSFunction> f = Handle<JSFunction>::cast(v8::Utils::OpenHandle( |
| 4099 v8::Utils::OpenHandle( | 4087 *v8::Handle<v8::Function>::Cast(CcTest::global()->Get(v8_str("f"))))); |
| 4100 *v8::Handle<v8::Function>::Cast( | |
| 4101 CcTest::global()->Get(v8_str("f")))); | |
| 4102 CHECK(f->is_compiled()); | 4088 CHECK(f->is_compiled()); |
| 4103 CompileRun("f = null;"); | 4089 CompileRun("f = null;"); |
| 4104 | 4090 |
| 4105 Handle<JSFunction> g = | 4091 Handle<JSFunction> g = Handle<JSFunction>::cast(v8::Utils::OpenHandle( |
| 4106 v8::Utils::OpenHandle( | 4092 *v8::Handle<v8::Function>::Cast(CcTest::global()->Get(v8_str("g"))))); |
| 4107 *v8::Handle<v8::Function>::Cast( | |
| 4108 CcTest::global()->Get(v8_str("g")))); | |
| 4109 CHECK(g->is_compiled()); | 4093 CHECK(g->is_compiled()); |
| 4110 const int kAgingThreshold = 6; | 4094 const int kAgingThreshold = 6; |
| 4111 for (int i = 0; i < kAgingThreshold; i++) { | 4095 for (int i = 0; i < kAgingThreshold; i++) { |
| 4112 g->code()->MakeOlder(static_cast<MarkingParity>(i % 2)); | 4096 g->code()->MakeOlder(static_cast<MarkingParity>(i % 2)); |
| 4113 } | 4097 } |
| 4114 | 4098 |
| 4115 code = inner_scope.CloseAndEscape(Handle<Code>(f->code())); | 4099 code = inner_scope.CloseAndEscape(Handle<Code>(f->code())); |
| 4116 } | 4100 } |
| 4117 | 4101 |
| 4118 // Simulate incremental marking so that the functions are enqueued as | 4102 // Simulate incremental marking so that the functions are enqueued as |
| (...skipping 23 matching lines...) Expand all Loading... |
| 4142 // but make sure the optimized code is unreachable. | 4126 // but make sure the optimized code is unreachable. |
| 4143 { | 4127 { |
| 4144 HandleScope inner_scope(isolate); | 4128 HandleScope inner_scope(isolate); |
| 4145 CompileRun("function mkClosure() {" | 4129 CompileRun("function mkClosure() {" |
| 4146 " return function(x) { return x + 1; };" | 4130 " return function(x) { return x + 1; };" |
| 4147 "}" | 4131 "}" |
| 4148 "var f = mkClosure();" | 4132 "var f = mkClosure();" |
| 4149 "f(1); f(2);" | 4133 "f(1); f(2);" |
| 4150 "%OptimizeFunctionOnNextCall(f); f(3);"); | 4134 "%OptimizeFunctionOnNextCall(f); f(3);"); |
| 4151 | 4135 |
| 4152 Handle<JSFunction> f = | 4136 Handle<JSFunction> f = Handle<JSFunction>::cast(v8::Utils::OpenHandle( |
| 4153 v8::Utils::OpenHandle( | 4137 *v8::Handle<v8::Function>::Cast(CcTest::global()->Get(v8_str("f"))))); |
| 4154 *v8::Handle<v8::Function>::Cast( | |
| 4155 CcTest::global()->Get(v8_str("f")))); | |
| 4156 CHECK(f->is_compiled()); | 4138 CHECK(f->is_compiled()); |
| 4157 const int kAgingThreshold = 6; | 4139 const int kAgingThreshold = 6; |
| 4158 for (int i = 0; i < kAgingThreshold; i++) { | 4140 for (int i = 0; i < kAgingThreshold; i++) { |
| 4159 f->shared()->code()->MakeOlder(static_cast<MarkingParity>(i % 2)); | 4141 f->shared()->code()->MakeOlder(static_cast<MarkingParity>(i % 2)); |
| 4160 } | 4142 } |
| 4161 | 4143 |
| 4162 CompileRun("f = null;"); | 4144 CompileRun("f = null;"); |
| 4163 } | 4145 } |
| 4164 | 4146 |
| 4165 // Simulate incremental marking so that unoptimized code is flushed | 4147 // Simulate incremental marking so that unoptimized code is flushed |
| (...skipping 23 matching lines...) Expand all Loading... |
| 4189 // the unoptimized code will be replaced during optimization. | 4171 // the unoptimized code will be replaced during optimization. |
| 4190 Handle<SharedFunctionInfo> shared1; | 4172 Handle<SharedFunctionInfo> shared1; |
| 4191 { | 4173 { |
| 4192 HandleScope inner_scope(isolate); | 4174 HandleScope inner_scope(isolate); |
| 4193 CompileRun("function f() { return 'foobar'; }" | 4175 CompileRun("function f() { return 'foobar'; }" |
| 4194 "function g(x) { if (x) f(); }" | 4176 "function g(x) { if (x) f(); }" |
| 4195 "f();" | 4177 "f();" |
| 4196 "g(false);" | 4178 "g(false);" |
| 4197 "g(false);"); | 4179 "g(false);"); |
| 4198 | 4180 |
| 4199 Handle<JSFunction> f = | 4181 Handle<JSFunction> f = Handle<JSFunction>::cast(v8::Utils::OpenHandle( |
| 4200 v8::Utils::OpenHandle( | 4182 *v8::Handle<v8::Function>::Cast(CcTest::global()->Get(v8_str("f"))))); |
| 4201 *v8::Handle<v8::Function>::Cast( | |
| 4202 CcTest::global()->Get(v8_str("f")))); | |
| 4203 CHECK(f->is_compiled()); | 4183 CHECK(f->is_compiled()); |
| 4204 const int kAgingThreshold = 6; | 4184 const int kAgingThreshold = 6; |
| 4205 for (int i = 0; i < kAgingThreshold; i++) { | 4185 for (int i = 0; i < kAgingThreshold; i++) { |
| 4206 f->shared()->code()->MakeOlder(static_cast<MarkingParity>(i % 2)); | 4186 f->shared()->code()->MakeOlder(static_cast<MarkingParity>(i % 2)); |
| 4207 } | 4187 } |
| 4208 | 4188 |
| 4209 shared1 = inner_scope.CloseAndEscape(handle(f->shared(), isolate)); | 4189 shared1 = inner_scope.CloseAndEscape(handle(f->shared(), isolate)); |
| 4210 } | 4190 } |
| 4211 | 4191 |
| 4212 // Prepare a shared function info eligible for code flushing that will | 4192 // Prepare a shared function info eligible for code flushing that will |
| 4213 // represent the dangling tail of the candidate list. | 4193 // represent the dangling tail of the candidate list. |
| 4214 Handle<SharedFunctionInfo> shared2; | 4194 Handle<SharedFunctionInfo> shared2; |
| 4215 { | 4195 { |
| 4216 HandleScope inner_scope(isolate); | 4196 HandleScope inner_scope(isolate); |
| 4217 CompileRun("function flushMe() { return 0; }" | 4197 CompileRun("function flushMe() { return 0; }" |
| 4218 "flushMe(1);"); | 4198 "flushMe(1);"); |
| 4219 | 4199 |
| 4220 Handle<JSFunction> f = | 4200 Handle<JSFunction> f = Handle<JSFunction>::cast( |
| 4221 v8::Utils::OpenHandle( | 4201 v8::Utils::OpenHandle(*v8::Handle<v8::Function>::Cast( |
| 4222 *v8::Handle<v8::Function>::Cast( | 4202 CcTest::global()->Get(v8_str("flushMe"))))); |
| 4223 CcTest::global()->Get(v8_str("flushMe")))); | |
| 4224 CHECK(f->is_compiled()); | 4203 CHECK(f->is_compiled()); |
| 4225 const int kAgingThreshold = 6; | 4204 const int kAgingThreshold = 6; |
| 4226 for (int i = 0; i < kAgingThreshold; i++) { | 4205 for (int i = 0; i < kAgingThreshold; i++) { |
| 4227 f->shared()->code()->MakeOlder(static_cast<MarkingParity>(i % 2)); | 4206 f->shared()->code()->MakeOlder(static_cast<MarkingParity>(i % 2)); |
| 4228 } | 4207 } |
| 4229 | 4208 |
| 4230 shared2 = inner_scope.CloseAndEscape(handle(f->shared(), isolate)); | 4209 shared2 = inner_scope.CloseAndEscape(handle(f->shared(), isolate)); |
| 4231 } | 4210 } |
| 4232 | 4211 |
| 4233 // Simulate incremental marking and collect code flushing candidates. | 4212 // Simulate incremental marking and collect code flushing candidates. |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4329 Heap* heap = isolate->heap(); | 4308 Heap* heap = isolate->heap(); |
| 4330 HandleScope scope(isolate); | 4309 HandleScope scope(isolate); |
| 4331 | 4310 |
| 4332 // Prepare function whose optimized code map we can use. | 4311 // Prepare function whose optimized code map we can use. |
| 4333 Handle<SharedFunctionInfo> shared; | 4312 Handle<SharedFunctionInfo> shared; |
| 4334 { | 4313 { |
| 4335 HandleScope inner_scope(isolate); | 4314 HandleScope inner_scope(isolate); |
| 4336 CompileRun("function f() { return 1 }" | 4315 CompileRun("function f() { return 1 }" |
| 4337 "f(); %OptimizeFunctionOnNextCall(f); f();"); | 4316 "f(); %OptimizeFunctionOnNextCall(f); f();"); |
| 4338 | 4317 |
| 4339 Handle<JSFunction> f = | 4318 Handle<JSFunction> f = Handle<JSFunction>::cast(v8::Utils::OpenHandle( |
| 4340 v8::Utils::OpenHandle( | 4319 *v8::Handle<v8::Function>::Cast(CcTest::global()->Get(v8_str("f"))))); |
| 4341 *v8::Handle<v8::Function>::Cast( | |
| 4342 CcTest::global()->Get(v8_str("f")))); | |
| 4343 shared = inner_scope.CloseAndEscape(handle(f->shared(), isolate)); | 4320 shared = inner_scope.CloseAndEscape(handle(f->shared(), isolate)); |
| 4344 CompileRun("f = null"); | 4321 CompileRun("f = null"); |
| 4345 } | 4322 } |
| 4346 | 4323 |
| 4347 // Prepare optimized code that we can use. | 4324 // Prepare optimized code that we can use. |
| 4348 Handle<Code> code; | 4325 Handle<Code> code; |
| 4349 { | 4326 { |
| 4350 HandleScope inner_scope(isolate); | 4327 HandleScope inner_scope(isolate); |
| 4351 CompileRun("function g() { return 2 }" | 4328 CompileRun("function g() { return 2 }" |
| 4352 "g(); %OptimizeFunctionOnNextCall(g); g();"); | 4329 "g(); %OptimizeFunctionOnNextCall(g); g();"); |
| 4353 | 4330 |
| 4354 Handle<JSFunction> g = | 4331 Handle<JSFunction> g = Handle<JSFunction>::cast(v8::Utils::OpenHandle( |
| 4355 v8::Utils::OpenHandle( | 4332 *v8::Handle<v8::Function>::Cast(CcTest::global()->Get(v8_str("g"))))); |
| 4356 *v8::Handle<v8::Function>::Cast( | |
| 4357 CcTest::global()->Get(v8_str("g")))); | |
| 4358 code = inner_scope.CloseAndEscape(handle(g->code(), isolate)); | 4333 code = inner_scope.CloseAndEscape(handle(g->code(), isolate)); |
| 4359 if (!code->is_optimized_code()) return; | 4334 if (!code->is_optimized_code()) return; |
| 4360 } | 4335 } |
| 4361 | 4336 |
| 4362 Handle<TypeFeedbackVector> vector = handle(shared->feedback_vector()); | 4337 Handle<TypeFeedbackVector> vector = handle(shared->feedback_vector()); |
| 4363 Handle<LiteralsArray> lit = | 4338 Handle<LiteralsArray> lit = |
| 4364 LiteralsArray::New(isolate, vector, shared->num_literals(), TENURED); | 4339 LiteralsArray::New(isolate, vector, shared->num_literals(), TENURED); |
| 4365 Handle<Context> context(isolate->context()); | 4340 Handle<Context> context(isolate->context()); |
| 4366 | 4341 |
| 4367 // Add the new code several times to the optimized code map and also set an | 4342 // Add the new code several times to the optimized code map and also set an |
| (...skipping 19 matching lines...) Expand all Loading... |
| 4387 // Perfrom one initial GC to enable code flushing. | 4362 // Perfrom one initial GC to enable code flushing. |
| 4388 CcTest::heap()->CollectAllGarbage(); | 4363 CcTest::heap()->CollectAllGarbage(); |
| 4389 | 4364 |
| 4390 // Prepare function whose optimized code map we can use. | 4365 // Prepare function whose optimized code map we can use. |
| 4391 Handle<SharedFunctionInfo> shared; | 4366 Handle<SharedFunctionInfo> shared; |
| 4392 { | 4367 { |
| 4393 HandleScope inner_scope(isolate); | 4368 HandleScope inner_scope(isolate); |
| 4394 CompileRun("function f() { return 1 }" | 4369 CompileRun("function f() { return 1 }" |
| 4395 "f(); %OptimizeFunctionOnNextCall(f); f();"); | 4370 "f(); %OptimizeFunctionOnNextCall(f); f();"); |
| 4396 | 4371 |
| 4397 Handle<JSFunction> f = | 4372 Handle<JSFunction> f = Handle<JSFunction>::cast(v8::Utils::OpenHandle( |
| 4398 v8::Utils::OpenHandle( | 4373 *v8::Handle<v8::Function>::Cast(CcTest::global()->Get(v8_str("f"))))); |
| 4399 *v8::Handle<v8::Function>::Cast( | |
| 4400 CcTest::global()->Get(v8_str("f")))); | |
| 4401 shared = inner_scope.CloseAndEscape(handle(f->shared(), isolate)); | 4374 shared = inner_scope.CloseAndEscape(handle(f->shared(), isolate)); |
| 4402 CompileRun("f = null"); | 4375 CompileRun("f = null"); |
| 4403 } | 4376 } |
| 4404 | 4377 |
| 4405 // Prepare optimized code that we can use. | 4378 // Prepare optimized code that we can use. |
| 4406 Handle<Code> code; | 4379 Handle<Code> code; |
| 4407 { | 4380 { |
| 4408 HandleScope inner_scope(isolate); | 4381 HandleScope inner_scope(isolate); |
| 4409 CompileRun("function g() { return 2 }" | 4382 CompileRun("function g() { return 2 }" |
| 4410 "g(); %OptimizeFunctionOnNextCall(g); g();"); | 4383 "g(); %OptimizeFunctionOnNextCall(g); g();"); |
| 4411 | 4384 |
| 4412 Handle<JSFunction> g = | 4385 Handle<JSFunction> g = Handle<JSFunction>::cast(v8::Utils::OpenHandle( |
| 4413 v8::Utils::OpenHandle( | 4386 *v8::Handle<v8::Function>::Cast(CcTest::global()->Get(v8_str("g"))))); |
| 4414 *v8::Handle<v8::Function>::Cast( | |
| 4415 CcTest::global()->Get(v8_str("g")))); | |
| 4416 code = inner_scope.CloseAndEscape(handle(g->code(), isolate)); | 4387 code = inner_scope.CloseAndEscape(handle(g->code(), isolate)); |
| 4417 if (!code->is_optimized_code()) return; | 4388 if (!code->is_optimized_code()) return; |
| 4418 } | 4389 } |
| 4419 | 4390 |
| 4420 Handle<TypeFeedbackVector> vector = handle(shared->feedback_vector()); | 4391 Handle<TypeFeedbackVector> vector = handle(shared->feedback_vector()); |
| 4421 Handle<LiteralsArray> lit = | 4392 Handle<LiteralsArray> lit = |
| 4422 LiteralsArray::New(isolate, vector, shared->num_literals(), TENURED); | 4393 LiteralsArray::New(isolate, vector, shared->num_literals(), TENURED); |
| 4423 Handle<Context> context(isolate->context()); | 4394 Handle<Context> context(isolate->context()); |
| 4424 | 4395 |
| 4425 // Add the code several times to the optimized code map. | 4396 // Add the code several times to the optimized code map. |
| (...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4629 AllocationSite::cast(heap->allocation_sites_list()))); | 4600 AllocationSite::cast(heap->allocation_sites_list()))); |
| 4630 | 4601 |
| 4631 CompileRun("%OptimizeFunctionOnNextCall(bar); bar();"); | 4602 CompileRun("%OptimizeFunctionOnNextCall(bar); bar();"); |
| 4632 | 4603 |
| 4633 DependentCode::GroupStartIndexes starts(site->dependent_code()); | 4604 DependentCode::GroupStartIndexes starts(site->dependent_code()); |
| 4634 CHECK_GE(starts.number_of_entries(), 1); | 4605 CHECK_GE(starts.number_of_entries(), 1); |
| 4635 int index = starts.at(DependentCode::kAllocationSiteTransitionChangedGroup); | 4606 int index = starts.at(DependentCode::kAllocationSiteTransitionChangedGroup); |
| 4636 CHECK(site->dependent_code()->object_at(index)->IsWeakCell()); | 4607 CHECK(site->dependent_code()->object_at(index)->IsWeakCell()); |
| 4637 Code* function_bar = Code::cast( | 4608 Code* function_bar = Code::cast( |
| 4638 WeakCell::cast(site->dependent_code()->object_at(index))->value()); | 4609 WeakCell::cast(site->dependent_code()->object_at(index))->value()); |
| 4639 Handle<JSFunction> bar_handle = | 4610 Handle<JSFunction> bar_handle = Handle<JSFunction>::cast( |
| 4640 v8::Utils::OpenHandle( | 4611 v8::Utils::OpenHandle(*v8::Handle<v8::Function>::Cast( |
| 4641 *v8::Handle<v8::Function>::Cast( | 4612 CcTest::global()->Get(v8_str("bar"))))); |
| 4642 CcTest::global()->Get(v8_str("bar")))); | |
| 4643 CHECK_EQ(bar_handle->code(), function_bar); | 4613 CHECK_EQ(bar_handle->code(), function_bar); |
| 4644 } | 4614 } |
| 4645 | 4615 |
| 4646 // Now make sure that a gc should get rid of the function, even though we | 4616 // Now make sure that a gc should get rid of the function, even though we |
| 4647 // still have the allocation site alive. | 4617 // still have the allocation site alive. |
| 4648 for (int i = 0; i < 4; i++) { | 4618 for (int i = 0; i < 4; i++) { |
| 4649 heap->CollectAllGarbage(); | 4619 heap->CollectAllGarbage(); |
| 4650 } | 4620 } |
| 4651 | 4621 |
| 4652 // The site still exists because of our global handle, but the code is no | 4622 // The site still exists because of our global handle, but the code is no |
| (...skipping 25 matching lines...) Expand all Loading... |
| 4678 " return foo(1);" | 4648 " return foo(1);" |
| 4679 " };" | 4649 " };" |
| 4680 " var foo = function(x) { with (x) { return 1 + x; } };" | 4650 " var foo = function(x) { with (x) { return 1 + x; } };" |
| 4681 " bar(foo);" | 4651 " bar(foo);" |
| 4682 " bar(foo);" | 4652 " bar(foo);" |
| 4683 " bar(foo);" | 4653 " bar(foo);" |
| 4684 " %OptimizeFunctionOnNextCall(bar);" | 4654 " %OptimizeFunctionOnNextCall(bar);" |
| 4685 " bar(foo);" | 4655 " bar(foo);" |
| 4686 " return bar;})();"); | 4656 " return bar;})();"); |
| 4687 | 4657 |
| 4688 Handle<JSFunction> bar = | 4658 Handle<JSFunction> bar = Handle<JSFunction>::cast(v8::Utils::OpenHandle( |
| 4689 v8::Utils::OpenHandle( | 4659 *v8::Handle<v8::Function>::Cast(CcTest::global()->Get(v8_str("bar"))))); |
| 4690 *v8::Handle<v8::Function>::Cast( | |
| 4691 CcTest::global()->Get(v8_str("bar")))); | |
| 4692 code = scope.CloseAndEscape(Handle<Code>(bar->code())); | 4660 code = scope.CloseAndEscape(Handle<Code>(bar->code())); |
| 4693 } | 4661 } |
| 4694 | 4662 |
| 4695 // Now make sure that a gc should get rid of the function | 4663 // Now make sure that a gc should get rid of the function |
| 4696 for (int i = 0; i < 4; i++) { | 4664 for (int i = 0; i < 4; i++) { |
| 4697 heap->CollectAllGarbage(); | 4665 heap->CollectAllGarbage(); |
| 4698 } | 4666 } |
| 4699 | 4667 |
| 4700 DCHECK(code->marked_for_deoptimization()); | 4668 DCHECK(code->marked_for_deoptimization()); |
| 4701 } | 4669 } |
| (...skipping 17 matching lines...) Expand all Loading... |
| 4719 CompileRun("function bar() {" | 4687 CompileRun("function bar() {" |
| 4720 " return foo(1);" | 4688 " return foo(1);" |
| 4721 "};" | 4689 "};" |
| 4722 "function foo(x) { with (x) { return 1 + x; } };" | 4690 "function foo(x) { with (x) { return 1 + x; } };" |
| 4723 "bar();" | 4691 "bar();" |
| 4724 "bar();" | 4692 "bar();" |
| 4725 "bar();" | 4693 "bar();" |
| 4726 "%OptimizeFunctionOnNextCall(bar);" | 4694 "%OptimizeFunctionOnNextCall(bar);" |
| 4727 "bar();"); | 4695 "bar();"); |
| 4728 | 4696 |
| 4729 Handle<JSFunction> bar = | 4697 Handle<JSFunction> bar = Handle<JSFunction>::cast(v8::Utils::OpenHandle( |
| 4730 v8::Utils::OpenHandle( | 4698 *v8::Handle<v8::Function>::Cast(CcTest::global()->Get(v8_str("bar"))))); |
| 4731 *v8::Handle<v8::Function>::Cast( | |
| 4732 CcTest::global()->Get(v8_str("bar")))); | |
| 4733 code = scope.CloseAndEscape(Handle<Code>(bar->code())); | 4699 code = scope.CloseAndEscape(Handle<Code>(bar->code())); |
| 4734 } | 4700 } |
| 4735 | 4701 |
| 4736 // Now make sure that a gc should get rid of the function | 4702 // Now make sure that a gc should get rid of the function |
| 4737 for (int i = 0; i < 4; i++) { | 4703 for (int i = 0; i < 4; i++) { |
| 4738 heap->CollectAllGarbage(); | 4704 heap->CollectAllGarbage(); |
| 4739 } | 4705 } |
| 4740 | 4706 |
| 4741 DCHECK(code->marked_for_deoptimization()); | 4707 DCHECK(code->marked_for_deoptimization()); |
| 4742 } | 4708 } |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4794 | 4760 |
| 4795 | 4761 |
| 4796 static Handle<JSFunction> OptimizeDummyFunction(const char* name) { | 4762 static Handle<JSFunction> OptimizeDummyFunction(const char* name) { |
| 4797 EmbeddedVector<char, 256> source; | 4763 EmbeddedVector<char, 256> source; |
| 4798 SNPrintF(source, | 4764 SNPrintF(source, |
| 4799 "function %s() { return 0; }" | 4765 "function %s() { return 0; }" |
| 4800 "%s(); %s();" | 4766 "%s(); %s();" |
| 4801 "%%OptimizeFunctionOnNextCall(%s);" | 4767 "%%OptimizeFunctionOnNextCall(%s);" |
| 4802 "%s();", name, name, name, name, name); | 4768 "%s();", name, name, name, name, name); |
| 4803 CompileRun(source.start()); | 4769 CompileRun(source.start()); |
| 4804 Handle<JSFunction> fun = | 4770 Handle<JSFunction> fun = Handle<JSFunction>::cast(v8::Utils::OpenHandle( |
| 4805 v8::Utils::OpenHandle( | 4771 *v8::Handle<v8::Function>::Cast(CcTest::global()->Get(v8_str(name))))); |
| 4806 *v8::Handle<v8::Function>::Cast( | |
| 4807 CcTest::global()->Get(v8_str(name)))); | |
| 4808 return fun; | 4772 return fun; |
| 4809 } | 4773 } |
| 4810 | 4774 |
| 4811 | 4775 |
| 4812 static int GetCodeChainLength(Code* code) { | 4776 static int GetCodeChainLength(Code* code) { |
| 4813 int result = 0; | 4777 int result = 0; |
| 4814 while (code->next_code_link()->IsCode()) { | 4778 while (code->next_code_link()->IsCode()) { |
| 4815 result++; | 4779 result++; |
| 4816 code = Code::cast(code->next_code_link()); | 4780 code = Code::cast(code->next_code_link()); |
| 4817 } | 4781 } |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4903 TEST(WeakFunctionInConstructor) { | 4867 TEST(WeakFunctionInConstructor) { |
| 4904 if (i::FLAG_always_opt) return; | 4868 if (i::FLAG_always_opt) return; |
| 4905 i::FLAG_stress_compaction = false; | 4869 i::FLAG_stress_compaction = false; |
| 4906 CcTest::InitializeVM(); | 4870 CcTest::InitializeVM(); |
| 4907 v8::Isolate* isolate = CcTest::isolate(); | 4871 v8::Isolate* isolate = CcTest::isolate(); |
| 4908 v8::HandleScope scope(isolate); | 4872 v8::HandleScope scope(isolate); |
| 4909 CompileRun( | 4873 CompileRun( |
| 4910 "function createObj(obj) {" | 4874 "function createObj(obj) {" |
| 4911 " return new obj();" | 4875 " return new obj();" |
| 4912 "}"); | 4876 "}"); |
| 4913 Handle<JSFunction> createObj = | 4877 Handle<JSFunction> createObj = Handle<JSFunction>::cast( |
| 4914 v8::Utils::OpenHandle(*v8::Handle<v8::Function>::Cast( | 4878 v8::Utils::OpenHandle(*v8::Handle<v8::Function>::Cast( |
| 4915 CcTest::global()->Get(v8_str("createObj")))); | 4879 CcTest::global()->Get(v8_str("createObj"))))); |
| 4916 | 4880 |
| 4917 v8::Persistent<v8::Object> garbage; | 4881 v8::Persistent<v8::Object> garbage; |
| 4918 { | 4882 { |
| 4919 v8::HandleScope scope(isolate); | 4883 v8::HandleScope scope(isolate); |
| 4920 const char* source = | 4884 const char* source = |
| 4921 " (function() {" | 4885 " (function() {" |
| 4922 " function hat() { this.x = 5; }" | 4886 " function hat() { this.x = 5; }" |
| 4923 " createObj(hat);" | 4887 " createObj(hat);" |
| 4924 " createObj(hat);" | 4888 " createObj(hat);" |
| 4925 " return hat;" | 4889 " return hat;" |
| (...skipping 984 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5910 | 5874 |
| 5911 CHECK(utils_has_been_collected); | 5875 CHECK(utils_has_been_collected); |
| 5912 } | 5876 } |
| 5913 | 5877 |
| 5914 | 5878 |
| 5915 TEST(Regress1878) { | 5879 TEST(Regress1878) { |
| 5916 FLAG_allow_natives_syntax = true; | 5880 FLAG_allow_natives_syntax = true; |
| 5917 CcTest::InitializeVM(); | 5881 CcTest::InitializeVM(); |
| 5918 v8::Isolate* isolate = CcTest::isolate(); | 5882 v8::Isolate* isolate = CcTest::isolate(); |
| 5919 v8::HandleScope scope(isolate); | 5883 v8::HandleScope scope(isolate); |
| 5920 v8::Local<v8::Function> constructor = | 5884 v8::Local<v8::Function> constructor = v8::Utils::FunctionToLocal( |
| 5921 v8::Utils::ToLocal(CcTest::i_isolate()->internal_array_function()); | 5885 CcTest::i_isolate()->internal_array_function()); |
| 5922 CcTest::global()->Set(v8_str("InternalArray"), constructor); | 5886 CcTest::global()->Set(v8_str("InternalArray"), constructor); |
| 5923 | 5887 |
| 5924 v8::TryCatch try_catch(isolate); | 5888 v8::TryCatch try_catch(isolate); |
| 5925 | 5889 |
| 5926 CompileRun( | 5890 CompileRun( |
| 5927 "var a = Array();" | 5891 "var a = Array();" |
| 5928 "for (var i = 0; i < 1000; i++) {" | 5892 "for (var i = 0; i < 1000; i++) {" |
| 5929 " var ai = new InternalArray(10000);" | 5893 " var ai = new InternalArray(10000);" |
| 5930 " if (%HaveSameMap(ai, a)) throw Error();" | 5894 " if (%HaveSameMap(ai, a)) throw Error();" |
| 5931 " if (!%HasFastObjectElements(ai)) throw Error();" | 5895 " if (!%HasFastObjectElements(ai)) throw Error();" |
| (...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6316 // The CollectGarbage call above starts sweeper threads. | 6280 // The CollectGarbage call above starts sweeper threads. |
| 6317 // The crash will happen if the following two functions | 6281 // The crash will happen if the following two functions |
| 6318 // are called before sweeping finishes. | 6282 // are called before sweeping finishes. |
| 6319 heap->StartIncrementalMarking(); | 6283 heap->StartIncrementalMarking(); |
| 6320 heap->FinalizeIncrementalMarkingIfComplete("test"); | 6284 heap->FinalizeIncrementalMarkingIfComplete("test"); |
| 6321 } | 6285 } |
| 6322 | 6286 |
| 6323 | 6287 |
| 6324 } // namespace internal | 6288 } // namespace internal |
| 6325 } // namespace v8 | 6289 } // namespace v8 |
| OLD | NEW |