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 4050 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4061 CHECK_EQ(new_count, (count + 1)); | 4061 CHECK_EQ(new_count, (count + 1)); |
4062 site = Handle<AllocationSite>::cast( | 4062 site = Handle<AllocationSite>::cast( |
4063 global_handles->Create( | 4063 global_handles->Create( |
4064 AllocationSite::cast(heap->allocation_sites_list()))); | 4064 AllocationSite::cast(heap->allocation_sites_list()))); |
4065 | 4065 |
4066 CompileRun("%OptimizeFunctionOnNextCall(bar); bar();"); | 4066 CompileRun("%OptimizeFunctionOnNextCall(bar); bar();"); |
4067 | 4067 |
4068 DependentCode::GroupStartIndexes starts(site->dependent_code()); | 4068 DependentCode::GroupStartIndexes starts(site->dependent_code()); |
4069 CHECK_GE(starts.number_of_entries(), 1); | 4069 CHECK_GE(starts.number_of_entries(), 1); |
4070 int index = starts.at(DependentCode::kAllocationSiteTransitionChangedGroup); | 4070 int index = starts.at(DependentCode::kAllocationSiteTransitionChangedGroup); |
4071 CHECK(site->dependent_code()->is_code_at(index)); | 4071 CHECK(site->dependent_code()->object_at(index)->IsWeakCell()); |
4072 Code* function_bar = site->dependent_code()->code_at(index); | 4072 Code* function_bar = Code::cast( |
| 4073 WeakCell::cast(site->dependent_code()->object_at(index))->value()); |
4073 Handle<JSFunction> bar_handle = | 4074 Handle<JSFunction> bar_handle = |
4074 v8::Utils::OpenHandle( | 4075 v8::Utils::OpenHandle( |
4075 *v8::Handle<v8::Function>::Cast( | 4076 *v8::Handle<v8::Function>::Cast( |
4076 CcTest::global()->Get(v8_str("bar")))); | 4077 CcTest::global()->Get(v8_str("bar")))); |
4077 CHECK_EQ(bar_handle->code(), function_bar); | 4078 CHECK_EQ(bar_handle->code(), function_bar); |
4078 } | 4079 } |
4079 | 4080 |
4080 // Now make sure that a gc should get rid of the function, even though we | 4081 // Now make sure that a gc should get rid of the function, even though we |
4081 // still have the allocation site alive. | 4082 // still have the allocation site alive. |
4082 for (int i = 0; i < 4; i++) { | 4083 for (int i = 0; i < 4; i++) { |
4083 heap->CollectAllGarbage(Heap::kNoGCFlags); | 4084 heap->CollectAllGarbage(Heap::kNoGCFlags); |
4084 } | 4085 } |
4085 | 4086 |
4086 // The site still exists because of our global handle, but the code is no | 4087 // The site still exists because of our global handle, but the code is no |
4087 // longer referred to by dependent_code(). | 4088 // longer referred to by dependent_code(). |
4088 DependentCode::GroupStartIndexes starts(site->dependent_code()); | 4089 DependentCode::GroupStartIndexes starts(site->dependent_code()); |
4089 int index = starts.at(DependentCode::kAllocationSiteTransitionChangedGroup); | 4090 int index = starts.at(DependentCode::kAllocationSiteTransitionChangedGroup); |
4090 CHECK(!(site->dependent_code()->is_code_at(index))); | 4091 CHECK(site->dependent_code()->object_at(index)->IsWeakCell() && |
| 4092 WeakCell::cast(site->dependent_code()->object_at(index))->cleared()); |
4091 } | 4093 } |
4092 | 4094 |
4093 | 4095 |
4094 TEST(CellsInOptimizedCodeAreWeak) { | 4096 TEST(CellsInOptimizedCodeAreWeak) { |
4095 if (i::FLAG_always_opt || !i::FLAG_crankshaft) return; | 4097 if (i::FLAG_always_opt || !i::FLAG_crankshaft) return; |
4096 i::FLAG_weak_embedded_objects_in_optimized_code = true; | 4098 i::FLAG_weak_embedded_objects_in_optimized_code = true; |
4097 i::FLAG_allow_natives_syntax = true; | 4099 i::FLAG_allow_natives_syntax = true; |
4098 CcTest::InitializeVM(); | 4100 CcTest::InitializeVM(); |
4099 Isolate* isolate = CcTest::i_isolate(); | 4101 Isolate* isolate = CcTest::i_isolate(); |
4100 v8::internal::Heap* heap = CcTest::heap(); | 4102 v8::internal::Heap* heap = CcTest::heap(); |
(...skipping 883 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4984 #ifdef DEBUG | 4986 #ifdef DEBUG |
4985 TEST(PathTracer) { | 4987 TEST(PathTracer) { |
4986 CcTest::InitializeVM(); | 4988 CcTest::InitializeVM(); |
4987 v8::HandleScope scope(CcTest::isolate()); | 4989 v8::HandleScope scope(CcTest::isolate()); |
4988 | 4990 |
4989 v8::Local<v8::Value> result = CompileRun("'abc'"); | 4991 v8::Local<v8::Value> result = CompileRun("'abc'"); |
4990 Handle<Object> o = v8::Utils::OpenHandle(*result); | 4992 Handle<Object> o = v8::Utils::OpenHandle(*result); |
4991 CcTest::i_isolate()->heap()->TracePathToObject(*o); | 4993 CcTest::i_isolate()->heap()->TracePathToObject(*o); |
4992 } | 4994 } |
4993 #endif // DEBUG | 4995 #endif // DEBUG |
OLD | NEW |