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 4798 matching lines...) Loading... |
4809 } | 4809 } |
4810 | 4810 |
4811 // Now make sure that a gc should get rid of the function | 4811 // Now make sure that a gc should get rid of the function |
4812 for (int i = 0; i < 4; i++) { | 4812 for (int i = 0; i < 4; i++) { |
4813 heap->CollectAllGarbage(); | 4813 heap->CollectAllGarbage(); |
4814 } | 4814 } |
4815 | 4815 |
4816 CHECK(code->marked_for_deoptimization()); | 4816 CHECK(code->marked_for_deoptimization()); |
4817 } | 4817 } |
4818 | 4818 |
| 4819 TEST(NewSpaceObjectsInOptimizedCode) { |
| 4820 if (i::FLAG_always_opt || !i::FLAG_crankshaft || i::FLAG_turbo) return; |
| 4821 i::FLAG_weak_embedded_objects_in_optimized_code = true; |
| 4822 i::FLAG_allow_natives_syntax = true; |
| 4823 CcTest::InitializeVM(); |
| 4824 Isolate* isolate = CcTest::i_isolate(); |
| 4825 v8::internal::Heap* heap = CcTest::heap(); |
| 4826 |
| 4827 if (!isolate->use_crankshaft()) return; |
| 4828 HandleScope outer_scope(heap->isolate()); |
| 4829 Handle<Code> code; |
| 4830 { |
| 4831 LocalContext context; |
| 4832 HandleScope scope(heap->isolate()); |
| 4833 |
| 4834 CompileRun( |
| 4835 "var foo;" |
| 4836 "var bar;" |
| 4837 "(function() {" |
| 4838 " function foo_func(x) { with (x) { return 1 + x; } };" |
| 4839 " %NeverOptimizeFunction(foo_func);" |
| 4840 " function bar_func() {" |
| 4841 " return foo(1);" |
| 4842 " };" |
| 4843 " bar = bar_func;" |
| 4844 " foo = foo_func;" |
| 4845 " bar_func();" |
| 4846 " bar_func();" |
| 4847 " bar_func();" |
| 4848 " %OptimizeFunctionOnNextCall(bar_func);" |
| 4849 " bar_func();" |
| 4850 "})();"); |
| 4851 |
| 4852 Handle<JSFunction> bar = Handle<JSFunction>::cast(v8::Utils::OpenHandle( |
| 4853 *v8::Local<v8::Function>::Cast(CcTest::global() |
| 4854 ->Get(context.local(), v8_str("bar")) |
| 4855 .ToLocalChecked()))); |
| 4856 |
| 4857 Handle<JSFunction> foo = Handle<JSFunction>::cast(v8::Utils::OpenHandle( |
| 4858 *v8::Local<v8::Function>::Cast(CcTest::global() |
| 4859 ->Get(context.local(), v8_str("foo")) |
| 4860 .ToLocalChecked()))); |
| 4861 |
| 4862 CHECK(heap->InNewSpace(*foo)); |
| 4863 heap->CollectGarbage(NEW_SPACE); |
| 4864 heap->CollectGarbage(NEW_SPACE); |
| 4865 CHECK(!heap->InNewSpace(*foo)); |
| 4866 #ifdef VERIFY_HEAP |
| 4867 heap->Verify(); |
| 4868 #endif |
| 4869 CHECK(!bar->code()->marked_for_deoptimization()); |
| 4870 code = scope.CloseAndEscape(Handle<Code>(bar->code())); |
| 4871 } |
| 4872 |
| 4873 // Now make sure that a gc should get rid of the function |
| 4874 for (int i = 0; i < 4; i++) { |
| 4875 heap->CollectAllGarbage(); |
| 4876 } |
| 4877 |
| 4878 CHECK(code->marked_for_deoptimization()); |
| 4879 } |
4819 | 4880 |
4820 TEST(NoWeakHashTableLeakWithIncrementalMarking) { | 4881 TEST(NoWeakHashTableLeakWithIncrementalMarking) { |
4821 if (i::FLAG_always_opt || !i::FLAG_crankshaft) return; | 4882 if (i::FLAG_always_opt || !i::FLAG_crankshaft) return; |
4822 if (!i::FLAG_incremental_marking) return; | 4883 if (!i::FLAG_incremental_marking) return; |
4823 i::FLAG_weak_embedded_objects_in_optimized_code = true; | 4884 i::FLAG_weak_embedded_objects_in_optimized_code = true; |
4824 i::FLAG_allow_natives_syntax = true; | 4885 i::FLAG_allow_natives_syntax = true; |
4825 i::FLAG_compilation_cache = false; | 4886 i::FLAG_compilation_cache = false; |
4826 i::FLAG_retain_maps_for_n_gc = 0; | 4887 i::FLAG_retain_maps_for_n_gc = 0; |
4827 CcTest::InitializeVM(); | 4888 CcTest::InitializeVM(); |
4828 Isolate* isolate = CcTest::i_isolate(); | 4889 Isolate* isolate = CcTest::i_isolate(); |
(...skipping 1926 matching lines...) Loading... |
6755 CHECK(marking->IsComplete()); | 6816 CHECK(marking->IsComplete()); |
6756 intptr_t size_before = heap->SizeOfObjects(); | 6817 intptr_t size_before = heap->SizeOfObjects(); |
6757 CcTest::heap()->CollectAllGarbage(); | 6818 CcTest::heap()->CollectAllGarbage(); |
6758 intptr_t size_after = heap->SizeOfObjects(); | 6819 intptr_t size_after = heap->SizeOfObjects(); |
6759 // Live size does not increase after garbage collection. | 6820 // Live size does not increase after garbage collection. |
6760 CHECK_LE(size_after, size_before); | 6821 CHECK_LE(size_after, size_before); |
6761 } | 6822 } |
6762 | 6823 |
6763 } // namespace internal | 6824 } // namespace internal |
6764 } // namespace v8 | 6825 } // namespace v8 |
OLD | NEW |