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 3646 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3657 for (int i = 0; i < 4; i++) { | 3657 for (int i = 0; i < 4; i++) { |
3658 heap->CollectAllGarbage(false); | 3658 heap->CollectAllGarbage(false); |
3659 } | 3659 } |
3660 | 3660 |
3661 // The site still exists because of our global handle, but the code is no | 3661 // The site still exists because of our global handle, but the code is no |
3662 // longer referred to by dependent_code(). | 3662 // longer referred to by dependent_code(). |
3663 DependentCode::GroupStartIndexes starts(site->dependent_code()); | 3663 DependentCode::GroupStartIndexes starts(site->dependent_code()); |
3664 int index = starts.at(DependentCode::kAllocationSiteTransitionChangedGroup); | 3664 int index = starts.at(DependentCode::kAllocationSiteTransitionChangedGroup); |
3665 CHECK(!(site->dependent_code()->is_code_at(index))); | 3665 CHECK(!(site->dependent_code()->is_code_at(index))); |
3666 } | 3666 } |
3667 | |
3668 | |
3669 TEST(CellsInOptimizedCodeAreWeak) { | |
3670 if (i::FLAG_always_opt || !i::FLAG_crankshaft) return; | |
3671 i::FLAG_weak_embedded_objects_in_optimized_code = true; | |
3672 i::FLAG_allow_natives_syntax = true; | |
3673 CcTest::InitializeVM(); | |
3674 Isolate* isolate = CcTest::i_isolate(); | |
3675 v8::internal::Heap* heap = CcTest::heap(); | |
3676 | |
3677 if (!isolate->use_crankshaft()) return; | |
3678 HandleScope outer_scope(heap->isolate()); | |
3679 Handle<Code> code; | |
3680 { | |
3681 LocalContext context; | |
3682 HandleScope scope(heap->isolate()); | |
3683 | |
3684 CompileRun("bar = (function() {" | |
3685 " function bar() {" | |
3686 " return foo(1);" | |
3687 " };" | |
3688 " var foo = function(x) { with (x) { return 1 + x; } };" | |
3689 " bar(foo);" | |
3690 " bar(foo);" | |
3691 " bar(foo);" | |
3692 " %OptimizeFunctionOnNextCall(bar);" | |
3693 " bar(foo);" | |
3694 " return bar;})();"); | |
3695 | |
3696 Handle<JSFunction> bar = | |
3697 v8::Utils::OpenHandle( | |
3698 *v8::Handle<v8::Function>::Cast( | |
3699 CcTest::global()->Get(v8_str("bar")))); | |
3700 code = scope.CloseAndEscape(Handle<Code>(bar->code())); | |
3701 } | |
3702 | |
3703 // Now make sure that a gc should get rid of the function | |
3704 for (int i = 0; i < 4; i++) { | |
3705 heap->CollectAllGarbage(false); | |
Hannes Payer (out of office)
2014/01/14 15:04:19
Is calling 3 times the GC not good enough? Moreove
ulan
2014/01/14 17:14:00
I am passing Heap::kAbortIncrementalMarkingMask no
| |
3706 } | |
3707 | |
3708 ASSERT(code->marked_for_deoptimization()); | |
3709 } | |
3710 | |
3711 | |
3712 TEST(ObjectsInOptimizedCodeAreWeak) { | |
3713 if (i::FLAG_always_opt || !i::FLAG_crankshaft) return; | |
3714 i::FLAG_weak_embedded_objects_in_optimized_code = true; | |
3715 i::FLAG_allow_natives_syntax = true; | |
3716 CcTest::InitializeVM(); | |
3717 Isolate* isolate = CcTest::i_isolate(); | |
3718 v8::internal::Heap* heap = CcTest::heap(); | |
3719 | |
3720 if (!isolate->use_crankshaft()) return; | |
3721 HandleScope outer_scope(heap->isolate()); | |
3722 Handle<Code> code; | |
3723 { | |
3724 LocalContext context; | |
3725 HandleScope scope(heap->isolate()); | |
3726 | |
3727 CompileRun("function bar() {" | |
3728 " return foo(1);" | |
3729 "};" | |
3730 "function foo(x) { with (x) { return 1 + x; } };" | |
3731 "bar();" | |
3732 "bar();" | |
3733 "bar();" | |
3734 "%OptimizeFunctionOnNextCall(bar);" | |
3735 "bar();"); | |
3736 | |
3737 Handle<JSFunction> bar = | |
3738 v8::Utils::OpenHandle( | |
3739 *v8::Handle<v8::Function>::Cast( | |
3740 CcTest::global()->Get(v8_str("bar")))); | |
3741 code = scope.CloseAndEscape(Handle<Code>(bar->code())); | |
3742 } | |
3743 | |
3744 // Now make sure that a gc should get rid of the function | |
3745 for (int i = 0; i < 10; i++) { | |
3746 heap->CollectAllGarbage(false); | |
Hannes Payer (out of office)
2014/01/14 15:04:19
Same as above.
| |
3747 } | |
3748 | |
3749 ASSERT(code->marked_for_deoptimization()); | |
3750 } | |
OLD | NEW |