| 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 4169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4180 CHECK_EQ(new_count, (count + 1)); | 4180 CHECK_EQ(new_count, (count + 1)); |
| 4181 site = Handle<AllocationSite>::cast( | 4181 site = Handle<AllocationSite>::cast( |
| 4182 global_handles->Create( | 4182 global_handles->Create( |
| 4183 AllocationSite::cast(heap->allocation_sites_list()))); | 4183 AllocationSite::cast(heap->allocation_sites_list()))); |
| 4184 | 4184 |
| 4185 CompileRun("%OptimizeFunctionOnNextCall(bar); bar();"); | 4185 CompileRun("%OptimizeFunctionOnNextCall(bar); bar();"); |
| 4186 | 4186 |
| 4187 DependentCode::GroupStartIndexes starts(site->dependent_code()); | 4187 DependentCode::GroupStartIndexes starts(site->dependent_code()); |
| 4188 CHECK_GE(starts.number_of_entries(), 1); | 4188 CHECK_GE(starts.number_of_entries(), 1); |
| 4189 int index = starts.at(DependentCode::kAllocationSiteTransitionChangedGroup); | 4189 int index = starts.at(DependentCode::kAllocationSiteTransitionChangedGroup); |
| 4190 CHECK(site->dependent_code()->is_code_at(index)); | 4190 CHECK(site->dependent_code()->object_at(index)->IsWeakCell()); |
| 4191 Code* function_bar = site->dependent_code()->code_at(index); | 4191 Code* function_bar = Code::cast( |
| 4192 WeakCell::cast(site->dependent_code()->object_at(index))->value()); |
| 4192 Handle<JSFunction> bar_handle = | 4193 Handle<JSFunction> bar_handle = |
| 4193 v8::Utils::OpenHandle( | 4194 v8::Utils::OpenHandle( |
| 4194 *v8::Handle<v8::Function>::Cast( | 4195 *v8::Handle<v8::Function>::Cast( |
| 4195 CcTest::global()->Get(v8_str("bar")))); | 4196 CcTest::global()->Get(v8_str("bar")))); |
| 4196 CHECK_EQ(bar_handle->code(), function_bar); | 4197 CHECK_EQ(bar_handle->code(), function_bar); |
| 4197 } | 4198 } |
| 4198 | 4199 |
| 4199 // Now make sure that a gc should get rid of the function, even though we | 4200 // Now make sure that a gc should get rid of the function, even though we |
| 4200 // still have the allocation site alive. | 4201 // still have the allocation site alive. |
| 4201 for (int i = 0; i < 4; i++) { | 4202 for (int i = 0; i < 4; i++) { |
| 4202 heap->CollectAllGarbage(Heap::kNoGCFlags); | 4203 heap->CollectAllGarbage(Heap::kNoGCFlags); |
| 4203 } | 4204 } |
| 4204 | 4205 |
| 4205 // The site still exists because of our global handle, but the code is no | 4206 // The site still exists because of our global handle, but the code is no |
| 4206 // longer referred to by dependent_code(). | 4207 // longer referred to by dependent_code(). |
| 4207 DependentCode::GroupStartIndexes starts(site->dependent_code()); | 4208 DependentCode::GroupStartIndexes starts(site->dependent_code()); |
| 4208 int index = starts.at(DependentCode::kAllocationSiteTransitionChangedGroup); | 4209 int index = starts.at(DependentCode::kAllocationSiteTransitionChangedGroup); |
| 4209 CHECK(!(site->dependent_code()->is_code_at(index))); | 4210 CHECK(site->dependent_code()->object_at(index)->IsWeakCell() && |
| 4211 WeakCell::cast(site->dependent_code()->object_at(index))->cleared()); |
| 4210 } | 4212 } |
| 4211 | 4213 |
| 4212 | 4214 |
| 4213 TEST(CellsInOptimizedCodeAreWeak) { | 4215 TEST(CellsInOptimizedCodeAreWeak) { |
| 4214 if (i::FLAG_always_opt || !i::FLAG_crankshaft) return; | 4216 if (i::FLAG_always_opt || !i::FLAG_crankshaft) return; |
| 4215 i::FLAG_weak_embedded_objects_in_optimized_code = true; | 4217 i::FLAG_weak_embedded_objects_in_optimized_code = true; |
| 4216 i::FLAG_allow_natives_syntax = true; | 4218 i::FLAG_allow_natives_syntax = true; |
| 4217 CcTest::InitializeVM(); | 4219 CcTest::InitializeVM(); |
| 4218 Isolate* isolate = CcTest::i_isolate(); | 4220 Isolate* isolate = CcTest::i_isolate(); |
| 4219 v8::internal::Heap* heap = CcTest::heap(); | 4221 v8::internal::Heap* heap = CcTest::heap(); |
| (...skipping 883 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5103 #ifdef DEBUG | 5105 #ifdef DEBUG |
| 5104 TEST(PathTracer) { | 5106 TEST(PathTracer) { |
| 5105 CcTest::InitializeVM(); | 5107 CcTest::InitializeVM(); |
| 5106 v8::HandleScope scope(CcTest::isolate()); | 5108 v8::HandleScope scope(CcTest::isolate()); |
| 5107 | 5109 |
| 5108 v8::Local<v8::Value> result = CompileRun("'abc'"); | 5110 v8::Local<v8::Value> result = CompileRun("'abc'"); |
| 5109 Handle<Object> o = v8::Utils::OpenHandle(*result); | 5111 Handle<Object> o = v8::Utils::OpenHandle(*result); |
| 5110 CcTest::i_isolate()->heap()->TracePathToObject(*o); | 5112 CcTest::i_isolate()->heap()->TracePathToObject(*o); |
| 5111 } | 5113 } |
| 5112 #endif // DEBUG | 5114 #endif // DEBUG |
| OLD | NEW |