diff options
Diffstat (limited to 'deps/v8/src/objects/code.cc')
-rw-r--r-- | deps/v8/src/objects/code.cc | 342 |
1 files changed, 150 insertions, 192 deletions
diff --git a/deps/v8/src/objects/code.cc b/deps/v8/src/objects/code.cc index 46d9edb471..1ca28beb30 100644 --- a/deps/v8/src/objects/code.cc +++ b/deps/v8/src/objects/code.cc @@ -6,6 +6,7 @@ #include <iomanip> +#include "src/base/v8-fallthrough.h" #include "src/codegen/assembler-inl.h" #include "src/codegen/cpu-features.h" #include "src/codegen/reloc-info.h" @@ -30,6 +31,10 @@ #include "src/diagnostics/eh-frame.h" #endif +#ifdef V8_ENABLE_WEBASSEMBLY +#include "src/wasm/wasm-code-manager.h" +#endif + namespace v8 { namespace internal { @@ -49,7 +54,7 @@ inline EmbeddedData EmbeddedDataWithMaybeRemappedEmbeddedBuiltins( // copy of the re-embedded builtins in the shared CodeRange, so use that if // it's present. if (v8_flags.jitless) return EmbeddedData::FromBlob(); - CodeRange* code_range = CodeRange::GetProcessWideCodeRange().get(); + CodeRange* code_range = CodeRange::GetProcessWideCodeRange(); return (code_range && code_range->embedded_blob_code_copy() != nullptr) ? EmbeddedData::FromBlob(code_range) : EmbeddedData::FromBlob(); @@ -62,91 +67,108 @@ inline EmbeddedData EmbeddedDataWithMaybeRemappedEmbeddedBuiltins( } // namespace -Address OffHeapInstructionStart(HeapObject code, Builtin builtin) { +Address Code::OffHeapInstructionStart() const { // TODO(11527): Here and below: pass Isolate as an argument for getting // the EmbeddedData. - EmbeddedData d = EmbeddedDataWithMaybeRemappedEmbeddedBuiltins(code); + Builtin builtin = builtin_id(); + EmbeddedData d = EmbeddedDataWithMaybeRemappedEmbeddedBuiltins(*this); return d.InstructionStartOfBuiltin(builtin); } -Address OffHeapInstructionEnd(HeapObject code, Builtin builtin) { - EmbeddedData d = EmbeddedDataWithMaybeRemappedEmbeddedBuiltins(code); +Address Code::OffHeapInstructionEnd() const { + Builtin builtin = builtin_id(); + EmbeddedData d = EmbeddedDataWithMaybeRemappedEmbeddedBuiltins(*this); return d.InstructionStartOfBuiltin(builtin) + d.InstructionSizeOfBuiltin(builtin); } -int OffHeapInstructionSize(HeapObject code, Builtin builtin) { - EmbeddedData d = EmbeddedDataWithMaybeRemappedEmbeddedBuiltins(code); +int Code::OffHeapInstructionSize() const { + Builtin builtin = builtin_id(); + EmbeddedData d = EmbeddedDataWithMaybeRemappedEmbeddedBuiltins(*this); return d.InstructionSizeOfBuiltin(builtin); } -Address OffHeapMetadataStart(HeapObject code, Builtin builtin) { - EmbeddedData d = EmbeddedDataWithMaybeRemappedEmbeddedBuiltins(code); +Address Code::OffHeapMetadataStart() const { + Builtin builtin = builtin_id(); + EmbeddedData d = EmbeddedDataWithMaybeRemappedEmbeddedBuiltins(*this); return d.MetadataStartOfBuiltin(builtin); } -Address OffHeapMetadataEnd(HeapObject code, Builtin builtin) { - EmbeddedData d = EmbeddedDataWithMaybeRemappedEmbeddedBuiltins(code); +Address Code::OffHeapMetadataEnd() const { + Builtin builtin = builtin_id(); + EmbeddedData d = EmbeddedDataWithMaybeRemappedEmbeddedBuiltins(*this); return d.MetadataStartOfBuiltin(builtin) + d.MetadataSizeOfBuiltin(builtin); } -int OffHeapMetadataSize(HeapObject code, Builtin builtin) { - EmbeddedData d = EmbeddedDataWithMaybeRemappedEmbeddedBuiltins(code); +int Code::OffHeapMetadataSize() const { + Builtin builtin = builtin_id(); + EmbeddedData d = EmbeddedDataWithMaybeRemappedEmbeddedBuiltins(*this); return d.MetadataSizeOfBuiltin(builtin); } -Address OffHeapSafepointTableAddress(HeapObject code, Builtin builtin) { - EmbeddedData d = EmbeddedDataWithMaybeRemappedEmbeddedBuiltins(code); +Address Code::OffHeapSafepointTableAddress() const { + Builtin builtin = builtin_id(); + EmbeddedData d = EmbeddedDataWithMaybeRemappedEmbeddedBuiltins(*this); return d.SafepointTableStartOf(builtin); } -int OffHeapSafepointTableSize(HeapObject code, Builtin builtin) { - EmbeddedData d = EmbeddedDataWithMaybeRemappedEmbeddedBuiltins(code); +int Code::OffHeapSafepointTableSize() const { + Builtin builtin = builtin_id(); + EmbeddedData d = EmbeddedDataWithMaybeRemappedEmbeddedBuiltins(*this); return d.SafepointTableSizeOf(builtin); } -Address OffHeapHandlerTableAddress(HeapObject code, Builtin builtin) { - EmbeddedData d = EmbeddedDataWithMaybeRemappedEmbeddedBuiltins(code); +Address Code::OffHeapHandlerTableAddress() const { + Builtin builtin = builtin_id(); + EmbeddedData d = EmbeddedDataWithMaybeRemappedEmbeddedBuiltins(*this); return d.HandlerTableStartOf(builtin); } -int OffHeapHandlerTableSize(HeapObject code, Builtin builtin) { - EmbeddedData d = EmbeddedDataWithMaybeRemappedEmbeddedBuiltins(code); +int Code::OffHeapHandlerTableSize() const { + Builtin builtin = builtin_id(); + EmbeddedData d = EmbeddedDataWithMaybeRemappedEmbeddedBuiltins(*this); return d.HandlerTableSizeOf(builtin); } -Address OffHeapConstantPoolAddress(HeapObject code, Builtin builtin) { - EmbeddedData d = EmbeddedDataWithMaybeRemappedEmbeddedBuiltins(code); +Address Code::OffHeapConstantPoolAddress() const { + Builtin builtin = builtin_id(); + EmbeddedData d = EmbeddedDataWithMaybeRemappedEmbeddedBuiltins(*this); return d.ConstantPoolStartOf(builtin); } -int OffHeapConstantPoolSize(HeapObject code, Builtin builtin) { - EmbeddedData d = EmbeddedDataWithMaybeRemappedEmbeddedBuiltins(code); +int Code::OffHeapConstantPoolSize() const { + Builtin builtin = builtin_id(); + EmbeddedData d = EmbeddedDataWithMaybeRemappedEmbeddedBuiltins(*this); return d.ConstantPoolSizeOf(builtin); } -Address OffHeapCodeCommentsAddress(HeapObject code, Builtin builtin) { - EmbeddedData d = EmbeddedDataWithMaybeRemappedEmbeddedBuiltins(code); +Address Code::OffHeapCodeCommentsAddress() const { + Builtin builtin = builtin_id(); + EmbeddedData d = EmbeddedDataWithMaybeRemappedEmbeddedBuiltins(*this); return d.CodeCommentsStartOf(builtin); } -int OffHeapCodeCommentsSize(HeapObject code, Builtin builtin) { - EmbeddedData d = EmbeddedDataWithMaybeRemappedEmbeddedBuiltins(code); +int Code::OffHeapCodeCommentsSize() const { + Builtin builtin = builtin_id(); + EmbeddedData d = EmbeddedDataWithMaybeRemappedEmbeddedBuiltins(*this); return d.CodeCommentsSizeOf(builtin); } -Address OffHeapUnwindingInfoAddress(HeapObject code, Builtin builtin) { - EmbeddedData d = EmbeddedDataWithMaybeRemappedEmbeddedBuiltins(code); +Address Code::OffHeapUnwindingInfoAddress() const { + Builtin builtin = builtin_id(); + EmbeddedData d = EmbeddedDataWithMaybeRemappedEmbeddedBuiltins(*this); return d.UnwindingInfoStartOf(builtin); } -int OffHeapUnwindingInfoSize(HeapObject code, Builtin builtin) { - EmbeddedData d = EmbeddedDataWithMaybeRemappedEmbeddedBuiltins(code); +int Code::OffHeapUnwindingInfoSize() const { + Builtin builtin = builtin_id(); + EmbeddedData d = EmbeddedDataWithMaybeRemappedEmbeddedBuiltins(*this); return d.UnwindingInfoSizeOf(builtin); } -int OffHeapStackSlots(HeapObject code, Builtin builtin) { - EmbeddedData d = EmbeddedDataWithMaybeRemappedEmbeddedBuiltins(code); +int Code::OffHeapStackSlots() const { + Builtin builtin = builtin_id(); + EmbeddedData d = EmbeddedDataWithMaybeRemappedEmbeddedBuiltins(*this); return d.StackSlotsOf(builtin); } @@ -160,25 +182,31 @@ void Code::ClearEmbeddedObjects(Heap* heap) { set_embedded_objects_cleared(true); } -void Code::Relocate(intptr_t delta) { - for (RelocIterator it(*this, RelocInfo::kApplyMask); !it.done(); it.next()) { +void InstructionStream::Relocate(intptr_t delta) { + Code code = unchecked_code(); + // This is called during evacuation and code.instruction_stream() will point + // to the old object. So pass *this directly to the RelocIterator and use a + // dummy Code() since it's not needed. + for (RelocIterator it(Code(), *this, code.unchecked_relocation_info(), + code.constant_pool(), RelocInfo::kApplyMask); + !it.done(); it.next()) { it.rinfo()->apply(delta); } - FlushICache(); + FlushInstructionCache(instruction_start(), code.instruction_size()); } void Code::FlushICache() const { - FlushInstructionCache(raw_instruction_start(), raw_instruction_size()); + FlushInstructionCache(InstructionStart(), instruction_size()); } void Code::CopyFromNoFlush(ByteArray reloc_info, Heap* heap, const CodeDesc& desc) { // Copy code. - static_assert(kOnHeapBodyIsContiguous); - CopyBytes(reinterpret_cast<byte*>(raw_instruction_start()), desc.buffer, + static_assert(InstructionStream::kOnHeapBodyIsContiguous); + CopyBytes(reinterpret_cast<byte*>(InstructionStart()), desc.buffer, static_cast<size_t>(desc.instr_size)); // TODO(jgruber,v8:11036): Merge with the above. - CopyBytes(reinterpret_cast<byte*>(raw_instruction_start() + desc.instr_size), + CopyBytes(reinterpret_cast<byte*>(InstructionStart() + desc.instr_size), desc.unwinding_info, static_cast<size_t>(desc.unwinding_info_size)); // Copy reloc info. @@ -203,9 +231,9 @@ void Code::RelocateFromDesc(ByteArray reloc_info, Heap* heap, // Rewrite code handles to direct pointers to the first instruction in the // code object. Handle<HeapObject> p = it.rinfo()->target_object_handle(origin); - DCHECK(p->IsCodeT(GetPtrComprCageBaseSlow(*p))); - Code code = FromCodeT(CodeT::cast(*p)); - it.rinfo()->set_target_address(code.raw_instruction_start(), + DCHECK(p->IsCode(GetPtrComprCageBaseSlow(*p))); + InstructionStream code = FromCode(Code::cast(*p)); + it.rinfo()->set_target_address(code.instruction_start(), UPDATE_WRITE_BARRIER, SKIP_ICACHE_FLUSH); } else if (RelocInfo::IsNearBuiltinEntry(mode)) { // Rewrite builtin IDs to PC-relative offset to the builtin entry point. @@ -215,9 +243,23 @@ void Code::RelocateFromDesc(ByteArray reloc_info, Heap* heap, it.rinfo()->set_target_address(p, UPDATE_WRITE_BARRIER, SKIP_ICACHE_FLUSH); DCHECK_EQ(p, it.rinfo()->target_address()); + } else if (RelocInfo::IsWasmStubCall(mode)) { +#if V8_ENABLE_WEBASSEMBLY + // Map wasm stub id to builtin. + uint32_t stub_call_tag = it.rinfo()->wasm_call_tag(); + DCHECK_LT(stub_call_tag, wasm::WasmCode::kRuntimeStubCount); + Builtin builtin = wasm::RuntimeStubIdToBuiltinName( + static_cast<wasm::WasmCode::RuntimeStubId>(stub_call_tag)); + // Store the builtin address in relocation info. + Address entry = + heap->isolate()->builtin_entry_table()[Builtins::ToInt(builtin)]; + it.rinfo()->set_wasm_stub_call_address(entry, SKIP_ICACHE_FLUSH); +#else + UNREACHABLE(); +#endif } else { intptr_t delta = - raw_instruction_start() - reinterpret_cast<Address>(desc.buffer); + InstructionStart() - reinterpret_cast<Address>(desc.buffer); it.rinfo()->apply(delta); } } @@ -229,15 +271,6 @@ SafepointEntry Code::GetSafepointEntry(Isolate* isolate, Address pc) { return table.FindEntry(pc); } -#ifdef V8_EXTERNAL_CODE_SPACE -SafepointEntry CodeDataContainer::GetSafepointEntry(Isolate* isolate, - Address pc) { - DCHECK(!is_maglevved()); - SafepointTable table(isolate, pc, *this); - return table.FindEntry(pc); -} -#endif // V8_EXTERNAL_CODE_SPACE - MaglevSafepointEntry Code::GetMaglevSafepointEntry(Isolate* isolate, Address pc) { DCHECK(is_maglevved()); @@ -245,60 +278,24 @@ MaglevSafepointEntry Code::GetMaglevSafepointEntry(Isolate* isolate, return table.FindEntry(pc); } -#ifdef V8_EXTERNAL_CODE_SPACE -MaglevSafepointEntry CodeDataContainer::GetMaglevSafepointEntry( - Isolate* isolate, Address pc) { - DCHECK(is_maglevved()); - MaglevSafepointTable table(isolate, pc, *this); - return table.FindEntry(pc); -} -#endif // V8_EXTERNAL_CODE_SPACE - Address Code::OffHeapInstructionStart(Isolate* isolate, Address pc) const { - DCHECK(is_off_heap_trampoline()); + DCHECK(!has_instruction_stream()); EmbeddedData d = EmbeddedData::GetEmbeddedDataForPC(isolate, pc); return d.InstructionStartOfBuiltin(builtin_id()); } -#ifdef V8_EXTERNAL_CODE_SPACE -Address CodeDataContainer::OffHeapInstructionStart(Isolate* isolate, - Address pc) const { - DCHECK(is_off_heap_trampoline()); - EmbeddedData d = EmbeddedData::GetEmbeddedDataForPC(isolate, pc); - return d.InstructionStartOfBuiltin(builtin_id()); -} -#endif - Address Code::OffHeapInstructionEnd(Isolate* isolate, Address pc) const { - DCHECK(is_off_heap_trampoline()); + DCHECK(!has_instruction_stream()); EmbeddedData d = EmbeddedData::GetEmbeddedDataForPC(isolate, pc); return d.InstructionEndOf(builtin_id()); } -#ifdef V8_EXTERNAL_CODE_SPACE -Address CodeDataContainer::OffHeapInstructionEnd(Isolate* isolate, - Address pc) const { - DCHECK(is_off_heap_trampoline()); - EmbeddedData d = EmbeddedData::GetEmbeddedDataForPC(isolate, pc); - return d.InstructionEndOf(builtin_id()); -} -#endif // V8_EXTERNAL_CODE_SPACE - bool Code::OffHeapBuiltinContains(Isolate* isolate, Address pc) const { - DCHECK(is_off_heap_trampoline()); + DCHECK(!has_instruction_stream()); EmbeddedData d = EmbeddedData::GetEmbeddedDataForPC(isolate, pc); return d.BuiltinContains(builtin_id(), pc); } -#ifdef V8_EXTERNAL_CODE_SPACE -bool CodeDataContainer::OffHeapBuiltinContains(Isolate* isolate, - Address pc) const { - DCHECK(is_off_heap_trampoline()); - EmbeddedData d = EmbeddedData::GetEmbeddedDataForPC(isolate, pc); - return d.BuiltinContains(builtin_id(), pc); -} -#endif // V8_EXTERNAL_CODE_SPACE - // TODO(cbruni): Move to BytecodeArray int AbstractCode::SourcePosition(PtrComprCageBase cage_base, int offset) { CHECK_NE(kind(cage_base), CodeKind::BASELINE); @@ -339,21 +336,6 @@ int AbstractCode::SourceStatementPosition(PtrComprCageBase cage_base, return statement_position; } -bool Code::CanDeoptAt(Isolate* isolate, Address pc) { - DeoptimizationData deopt_data = - DeoptimizationData::cast(deoptimization_data()); - Address code_start_address = InstructionStart(isolate, pc); - for (int i = 0; i < deopt_data.DeoptCount(); i++) { - if (deopt_data.Pc(i).value() == -1) continue; - Address address = code_start_address + deopt_data.Pc(i).value(); - if (address == pc && - deopt_data.GetBytecodeOffset(i) != BytecodeOffset::None()) { - return true; - } - } - return false; -} - bool Code::IsIsolateIndependent(Isolate* isolate) { static constexpr int kModeMask = RelocInfo::AllRealModesMask() & @@ -389,9 +371,10 @@ bool Code::IsIsolateIndependent(Isolate* isolate) { if (OffHeapInstructionStream::PcIsOffHeap(isolate, target_address)) continue; - Code target = Code::GetCodeFromTargetAddress(target_address); - CHECK(target.IsCode()); - if (Builtins::IsIsolateIndependentBuiltin(target)) continue; + Code target = Code::FromTargetAddress(target_address); + if (Builtins::IsIsolateIndependentBuiltin(target)) { + continue; + } } return false; } @@ -417,35 +400,48 @@ bool Code::Inlines(SharedFunctionInfo sfi) { return false; } -Code::OptimizedCodeIterator::OptimizedCodeIterator(Isolate* isolate) { - isolate_ = isolate; - Object list = isolate->heap()->native_contexts_list(); - next_context_ = - list.IsUndefined(isolate_) ? NativeContext() : NativeContext::cast(list); -} +Code::OptimizedCodeIterator::OptimizedCodeIterator(Isolate* isolate) + : isolate_(isolate), + safepoint_scope_(std::make_unique<SafepointScope>( + isolate, isolate->is_shared_space_isolate() + ? SafepointKind::kGlobal + : SafepointKind::kIsolate)), + object_iterator_( + isolate->heap()->code_space()->GetObjectIterator(isolate->heap())), + state_(kIteratingCodeSpace) {} Code Code::OptimizedCodeIterator::Next() { - do { - Object next; - if (!current_code_.is_null()) { - // Get next code in the linked list. - next = current_code_.next_code_link(); - } else if (!next_context_.is_null()) { - // Linked list of code exhausted. Get list of next context. - next = next_context_.OptimizedCodeListHead(); - Object next_context = next_context_.next_context_link(); - next_context_ = next_context.IsUndefined(isolate_) - ? NativeContext() - : NativeContext::cast(next_context); - } else { - // Exhausted contexts. - return Code(); + while (true) { + HeapObject object = object_iterator_->Next(); + if (object.is_null()) { + // No objects left in the current iterator, try to move to the next space + // based on the state. + switch (state_) { + case kIteratingCodeSpace: { + object_iterator_ = + isolate_->heap()->code_lo_space()->GetObjectIterator( + isolate_->heap()); + state_ = kIteratingCodeLOSpace; + continue; + } + case kIteratingCodeLOSpace: + // No other spaces to iterate, so clean up and we're done. Keep the + // object iterator so that it keeps returning null on Next(), to avoid + // needing to branch on state_ before the while loop, but drop the + // safepoint scope since we no longer need to stop the heap from + // moving. + safepoint_scope_.reset(); + state_ = kDone; + V8_FALLTHROUGH; + case kDone: + return Code(); + } } - current_code_ = - next.IsUndefined(isolate_) ? Code() : FromCodeT(CodeT::cast(next)); - } while (current_code_.is_null()); - DCHECK(CodeKindCanDeoptimize(current_code_.kind())); - return current_code_; + InstructionStream istream = InstructionStream::cast(object); + Code code = istream.code(kAcquireLoad); + if (!CodeKindCanDeoptimize(code.kind())) continue; + return code; + } } Handle<DeoptimizationData> DeoptimizationData::New(Isolate* isolate, @@ -528,10 +524,8 @@ void DeoptimizationData::DeoptimizationDataPrint(std::ostream& os) { namespace { -template <typename CodeOrCodeT> -inline void DisassembleCodeRange(Isolate* isolate, std::ostream& os, - CodeOrCodeT code, Address begin, size_t size, - Address current_pc) { +void DisassembleCodeRange(Isolate* isolate, std::ostream& os, Code code, + Address begin, size_t size, Address current_pc) { Address end = begin + size; AllowHandleAllocation allow_handles; DisallowGarbageCollection no_gc; @@ -541,9 +535,8 @@ inline void DisassembleCodeRange(Isolate* isolate, std::ostream& os, CodeReference(handle(code, isolate)), current_pc); } -template <typename CodeOrCodeT> void Disassemble(const char* name, std::ostream& os, Isolate* isolate, - CodeOrCodeT code, Address current_pc) { + Code code, Address current_pc) { CodeKind kind = code.kind(); os << "kind = " << CodeKindToString(kind) << "\n"; if (name == nullptr && code.is_builtin()) { @@ -563,16 +556,6 @@ void Disassemble(const char* name, std::ostream& os, Isolate* isolate, << "\n"; os << "address = " << reinterpret_cast<void*>(code.ptr()) << "\n\n"; - if (code.IsCode() && code.is_off_heap_trampoline()) { - Code trampoline_code = Code::cast(code); - int trampoline_size = trampoline_code.raw_instruction_size(); - os << "Trampoline (size = " << trampoline_size << ")\n"; - DisassembleCodeRange(isolate, os, trampoline_code, - trampoline_code.raw_instruction_start(), - trampoline_size, current_pc); - os << "\n"; - } - { int code_size = code.InstructionSize(); os << "Instructions (size = " << code_size << ")\n"; @@ -654,8 +637,8 @@ void Disassemble(const char* name, std::ostream& os, Isolate* isolate, } os << "RelocInfo (size = " << code.relocation_size() << ")\n"; - if (code.IsCode()) { - for (RelocIterator it(Code::cast(code)); !it.done(); it.next()) { + if (code.has_instruction_stream()) { + for (RelocIterator it(code); !it.done(); it.next()) { it.rinfo()->Print(isolate, os); } } @@ -678,13 +661,6 @@ void Code::Disassemble(const char* name, std::ostream& os, Isolate* isolate, i::Disassemble(name, os, isolate, *this, current_pc); } -#ifdef V8_EXTERNAL_CODE_SPACE -void CodeDataContainer::Disassemble(const char* name, std::ostream& os, - Isolate* isolate, Address current_pc) { - i::Disassemble(name, os, isolate, *this, current_pc); -} -#endif // V8_EXTERNAL_CODE_SPACE - #endif // ENABLE_DISASSEMBLER void BytecodeArray::PrintJson(std::ostream& os) { @@ -897,8 +873,8 @@ void DependentCode::InstallDependency(Isolate* isolate, Handle<Code> code, Handle<HeapObject> object, DependencyGroups groups) { if (V8_UNLIKELY(v8_flags.trace_compilation_dependencies)) { - StdoutStream{} << "Installing dependency of [" << code->GetHeapObject() - << "] on [" << object << "] in groups ["; + StdoutStream{} << "Installing dependency of [" << code << "] on [" << object + << "] in groups ["; PrintDependencyGroups(groups); StdoutStream{} << "]\n"; } @@ -918,11 +894,10 @@ Handle<DependentCode> DependentCode::InsertWeakCode( Handle<Code> code) { if (entries->length() == entries->capacity()) { // We'd have to grow - try to compact first. - entries->IterateAndCompact([](CodeT, DependencyGroups) { return false; }); + entries->IterateAndCompact([](Code, DependencyGroups) { return false; }); } - MaybeObjectHandle code_slot(HeapObjectReference::Weak(ToCodeT(*code)), - isolate); + MaybeObjectHandle code_slot(HeapObjectReference::Weak(*code), isolate); MaybeObjectHandle group_slot(MaybeObject::FromSmi(Smi::FromInt(groups)), isolate); entries = Handle<DependentCode>::cast( @@ -930,16 +905,6 @@ Handle<DependentCode> DependentCode::InsertWeakCode( return entries; } -Handle<DependentCode> DependentCode::New(Isolate* isolate, - DependencyGroups groups, - Handle<Code> code) { - Handle<DependentCode> result = Handle<DependentCode>::cast( - isolate->factory()->NewWeakArrayList(LengthFor(1), AllocationType::kOld)); - result->Set(0, HeapObjectReference::Weak(ToCodeT(*code))); - result->Set(1, Smi::FromInt(groups)); - return result; -} - void DependentCode::IterateAndCompact(const IterateAndCompactFn& fn) { DisallowGarbageCollection no_gc; @@ -960,7 +925,7 @@ void DependentCode::IterateAndCompact(const IterateAndCompactFn& fn) { continue; } - if (fn(CodeT::cast(obj->GetHeapObjectAssumeWeak()), + if (fn(Code::cast(obj->GetHeapObjectAssumeWeak()), static_cast<DependencyGroups>( Get(i + kGroupsSlotOffset).ToSmi().value()))) { len = FillEntryFromBack(i, len); @@ -973,15 +938,15 @@ void DependentCode::IterateAndCompact(const IterateAndCompactFn& fn) { } bool DependentCode::MarkCodeForDeoptimization( - DependentCode::DependencyGroups deopt_groups) { + Isolate* isolate, DependentCode::DependencyGroups deopt_groups) { DisallowGarbageCollection no_gc; bool marked_something = false; - IterateAndCompact([&](CodeT code, DependencyGroups groups) { + IterateAndCompact([&](Code code, DependencyGroups groups) { if ((groups & deopt_groups) == 0) return false; if (!code.marked_for_deoptimization()) { - code.SetMarkedForDeoptimization("code dependencies"); + code.SetMarkedForDeoptimization(isolate, "code dependencies"); marked_something = true; } @@ -1009,7 +974,7 @@ int DependentCode::FillEntryFromBack(int index, int length) { void DependentCode::DeoptimizeDependencyGroups( Isolate* isolate, DependentCode::DependencyGroups groups) { DisallowGarbageCollection no_gc_scope; - bool marked_something = MarkCodeForDeoptimization(groups); + bool marked_something = MarkCodeForDeoptimization(isolate, groups); if (marked_something) { DCHECK(AllowCodeDependencyChange::IsAllowed()); Deoptimizer::DeoptimizeMarkedCode(isolate); @@ -1021,17 +986,10 @@ DependentCode DependentCode::empty_dependent_code(const ReadOnlyRoots& roots) { return DependentCode::cast(roots.empty_weak_array_list()); } -void Code::SetMarkedForDeoptimization(const char* reason) { - set_marked_for_deoptimization(true); - Deoptimizer::TraceMarkForDeoptimization(*this, reason); -} - -#ifdef V8_EXTERNAL_CODE_SPACE -void CodeDataContainer::SetMarkedForDeoptimization(const char* reason) { +void Code::SetMarkedForDeoptimization(Isolate* isolate, const char* reason) { set_marked_for_deoptimization(true); - Deoptimizer::TraceMarkForDeoptimization(FromCodeT(*this), reason); + Deoptimizer::TraceMarkForDeoptimization(isolate, *this, reason); } -#endif const char* DependentCode::DependencyGroupName(DependencyGroup group) { switch (group) { |