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 4704 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4715 | 4715 |
4716 // One allocation site should have been created. | 4716 // One allocation site should have been created. |
4717 int new_count = AllocationSitesCount(heap); | 4717 int new_count = AllocationSitesCount(heap); |
4718 CHECK_EQ(new_count, (count + 1)); | 4718 CHECK_EQ(new_count, (count + 1)); |
4719 site = Handle<AllocationSite>::cast( | 4719 site = Handle<AllocationSite>::cast( |
4720 global_handles->Create( | 4720 global_handles->Create( |
4721 AllocationSite::cast(heap->allocation_sites_list()))); | 4721 AllocationSite::cast(heap->allocation_sites_list()))); |
4722 | 4722 |
4723 CompileRun("%OptimizeFunctionOnNextCall(bar); bar();"); | 4723 CompileRun("%OptimizeFunctionOnNextCall(bar); bar();"); |
4724 | 4724 |
4725 DependentCode::GroupStartIndexes starts(site->dependent_code()); | 4725 CHECK_EQ(DependentCode::kAllocationSiteTransitionChangedGroup, |
4726 CHECK_GE(starts.number_of_entries(), 1); | 4726 site->dependent_code()->group()); |
4727 int index = starts.at(DependentCode::kAllocationSiteTransitionChangedGroup); | 4727 CHECK_EQ(1, site->dependent_code()->count()); |
4728 CHECK(site->dependent_code()->object_at(index)->IsWeakCell()); | 4728 CHECK(site->dependent_code()->object_at(0)->IsWeakCell()); |
4729 Code* function_bar = Code::cast( | 4729 Code* function_bar = Code::cast( |
4730 WeakCell::cast(site->dependent_code()->object_at(index))->value()); | 4730 WeakCell::cast(site->dependent_code()->object_at(0))->value()); |
4731 Handle<JSFunction> bar_handle = Handle<JSFunction>::cast( | 4731 Handle<JSFunction> bar_handle = Handle<JSFunction>::cast( |
4732 v8::Utils::OpenHandle(*v8::Local<v8::Function>::Cast( | 4732 v8::Utils::OpenHandle(*v8::Local<v8::Function>::Cast( |
4733 CcTest::global() | 4733 CcTest::global() |
4734 ->Get(context.local(), v8_str("bar")) | 4734 ->Get(context.local(), v8_str("bar")) |
4735 .ToLocalChecked()))); | 4735 .ToLocalChecked()))); |
4736 CHECK_EQ(bar_handle->code(), function_bar); | 4736 CHECK_EQ(bar_handle->code(), function_bar); |
4737 } | 4737 } |
4738 | 4738 |
4739 // Now make sure that a gc should get rid of the function, even though we | 4739 // Now make sure that a gc should get rid of the function, even though we |
4740 // still have the allocation site alive. | 4740 // still have the allocation site alive. |
4741 for (int i = 0; i < 4; i++) { | 4741 for (int i = 0; i < 4; i++) { |
4742 heap->CollectAllGarbage(); | 4742 heap->CollectAllGarbage(); |
4743 } | 4743 } |
4744 | 4744 |
4745 // The site still exists because of our global handle, but the code is no | 4745 // The site still exists because of our global handle, but the code is no |
4746 // longer referred to by dependent_code(). | 4746 // longer referred to by dependent_code(). |
4747 DependentCode::GroupStartIndexes starts(site->dependent_code()); | 4747 CHECK(site->dependent_code()->object_at(0)->IsWeakCell() && |
4748 int index = starts.at(DependentCode::kAllocationSiteTransitionChangedGroup); | 4748 WeakCell::cast(site->dependent_code()->object_at(0))->cleared()); |
4749 CHECK(site->dependent_code()->object_at(index)->IsWeakCell() && | |
4750 WeakCell::cast(site->dependent_code()->object_at(index))->cleared()); | |
4751 } | 4749 } |
4752 | 4750 |
4753 | 4751 |
4754 TEST(CellsInOptimizedCodeAreWeak) { | 4752 TEST(CellsInOptimizedCodeAreWeak) { |
4755 if (i::FLAG_always_opt || !i::FLAG_crankshaft) return; | 4753 if (i::FLAG_always_opt || !i::FLAG_crankshaft) return; |
4756 i::FLAG_weak_embedded_objects_in_optimized_code = true; | 4754 i::FLAG_weak_embedded_objects_in_optimized_code = true; |
4757 i::FLAG_allow_natives_syntax = true; | 4755 i::FLAG_allow_natives_syntax = true; |
4758 CcTest::InitializeVM(); | 4756 CcTest::InitializeVM(); |
4759 Isolate* isolate = CcTest::i_isolate(); | 4757 Isolate* isolate = CcTest::i_isolate(); |
4760 v8::internal::Heap* heap = CcTest::heap(); | 4758 v8::internal::Heap* heap = CcTest::heap(); |
(...skipping 1689 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6450 isolate->IncrementJsCallsFromApiCounter(); | 6448 isolate->IncrementJsCallsFromApiCounter(); |
6451 isolate->IncrementJsCallsFromApiCounter(); | 6449 isolate->IncrementJsCallsFromApiCounter(); |
6452 isolate->IncrementJsCallsFromApiCounter(); | 6450 isolate->IncrementJsCallsFromApiCounter(); |
6453 calls_per_ms = memory_reducer->SampleAndGetJsCallsPerMs(4); | 6451 calls_per_ms = memory_reducer->SampleAndGetJsCallsPerMs(4); |
6454 CheckDoubleEquals(2, calls_per_ms); | 6452 CheckDoubleEquals(2, calls_per_ms); |
6455 } | 6453 } |
6456 | 6454 |
6457 | 6455 |
6458 } // namespace internal | 6456 } // namespace internal |
6459 } // namespace v8 | 6457 } // namespace v8 |
OLD | NEW |