Commit fe6e6412 authored by ishell@chromium.org's avatar ishell@chromium.org Committed by V8 LUCI CQ

[ext-code-space] Update loggers for handling Code-less builtins

Bug: v8:11880
Change-Id: I745caa10106870eb06526cccb8693797a36ba7bd
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3825888Reviewed-by: 's avatarDominik Inführ <dinfuehr@chromium.org>
Reviewed-by: 's avatarCamillo Bruni <cbruni@chromium.org>
Reviewed-by: 's avatarJakob Linke <jgruber@chromium.org>
Commit-Queue: Igor Sheludko <ishell@chromium.org>
Cr-Commit-Position: refs/heads/main@{#82430}
parent 1cc4331e
...@@ -181,7 +181,7 @@ FullObjectSlot Builtins::builtin_tier0_slot(Builtin builtin) { ...@@ -181,7 +181,7 @@ FullObjectSlot Builtins::builtin_tier0_slot(Builtin builtin) {
void Builtins::set_code(Builtin builtin, CodeT code) { void Builtins::set_code(Builtin builtin, CodeT code) {
DCHECK_EQ(builtin, code.builtin_id()); DCHECK_EQ(builtin, code.builtin_id());
if (V8_EXTERNAL_CODE_SPACE_BOOL) { if (!V8_REMOVE_BUILTINS_CODE_OBJECTS && V8_EXTERNAL_CODE_SPACE_BOOL) {
DCHECK_EQ(builtin, FromCodeT(code).builtin_id()); DCHECK_EQ(builtin, FromCodeT(code).builtin_id());
} }
DCHECK(Internals::HasHeapObjectTag(code.ptr())); DCHECK(Internals::HasHeapObjectTag(code.ptr()));
......
...@@ -298,10 +298,11 @@ void Compiler::LogFunctionCompilation(Isolate* isolate, ...@@ -298,10 +298,11 @@ void Compiler::LogFunctionCompilation(Isolate* isolate,
Handle<AbstractCode> abstract_code, Handle<AbstractCode> abstract_code,
CodeKind kind, double time_taken_ms) { CodeKind kind, double time_taken_ms) {
DCHECK(!abstract_code.is_null()); DCHECK(!abstract_code.is_null());
if (V8_EXTERNAL_CODE_SPACE_BOOL) { DCHECK(!abstract_code.is_identical_to(BUILTIN_CODE(isolate, CompileLazy)));
if (!V8_REMOVE_BUILTINS_CODE_OBJECTS && V8_EXTERNAL_CODE_SPACE_BOOL) {
// TODO(v8:11880): remove once AbstactCode representing an embedded builtin
// will contain CodeDataContainer.
DCHECK_NE(*abstract_code, FromCodeT(*BUILTIN_CODE(isolate, CompileLazy))); DCHECK_NE(*abstract_code, FromCodeT(*BUILTIN_CODE(isolate, CompileLazy)));
} else {
DCHECK(!abstract_code.is_identical_to(BUILTIN_CODE(isolate, CompileLazy)));
} }
// Log the code generation. If source information is available include // Log the code generation. If source information is available include
...@@ -1157,8 +1158,8 @@ MaybeHandle<CodeT> CompileTurbofan(Isolate* isolate, ...@@ -1157,8 +1158,8 @@ MaybeHandle<CodeT> CompileTurbofan(Isolate* isolate,
void RecordMaglevFunctionCompilation(Isolate* isolate, void RecordMaglevFunctionCompilation(Isolate* isolate,
Handle<JSFunction> function) { Handle<JSFunction> function) {
PtrComprCageBase cage_base(isolate); PtrComprCageBase cage_base(isolate);
Handle<AbstractCode> abstract_code( Handle<AbstractCode> abstract_code(ToAbstractCode(function->code(cage_base)),
AbstractCode::cast(FromCodeT(function->code(cage_base))), isolate); isolate);
Handle<SharedFunctionInfo> shared(function->shared(cage_base), isolate); Handle<SharedFunctionInfo> shared(function->shared(cage_base), isolate);
Handle<Script> script(Script::cast(shared->script(cage_base)), isolate); Handle<Script> script(Script::cast(shared->script(cage_base)), isolate);
Handle<FeedbackVector> feedback_vector(function->feedback_vector(cage_base), Handle<FeedbackVector> feedback_vector(function->feedback_vector(cage_base),
......
...@@ -1550,7 +1550,7 @@ void JSRegExp::JSRegExpVerify(Isolate* isolate) { ...@@ -1550,7 +1550,7 @@ void JSRegExp::JSRegExpVerify(Isolate* isolate) {
bool is_compiled = latin1_code.IsCodeT(); bool is_compiled = latin1_code.IsCodeT();
if (is_compiled) { if (is_compiled) {
CHECK_EQ(FromCodeT(CodeT::cast(latin1_code)).builtin_id(), CHECK_EQ(CodeT::cast(latin1_code).builtin_id(),
Builtin::kRegExpExperimentalTrampoline); Builtin::kRegExpExperimentalTrampoline);
CHECK_EQ(uc16_code, latin1_code); CHECK_EQ(uc16_code, latin1_code);
......
...@@ -1756,12 +1756,17 @@ void Code::CodePrint(std::ostream& os) { ...@@ -1756,12 +1756,17 @@ void Code::CodePrint(std::ostream& os) {
void CodeDataContainer::CodeDataContainerPrint(std::ostream& os) { void CodeDataContainer::CodeDataContainerPrint(std::ostream& os) {
PrintHeader(os, "CodeDataContainer"); PrintHeader(os, "CodeDataContainer");
os << "\n - kind_specific_flags: " << kind_specific_flags(kRelaxedLoad); #ifdef V8_EXTERNAL_CODE_SPACE
if (V8_EXTERNAL_CODE_SPACE_BOOL) { os << "\n - kind: " << CodeKindToString(kind());
os << "\n - code: " << Brief(code()); if (is_builtin()) {
os << "\n - code_entry_point: " os << "\n - builtin: " << Builtins::name(builtin_id());
<< reinterpret_cast<void*>(code_entry_point());
} }
os << "\n - is_off_heap_trampoline: " << is_off_heap_trampoline();
os << "\n - code: " << Brief(raw_code());
os << "\n - code_entry_point: "
<< reinterpret_cast<void*>(code_entry_point());
#endif // V8_EXTERNAL_CODE_SPACE
os << "\n - kind_specific_flags: " << kind_specific_flags(kRelaxedLoad);
os << "\n"; os << "\n";
} }
......
...@@ -45,7 +45,7 @@ void CodeStatistics::RecordCodeAndMetadataStatistics(HeapObject object, ...@@ -45,7 +45,7 @@ void CodeStatistics::RecordCodeAndMetadataStatistics(HeapObject object,
CodeKind code_kind = abstract_code.kind(cage_base); CodeKind code_kind = abstract_code.kind(cage_base);
isolate->code_kind_statistics()[static_cast<int>(code_kind)] += isolate->code_kind_statistics()[static_cast<int>(code_kind)] +=
abstract_code.Size(cage_base); abstract_code.Size(cage_base);
CodeStatistics::CollectCodeCommentStatistics(object, isolate); CodeStatistics::CollectCodeCommentStatistics(abstract_code, isolate);
#endif #endif
} }
} }
...@@ -197,14 +197,14 @@ void CodeStatistics::CollectCommentStatistics(Isolate* isolate, ...@@ -197,14 +197,14 @@ void CodeStatistics::CollectCommentStatistics(Isolate* isolate,
} }
// Collects code comment statistics. // Collects code comment statistics.
void CodeStatistics::CollectCodeCommentStatistics(HeapObject obj, void CodeStatistics::CollectCodeCommentStatistics(AbstractCode obj,
Isolate* isolate) { Isolate* isolate) {
// Bytecode objects do not contain RelocInfo. Only process code objects // Bytecode objects do not contain RelocInfo. Off-heap builtins might contain
// for code comment statistics. // comments but they are a part of binary so it doesn't make sense to account
if (!obj.IsCode()) { // them in the stats.
DCHECK(obj.IsBytecodeArray()); // Only process code objects for code comment statistics.
return; PtrComprCageBase cage_base(isolate);
} if (!obj.IsCode(cage_base)) return;
Code code = Code::cast(obj); Code code = Code::cast(obj);
CodeCommentsIterator cit(code.code_comments(), code.code_comments_size()); CodeCommentsIterator cit(code.code_comments(), code.code_comments_size());
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
namespace v8 { namespace v8 {
namespace internal { namespace internal {
class AbstractCode;
class CodeCommentsIterator; class CodeCommentsIterator;
class HeapObject; class HeapObject;
class Isolate; class Isolate;
...@@ -38,7 +39,7 @@ class CodeStatistics { ...@@ -38,7 +39,7 @@ class CodeStatistics {
#ifdef DEBUG #ifdef DEBUG
static void CollectCommentStatistics(Isolate* isolate, static void CollectCommentStatistics(Isolate* isolate,
CodeCommentsIterator* it); CodeCommentsIterator* it);
static void CollectCodeCommentStatistics(HeapObject obj, Isolate* isolate); static void CollectCodeCommentStatistics(AbstractCode obj, Isolate* isolate);
static void EnterComment(Isolate* isolate, const char* comment, int delta); static void EnterComment(Isolate* isolate, const char* comment, int delta);
static void ResetCodeStatistics(Isolate* isolate); static void ResetCodeStatistics(Isolate* isolate);
#endif #endif
......
...@@ -128,9 +128,8 @@ const char* ComputeMarker(SharedFunctionInfo shared, AbstractCode code) { ...@@ -128,9 +128,8 @@ const char* ComputeMarker(SharedFunctionInfo shared, AbstractCode code) {
// We record interpreter trampoline builtin copies as having the // We record interpreter trampoline builtin copies as having the
// "interpreted" marker. // "interpreted" marker.
if (FLAG_interpreted_frames_native_stack && kind == CodeKind::BUILTIN && if (FLAG_interpreted_frames_native_stack && kind == CodeKind::BUILTIN &&
code.GetCode().is_interpreter_trampoline_builtin() && !code.is_off_heap_trampoline(cage_base)) {
ToCodeT(code.GetCode()) != DCHECK_EQ(code.builtin_id(cage_base), Builtin::kInterpreterEntryTrampoline);
*BUILTIN_CODE(shared.GetIsolate(), InterpreterEntryTrampoline)) {
kind = CodeKind::INTERPRETED_FUNCTION; kind = CodeKind::INTERPRETED_FUNCTION;
} }
if (shared.optimization_disabled() && if (shared.optimization_disabled() &&
...@@ -449,6 +448,7 @@ ExternalLogEventListener::~ExternalLogEventListener() { ...@@ -449,6 +448,7 @@ ExternalLogEventListener::~ExternalLogEventListener() {
void ExternalLogEventListener::LogExistingCode() { void ExternalLogEventListener::LogExistingCode() {
HandleScope scope(isolate_); HandleScope scope(isolate_);
ExistingCodeLogger logger(isolate_, this); ExistingCodeLogger logger(isolate_, this);
logger.LogBuiltins();
logger.LogCodeObjects(); logger.LogCodeObjects();
logger.LogCompiledFunctions(); logger.LogCompiledFunctions();
} }
...@@ -1359,6 +1359,11 @@ void V8FileLogger::LogCodeDisassemble(Handle<AbstractCode> code) { ...@@ -1359,6 +1359,11 @@ void V8FileLogger::LogCodeDisassemble(Handle<AbstractCode> code) {
if (code->IsCode(cage_base)) { if (code->IsCode(cage_base)) {
#ifdef ENABLE_DISASSEMBLER #ifdef ENABLE_DISASSEMBLER
Code::cast(*code).Disassemble(nullptr, stream, isolate_); Code::cast(*code).Disassemble(nullptr, stream, isolate_);
#endif
} else if (V8_REMOVE_BUILTINS_CODE_OBJECTS &&
code->IsCodeDataContainer(cage_base)) {
#ifdef ENABLE_DISASSEMBLER
CodeT::cast(*code).Disassemble(nullptr, stream, isolate_);
#endif #endif
} else { } else {
BytecodeArray::cast(*code).Disassemble(stream); BytecodeArray::cast(*code).Disassemble(stream);
...@@ -2141,8 +2146,8 @@ void V8FileLogger::SetCodeEventHandler(uint32_t options, ...@@ -2141,8 +2146,8 @@ void V8FileLogger::SetCodeEventHandler(uint32_t options,
AddLogEventListener(jit_logger_.get()); AddLogEventListener(jit_logger_.get());
if (options & kJitCodeEventEnumExisting) { if (options & kJitCodeEventEnumExisting) {
HandleScope scope(isolate_); HandleScope scope(isolate_);
LogCodeObjects();
LogBuiltins(); LogBuiltins();
LogCodeObjects();
LogCompiledFunctions(); LogCompiledFunctions();
} }
} }
...@@ -2206,12 +2211,13 @@ void V8FileLogger::UpdateIsLogging(bool value) { ...@@ -2206,12 +2211,13 @@ void V8FileLogger::UpdateIsLogging(bool value) {
isolate_->UpdateLogObjectRelocation(); isolate_->UpdateLogObjectRelocation();
} }
void ExistingCodeLogger::LogCodeObject(Object object) { void ExistingCodeLogger::LogCodeObject(AbstractCode object) {
HandleScope scope(isolate_); HandleScope scope(isolate_);
Handle<AbstractCode> abstract_code(AbstractCode::cast(object), isolate_); Handle<AbstractCode> abstract_code(object, isolate_);
CodeTag tag = CodeTag::kStub; CodeTag tag = CodeTag::kStub;
const char* description = "Unknown code from before profiling"; const char* description = "Unknown code from before profiling";
switch (abstract_code->kind(isolate_)) { PtrComprCageBase cage_base(isolate_);
switch (abstract_code->kind(cage_base)) {
case CodeKind::INTERPRETED_FUNCTION: case CodeKind::INTERPRETED_FUNCTION:
case CodeKind::TURBOFAN: case CodeKind::TURBOFAN:
case CodeKind::BASELINE: case CodeKind::BASELINE:
...@@ -2227,17 +2233,18 @@ void ExistingCodeLogger::LogCodeObject(Object object) { ...@@ -2227,17 +2233,18 @@ void ExistingCodeLogger::LogCodeObject(Object object) {
break; break;
case CodeKind::BYTECODE_HANDLER: case CodeKind::BYTECODE_HANDLER:
description = description =
isolate_->builtins()->name(abstract_code->GetCode().builtin_id()); isolate_->builtins()->name(abstract_code->builtin_id(cage_base));
tag = CodeTag::kBytecodeHandler; tag = CodeTag::kBytecodeHandler;
break; break;
case CodeKind::BUILTIN: case CodeKind::BUILTIN:
if (Code::cast(object).is_interpreter_trampoline_builtin() && if (!abstract_code->is_off_heap_trampoline(cage_base)) {
ToCodeT(Code::cast(object)) != DCHECK_EQ(abstract_code->builtin_id(cage_base),
*BUILTIN_CODE(isolate_, InterpreterEntryTrampoline)) { Builtin::kInterpreterEntryTrampoline);
// We treat interpreter trampoline builtin copies as
// INTERPRETED_FUNCTION, which are logged using LogCompiledFunctions.
return; return;
} }
description = description = Builtins::name(abstract_code->builtin_id(cage_base));
isolate_->builtins()->name(abstract_code->GetCode().builtin_id());
tag = CodeTag::kBuiltin; tag = CodeTag::kBuiltin;
break; break;
case CodeKind::WASM_FUNCTION: case CodeKind::WASM_FUNCTION:
...@@ -2272,21 +2279,35 @@ void ExistingCodeLogger::LogCodeObjects() { ...@@ -2272,21 +2279,35 @@ void ExistingCodeLogger::LogCodeObjects() {
Heap* heap = isolate_->heap(); Heap* heap = isolate_->heap();
HeapObjectIterator iterator(heap); HeapObjectIterator iterator(heap);
DisallowGarbageCollection no_gc; DisallowGarbageCollection no_gc;
PtrComprCageBase cage_base(isolate_);
for (HeapObject obj = iterator.Next(); !obj.is_null(); for (HeapObject obj = iterator.Next(); !obj.is_null();
obj = iterator.Next()) { obj = iterator.Next()) {
if (obj.IsCode()) LogCodeObject(obj); InstanceType instance_type = obj.map(cage_base).instance_type();
if (obj.IsBytecodeArray()) LogCodeObject(obj); if (V8_REMOVE_BUILTINS_CODE_OBJECTS) {
// In this case AbstactCode is Code|CodeDataContainer|BytecodeArray but
// we want to log code objects only once, thus we ignore Code objects
// which will be logged via corresponding CodeDataContainer.
if (InstanceTypeChecker::IsCodeT(instance_type) ||
InstanceTypeChecker::IsBytecodeArray(instance_type)) {
LogCodeObject(AbstractCode::cast(obj));
}
} else {
// In this case AbstactCode is Code|BytecodeArray.
if (InstanceTypeChecker::IsCode(instance_type) ||
InstanceTypeChecker::IsBytecodeArray(instance_type)) {
LogCodeObject(AbstractCode::cast(obj));
}
}
} }
} }
void ExistingCodeLogger::LogBuiltins() { void ExistingCodeLogger::LogBuiltins() {
Builtins* builtins = isolate_->builtins(); DCHECK(isolate_->builtins()->is_initialized());
DCHECK(builtins->is_initialized()); // The main "copy" of used builtins are logged by LogCodeObjects() while
for (Builtin builtin = Builtins::kFirst; builtin <= Builtins::kLast; // iterating CodeT objects.
++builtin) { // TODO(v8:11880): Log other copies of remapped builtins once we
Code code = FromCodeT(builtins->code(builtin)); // decide to remap them multiple times into the code range (for example
LogCodeObject(code); // for arm64).
}
} }
void ExistingCodeLogger::LogCompiledFunctions() { void ExistingCodeLogger::LogCompiledFunctions() {
......
...@@ -95,7 +95,7 @@ class ExistingCodeLogger { ...@@ -95,7 +95,7 @@ class ExistingCodeLogger {
void LogExistingFunction( void LogExistingFunction(
Handle<SharedFunctionInfo> shared, Handle<AbstractCode> code, Handle<SharedFunctionInfo> shared, Handle<AbstractCode> code,
LogEventListener::CodeTag tag = LogEventListener::CodeTag::kFunction); LogEventListener::CodeTag tag = LogEventListener::CodeTag::kFunction);
void LogCodeObject(Object object); void LogCodeObject(AbstractCode object);
private: private:
Isolate* isolate_; Isolate* isolate_;
......
...@@ -35,6 +35,10 @@ DEF_GETTER(CallSiteInfo, code_object, HeapObject) { ...@@ -35,6 +35,10 @@ DEF_GETTER(CallSiteInfo, code_object, HeapObject) {
HeapObject value = TorqueGeneratedClass::code_object(cage_base); HeapObject value = TorqueGeneratedClass::code_object(cage_base);
// The |code_object| field can contain many types of objects, but only CodeT // The |code_object| field can contain many types of objects, but only CodeT
// values have to be converted to Code. // values have to be converted to Code.
if (V8_REMOVE_BUILTINS_CODE_OBJECTS) {
// In this mode the callers are fine with CodeT result.
return value;
}
if (V8_EXTERNAL_CODE_SPACE_BOOL && value.IsCodeT()) { if (V8_EXTERNAL_CODE_SPACE_BOOL && value.IsCodeT()) {
return FromCodeT(CodeT::cast(value)); return FromCodeT(CodeT::cast(value));
} }
...@@ -44,7 +48,7 @@ DEF_GETTER(CallSiteInfo, code_object, HeapObject) { ...@@ -44,7 +48,7 @@ DEF_GETTER(CallSiteInfo, code_object, HeapObject) {
void CallSiteInfo::set_code_object(HeapObject code, WriteBarrierMode mode) { void CallSiteInfo::set_code_object(HeapObject code, WriteBarrierMode mode) {
// The |code_object| field can contain many types of objects, but only Code // The |code_object| field can contain many types of objects, but only Code
// values have to be converted to CodeT. // values have to be converted to CodeT.
if (V8_EXTERNAL_CODE_SPACE_BOOL && code.IsCode()) { if (V8_EXTERNAL_CODE_SPACE_BOOL && IsCodeSpaceObject(code)) {
TorqueGeneratedClass::set_code_object(ToCodeT(Code::cast(code)), mode); TorqueGeneratedClass::set_code_object(ToCodeT(Code::cast(code)), mode);
} else { } else {
TorqueGeneratedClass::set_code_object(code, mode); TorqueGeneratedClass::set_code_object(code, mode);
......
...@@ -181,14 +181,13 @@ Builtin AbstractCode::builtin_id(PtrComprCageBase cage_base) { ...@@ -181,14 +181,13 @@ Builtin AbstractCode::builtin_id(PtrComprCageBase cage_base) {
} }
} }
bool AbstractCode::is_interpreter_trampoline_builtin( bool AbstractCode::is_off_heap_trampoline(PtrComprCageBase cage_base) {
PtrComprCageBase cage_base) {
InstanceType instance_type = map(cage_base).instance_type(); InstanceType instance_type = map(cage_base).instance_type();
if (InstanceTypeChecker::IsCode(instance_type)) { if (InstanceTypeChecker::IsCode(instance_type)) {
return GetCode().is_interpreter_trampoline_builtin(); return GetCode().is_off_heap_trampoline();
} else if (V8_REMOVE_BUILTINS_CODE_OBJECTS && } else if (V8_REMOVE_BUILTINS_CODE_OBJECTS &&
InstanceTypeChecker::IsCodeDataContainer(instance_type)) { InstanceTypeChecker::IsCodeDataContainer(instance_type)) {
return GetCodeT().is_interpreter_trampoline_builtin(); return GetCodeT().is_off_heap_trampoline();
} else { } else {
DCHECK(InstanceTypeChecker::IsBytecodeArray(instance_type)); DCHECK(InstanceTypeChecker::IsBytecodeArray(instance_type));
return false; return false;
...@@ -232,6 +231,20 @@ BytecodeArray AbstractCode::GetBytecodeArray() { ...@@ -232,6 +231,20 @@ BytecodeArray AbstractCode::GetBytecodeArray() {
return BytecodeArray::cast(*this); return BytecodeArray::cast(*this);
} }
Code AbstractCode::ToCode(PtrComprCageBase cage_base) {
InstanceType instance_type = map(cage_base).instance_type();
if (InstanceTypeChecker::IsCode(instance_type)) {
return GetCode();
} else if (V8_REMOVE_BUILTINS_CODE_OBJECTS &&
InstanceTypeChecker::IsCodeDataContainer(instance_type)) {
CodeT codet = GetCodeT();
DCHECK(!codet.is_off_heap_trampoline());
return FromCodeT(codet);
} else {
UNREACHABLE();
}
}
CodeT AbstractCode::ToCodeT(PtrComprCageBase cage_base) { CodeT AbstractCode::ToCodeT(PtrComprCageBase cage_base) {
InstanceType instance_type = map(cage_base).instance_type(); InstanceType instance_type = map(cage_base).instance_type();
if (InstanceTypeChecker::IsCode(instance_type)) { if (InstanceTypeChecker::IsCode(instance_type)) {
......
...@@ -1053,7 +1053,7 @@ class AbstractCode : public HeapObject { ...@@ -1053,7 +1053,7 @@ class AbstractCode : public HeapObject {
inline Builtin builtin_id(PtrComprCageBase cage_base); inline Builtin builtin_id(PtrComprCageBase cage_base);
inline bool is_interpreter_trampoline_builtin(PtrComprCageBase cage_base); inline bool is_off_heap_trampoline(PtrComprCageBase cage_base);
inline HandlerTable::CatchPrediction GetBuiltinCatchPrediction( inline HandlerTable::CatchPrediction GetBuiltinCatchPrediction(
PtrComprCageBase cage_base); PtrComprCageBase cage_base);
...@@ -1068,6 +1068,7 @@ class AbstractCode : public HeapObject { ...@@ -1068,6 +1068,7 @@ class AbstractCode : public HeapObject {
inline bool IsCodeT(PtrComprCageBase cage_base) const; inline bool IsCodeT(PtrComprCageBase cage_base) const;
inline bool IsBytecodeArray(PtrComprCageBase cage_base) const; inline bool IsBytecodeArray(PtrComprCageBase cage_base) const;
inline Code ToCode(PtrComprCageBase cage_base);
inline CodeT ToCodeT(PtrComprCageBase cage_base); inline CodeT ToCodeT(PtrComprCageBase cage_base);
inline Code GetCode(); inline Code GetCode();
......
...@@ -79,6 +79,12 @@ V8_INLINE constexpr bool IsThinString(InstanceType instance_type) { ...@@ -79,6 +79,12 @@ V8_INLINE constexpr bool IsThinString(InstanceType instance_type) {
return (instance_type & kStringRepresentationMask) == kThinStringTag; return (instance_type & kStringRepresentationMask) == kThinStringTag;
} }
V8_INLINE constexpr bool IsAbstractCode(InstanceType instance_type) {
return IsBytecodeArray(instance_type) || IsCode(instance_type) ||
(V8_REMOVE_BUILTINS_CODE_OBJECTS &&
IsCodeDataContainer(instance_type));
}
V8_INLINE constexpr bool IsFreeSpaceOrFiller(InstanceType instance_type) { V8_INLINE constexpr bool IsFreeSpaceOrFiller(InstanceType instance_type) {
return instance_type == FREE_SPACE_TYPE || instance_type == FILLER_TYPE; return instance_type == FREE_SPACE_TYPE || instance_type == FILLER_TYPE;
} }
......
...@@ -273,6 +273,7 @@ V8_EXPORT_PRIVATE std::ostream& operator<<(std::ostream& os, ...@@ -273,6 +273,7 @@ V8_EXPORT_PRIVATE std::ostream& operator<<(std::ostream& os,
TORQUE_INSTANCE_CHECKERS_RANGE_ONLY_DECLARED(V) TORQUE_INSTANCE_CHECKERS_RANGE_ONLY_DECLARED(V)
#define INSTANCE_TYPE_CHECKERS_CUSTOM(V) \ #define INSTANCE_TYPE_CHECKERS_CUSTOM(V) \
V(AbstractCode) \
V(FreeSpaceOrFiller) \ V(FreeSpaceOrFiller) \
V(ExternalString) \ V(ExternalString) \
V(InternalizedString) V(InternalizedString)
......
...@@ -348,17 +348,6 @@ DEF_GETTER(HeapObject, IsOSROptimizedCodeCache, bool) { ...@@ -348,17 +348,6 @@ DEF_GETTER(HeapObject, IsOSROptimizedCodeCache, bool) {
return IsWeakFixedArray(cage_base); return IsWeakFixedArray(cage_base);
} }
bool HeapObject::IsAbstractCode() const {
// TODO(v8:11880): Either make AbstractCode be ByteArray|CodeT or
// ensure this version is not called for hot code.
PtrComprCageBase cage_base = GetPtrComprCageBaseSlow(*this);
return HeapObject::IsAbstractCode(cage_base);
}
bool HeapObject::IsAbstractCode(PtrComprCageBase cage_base) const {
return IsBytecodeArray(cage_base) || IsCode(cage_base) ||
(V8_REMOVE_BUILTINS_CODE_OBJECTS && IsCodeDataContainer(cage_base));
}
DEF_GETTER(HeapObject, IsStringWrapper, bool) { DEF_GETTER(HeapObject, IsStringWrapper, bool) {
return IsJSPrimitiveWrapper(cage_base) && return IsJSPrimitiveWrapper(cage_base) &&
JSPrimitiveWrapper::cast(*this).value().IsString(cage_base); JSPrimitiveWrapper::cast(*this).value().IsString(cage_base);
......
...@@ -564,6 +564,7 @@ DEF_GETTER(SharedFunctionInfo, HasBytecodeArray, bool) { ...@@ -564,6 +564,7 @@ DEF_GETTER(SharedFunctionInfo, HasBytecodeArray, bool) {
template <typename IsolateT> template <typename IsolateT>
BytecodeArray SharedFunctionInfo::GetBytecodeArray(IsolateT* isolate) const { BytecodeArray SharedFunctionInfo::GetBytecodeArray(IsolateT* isolate) const {
// TODO(ishell): access shared_function_info_access() via IsolateT.
SharedMutexGuardIfOffThread<IsolateT, base::kShared> mutex_guard( SharedMutexGuardIfOffThread<IsolateT, base::kShared> mutex_guard(
GetIsolate()->shared_function_info_access(), isolate); GetIsolate()->shared_function_info_access(), isolate);
......
...@@ -136,7 +136,8 @@ void ProfilerListener::CodeCreateEvent(CodeTag tag, ...@@ -136,7 +136,8 @@ void ProfilerListener::CodeCreateEvent(CodeTag tag,
Handle<BytecodeArray> bytecodes(shared->GetBytecodeArray(isolate_), Handle<BytecodeArray> bytecodes(shared->GetBytecodeArray(isolate_),
isolate_); isolate_);
Handle<ByteArray> bytecode_offsets( Handle<ByteArray> bytecode_offsets(
abstract_code->GetCode().bytecode_offset_table(), isolate_); abstract_code->ToCode(cage_base).bytecode_offset_table(cage_base),
isolate_);
baseline_iterator = std::make_unique<baseline::BytecodeOffsetIterator>( baseline_iterator = std::make_unique<baseline::BytecodeOffsetIterator>(
bytecode_offsets, bytecodes); bytecode_offsets, bytecodes);
} }
......
...@@ -296,13 +296,12 @@ TEST(Unwind_CodeObjectPCInMiddle_Success_CodePagesAPI) { ...@@ -296,13 +296,12 @@ TEST(Unwind_CodeObjectPCInMiddle_Success_CodePagesAPI) {
Handle<JSFunction>::cast(v8::Utils::OpenHandle(*local_foo)); Handle<JSFunction>::cast(v8::Utils::OpenHandle(*local_foo));
// Put the current PC inside of the created code object. // Put the current PC inside of the created code object.
AbstractCode abstract_code = foo->abstract_code(i_isolate); CodeT codet = foo->code();
PtrComprCageBase cage_base(i_isolate); // We don't produce optimized code when run with --no-turbofan and
// We don't produce optimized code when run with --no-turbofan. // --no-maglev.
if (!abstract_code.IsCode(cage_base) && !FLAG_turbofan) return; if (!codet.is_optimized_code()) return;
CHECK(abstract_code.IsCode(cage_base));
Code code = abstract_code.GetCode(); Code code = FromCodeT(codet);
// We don't want the offset too early or it could be the `push rbp` // We don't want the offset too early or it could be the `push rbp`
// instruction (which is not at the start of generated code, because the lazy // instruction (which is not at the start of generated code, because the lazy
// deopt check happens before frame setup). // deopt check happens before frame setup).
......
...@@ -149,12 +149,11 @@ TEST_F(CodePagesTest, OptimizedCodeWithCodeRange) { ...@@ -149,12 +149,11 @@ TEST_F(CodePagesTest, OptimizedCodeWithCodeRange) {
Handle<JSFunction> foo = Handle<JSFunction> foo =
Handle<JSFunction>::cast(v8::Utils::OpenHandle(*local_foo)); Handle<JSFunction>::cast(v8::Utils::OpenHandle(*local_foo));
AbstractCode abstract_code = foo->abstract_code(i_isolate()); CodeT codet = foo->code();
PtrComprCageBase cage_base(i_isolate()); // We don't produce optimized code when run with --no-turbofan and
// We don't produce optimized code when run with --no-turbofan. // --no-maglev.
if (!abstract_code.IsCode(cage_base) && !FLAG_turbofan) return; if (!codet.is_optimized_code()) return;
EXPECT_TRUE(abstract_code.IsCode(cage_base)); Code foo_code = FromCodeT(codet);
Code foo_code = abstract_code.GetCode();
EXPECT_TRUE(i_isolate()->heap()->InSpace(foo_code, CODE_SPACE)); EXPECT_TRUE(i_isolate()->heap()->InSpace(foo_code, CODE_SPACE));
...@@ -200,12 +199,11 @@ TEST_F(CodePagesTest, OptimizedCodeWithCodePages) { ...@@ -200,12 +199,11 @@ TEST_F(CodePagesTest, OptimizedCodeWithCodePages) {
EXPECT_TRUE(FLAG_always_sparkplug); EXPECT_TRUE(FLAG_always_sparkplug);
return; return;
} }
AbstractCode abstract_code = foo->abstract_code(i_isolate()); CodeT codet = foo->code();
PtrComprCageBase cage_base(i_isolate()); // We don't produce optimized code when run with --no-turbofan and
// We don't produce optimized code when run with --no-turbofan. // --no-maglev.
if (!abstract_code.IsCode(cage_base) && !FLAG_turbofan) return; if (!codet.is_optimized_code()) return;
EXPECT_TRUE(abstract_code.IsCode(cage_base)); Code foo_code = FromCodeT(codet);
Code foo_code = abstract_code.GetCode();
EXPECT_TRUE(i_isolate()->heap()->InSpace(foo_code, CODE_SPACE)); EXPECT_TRUE(i_isolate()->heap()->InSpace(foo_code, CODE_SPACE));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment