| OLD | NEW |
| 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 396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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, | 416 static void AddWeakObjectToCodeDependency(Isolate* isolate, |
| 417 Handle<Object> object, | 417 Handle<HeapObject> object, |
| 418 Handle<Code> code) { | 418 Handle<Code> code) { |
| 419 Handle<WeakCell> cell = Code::WeakCellFor(code); |
| 419 Heap* heap = isolate->heap(); | 420 Heap* heap = isolate->heap(); |
| 420 heap->EnsureWeakObjectToCodeTable(); | |
| 421 Handle<DependentCode> dep(heap->LookupWeakObjectToCodeDependency(object)); | 421 Handle<DependentCode> dep(heap->LookupWeakObjectToCodeDependency(object)); |
| 422 dep = DependentCode::Insert(dep, DependentCode::kWeakCodeGroup, code); | 422 dep = DependentCode::InsertWeakCode(dep, DependentCode::kWeakCodeGroup, cell); |
| 423 heap->AddWeakObjectToCodeDependency(object, dep); | 423 heap->AddWeakObjectToCodeDependency(object, dep); |
| 424 } | 424 } |
| 425 | 425 |
| 426 | 426 |
| 427 void LChunk::RegisterWeakObjectsInOptimizedCode(Handle<Code> code) const { | 427 void LChunk::RegisterWeakObjectsInOptimizedCode(Handle<Code> code) const { |
| 428 DCHECK(code->is_optimized_code()); | 428 DCHECK(code->is_optimized_code()); |
| 429 ZoneList<Handle<Map> > maps(1, zone()); | 429 ZoneList<Handle<Map> > maps(1, zone()); |
| 430 ZoneList<Handle<HeapObject> > objects(1, zone()); | 430 ZoneList<Handle<HeapObject> > objects(1, zone()); |
| 431 int mode_mask = RelocInfo::ModeMask(RelocInfo::EMBEDDED_OBJECT) | | 431 int mode_mask = RelocInfo::ModeMask(RelocInfo::EMBEDDED_OBJECT) | |
| 432 RelocInfo::ModeMask(RelocInfo::CELL); | 432 RelocInfo::ModeMask(RelocInfo::CELL); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 455 } | 455 } |
| 456 if (FLAG_enable_ool_constant_pool) { | 456 if (FLAG_enable_ool_constant_pool) { |
| 457 code->constant_pool()->set_weak_object_state( | 457 code->constant_pool()->set_weak_object_state( |
| 458 ConstantPoolArray::WEAK_OBJECTS_IN_OPTIMIZED_CODE); | 458 ConstantPoolArray::WEAK_OBJECTS_IN_OPTIMIZED_CODE); |
| 459 } | 459 } |
| 460 code->set_can_have_weak_objects(true); | 460 code->set_can_have_weak_objects(true); |
| 461 } | 461 } |
| 462 | 462 |
| 463 | 463 |
| 464 void LChunk::CommitDependencies(Handle<Code> code) const { | 464 void LChunk::CommitDependencies(Handle<Code> code) const { |
| 465 if (!code->is_optimized_code()) return; |
| 466 HandleScope scope(isolate()); |
| 467 |
| 465 for (MapSet::const_iterator it = deprecation_dependencies_.begin(), | 468 for (MapSet::const_iterator it = deprecation_dependencies_.begin(), |
| 466 iend = deprecation_dependencies_.end(); it != iend; ++it) { | 469 iend = deprecation_dependencies_.end(); it != iend; ++it) { |
| 467 Handle<Map> map = *it; | 470 Handle<Map> map = *it; |
| 468 DCHECK(!map->is_deprecated()); | 471 DCHECK(!map->is_deprecated()); |
| 469 DCHECK(map->CanBeDeprecated()); | 472 DCHECK(map->CanBeDeprecated()); |
| 470 Map::AddDependentCode(map, DependentCode::kTransitionGroup, code); | 473 Map::AddDependentCode(map, DependentCode::kTransitionGroup, code); |
| 471 } | 474 } |
| 472 | 475 |
| 473 for (MapSet::const_iterator it = stability_dependencies_.begin(), | 476 for (MapSet::const_iterator it = stability_dependencies_.begin(), |
| 474 iend = stability_dependencies_.end(); it != iend; ++it) { | 477 iend = stability_dependencies_.end(); it != iend; ++it) { |
| 475 Handle<Map> map = *it; | 478 Handle<Map> map = *it; |
| 476 DCHECK(map->is_stable()); | 479 DCHECK(map->is_stable()); |
| 477 DCHECK(map->CanTransition()); | 480 DCHECK(map->CanTransition()); |
| 478 Map::AddDependentCode(map, DependentCode::kPrototypeCheckGroup, code); | 481 Map::AddDependentCode(map, DependentCode::kPrototypeCheckGroup, code); |
| 479 } | 482 } |
| 480 | 483 |
| 481 info_->CommitDependencies(code); | 484 info_->CommitDependencies(code); |
| 482 if (code->is_optimized_code()) RegisterWeakObjectsInOptimizedCode(code); | 485 RegisterWeakObjectsInOptimizedCode(code); |
| 483 } | 486 } |
| 484 | 487 |
| 485 | 488 |
| 486 LChunk* LChunk::NewChunk(HGraph* graph) { | 489 LChunk* LChunk::NewChunk(HGraph* graph) { |
| 487 DisallowHandleAllocation no_handles; | 490 DisallowHandleAllocation no_handles; |
| 488 DisallowHeapAllocation no_gc; | 491 DisallowHeapAllocation no_gc; |
| 489 graph->DisallowAddingNewValues(); | 492 graph->DisallowAddingNewValues(); |
| 490 int values = graph->GetMaximumValueID(); | 493 int values = graph->GetMaximumValueID(); |
| 491 CompilationInfo* info = graph->info(); | 494 CompilationInfo* info = graph->info(); |
| 492 if (values > LUnallocated::kMaxVirtualRegisters) { | 495 if (values > LUnallocated::kMaxVirtualRegisters) { |
| (...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 714 | 717 |
| 715 | 718 |
| 716 LPhase::~LPhase() { | 719 LPhase::~LPhase() { |
| 717 if (ShouldProduceTraceOutput()) { | 720 if (ShouldProduceTraceOutput()) { |
| 718 isolate()->GetHTracer()->TraceLithium(name(), chunk_); | 721 isolate()->GetHTracer()->TraceLithium(name(), chunk_); |
| 719 } | 722 } |
| 720 } | 723 } |
| 721 | 724 |
| 722 | 725 |
| 723 } } // namespace v8::internal | 726 } } // namespace v8::internal |
| OLD | NEW |