[turbofan] Move RegisterWeakObjectsInOptimizedCode.
This addresses a TODO about the correct location of the helper function in question, it is now internal to TurboFan instead of being shared. R=jarin@chromium.org Change-Id: I7e6112e9bc9759255a416fa2e2a9f92a8e4248c8 Reviewed-on: https://chromium-review.googlesource.com/542840 Reviewed-by: Jaroslav Sevcik <jarin@chromium.org> Commit-Queue: Michael Starzinger <mstarzinger@chromium.org> Cr-Commit-Position: refs/heads/master@{#46086}
This commit is contained in:
parent
ee35abf125
commit
72a597fa21
@ -212,64 +212,6 @@ void CompilationJob::RecordOptimizedCompilationStats() const {
|
||||
|
||||
Isolate* CompilationJob::isolate() const { return info()->isolate(); }
|
||||
|
||||
namespace {
|
||||
|
||||
void AddWeakObjectToCodeDependency(Isolate* isolate, Handle<HeapObject> object,
|
||||
Handle<Code> code) {
|
||||
Handle<WeakCell> cell = Code::WeakCellFor(code);
|
||||
Heap* heap = isolate->heap();
|
||||
if (heap->InNewSpace(*object)) {
|
||||
heap->AddWeakNewSpaceObjectToCodeDependency(object, cell);
|
||||
} else {
|
||||
Handle<DependentCode> dep(heap->LookupWeakObjectToCodeDependency(object));
|
||||
dep =
|
||||
DependentCode::InsertWeakCode(dep, DependentCode::kWeakCodeGroup, cell);
|
||||
heap->AddWeakObjectToCodeDependency(object, dep);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
void CompilationJob::RegisterWeakObjectsInOptimizedCode(Handle<Code> code) {
|
||||
// TODO(turbofan): Move this to pipeline.cc once Crankshaft dies.
|
||||
Isolate* const isolate = code->GetIsolate();
|
||||
DCHECK(code->is_optimized_code());
|
||||
MapHandles maps;
|
||||
std::vector<Handle<HeapObject>> objects;
|
||||
{
|
||||
DisallowHeapAllocation no_gc;
|
||||
int const mode_mask = RelocInfo::ModeMask(RelocInfo::EMBEDDED_OBJECT) |
|
||||
RelocInfo::ModeMask(RelocInfo::CELL);
|
||||
for (RelocIterator it(*code, mode_mask); !it.done(); it.next()) {
|
||||
RelocInfo::Mode mode = it.rinfo()->rmode();
|
||||
if (mode == RelocInfo::CELL &&
|
||||
code->IsWeakObjectInOptimizedCode(it.rinfo()->target_cell())) {
|
||||
objects.push_back(handle(it.rinfo()->target_cell(), isolate));
|
||||
} else if (mode == RelocInfo::EMBEDDED_OBJECT &&
|
||||
code->IsWeakObjectInOptimizedCode(
|
||||
it.rinfo()->target_object())) {
|
||||
Handle<HeapObject> object(HeapObject::cast(it.rinfo()->target_object()),
|
||||
isolate);
|
||||
if (object->IsMap()) {
|
||||
maps.push_back(Handle<Map>::cast(object));
|
||||
} else {
|
||||
objects.push_back(object);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for (Handle<Map> map : maps) {
|
||||
if (map->dependent_code()->IsEmpty(DependentCode::kWeakCodeGroup)) {
|
||||
isolate->heap()->AddRetainedMap(map);
|
||||
}
|
||||
Map::AddDependentCode(map, DependentCode::kWeakCodeGroup, code);
|
||||
}
|
||||
for (Handle<HeapObject> object : objects) {
|
||||
AddWeakObjectToCodeDependency(isolate, object, code);
|
||||
}
|
||||
code->set_can_have_weak_objects(true);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// Local helper methods that make up the compilation pipeline.
|
||||
|
||||
|
@ -216,10 +216,6 @@ class V8_EXPORT_PRIVATE CompilationJob {
|
||||
virtual Status ExecuteJobImpl() = 0;
|
||||
virtual Status FinalizeJobImpl() = 0;
|
||||
|
||||
// Registers weak object to optimized code dependencies.
|
||||
// TODO(turbofan): Move this to pipeline.cc once Crankshaft dies.
|
||||
void RegisterWeakObjectsInOptimizedCode(Handle<Code> code);
|
||||
|
||||
private:
|
||||
CompilationInfo* info_;
|
||||
ThreadId isolate_thread_id_;
|
||||
|
@ -584,6 +584,9 @@ class PipelineCompilationJob final : public CompilationJob {
|
||||
Status ExecuteJobImpl() final;
|
||||
Status FinalizeJobImpl() final;
|
||||
|
||||
// Registers weak object to optimized code dependencies.
|
||||
void RegisterWeakObjectsInOptimizedCode(Handle<Code> code);
|
||||
|
||||
private:
|
||||
std::unique_ptr<ParseInfo> parse_info_;
|
||||
ZoneStats zone_stats_;
|
||||
@ -667,6 +670,63 @@ PipelineCompilationJob::Status PipelineCompilationJob::FinalizeJobImpl() {
|
||||
return SUCCEEDED;
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
void AddWeakObjectToCodeDependency(Isolate* isolate, Handle<HeapObject> object,
|
||||
Handle<Code> code) {
|
||||
Handle<WeakCell> cell = Code::WeakCellFor(code);
|
||||
Heap* heap = isolate->heap();
|
||||
if (heap->InNewSpace(*object)) {
|
||||
heap->AddWeakNewSpaceObjectToCodeDependency(object, cell);
|
||||
} else {
|
||||
Handle<DependentCode> dep(heap->LookupWeakObjectToCodeDependency(object));
|
||||
dep =
|
||||
DependentCode::InsertWeakCode(dep, DependentCode::kWeakCodeGroup, cell);
|
||||
heap->AddWeakObjectToCodeDependency(object, dep);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
void PipelineCompilationJob::RegisterWeakObjectsInOptimizedCode(
|
||||
Handle<Code> code) {
|
||||
DCHECK(code->is_optimized_code());
|
||||
std::vector<Handle<Map>> maps;
|
||||
std::vector<Handle<HeapObject>> objects;
|
||||
{
|
||||
DisallowHeapAllocation no_gc;
|
||||
int const mode_mask = RelocInfo::ModeMask(RelocInfo::EMBEDDED_OBJECT) |
|
||||
RelocInfo::ModeMask(RelocInfo::CELL);
|
||||
for (RelocIterator it(*code, mode_mask); !it.done(); it.next()) {
|
||||
RelocInfo::Mode mode = it.rinfo()->rmode();
|
||||
if (mode == RelocInfo::CELL &&
|
||||
code->IsWeakObjectInOptimizedCode(it.rinfo()->target_cell())) {
|
||||
objects.push_back(handle(it.rinfo()->target_cell(), isolate()));
|
||||
} else if (mode == RelocInfo::EMBEDDED_OBJECT &&
|
||||
code->IsWeakObjectInOptimizedCode(
|
||||
it.rinfo()->target_object())) {
|
||||
Handle<HeapObject> object(HeapObject::cast(it.rinfo()->target_object()),
|
||||
isolate());
|
||||
if (object->IsMap()) {
|
||||
maps.push_back(Handle<Map>::cast(object));
|
||||
} else {
|
||||
objects.push_back(object);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for (Handle<Map> map : maps) {
|
||||
if (map->dependent_code()->IsEmpty(DependentCode::kWeakCodeGroup)) {
|
||||
isolate()->heap()->AddRetainedMap(map);
|
||||
}
|
||||
Map::AddDependentCode(map, DependentCode::kWeakCodeGroup, code);
|
||||
}
|
||||
for (Handle<HeapObject> object : objects) {
|
||||
AddWeakObjectToCodeDependency(isolate(), object, code);
|
||||
}
|
||||
code->set_can_have_weak_objects(true);
|
||||
}
|
||||
|
||||
class PipelineWasmCompilationJob final : public CompilationJob {
|
||||
public:
|
||||
explicit PipelineWasmCompilationJob(
|
||||
|
Loading…
Reference in New Issue
Block a user