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 3566 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3577 v8::HandleScope scope(context->GetIsolate()); | 3577 v8::HandleScope scope(context->GetIsolate()); |
3578 | 3578 |
3579 int count = AllocationSitesCount(heap); | 3579 int count = AllocationSitesCount(heap); |
3580 CompileRun("var bar = function() { return (new Array()); };" | 3580 CompileRun("var bar = function() { return (new Array()); };" |
3581 "var a = bar();" | 3581 "var a = bar();" |
3582 "bar();" | 3582 "bar();" |
3583 "bar();"); | 3583 "bar();"); |
3584 | 3584 |
3585 // One allocation site should have been created. | 3585 // One allocation site should have been created. |
3586 int new_count = AllocationSitesCount(heap); | 3586 int new_count = AllocationSitesCount(heap); |
3587 ASSERT(new_count == (count + 1)); | 3587 CHECK_EQ(new_count, (count + 1)); |
3588 site = Handle<AllocationSite>::cast( | 3588 site = Handle<AllocationSite>::cast( |
3589 global_handles->Create( | 3589 global_handles->Create( |
3590 AllocationSite::cast(heap->allocation_sites_list()))); | 3590 AllocationSite::cast(heap->allocation_sites_list()))); |
3591 | 3591 |
3592 CompileRun("%OptimizeFunctionOnNextCall(bar); bar();"); | 3592 CompileRun("%OptimizeFunctionOnNextCall(bar); bar();"); |
3593 | 3593 |
3594 DependentCode::GroupStartIndexes starts(site->dependent_code()); | 3594 DependentCode::GroupStartIndexes starts(site->dependent_code()); |
3595 ASSERT(starts.number_of_entries() >= 1); | 3595 CHECK_GE(starts.number_of_entries(), 1); |
3596 int index = starts.at(DependentCode::kAllocationSiteTransitionChangedGroup); | 3596 int index = starts.at(DependentCode::kAllocationSiteTransitionChangedGroup); |
3597 ASSERT(site->dependent_code()->is_code_at(index)); | 3597 CHECK(site->dependent_code()->is_code_at(index)); |
3598 Code* function_bar = site->dependent_code()->code_at(index); | 3598 Code* function_bar = site->dependent_code()->code_at(index); |
3599 Handle<JSFunction> bar_handle = | 3599 Handle<JSFunction> bar_handle = |
3600 v8::Utils::OpenHandle( | 3600 v8::Utils::OpenHandle( |
3601 *v8::Handle<v8::Function>::Cast( | 3601 *v8::Handle<v8::Function>::Cast( |
3602 CcTest::global()->Get(v8_str("bar")))); | 3602 CcTest::global()->Get(v8_str("bar")))); |
3603 ASSERT(bar_handle->code() == function_bar); | 3603 CHECK_EQ(bar_handle->code(), function_bar); |
3604 } | 3604 } |
3605 | 3605 |
3606 // Now make sure that a gc should get rid of the function, even though we | 3606 // Now make sure that a gc should get rid of the function, even though we |
3607 // still have the allocation site alive. | 3607 // still have the allocation site alive. |
3608 for (int i = 0; i < 4; i++) { | 3608 for (int i = 0; i < 4; i++) { |
3609 heap->CollectAllGarbage(false); | 3609 heap->CollectAllGarbage(false); |
3610 } | 3610 } |
3611 | 3611 |
3612 // The site still exists because of our global handle, but the code is no | 3612 // The site still exists because of our global handle, but the code is no |
3613 // longer referred to by dependent_code(). | 3613 // longer referred to by dependent_code(). |
3614 DependentCode::GroupStartIndexes starts(site->dependent_code()); | 3614 DependentCode::GroupStartIndexes starts(site->dependent_code()); |
3615 int index = starts.at(DependentCode::kAllocationSiteTransitionChangedGroup); | 3615 int index = starts.at(DependentCode::kAllocationSiteTransitionChangedGroup); |
3616 ASSERT(!(site->dependent_code()->is_code_at(index))); | 3616 CHECK(!(site->dependent_code()->is_code_at(index))); |
3617 } | 3617 } |
OLD | NEW |