mirror of
https://github.com/dart-lang/sdk
synced 2024-09-05 00:13:50 +00:00
[vm] Avoid allocation when printing type names.
Avoids recursive assertion failures when a GC assertion failure occurs during a compile. TEST=ci Change-Id: I2fd2b29c1a7d83c426ceb437f3880746a4c8d8b9 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/349142 Commit-Queue: Ryan Macnak <rmacnak@google.com> Reviewed-by: Alexander Aprelev <aam@google.com>
This commit is contained in:
parent
8c5407b3dd
commit
1501d688c0
|
@ -209,10 +209,8 @@ DEFINE_NATIVE_ENTRY(Object_instanceOf, 0, 4) {
|
|||
THR_Print("Native Object.instanceOf: result %s\n", result_str);
|
||||
const AbstractType& instance_type =
|
||||
AbstractType::Handle(zone, instance.GetType(Heap::kNew));
|
||||
THR_Print(" instance type: %s\n",
|
||||
String::Handle(zone, instance_type.Name()).ToCString());
|
||||
THR_Print(" test type: %s\n",
|
||||
String::Handle(zone, type.Name()).ToCString());
|
||||
THR_Print(" instance type: %s\n", instance_type.NameCString());
|
||||
THR_Print(" test type: %s\n", type.NameCString());
|
||||
}
|
||||
return Bool::Get(is_instance_of).ptr();
|
||||
}
|
||||
|
|
|
@ -48,8 +48,7 @@ static bool PassesFilter(const char* filter,
|
|||
#endif
|
||||
|
||||
char* save_ptr; // Needed for strtok_r.
|
||||
const char* scrubbed_name =
|
||||
String::Handle(function.QualifiedScrubbedName()).ToCString();
|
||||
const char* scrubbed_name = function.QualifiedScrubbedNameCString();
|
||||
const char* function_name = function.ToFullyQualifiedCString();
|
||||
intptr_t function_name_len = strlen(function_name);
|
||||
|
||||
|
|
|
@ -6218,7 +6218,7 @@ void CheckNullInstr::AddMetadataForRuntimeCall(CheckNullInstr* check_null,
|
|||
void BoxAllocationSlowPath::EmitNativeCode(FlowGraphCompiler* compiler) {
|
||||
if (compiler::Assembler::EmittingComments()) {
|
||||
__ Comment("%s slow path allocation of %s", instruction()->DebugName(),
|
||||
String::Handle(cls_.ScrubbedName()).ToCString());
|
||||
cls_.ScrubbedNameCString());
|
||||
}
|
||||
__ Bind(entry_label());
|
||||
const auto& stub = Code::ZoneHandle(
|
||||
|
|
|
@ -423,8 +423,8 @@ void FlowGraphPrinter::PrintTypeCheck(const ParsedFunction& parsed_function,
|
|||
"%s type check: compile type %s is %s specific than "
|
||||
"type '%s' of '%s'.\n",
|
||||
eliminated ? "Eliminated" : "Generated", compile_type_name,
|
||||
eliminated ? "more" : "not more",
|
||||
String::Handle(dst_type.Name()).ToCString(), dst_name.ToCString());
|
||||
eliminated ? "more" : "not more", dst_type.NameCString(),
|
||||
dst_name.ToCString());
|
||||
}
|
||||
|
||||
static void PrintTargetsHelper(BaseTextBuffer* f,
|
||||
|
@ -970,7 +970,7 @@ void StoreStaticFieldInstr::PrintOperandsTo(BaseTextBuffer* f) const {
|
|||
|
||||
void InstanceOfInstr::PrintOperandsTo(BaseTextBuffer* f) const {
|
||||
value()->PrintTo(f);
|
||||
f->Printf(" IS %s,", String::Handle(type().Name()).ToCString());
|
||||
f->Printf(" IS %s,", type().NameCString());
|
||||
f->AddString(" instantiator_type_args(");
|
||||
instantiator_type_arguments()->PrintTo(f);
|
||||
f->AddString("), function_type_args(");
|
||||
|
@ -996,7 +996,7 @@ void AllocationInstr::PrintOperandsTo(BaseTextBuffer* f) const {
|
|||
}
|
||||
|
||||
void AllocateObjectInstr::PrintOperandsTo(BaseTextBuffer* f) const {
|
||||
f->Printf("cls=%s", String::Handle(cls().ScrubbedName()).ToCString());
|
||||
f->Printf("cls=%s", cls().ScrubbedNameCString());
|
||||
if (InputCount() > 0 || Identity().IsNotAliased()) {
|
||||
f->AddString(", ");
|
||||
}
|
||||
|
@ -1004,7 +1004,7 @@ void AllocateObjectInstr::PrintOperandsTo(BaseTextBuffer* f) const {
|
|||
}
|
||||
|
||||
void MaterializeObjectInstr::PrintOperandsTo(BaseTextBuffer* f) const {
|
||||
f->Printf("%s", String::Handle(cls_.ScrubbedName()).ToCString());
|
||||
f->Printf("%s", cls_.ScrubbedNameCString());
|
||||
for (intptr_t i = 0; i < InputCount(); i++) {
|
||||
f->AddString(", ");
|
||||
f->Printf("%s: ", slots_[i]->Name());
|
||||
|
|
|
@ -1038,11 +1038,9 @@ void CompileType::PrintTo(BaseTextBuffer* f) const {
|
|||
} else if ((cid_ != kIllegalCid) && (cid_ != kDynamicCid)) {
|
||||
const Class& cls =
|
||||
Class::Handle(IsolateGroup::Current()->class_table()->At(cid_));
|
||||
type_name = String::Handle(cls.ScrubbedName()).ToCString();
|
||||
type_name = cls.ScrubbedNameCString();
|
||||
} else if (type_ != nullptr) {
|
||||
type_name = type_->IsDynamicType()
|
||||
? "*"
|
||||
: String::Handle(type_->ScrubbedName()).ToCString();
|
||||
type_name = type_->IsDynamicType() ? "*" : type_->ScrubbedNameCString();
|
||||
} else if (!is_nullable()) {
|
||||
type_name = "!null";
|
||||
}
|
||||
|
|
|
@ -21446,24 +21446,36 @@ const char* AbstractType::NullabilitySuffix(
|
|||
}
|
||||
|
||||
StringPtr AbstractType::Name() const {
|
||||
return Symbols::New(Thread::Current(), NameCString());
|
||||
}
|
||||
|
||||
const char* AbstractType::NameCString() const {
|
||||
Thread* thread = Thread::Current();
|
||||
ZoneTextBuffer printer(thread->zone());
|
||||
PrintName(kInternalName, &printer);
|
||||
return Symbols::New(thread, printer.buffer());
|
||||
return printer.buffer();
|
||||
}
|
||||
|
||||
StringPtr AbstractType::UserVisibleName() const {
|
||||
return Symbols::New(Thread::Current(), UserVisibleNameCString());
|
||||
}
|
||||
|
||||
const char* AbstractType::UserVisibleNameCString() const {
|
||||
Thread* thread = Thread::Current();
|
||||
ZoneTextBuffer printer(thread->zone());
|
||||
PrintName(kUserVisibleName, &printer);
|
||||
return Symbols::New(thread, printer.buffer());
|
||||
return printer.buffer();
|
||||
}
|
||||
|
||||
StringPtr AbstractType::ScrubbedName() const {
|
||||
return Symbols::New(Thread::Current(), ScrubbedNameCString());
|
||||
}
|
||||
|
||||
const char* AbstractType::ScrubbedNameCString() const {
|
||||
Thread* thread = Thread::Current();
|
||||
ZoneTextBuffer printer(thread->zone());
|
||||
PrintName(kScrubbedName, &printer);
|
||||
return Symbols::New(thread, printer.buffer());
|
||||
return printer.buffer();
|
||||
}
|
||||
|
||||
void AbstractType::PrintName(NameVisibility name_visibility,
|
||||
|
|
|
@ -9087,15 +9087,18 @@ class AbstractType : public Instance {
|
|||
virtual const char* NullabilitySuffix(NameVisibility name_visibility) const;
|
||||
|
||||
// The name of this type, including the names of its type arguments, if any.
|
||||
virtual StringPtr Name() const;
|
||||
StringPtr Name() const;
|
||||
const char* NameCString() const;
|
||||
|
||||
// The name of this type, including the names of its type arguments, if any.
|
||||
// Names of internal classes are mapped to their public interfaces.
|
||||
virtual StringPtr UserVisibleName() const;
|
||||
StringPtr UserVisibleName() const;
|
||||
const char* UserVisibleNameCString() const;
|
||||
|
||||
// The name of this type, including the names of its type arguments, if any.
|
||||
// Privacy suffixes are dropped.
|
||||
virtual StringPtr ScrubbedName() const;
|
||||
StringPtr ScrubbedName() const;
|
||||
const char* ScrubbedNameCString() const;
|
||||
|
||||
// Return the internal or public name of this type, including the names of its
|
||||
// type arguments, if any.
|
||||
|
|
|
@ -626,9 +626,8 @@ static void PrintSubtypeCheck(const AbstractType& subtype,
|
|||
|
||||
LogBlock lb;
|
||||
THR_Print("SubtypeCheck: '%s' %d %s '%s' %d (pc: %#" Px ").\n",
|
||||
String::Handle(subtype.Name()).ToCString(), subtype.type_class_id(),
|
||||
result ? "is" : "is !",
|
||||
String::Handle(supertype.Name()).ToCString(),
|
||||
subtype.NameCString(), subtype.type_class_id(),
|
||||
result ? "is" : "is !", supertype.NameCString(),
|
||||
supertype.type_class_id(), caller_frame->pc());
|
||||
|
||||
const Function& function =
|
||||
|
@ -840,21 +839,19 @@ static void PrintTypeCheck(const char* message,
|
|||
LogBlock lb;
|
||||
if (type.IsInstantiated()) {
|
||||
THR_Print("%s: '%s' %d %s '%s' %d (pc: %#" Px ").\n", message,
|
||||
String::Handle(instance_type.Name()).ToCString(),
|
||||
instance_type.type_class_id(),
|
||||
instance_type.NameCString(), instance_type.type_class_id(),
|
||||
(result.ptr() == Bool::True().ptr()) ? "is" : "is !",
|
||||
String::Handle(type.Name()).ToCString(), type.type_class_id(),
|
||||
caller_frame->pc());
|
||||
type.NameCString(), type.type_class_id(), caller_frame->pc());
|
||||
} else {
|
||||
// Instantiate type before printing.
|
||||
const AbstractType& instantiated_type = AbstractType::Handle(
|
||||
type.InstantiateFrom(instantiator_type_arguments,
|
||||
function_type_arguments, kAllFree, Heap::kOld));
|
||||
THR_Print("%s: '%s' %s '%s' instantiated from '%s' (pc: %#" Px ").\n",
|
||||
message, String::Handle(instance_type.Name()).ToCString(),
|
||||
message, instance_type.NameCString(),
|
||||
(result.ptr() == Bool::True().ptr()) ? "is" : "is !",
|
||||
String::Handle(instantiated_type.Name()).ToCString(),
|
||||
String::Handle(type.Name()).ToCString(), caller_frame->pc());
|
||||
instantiated_type.NameCString(), type.NameCString(),
|
||||
caller_frame->pc());
|
||||
}
|
||||
const Function& function =
|
||||
Function::Handle(caller_frame->LookupDartFunction());
|
||||
|
|
Loading…
Reference in a new issue