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

Side by Side Diff: src/lithium.cc

Issue 866723002: Treat pointers in optimized code as strong before all weak dependencies are registered. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: fix check Created 5 years, 11 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/lithium.h ('k') | src/lithium-codegen.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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 "src/lithium.h" 5 #include "src/lithium.h"
6 6
7 #include "src/v8.h" 7 #include "src/v8.h"
8 8
9 #include "src/scopes.h" 9 #include "src/scopes.h"
10 #include "src/serialize.h" 10 #include "src/serialize.h"
(...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after
406 return HConstant::cast(graph_->LookupValue(operand->index())); 406 return HConstant::cast(graph_->LookupValue(operand->index()));
407 } 407 }
408 408
409 409
410 Representation LChunk::LookupLiteralRepresentation( 410 Representation LChunk::LookupLiteralRepresentation(
411 LConstantOperand* operand) const { 411 LConstantOperand* operand) const {
412 return graph_->LookupValue(operand->index())->representation(); 412 return graph_->LookupValue(operand->index())->representation();
413 } 413 }
414 414
415 415
416 static void AddWeakObjectToCodeDependency(Isolate* isolate,
417 Handle<Object> object,
418 Handle<Code> code) {
419 Heap* heap = isolate->heap();
420 heap->EnsureWeakObjectToCodeTable();
421 Handle<DependentCode> dep(heap->LookupWeakObjectToCodeDependency(object));
422 dep = DependentCode::Insert(dep, DependentCode::kWeakCodeGroup, code);
423 heap->AddWeakObjectToCodeDependency(object, dep);
424 }
425
426
427 void LChunk::RegisterWeakObjectsInOptimizedCode(Handle<Code> code) const {
428 DCHECK(code->is_optimized_code());
429 ZoneList<Handle<Map> > maps(1, zone());
430 ZoneList<Handle<JSObject> > objects(1, zone());
431 ZoneList<Handle<Cell> > cells(1, zone());
432 int mode_mask = RelocInfo::ModeMask(RelocInfo::EMBEDDED_OBJECT) |
433 RelocInfo::ModeMask(RelocInfo::CELL);
434 for (RelocIterator it(*code, mode_mask); !it.done(); it.next()) {
435 RelocInfo::Mode mode = it.rinfo()->rmode();
436 if (mode == RelocInfo::CELL &&
437 code->IsWeakObjectInOptimizedCode(it.rinfo()->target_cell())) {
438 Handle<Cell> cell(it.rinfo()->target_cell());
439 cells.Add(cell, zone());
440 } else if (mode == RelocInfo::EMBEDDED_OBJECT &&
441 code->IsWeakObjectInOptimizedCode(it.rinfo()->target_object())) {
442 if (it.rinfo()->target_object()->IsMap()) {
443 Handle<Map> map(Map::cast(it.rinfo()->target_object()));
444 maps.Add(map, zone());
445 } else if (it.rinfo()->target_object()->IsJSObject()) {
446 Handle<JSObject> object(JSObject::cast(it.rinfo()->target_object()));
447 objects.Add(object, zone());
448 } else if (it.rinfo()->target_object()->IsCell()) {
449 Handle<Cell> cell(Cell::cast(it.rinfo()->target_object()));
450 cells.Add(cell, zone());
451 }
452 }
453 }
454 for (int i = 0; i < maps.length(); i++) {
455 Map::AddDependentCode(maps.at(i), DependentCode::kWeakCodeGroup, code);
456 }
457 for (int i = 0; i < objects.length(); i++) {
458 AddWeakObjectToCodeDependency(isolate(), objects.at(i), code);
459 }
460 for (int i = 0; i < cells.length(); i++) {
461 AddWeakObjectToCodeDependency(isolate(), cells.at(i), code);
462 }
463 if (FLAG_enable_ool_constant_pool) {
464 code->constant_pool()->set_weak_object_state(
465 ConstantPoolArray::WEAK_OBJECTS_IN_OPTIMIZED_CODE);
466 }
467 code->set_can_have_weak_objects(true);
468 }
469
470
416 void LChunk::CommitDependencies(Handle<Code> code) const { 471 void LChunk::CommitDependencies(Handle<Code> code) const {
417 for (MapSet::const_iterator it = deprecation_dependencies_.begin(), 472 for (MapSet::const_iterator it = deprecation_dependencies_.begin(),
418 iend = deprecation_dependencies_.end(); it != iend; ++it) { 473 iend = deprecation_dependencies_.end(); it != iend; ++it) {
419 Handle<Map> map = *it; 474 Handle<Map> map = *it;
420 DCHECK(!map->is_deprecated()); 475 DCHECK(!map->is_deprecated());
421 DCHECK(map->CanBeDeprecated()); 476 DCHECK(map->CanBeDeprecated());
422 Map::AddDependentCode(map, DependentCode::kTransitionGroup, code); 477 Map::AddDependentCode(map, DependentCode::kTransitionGroup, code);
423 } 478 }
424 479
425 for (MapSet::const_iterator it = stability_dependencies_.begin(), 480 for (MapSet::const_iterator it = stability_dependencies_.begin(),
426 iend = stability_dependencies_.end(); it != iend; ++it) { 481 iend = stability_dependencies_.end(); it != iend; ++it) {
427 Handle<Map> map = *it; 482 Handle<Map> map = *it;
428 DCHECK(map->is_stable()); 483 DCHECK(map->is_stable());
429 DCHECK(map->CanTransition()); 484 DCHECK(map->CanTransition());
430 Map::AddDependentCode(map, DependentCode::kPrototypeCheckGroup, code); 485 Map::AddDependentCode(map, DependentCode::kPrototypeCheckGroup, code);
431 } 486 }
432 487
433 info_->CommitDependencies(code); 488 info_->CommitDependencies(code);
489 if (code->is_optimized_code()) RegisterWeakObjectsInOptimizedCode(code);
434 } 490 }
435 491
436 492
437 LChunk* LChunk::NewChunk(HGraph* graph) { 493 LChunk* LChunk::NewChunk(HGraph* graph) {
438 DisallowHandleAllocation no_handles; 494 DisallowHandleAllocation no_handles;
439 DisallowHeapAllocation no_gc; 495 DisallowHeapAllocation no_gc;
440 graph->DisallowAddingNewValues(); 496 graph->DisallowAddingNewValues();
441 int values = graph->GetMaximumValueID(); 497 int values = graph->GetMaximumValueID();
442 CompilationInfo* info = graph->info(); 498 CompilationInfo* info = graph->info();
443 if (values > LUnallocated::kMaxVirtualRegisters) { 499 if (values > LUnallocated::kMaxVirtualRegisters) {
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
665 721
666 722
667 LPhase::~LPhase() { 723 LPhase::~LPhase() {
668 if (ShouldProduceTraceOutput()) { 724 if (ShouldProduceTraceOutput()) {
669 isolate()->GetHTracer()->TraceLithium(name(), chunk_); 725 isolate()->GetHTracer()->TraceLithium(name(), chunk_);
670 } 726 }
671 } 727 }
672 728
673 729
674 } } // namespace v8::internal 730 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/lithium.h ('k') | src/lithium-codegen.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698