OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <iomanip> | 5 #include <iomanip> |
6 #include <sstream> | 6 #include <sstream> |
7 | 7 |
8 #include "src/v8.h" | 8 #include "src/v8.h" |
9 | 9 |
10 #include "src/accessors.h" | 10 #include "src/accessors.h" |
11 #include "src/allocation-site-scopes.h" | 11 #include "src/allocation-site-scopes.h" |
12 #include "src/api.h" | 12 #include "src/api.h" |
13 #include "src/arguments.h" | 13 #include "src/arguments.h" |
14 #include "src/base/bits.h" | 14 #include "src/base/bits.h" |
15 #include "src/bootstrapper.h" | 15 #include "src/bootstrapper.h" |
16 #include "src/code-stubs.h" | 16 #include "src/code-stubs.h" |
17 #include "src/codegen.h" | 17 #include "src/codegen.h" |
18 #include "src/compiler.h" | 18 #include "src/compiler.h" |
19 #include "src/cpu-profiler.h" | 19 #include "src/cpu-profiler.h" |
20 #include "src/date.h" | 20 #include "src/date.h" |
21 #include "src/debug.h" | 21 #include "src/debug.h" |
22 #include "src/deoptimizer.h" | 22 #include "src/deoptimizer.h" |
| 23 #include "src/dependencies.h" |
23 #include "src/elements.h" | 24 #include "src/elements.h" |
24 #include "src/execution.h" | 25 #include "src/execution.h" |
25 #include "src/field-index-inl.h" | 26 #include "src/field-index-inl.h" |
26 #include "src/field-index.h" | 27 #include "src/field-index.h" |
27 #include "src/full-codegen.h" | 28 #include "src/full-codegen.h" |
28 #include "src/heap/mark-compact.h" | 29 #include "src/heap/mark-compact.h" |
29 #include "src/heap/objects-visiting-inl.h" | 30 #include "src/heap/objects-visiting-inl.h" |
30 #include "src/hydrogen.h" | 31 #include "src/hydrogen.h" |
31 #include "src/ic/ic.h" | 32 #include "src/ic/ic.h" |
32 #include "src/isolate-inl.h" | 33 #include "src/isolate-inl.h" |
(...skipping 12010 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12043 } | 12044 } |
12044 | 12045 |
12045 RETURN_ON_EXCEPTION( | 12046 RETURN_ON_EXCEPTION( |
12046 isolate, EnqueueSpliceRecord(array, index, deleted, add_count), Object); | 12047 isolate, EnqueueSpliceRecord(array, index, deleted, add_count), Object); |
12047 | 12048 |
12048 return hresult; | 12049 return hresult; |
12049 } | 12050 } |
12050 | 12051 |
12051 | 12052 |
12052 // static | 12053 // static |
12053 void Map::AddDependentCompilationInfo(Handle<Map> map, | |
12054 DependentCode::DependencyGroup group, | |
12055 CompilationInfo* info) { | |
12056 Handle<DependentCode> codes = DependentCode::InsertCompilationInfo( | |
12057 handle(map->dependent_code(), info->isolate()), group, | |
12058 info->object_wrapper()); | |
12059 if (*codes != map->dependent_code()) map->set_dependent_code(*codes); | |
12060 info->dependencies(group)->Add(map, info->zone()); | |
12061 } | |
12062 | |
12063 | |
12064 // static | |
12065 void Map::AddDependentCode(Handle<Map> map, | 12054 void Map::AddDependentCode(Handle<Map> map, |
12066 DependentCode::DependencyGroup group, | 12055 DependentCode::DependencyGroup group, |
12067 Handle<Code> code) { | 12056 Handle<Code> code) { |
12068 Handle<WeakCell> cell = Code::WeakCellFor(code); | 12057 Handle<WeakCell> cell = Code::WeakCellFor(code); |
12069 Handle<DependentCode> codes = DependentCode::InsertWeakCode( | 12058 Handle<DependentCode> codes = DependentCode::InsertWeakCode( |
12070 Handle<DependentCode>(map->dependent_code()), group, cell); | 12059 Handle<DependentCode>(map->dependent_code()), group, cell); |
12071 if (*codes != map->dependent_code()) map->set_dependent_code(*codes); | 12060 if (*codes != map->dependent_code()) map->set_dependent_code(*codes); |
12072 } | 12061 } |
12073 | 12062 |
12074 | 12063 |
(...skipping 17 matching lines...) Expand all Loading... |
12092 if (group == DependentCode::kPropertyCellChangedGroup) { | 12081 if (group == DependentCode::kPropertyCellChangedGroup) { |
12093 return Handle<PropertyCell>::cast(object)->dependent_code(); | 12082 return Handle<PropertyCell>::cast(object)->dependent_code(); |
12094 } else if (group == DependentCode::kAllocationSiteTenuringChangedGroup || | 12083 } else if (group == DependentCode::kAllocationSiteTenuringChangedGroup || |
12095 group == DependentCode::kAllocationSiteTransitionChangedGroup) { | 12084 group == DependentCode::kAllocationSiteTransitionChangedGroup) { |
12096 return Handle<AllocationSite>::cast(object)->dependent_code(); | 12085 return Handle<AllocationSite>::cast(object)->dependent_code(); |
12097 } | 12086 } |
12098 return Handle<Map>::cast(object)->dependent_code(); | 12087 return Handle<Map>::cast(object)->dependent_code(); |
12099 } | 12088 } |
12100 | 12089 |
12101 | 12090 |
12102 Handle<DependentCode> DependentCode::InsertCompilationInfo( | 12091 Handle<DependentCode> DependentCode::InsertCompilationDependencies( |
12103 Handle<DependentCode> entries, DependencyGroup group, | 12092 Handle<DependentCode> entries, DependencyGroup group, |
12104 Handle<Foreign> info) { | 12093 Handle<Foreign> info) { |
12105 return Insert(entries, group, info); | 12094 return Insert(entries, group, info); |
12106 } | 12095 } |
12107 | 12096 |
12108 | 12097 |
12109 Handle<DependentCode> DependentCode::InsertWeakCode( | 12098 Handle<DependentCode> DependentCode::InsertWeakCode( |
12110 Handle<DependentCode> entries, DependencyGroup group, | 12099 Handle<DependentCode> entries, DependencyGroup group, |
12111 Handle<WeakCell> code_cell) { | 12100 Handle<WeakCell> code_cell) { |
12112 return Insert(entries, group, code_cell); | 12101 return Insert(entries, group, code_cell); |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12198 } | 12187 } |
12199 | 12188 |
12200 #ifdef DEBUG | 12189 #ifdef DEBUG |
12201 for (int i = start; i < end; i++) { | 12190 for (int i = start; i < end; i++) { |
12202 DCHECK(object_at(i) != info); | 12191 DCHECK(object_at(i) != info); |
12203 } | 12192 } |
12204 #endif | 12193 #endif |
12205 } | 12194 } |
12206 | 12195 |
12207 | 12196 |
12208 void DependentCode::RemoveCompilationInfo(DependentCode::DependencyGroup group, | 12197 void DependentCode::RemoveCompilationDependencies( |
12209 Foreign* info) { | 12198 DependentCode::DependencyGroup group, Foreign* info) { |
12210 DisallowHeapAllocation no_allocation; | 12199 DisallowHeapAllocation no_allocation; |
12211 GroupStartIndexes starts(this); | 12200 GroupStartIndexes starts(this); |
12212 int start = starts.at(group); | 12201 int start = starts.at(group); |
12213 int end = starts.at(group + 1); | 12202 int end = starts.at(group + 1); |
12214 // Find compilation info wrapper. | 12203 // Find compilation info wrapper. |
12215 int info_pos = -1; | 12204 int info_pos = -1; |
12216 for (int i = start; i < end; i++) { | 12205 for (int i = start; i < end; i++) { |
12217 if (object_at(i) == info) { | 12206 if (object_at(i) == info) { |
12218 info_pos = i; | 12207 info_pos = i; |
12219 break; | 12208 break; |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12273 Code* code = Code::cast(cell->value()); | 12262 Code* code = Code::cast(cell->value()); |
12274 if (!code->marked_for_deoptimization()) { | 12263 if (!code->marked_for_deoptimization()) { |
12275 SetMarkedForDeoptimization(code, group); | 12264 SetMarkedForDeoptimization(code, group); |
12276 if (invalidate_embedded_objects) { | 12265 if (invalidate_embedded_objects) { |
12277 code->InvalidateEmbeddedObjects(); | 12266 code->InvalidateEmbeddedObjects(); |
12278 } | 12267 } |
12279 marked = true; | 12268 marked = true; |
12280 } | 12269 } |
12281 } else { | 12270 } else { |
12282 DCHECK(obj->IsForeign()); | 12271 DCHECK(obj->IsForeign()); |
12283 CompilationInfo* info = reinterpret_cast<CompilationInfo*>( | 12272 CompilationDependencies* info = |
12284 Foreign::cast(obj)->foreign_address()); | 12273 reinterpret_cast<CompilationDependencies*>( |
12285 info->AbortDueToDependencyChange(); | 12274 Foreign::cast(obj)->foreign_address()); |
| 12275 info->Abort(); |
12286 } | 12276 } |
12287 } | 12277 } |
12288 // Compact the array by moving all subsequent groups to fill in the new holes. | 12278 // Compact the array by moving all subsequent groups to fill in the new holes. |
12289 for (int src = end, dst = start; src < code_entries; src++, dst++) { | 12279 for (int src = end, dst = start; src < code_entries; src++, dst++) { |
12290 copy(src, dst); | 12280 copy(src, dst); |
12291 } | 12281 } |
12292 // Now the holes are at the end of the array, zap them for heap-verifier. | 12282 // Now the holes are at the end of the array, zap them for heap-verifier. |
12293 int removed = end - start; | 12283 int removed = end - start; |
12294 for (int i = code_entries - removed; i < code_entries; i++) { | 12284 for (int i = code_entries - removed; i < code_entries; i++) { |
12295 clear_at(i); | 12285 clear_at(i); |
(...skipping 1061 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13357 ElementsKindToString(to_kind)); | 13347 ElementsKindToString(to_kind)); |
13358 } | 13348 } |
13359 site->SetElementsKind(to_kind); | 13349 site->SetElementsKind(to_kind); |
13360 site->dependent_code()->DeoptimizeDependentCodeGroup( | 13350 site->dependent_code()->DeoptimizeDependentCodeGroup( |
13361 isolate, DependentCode::kAllocationSiteTransitionChangedGroup); | 13351 isolate, DependentCode::kAllocationSiteTransitionChangedGroup); |
13362 } | 13352 } |
13363 } | 13353 } |
13364 } | 13354 } |
13365 | 13355 |
13366 | 13356 |
13367 // static | |
13368 void AllocationSite::RegisterForDeoptOnTenureChange(Handle<AllocationSite> site, | |
13369 CompilationInfo* info) { | |
13370 AddDependentCompilationInfo( | |
13371 site, DependentCode::kAllocationSiteTenuringChangedGroup, info); | |
13372 } | |
13373 | |
13374 | |
13375 // static | |
13376 void AllocationSite::RegisterForDeoptOnTransitionChange( | |
13377 Handle<AllocationSite> site, CompilationInfo* info) { | |
13378 // Do nothing if the object doesn't have any useful element transitions left. | |
13379 ElementsKind kind = | |
13380 site->SitePointsToLiteral() | |
13381 ? JSObject::cast(site->transition_info())->GetElementsKind() | |
13382 : site->GetElementsKind(); | |
13383 if (AllocationSite::GetMode(kind) == TRACK_ALLOCATION_SITE) { | |
13384 AddDependentCompilationInfo( | |
13385 site, DependentCode::kAllocationSiteTransitionChangedGroup, info); | |
13386 } | |
13387 } | |
13388 | |
13389 | |
13390 // static | |
13391 void AllocationSite::AddDependentCompilationInfo( | |
13392 Handle<AllocationSite> site, DependentCode::DependencyGroup group, | |
13393 CompilationInfo* info) { | |
13394 Handle<DependentCode> dep(site->dependent_code()); | |
13395 Handle<DependentCode> codes = | |
13396 DependentCode::InsertCompilationInfo(dep, group, info->object_wrapper()); | |
13397 if (*codes != site->dependent_code()) site->set_dependent_code(*codes); | |
13398 info->dependencies(group)->Add(Handle<HeapObject>(*site), info->zone()); | |
13399 } | |
13400 | |
13401 | |
13402 const char* AllocationSite::PretenureDecisionName(PretenureDecision decision) { | 13357 const char* AllocationSite::PretenureDecisionName(PretenureDecision decision) { |
13403 switch (decision) { | 13358 switch (decision) { |
13404 case kUndecided: return "undecided"; | 13359 case kUndecided: return "undecided"; |
13405 case kDontTenure: return "don't tenure"; | 13360 case kDontTenure: return "don't tenure"; |
13406 case kMaybeTenure: return "maybe tenure"; | 13361 case kMaybeTenure: return "maybe tenure"; |
13407 case kTenure: return "tenure"; | 13362 case kTenure: return "tenure"; |
13408 case kZombie: return "zombie"; | 13363 case kZombie: return "zombie"; |
13409 default: UNREACHABLE(); | 13364 default: UNREACHABLE(); |
13410 } | 13365 } |
13411 return NULL; | 13366 return NULL; |
(...skipping 3633 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
17045 // Deopt when transitioning from a constant type. | 17000 // Deopt when transitioning from a constant type. |
17046 if (!invalidate && old_type == PropertyCellType::kConstant && | 17001 if (!invalidate && old_type == PropertyCellType::kConstant && |
17047 new_type != PropertyCellType::kConstant) { | 17002 new_type != PropertyCellType::kConstant) { |
17048 auto isolate = dictionary->GetIsolate(); | 17003 auto isolate = dictionary->GetIsolate(); |
17049 cell->dependent_code()->DeoptimizeDependentCodeGroup( | 17004 cell->dependent_code()->DeoptimizeDependentCodeGroup( |
17050 isolate, DependentCode::kPropertyCellChangedGroup); | 17005 isolate, DependentCode::kPropertyCellChangedGroup); |
17051 } | 17006 } |
17052 return value; | 17007 return value; |
17053 } | 17008 } |
17054 | 17009 |
17055 | |
17056 // static | |
17057 void PropertyCell::AddDependentCompilationInfo(Handle<PropertyCell> cell, | |
17058 CompilationInfo* info) { | |
17059 Handle<DependentCode> codes = DependentCode::InsertCompilationInfo( | |
17060 handle(cell->dependent_code(), info->isolate()), | |
17061 DependentCode::kPropertyCellChangedGroup, info->object_wrapper()); | |
17062 if (*codes != cell->dependent_code()) cell->set_dependent_code(*codes); | |
17063 info->dependencies(DependentCode::kPropertyCellChangedGroup)->Add( | |
17064 cell, info->zone()); | |
17065 } | |
17066 | |
17067 } } // namespace v8::internal | 17010 } } // namespace v8::internal |
OLD | NEW |