Skip to content

Commit f4229da

Browse files
rmacnak-googlecommit-bot@chromium.org
authored andcommitted
[vm, bytecode] Produce compile-time errors instead of crashing when failing to resolve libraries etc.
Compare c304336, which did the same for the kernel loader. Causes tests involving libraries with data URIs to fail the same way during reload testing with ASTs and bytecode. Change-Id: I7ade75e427eefa666b89c48ced70b574160fceb1 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/115764 Commit-Queue: Ryan Macnak <[email protected]> Reviewed-by: Régis Crelier <[email protected]> Reviewed-by: Alexander Markov <[email protected]>
1 parent a64b06e commit f4229da

File tree

1 file changed

+33
-7
lines changed

1 file changed

+33
-7
lines changed

runtime/vm/compiler/frontend/bytecode_reader.cc

Lines changed: 33 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1372,7 +1372,6 @@ RawObject* BytecodeReaderHelper::ReadObjectContents(uint32_t header) {
13721372
uri ^= ReadObject();
13731373
}
13741374
RawLibrary* library = Library::LookupLibrary(thread_, uri);
1375-
NoSafepointScope no_safepoint_scope(thread_);
13761375
if (library == Library::null()) {
13771376
// We do not register expression evaluation libraries with the VM:
13781377
// The expression evaluation functions should be GC-able as soon as
@@ -1381,7 +1380,15 @@ RawObject* BytecodeReaderHelper::ReadObjectContents(uint32_t header) {
13811380
ASSERT(expression_evaluation_library_ != nullptr);
13821381
return expression_evaluation_library_->raw();
13831382
}
1383+
#if !defined(PRODUCT)
1384+
ASSERT(Isolate::Current()->HasAttemptedReload());
1385+
const String& msg = String::Handle(
1386+
Z,
1387+
String::NewFormatted("Unable to find library %s", uri.ToCString()));
1388+
Report::LongJump(LanguageError::Handle(Z, LanguageError::New(msg)));
1389+
#else
13841390
FATAL1("Unable to find library %s", uri.ToCString());
1391+
#endif
13851392
}
13861393
return library;
13871394
}
@@ -1397,13 +1404,21 @@ RawObject* BytecodeReaderHelper::ReadObjectContents(uint32_t header) {
13971404
return cls;
13981405
}
13991406
RawClass* cls = library.LookupLocalClass(class_name);
1400-
NoSafepointScope no_safepoint_scope(thread_);
14011407
if (cls == Class::null()) {
14021408
if (IsExpressionEvaluationLibrary(library)) {
14031409
return H.GetExpressionEvaluationRealClass();
14041410
}
1411+
#if !defined(PRODUCT)
1412+
ASSERT(Isolate::Current()->HasAttemptedReload());
1413+
const String& msg = String::Handle(
1414+
Z,
1415+
String::NewFormatted("Unable to find class %s in %s",
1416+
class_name.ToCString(), library.ToCString()));
1417+
Report::LongJump(LanguageError::Handle(Z, LanguageError::New(msg)));
1418+
#else
14051419
FATAL2("Unable to find class %s in %s", class_name.ToCString(),
14061420
library.ToCString());
1421+
#endif
14071422
}
14081423
return cls;
14091424
}
@@ -1412,10 +1427,17 @@ RawObject* BytecodeReaderHelper::ReadObjectContents(uint32_t header) {
14121427
String& name = String::CheckedHandle(Z, ReadObject());
14131428
if ((flags & kFlagIsField) != 0) {
14141429
RawField* field = cls.LookupField(name);
1415-
NoSafepointScope no_safepoint_scope(thread_);
14161430
if (field == Field::null()) {
1431+
#if !defined(PRODUCT)
1432+
ASSERT(Isolate::Current()->HasAttemptedReload());
1433+
const String& msg = String::Handle(
1434+
Z, String::NewFormatted("Unable to find field %s in %s",
1435+
name.ToCString(), cls.ToCString()));
1436+
Report::LongJump(LanguageError::Handle(Z, LanguageError::New(msg)));
1437+
#else
14171438
FATAL2("Unable to find field %s in %s", name.ToCString(),
14181439
cls.ToCString());
1440+
#endif
14191441
}
14201442
return field;
14211443
} else {
@@ -1428,10 +1450,6 @@ RawObject* BytecodeReaderHelper::ReadObjectContents(uint32_t header) {
14281450
return scoped_function_.raw();
14291451
}
14301452
RawFunction* function = cls.LookupFunction(name);
1431-
{
1432-
// To verify that it's OK to hold raw function pointer at this point.
1433-
NoSafepointScope no_safepoint_scope(thread_);
1434-
}
14351453
if (function == Function::null()) {
14361454
// When requesting a getter, also return method extractors.
14371455
if (Field::IsGetterName(name)) {
@@ -1446,8 +1464,16 @@ RawObject* BytecodeReaderHelper::ReadObjectContents(uint32_t header) {
14461464
}
14471465
}
14481466
}
1467+
#if !defined(PRODUCT)
1468+
ASSERT(Isolate::Current()->HasAttemptedReload());
1469+
const String& msg = String::Handle(
1470+
Z, String::NewFormatted("Unable to find function %s in %s",
1471+
name.ToCString(), cls.ToCString()));
1472+
Report::LongJump(LanguageError::Handle(Z, LanguageError::New(msg)));
1473+
#else
14491474
FATAL2("Unable to find function %s in %s", name.ToCString(),
14501475
cls.ToCString());
1476+
#endif
14511477
}
14521478
return function;
14531479
}

0 commit comments

Comments
 (0)