Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(327)

Side by Side Diff: src/objects.cc

Issue 1095433002: Refactor compilation dependency handling. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/objects.h ('k') | test/cctest/test-migrations.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/compilation-dependencies.h"
18 #include "src/compiler.h" 19 #include "src/compiler.h"
19 #include "src/cpu-profiler.h" 20 #include "src/cpu-profiler.h"
20 #include "src/date.h" 21 #include "src/date.h"
21 #include "src/debug.h" 22 #include "src/debug.h"
22 #include "src/deoptimizer.h" 23 #include "src/deoptimizer.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"
(...skipping 12102 matching lines...) Expand 10 before | Expand all | Expand 10 after
12130 } 12131 }
12131 12132
12132 RETURN_ON_EXCEPTION( 12133 RETURN_ON_EXCEPTION(
12133 isolate, EnqueueSpliceRecord(array, index, deleted, add_count), Object); 12134 isolate, EnqueueSpliceRecord(array, index, deleted, add_count), Object);
12134 12135
12135 return hresult; 12136 return hresult;
12136 } 12137 }
12137 12138
12138 12139
12139 // static 12140 // static
12140 void Map::AddDependentCompilationInfo(Handle<Map> map,
12141 DependentCode::DependencyGroup group,
12142 CompilationInfo* info) {
12143 Handle<DependentCode> codes = DependentCode::InsertCompilationInfo(
12144 handle(map->dependent_code(), info->isolate()), group,
12145 info->object_wrapper());
12146 if (*codes != map->dependent_code()) map->set_dependent_code(*codes);
12147 info->dependencies(group)->Add(map, info->zone());
12148 }
12149
12150
12151 // static
12152 void Map::AddDependentCode(Handle<Map> map, 12141 void Map::AddDependentCode(Handle<Map> map,
12153 DependentCode::DependencyGroup group, 12142 DependentCode::DependencyGroup group,
12154 Handle<Code> code) { 12143 Handle<Code> code) {
12155 Handle<WeakCell> cell = Code::WeakCellFor(code); 12144 Handle<WeakCell> cell = Code::WeakCellFor(code);
12156 Handle<DependentCode> codes = DependentCode::InsertWeakCode( 12145 Handle<DependentCode> codes = DependentCode::InsertWeakCode(
12157 Handle<DependentCode>(map->dependent_code()), group, cell); 12146 Handle<DependentCode>(map->dependent_code()), group, cell);
12158 if (*codes != map->dependent_code()) map->set_dependent_code(*codes); 12147 if (*codes != map->dependent_code()) map->set_dependent_code(*codes);
12159 } 12148 }
12160 12149
12161 12150
12162 DependentCode::GroupStartIndexes::GroupStartIndexes(DependentCode* entries) { 12151 DependentCode::GroupStartIndexes::GroupStartIndexes(DependentCode* entries) {
12163 Recompute(entries); 12152 Recompute(entries);
12164 } 12153 }
12165 12154
12166 12155
12167 void DependentCode::GroupStartIndexes::Recompute(DependentCode* entries) { 12156 void DependentCode::GroupStartIndexes::Recompute(DependentCode* entries) {
12168 start_indexes_[0] = 0; 12157 start_indexes_[0] = 0;
12169 for (int g = 1; g <= kGroupCount; g++) { 12158 for (int g = 1; g <= kGroupCount; g++) {
12170 int count = entries->number_of_entries(static_cast<DependencyGroup>(g - 1)); 12159 int count = entries->number_of_entries(static_cast<DependencyGroup>(g - 1));
12171 start_indexes_[g] = start_indexes_[g - 1] + count; 12160 start_indexes_[g] = start_indexes_[g - 1] + count;
12172 } 12161 }
12173 } 12162 }
12174 12163
12175 12164
12176 DependentCode* DependentCode::ForObject(Handle<HeapObject> object, 12165 Handle<DependentCode> DependentCode::InsertCompilationDependencies(
12177 DependencyGroup group) {
12178 AllowDeferredHandleDereference dependencies_are_safe;
12179 if (group == DependentCode::kPropertyCellChangedGroup) {
12180 return Handle<PropertyCell>::cast(object)->dependent_code();
12181 } else if (group == DependentCode::kAllocationSiteTenuringChangedGroup ||
12182 group == DependentCode::kAllocationSiteTransitionChangedGroup) {
12183 return Handle<AllocationSite>::cast(object)->dependent_code();
12184 }
12185 return Handle<Map>::cast(object)->dependent_code();
12186 }
12187
12188
12189 Handle<DependentCode> DependentCode::InsertCompilationInfo(
12190 Handle<DependentCode> entries, DependencyGroup group, 12166 Handle<DependentCode> entries, DependencyGroup group,
12191 Handle<Foreign> info) { 12167 Handle<Foreign> info) {
12192 return Insert(entries, group, info); 12168 return Insert(entries, group, info);
12193 } 12169 }
12194 12170
12195 12171
12196 Handle<DependentCode> DependentCode::InsertWeakCode( 12172 Handle<DependentCode> DependentCode::InsertWeakCode(
12197 Handle<DependentCode> entries, DependencyGroup group, 12173 Handle<DependentCode> entries, DependencyGroup group,
12198 Handle<WeakCell> code_cell) { 12174 Handle<WeakCell> code_cell) {
12199 return Insert(entries, group, code_cell); 12175 return Insert(entries, group, code_cell);
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
12285 } 12261 }
12286 12262
12287 #ifdef DEBUG 12263 #ifdef DEBUG
12288 for (int i = start; i < end; i++) { 12264 for (int i = start; i < end; i++) {
12289 DCHECK(object_at(i) != info); 12265 DCHECK(object_at(i) != info);
12290 } 12266 }
12291 #endif 12267 #endif
12292 } 12268 }
12293 12269
12294 12270
12295 void DependentCode::RemoveCompilationInfo(DependentCode::DependencyGroup group, 12271 void DependentCode::RemoveCompilationDependencies(
12296 Foreign* info) { 12272 DependentCode::DependencyGroup group, Foreign* info) {
12297 DisallowHeapAllocation no_allocation; 12273 DisallowHeapAllocation no_allocation;
12298 GroupStartIndexes starts(this); 12274 GroupStartIndexes starts(this);
12299 int start = starts.at(group); 12275 int start = starts.at(group);
12300 int end = starts.at(group + 1); 12276 int end = starts.at(group + 1);
12301 // Find compilation info wrapper. 12277 // Find compilation info wrapper.
12302 int info_pos = -1; 12278 int info_pos = -1;
12303 for (int i = start; i < end; i++) { 12279 for (int i = start; i < end; i++) {
12304 if (object_at(i) == info) { 12280 if (object_at(i) == info) {
12305 info_pos = i; 12281 info_pos = i;
12306 break; 12282 break;
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
12360 Code* code = Code::cast(cell->value()); 12336 Code* code = Code::cast(cell->value());
12361 if (!code->marked_for_deoptimization()) { 12337 if (!code->marked_for_deoptimization()) {
12362 SetMarkedForDeoptimization(code, group); 12338 SetMarkedForDeoptimization(code, group);
12363 if (invalidate_embedded_objects) { 12339 if (invalidate_embedded_objects) {
12364 code->InvalidateEmbeddedObjects(); 12340 code->InvalidateEmbeddedObjects();
12365 } 12341 }
12366 marked = true; 12342 marked = true;
12367 } 12343 }
12368 } else { 12344 } else {
12369 DCHECK(obj->IsForeign()); 12345 DCHECK(obj->IsForeign());
12370 CompilationInfo* info = reinterpret_cast<CompilationInfo*>( 12346 CompilationDependencies* info =
12371 Foreign::cast(obj)->foreign_address()); 12347 reinterpret_cast<CompilationDependencies*>(
12372 info->AbortDueToDependencyChange(); 12348 Foreign::cast(obj)->foreign_address());
12349 info->Abort();
12373 } 12350 }
12374 } 12351 }
12375 // Compact the array by moving all subsequent groups to fill in the new holes. 12352 // Compact the array by moving all subsequent groups to fill in the new holes.
12376 for (int src = end, dst = start; src < code_entries; src++, dst++) { 12353 for (int src = end, dst = start; src < code_entries; src++, dst++) {
12377 copy(src, dst); 12354 copy(src, dst);
12378 } 12355 }
12379 // Now the holes are at the end of the array, zap them for heap-verifier. 12356 // Now the holes are at the end of the array, zap them for heap-verifier.
12380 int removed = end - start; 12357 int removed = end - start;
12381 for (int i = code_entries - removed; i < code_entries; i++) { 12358 for (int i = code_entries - removed; i < code_entries; i++) {
12382 clear_at(i); 12359 clear_at(i);
(...skipping 1059 matching lines...) Expand 10 before | Expand all | Expand 10 after
13442 ElementsKindToString(to_kind)); 13419 ElementsKindToString(to_kind));
13443 } 13420 }
13444 site->SetElementsKind(to_kind); 13421 site->SetElementsKind(to_kind);
13445 site->dependent_code()->DeoptimizeDependentCodeGroup( 13422 site->dependent_code()->DeoptimizeDependentCodeGroup(
13446 isolate, DependentCode::kAllocationSiteTransitionChangedGroup); 13423 isolate, DependentCode::kAllocationSiteTransitionChangedGroup);
13447 } 13424 }
13448 } 13425 }
13449 } 13426 }
13450 13427
13451 13428
13452 // static
13453 void AllocationSite::RegisterForDeoptOnTenureChange(Handle<AllocationSite> site,
13454 CompilationInfo* info) {
13455 AddDependentCompilationInfo(
13456 site, DependentCode::kAllocationSiteTenuringChangedGroup, info);
13457 }
13458
13459
13460 // static
13461 void AllocationSite::RegisterForDeoptOnTransitionChange(
13462 Handle<AllocationSite> site, CompilationInfo* info) {
13463 // Do nothing if the object doesn't have any useful element transitions left.
13464 ElementsKind kind =
13465 site->SitePointsToLiteral()
13466 ? JSObject::cast(site->transition_info())->GetElementsKind()
13467 : site->GetElementsKind();
13468 if (AllocationSite::GetMode(kind) == TRACK_ALLOCATION_SITE) {
13469 AddDependentCompilationInfo(
13470 site, DependentCode::kAllocationSiteTransitionChangedGroup, info);
13471 }
13472 }
13473
13474
13475 // static
13476 void AllocationSite::AddDependentCompilationInfo(
13477 Handle<AllocationSite> site, DependentCode::DependencyGroup group,
13478 CompilationInfo* info) {
13479 Handle<DependentCode> dep(site->dependent_code());
13480 Handle<DependentCode> codes =
13481 DependentCode::InsertCompilationInfo(dep, group, info->object_wrapper());
13482 if (*codes != site->dependent_code()) site->set_dependent_code(*codes);
13483 info->dependencies(group)->Add(Handle<HeapObject>(*site), info->zone());
13484 }
13485
13486
13487 const char* AllocationSite::PretenureDecisionName(PretenureDecision decision) { 13429 const char* AllocationSite::PretenureDecisionName(PretenureDecision decision) {
13488 switch (decision) { 13430 switch (decision) {
13489 case kUndecided: return "undecided"; 13431 case kUndecided: return "undecided";
13490 case kDontTenure: return "don't tenure"; 13432 case kDontTenure: return "don't tenure";
13491 case kMaybeTenure: return "maybe tenure"; 13433 case kMaybeTenure: return "maybe tenure";
13492 case kTenure: return "tenure"; 13434 case kTenure: return "tenure";
13493 case kZombie: return "zombie"; 13435 case kZombie: return "zombie";
13494 default: UNREACHABLE(); 13436 default: UNREACHABLE();
13495 } 13437 }
13496 return NULL; 13438 return NULL;
(...skipping 3633 matching lines...) Expand 10 before | Expand all | Expand 10 after
17130 // Deopt when transitioning from a constant type. 17072 // Deopt when transitioning from a constant type.
17131 if (!invalidate && old_type == PropertyCellType::kConstant && 17073 if (!invalidate && old_type == PropertyCellType::kConstant &&
17132 new_type != PropertyCellType::kConstant) { 17074 new_type != PropertyCellType::kConstant) {
17133 auto isolate = dictionary->GetIsolate(); 17075 auto isolate = dictionary->GetIsolate();
17134 cell->dependent_code()->DeoptimizeDependentCodeGroup( 17076 cell->dependent_code()->DeoptimizeDependentCodeGroup(
17135 isolate, DependentCode::kPropertyCellChangedGroup); 17077 isolate, DependentCode::kPropertyCellChangedGroup);
17136 } 17078 }
17137 return value; 17079 return value;
17138 } 17080 }
17139 17081
17140
17141 // static
17142 void PropertyCell::AddDependentCompilationInfo(Handle<PropertyCell> cell,
17143 CompilationInfo* info) {
17144 Handle<DependentCode> codes = DependentCode::InsertCompilationInfo(
17145 handle(cell->dependent_code(), info->isolate()),
17146 DependentCode::kPropertyCellChangedGroup, info->object_wrapper());
17147 if (*codes != cell->dependent_code()) cell->set_dependent_code(*codes);
17148 info->dependencies(DependentCode::kPropertyCellChangedGroup)->Add(
17149 cell, info->zone());
17150 }
17151
17152 } } // namespace v8::internal 17082 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/objects.h ('k') | test/cctest/test-migrations.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698