Reland "[vm] Check prefix.loadLibrary is called and returns before prefix members are used."
This reverts commit9a87cf9174. Reason for revert: Broken test disabled Original change's description: > Revert "[vm] Check prefix.loadLibrary is called and returns before prefix members are used." > > This reverts commitb0484ecbde. > > Reason for revert: timeouts on Flutter integration tests > (https://github.com/dart-lang/sdk/issues/42350). > > Original change's description: > > [vm] Check prefix.loadLibrary is called and returns before prefix members are used. > > > > Restore checks against reloading a library with deferred prefixes. > > > > No loading is actually deferred. > > > > Bug: https://github.com/dart-lang/sdk/issues/26878 > > Bug: https://github.com/dart-lang/sdk/issues/41974 > > Change-Id: Iec2662de117453d596cca28dd9481a9751091ce9 > > Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/149613 > > Commit-Queue: Ryan Macnak <rmacnak@google.com> > > Reviewed-by: Alexander Markov <alexmarkov@google.com> > > Reviewed-by: Siva Annamalai <asiva@google.com> > > TBR=rmacnak@google.com,alexmarkov@google.com,asiva@google.com > > # Not skipping CQ checks because original CL landed > 1 day ago. > > Bug: https://github.com/dart-lang/sdk/issues/26878, https://github.com/dart-lang/sdk/issues/41974 > Change-Id: I78709650e91d206b84a8ddd9171ef66d6cf1b008 > Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/151169 > Reviewed-by: Alexander Markov <alexmarkov@google.com> > Commit-Queue: Alexander Markov <alexmarkov@google.com> TBR=rmacnak@google.com,alexmarkov@google.com,asiva@google.com # Not skipping CQ checks because this is a reland. Bug: https://github.com/dart-lang/sdk/issues/26878, https://github.com/dart-lang/sdk/issues/41974 Change-Id: Ife76bd51db65ca58e08655a9b8406c8ca483447f Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/151326 Reviewed-by: Ryan Macnak <rmacnak@google.com> Reviewed-by: Alexander Markov <alexmarkov@google.com> Commit-Queue: Ryan Macnak <rmacnak@google.com>
This commit is contained in:
committed by
commit-bot@chromium.org
parent
ed9112e862
commit
62893f9b00
@@ -196,6 +196,19 @@ DEFINE_NATIVE_ENTRY(Type_equality, 0, 2) {
|
||||
return Bool::Get(type.IsEquivalent(other, TypeEquality::kSyntactical)).raw();
|
||||
}
|
||||
|
||||
DEFINE_NATIVE_ENTRY(LibraryPrefix_isLoaded, 0, 1) {
|
||||
const LibraryPrefix& prefix =
|
||||
LibraryPrefix::CheckedHandle(zone, arguments->NativeArgAt(0));
|
||||
return Bool::Get(prefix.is_loaded()).raw();
|
||||
}
|
||||
|
||||
DEFINE_NATIVE_ENTRY(LibraryPrefix_setLoaded, 0, 1) {
|
||||
const LibraryPrefix& prefix =
|
||||
LibraryPrefix::CheckedHandle(zone, arguments->NativeArgAt(0));
|
||||
prefix.set_is_loaded(true);
|
||||
return Instance::null();
|
||||
}
|
||||
|
||||
DEFINE_NATIVE_ENTRY(Internal_inquireIs64Bit, 0, 0) {
|
||||
#if defined(ARCH_IS_64_BIT)
|
||||
return Bool::True().raw();
|
||||
|
||||
@@ -31,6 +31,8 @@ namespace dart {
|
||||
V(AbstractType_toString, 1) \
|
||||
V(Type_getHashCode, 1) \
|
||||
V(Type_equality, 2) \
|
||||
V(LibraryPrefix_isLoaded, 1) \
|
||||
V(LibraryPrefix_setLoaded, 1) \
|
||||
V(Identical_comparison, 2) \
|
||||
V(Integer_bitAndFromInteger, 2) \
|
||||
V(Integer_bitOrFromInteger, 2) \
|
||||
|
||||
@@ -3248,6 +3248,7 @@ class LibraryPrefixDeserializationCluster : public DeserializationCluster {
|
||||
ReadFromTo(prefix);
|
||||
prefix->ptr()->num_imports_ = d->Read<uint16_t>();
|
||||
prefix->ptr()->is_deferred_load_ = d->Read<bool>();
|
||||
prefix->ptr()->is_loaded_ = !prefix->ptr()->is_deferred_load_;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1097,7 +1097,11 @@ ConstantInstr::ConstantInstr(const Object& value, TokenPosition token_pos)
|
||||
// tables used for certain character classes are represented as TypedData,
|
||||
// and so those values are also neither immutable (as there are no immutable
|
||||
// TypedData values) or canonical.
|
||||
ASSERT(value.IsTypeParameter() || value.IsArray() || value.IsTypedData());
|
||||
//
|
||||
// LibraryPrefixes are also never canonicalized since their equality is
|
||||
// their identity.
|
||||
ASSERT(value.IsTypeParameter() || value.IsArray() || value.IsTypedData() ||
|
||||
value.IsLibraryPrefix());
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -1363,9 +1363,9 @@ Fragment StreamingFlowGraphBuilder::BuildExpression(TokenPosition* position) {
|
||||
case kInstantiation:
|
||||
return BuildPartialTearoffInstantiation(position);
|
||||
case kLoadLibrary:
|
||||
return BuildLibraryPrefixAction(position, Symbols::LoadLibrary());
|
||||
case kCheckLibraryIsLoaded:
|
||||
ReadUInt(); // skip library index
|
||||
return BuildFutureNullValue(position);
|
||||
return BuildLibraryPrefixAction(position, Symbols::CheckLoaded());
|
||||
case kConstStaticInvocation:
|
||||
case kConstConstructorInvocation:
|
||||
case kConstListLiteral:
|
||||
@@ -4068,6 +4068,26 @@ Fragment StreamingFlowGraphBuilder::BuildPartialTearoffInstantiation(
|
||||
return instructions;
|
||||
}
|
||||
|
||||
Fragment StreamingFlowGraphBuilder::BuildLibraryPrefixAction(
|
||||
TokenPosition* position,
|
||||
const String& selector) {
|
||||
const intptr_t dependency_index = ReadUInt();
|
||||
const Library& current_library = Library::Handle(
|
||||
Z, Class::Handle(Z, parsed_function()->function().origin()).library());
|
||||
const Array& dependencies = Array::Handle(Z, current_library.dependencies());
|
||||
const LibraryPrefix& prefix =
|
||||
LibraryPrefix::CheckedZoneHandle(Z, dependencies.At(dependency_index));
|
||||
const Function& function =
|
||||
Function::ZoneHandle(Z, Library::Handle(Z, Library::CoreLibrary())
|
||||
.LookupFunctionAllowPrivate(selector));
|
||||
ASSERT(!function.IsNull());
|
||||
Fragment instructions;
|
||||
instructions += Constant(prefix);
|
||||
instructions +=
|
||||
StaticCall(TokenPosition::kNoSource, function, 1, ICData::kStatic);
|
||||
return instructions;
|
||||
}
|
||||
|
||||
Fragment StreamingFlowGraphBuilder::BuildExpressionStatement() {
|
||||
Fragment instructions = BuildExpression(); // read expression.
|
||||
instructions += Drop();
|
||||
|
||||
@@ -335,6 +335,8 @@ class StreamingFlowGraphBuilder : public KernelReaderHelper {
|
||||
Fragment BuildFutureNullValue(TokenPosition* position);
|
||||
Fragment BuildConstantExpression(TokenPosition* position, Tag tag);
|
||||
Fragment BuildPartialTearoffInstantiation(TokenPosition* position);
|
||||
Fragment BuildLibraryPrefixAction(TokenPosition* position,
|
||||
const String& selector);
|
||||
|
||||
Fragment BuildExpressionStatement();
|
||||
Fragment BuildBlock();
|
||||
|
||||
@@ -450,7 +450,7 @@ static constexpr dart::compiler::target::word Integer_InstanceSize = 4;
|
||||
static constexpr dart::compiler::target::word KernelProgramInfo_InstanceSize =
|
||||
64;
|
||||
static constexpr dart::compiler::target::word LanguageError_InstanceSize = 28;
|
||||
static constexpr dart::compiler::target::word Library_InstanceSize = 76;
|
||||
static constexpr dart::compiler::target::word Library_InstanceSize = 80;
|
||||
static constexpr dart::compiler::target::word LibraryPrefix_InstanceSize = 20;
|
||||
static constexpr dart::compiler::target::word LinkedHashMap_InstanceSize = 28;
|
||||
static constexpr dart::compiler::target::word LocalVarDescriptors_InstanceSize =
|
||||
@@ -944,7 +944,7 @@ static constexpr dart::compiler::target::word Integer_InstanceSize = 8;
|
||||
static constexpr dart::compiler::target::word KernelProgramInfo_InstanceSize =
|
||||
128;
|
||||
static constexpr dart::compiler::target::word LanguageError_InstanceSize = 48;
|
||||
static constexpr dart::compiler::target::word Library_InstanceSize = 144;
|
||||
static constexpr dart::compiler::target::word Library_InstanceSize = 152;
|
||||
static constexpr dart::compiler::target::word LibraryPrefix_InstanceSize = 40;
|
||||
static constexpr dart::compiler::target::word LinkedHashMap_InstanceSize = 56;
|
||||
static constexpr dart::compiler::target::word LocalVarDescriptors_InstanceSize =
|
||||
@@ -1429,7 +1429,7 @@ static constexpr dart::compiler::target::word Integer_InstanceSize = 4;
|
||||
static constexpr dart::compiler::target::word KernelProgramInfo_InstanceSize =
|
||||
64;
|
||||
static constexpr dart::compiler::target::word LanguageError_InstanceSize = 28;
|
||||
static constexpr dart::compiler::target::word Library_InstanceSize = 76;
|
||||
static constexpr dart::compiler::target::word Library_InstanceSize = 80;
|
||||
static constexpr dart::compiler::target::word LibraryPrefix_InstanceSize = 20;
|
||||
static constexpr dart::compiler::target::word LinkedHashMap_InstanceSize = 28;
|
||||
static constexpr dart::compiler::target::word LocalVarDescriptors_InstanceSize =
|
||||
@@ -1924,7 +1924,7 @@ static constexpr dart::compiler::target::word Integer_InstanceSize = 8;
|
||||
static constexpr dart::compiler::target::word KernelProgramInfo_InstanceSize =
|
||||
128;
|
||||
static constexpr dart::compiler::target::word LanguageError_InstanceSize = 48;
|
||||
static constexpr dart::compiler::target::word Library_InstanceSize = 144;
|
||||
static constexpr dart::compiler::target::word Library_InstanceSize = 152;
|
||||
static constexpr dart::compiler::target::word LibraryPrefix_InstanceSize = 40;
|
||||
static constexpr dart::compiler::target::word LinkedHashMap_InstanceSize = 56;
|
||||
static constexpr dart::compiler::target::word LocalVarDescriptors_InstanceSize =
|
||||
@@ -2408,7 +2408,7 @@ static constexpr dart::compiler::target::word Integer_InstanceSize = 4;
|
||||
static constexpr dart::compiler::target::word KernelProgramInfo_InstanceSize =
|
||||
64;
|
||||
static constexpr dart::compiler::target::word LanguageError_InstanceSize = 28;
|
||||
static constexpr dart::compiler::target::word Library_InstanceSize = 76;
|
||||
static constexpr dart::compiler::target::word Library_InstanceSize = 80;
|
||||
static constexpr dart::compiler::target::word LibraryPrefix_InstanceSize = 20;
|
||||
static constexpr dart::compiler::target::word LinkedHashMap_InstanceSize = 28;
|
||||
static constexpr dart::compiler::target::word LocalVarDescriptors_InstanceSize =
|
||||
@@ -2896,7 +2896,7 @@ static constexpr dart::compiler::target::word Integer_InstanceSize = 8;
|
||||
static constexpr dart::compiler::target::word KernelProgramInfo_InstanceSize =
|
||||
128;
|
||||
static constexpr dart::compiler::target::word LanguageError_InstanceSize = 48;
|
||||
static constexpr dart::compiler::target::word Library_InstanceSize = 144;
|
||||
static constexpr dart::compiler::target::word Library_InstanceSize = 152;
|
||||
static constexpr dart::compiler::target::word LibraryPrefix_InstanceSize = 40;
|
||||
static constexpr dart::compiler::target::word LinkedHashMap_InstanceSize = 56;
|
||||
static constexpr dart::compiler::target::word LocalVarDescriptors_InstanceSize =
|
||||
@@ -3375,7 +3375,7 @@ static constexpr dart::compiler::target::word Integer_InstanceSize = 4;
|
||||
static constexpr dart::compiler::target::word KernelProgramInfo_InstanceSize =
|
||||
64;
|
||||
static constexpr dart::compiler::target::word LanguageError_InstanceSize = 28;
|
||||
static constexpr dart::compiler::target::word Library_InstanceSize = 76;
|
||||
static constexpr dart::compiler::target::word Library_InstanceSize = 80;
|
||||
static constexpr dart::compiler::target::word LibraryPrefix_InstanceSize = 20;
|
||||
static constexpr dart::compiler::target::word LinkedHashMap_InstanceSize = 28;
|
||||
static constexpr dart::compiler::target::word LocalVarDescriptors_InstanceSize =
|
||||
@@ -3864,7 +3864,7 @@ static constexpr dart::compiler::target::word Integer_InstanceSize = 8;
|
||||
static constexpr dart::compiler::target::word KernelProgramInfo_InstanceSize =
|
||||
128;
|
||||
static constexpr dart::compiler::target::word LanguageError_InstanceSize = 48;
|
||||
static constexpr dart::compiler::target::word Library_InstanceSize = 144;
|
||||
static constexpr dart::compiler::target::word Library_InstanceSize = 152;
|
||||
static constexpr dart::compiler::target::word LibraryPrefix_InstanceSize = 40;
|
||||
static constexpr dart::compiler::target::word LinkedHashMap_InstanceSize = 56;
|
||||
static constexpr dart::compiler::target::word LocalVarDescriptors_InstanceSize =
|
||||
@@ -4384,7 +4384,7 @@ static constexpr dart::compiler::target::word
|
||||
AOT_KernelProgramInfo_InstanceSize = 64;
|
||||
static constexpr dart::compiler::target::word AOT_LanguageError_InstanceSize =
|
||||
28;
|
||||
static constexpr dart::compiler::target::word AOT_Library_InstanceSize = 72;
|
||||
static constexpr dart::compiler::target::word AOT_Library_InstanceSize = 76;
|
||||
static constexpr dart::compiler::target::word AOT_LibraryPrefix_InstanceSize =
|
||||
20;
|
||||
static constexpr dart::compiler::target::word AOT_LinkedHashMap_InstanceSize =
|
||||
@@ -4919,7 +4919,7 @@ static constexpr dart::compiler::target::word
|
||||
AOT_KernelProgramInfo_InstanceSize = 128;
|
||||
static constexpr dart::compiler::target::word AOT_LanguageError_InstanceSize =
|
||||
48;
|
||||
static constexpr dart::compiler::target::word AOT_Library_InstanceSize = 136;
|
||||
static constexpr dart::compiler::target::word AOT_Library_InstanceSize = 144;
|
||||
static constexpr dart::compiler::target::word AOT_LibraryPrefix_InstanceSize =
|
||||
40;
|
||||
static constexpr dart::compiler::target::word AOT_LinkedHashMap_InstanceSize =
|
||||
@@ -5458,7 +5458,7 @@ static constexpr dart::compiler::target::word
|
||||
AOT_KernelProgramInfo_InstanceSize = 128;
|
||||
static constexpr dart::compiler::target::word AOT_LanguageError_InstanceSize =
|
||||
48;
|
||||
static constexpr dart::compiler::target::word AOT_Library_InstanceSize = 136;
|
||||
static constexpr dart::compiler::target::word AOT_Library_InstanceSize = 144;
|
||||
static constexpr dart::compiler::target::word AOT_LibraryPrefix_InstanceSize =
|
||||
40;
|
||||
static constexpr dart::compiler::target::word AOT_LinkedHashMap_InstanceSize =
|
||||
@@ -5984,7 +5984,7 @@ static constexpr dart::compiler::target::word
|
||||
AOT_KernelProgramInfo_InstanceSize = 64;
|
||||
static constexpr dart::compiler::target::word AOT_LanguageError_InstanceSize =
|
||||
28;
|
||||
static constexpr dart::compiler::target::word AOT_Library_InstanceSize = 72;
|
||||
static constexpr dart::compiler::target::word AOT_Library_InstanceSize = 76;
|
||||
static constexpr dart::compiler::target::word AOT_LibraryPrefix_InstanceSize =
|
||||
20;
|
||||
static constexpr dart::compiler::target::word AOT_LinkedHashMap_InstanceSize =
|
||||
@@ -6512,7 +6512,7 @@ static constexpr dart::compiler::target::word
|
||||
AOT_KernelProgramInfo_InstanceSize = 128;
|
||||
static constexpr dart::compiler::target::word AOT_LanguageError_InstanceSize =
|
||||
48;
|
||||
static constexpr dart::compiler::target::word AOT_Library_InstanceSize = 136;
|
||||
static constexpr dart::compiler::target::word AOT_Library_InstanceSize = 144;
|
||||
static constexpr dart::compiler::target::word AOT_LibraryPrefix_InstanceSize =
|
||||
40;
|
||||
static constexpr dart::compiler::target::word AOT_LinkedHashMap_InstanceSize =
|
||||
@@ -7044,7 +7044,7 @@ static constexpr dart::compiler::target::word
|
||||
AOT_KernelProgramInfo_InstanceSize = 128;
|
||||
static constexpr dart::compiler::target::word AOT_LanguageError_InstanceSize =
|
||||
48;
|
||||
static constexpr dart::compiler::target::word AOT_Library_InstanceSize = 136;
|
||||
static constexpr dart::compiler::target::word AOT_Library_InstanceSize = 144;
|
||||
static constexpr dart::compiler::target::word AOT_LibraryPrefix_InstanceSize =
|
||||
40;
|
||||
static constexpr dart::compiler::target::word AOT_LinkedHashMap_InstanceSize =
|
||||
|
||||
@@ -738,7 +738,7 @@ bool IsolateGroupReloadContext::Reload(bool force_reload,
|
||||
|
||||
// Ensure all functions on the stack have unoptimized code.
|
||||
// Deoptimize all code that had optimizing decisions that are dependent on
|
||||
// assumptions from field guards or CHA.
|
||||
// assumptions from field guards or CHA or deferred library prefixes.
|
||||
// TODO(johnmccutchan): Deoptimizing dependent code here (before the reload)
|
||||
// is paranoid. This likely can be moved to the commit phase.
|
||||
ForEachIsolate([&](Isolate* isolate) {
|
||||
@@ -1312,6 +1312,8 @@ void IsolateReloadContext::DeoptimizeDependentCode() {
|
||||
}
|
||||
|
||||
DeoptimizeTypeTestingStubs();
|
||||
|
||||
// TODO(rmacnak): Also call LibraryPrefix::InvalidateDependentCode.
|
||||
}
|
||||
|
||||
void IsolateGroupReloadContext::CheckpointSharedClassTable() {
|
||||
|
||||
@@ -1305,6 +1305,7 @@ void KernelLoader::LoadLibraryImportsAndExports(Library* library,
|
||||
LibraryPrefix& library_prefix = LibraryPrefix::Handle(Z);
|
||||
|
||||
const intptr_t deps_count = helper_.ReadListLength();
|
||||
const Array& deps = Array::Handle(Array::New(deps_count));
|
||||
for (intptr_t dep = 0; dep < deps_count; ++dep) {
|
||||
LibraryDependencyHelper dependency_helper(&helper_);
|
||||
|
||||
@@ -1388,12 +1389,21 @@ void KernelLoader::LoadLibraryImportsAndExports(Library* library,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (FLAG_enable_mirrors && dependency_helper.annotation_count_ > 0) {
|
||||
ASSERT(annotations_kernel_offset > 0);
|
||||
ns.AddMetadata(toplevel_class, TokenPosition::kNoSource,
|
||||
annotations_kernel_offset);
|
||||
}
|
||||
|
||||
if (prefix.IsNull()) {
|
||||
deps.SetAt(dep, ns);
|
||||
} else {
|
||||
deps.SetAt(dep, library_prefix);
|
||||
}
|
||||
}
|
||||
|
||||
library->set_dependencies(deps);
|
||||
}
|
||||
|
||||
void KernelLoader::LoadPreliminaryClass(ClassHelper* class_helper,
|
||||
|
||||
+6
-23
@@ -11081,27 +11081,6 @@ void ClassDictionaryIterator::MoveToNextClass() {
|
||||
}
|
||||
}
|
||||
|
||||
LibraryPrefixIterator::LibraryPrefixIterator(const Library& library)
|
||||
: DictionaryIterator(library) {
|
||||
Advance();
|
||||
}
|
||||
|
||||
LibraryPrefixPtr LibraryPrefixIterator::GetNext() {
|
||||
ASSERT(HasNext());
|
||||
int ix = next_ix_++;
|
||||
Object& obj = Object::Handle(array_.At(ix));
|
||||
Advance();
|
||||
return LibraryPrefix::Cast(obj).raw();
|
||||
}
|
||||
|
||||
void LibraryPrefixIterator::Advance() {
|
||||
Object& obj = Object::Handle(array_.At(next_ix_));
|
||||
while (!obj.IsLibraryPrefix() && HasNext()) {
|
||||
next_ix_++;
|
||||
obj = array_.At(next_ix_);
|
||||
}
|
||||
}
|
||||
|
||||
static void ReportTooManyImports(const Library& lib) {
|
||||
const String& url = String::Handle(lib.url());
|
||||
Report::MessageF(Report::kError, Script::Handle(lib.LookupScript(url)),
|
||||
@@ -12075,6 +12054,10 @@ void Library::set_toplevel_class(const Class& value) const {
|
||||
StorePointer(&raw_ptr()->toplevel_class_, value.raw());
|
||||
}
|
||||
|
||||
void Library::set_dependencies(const Array& deps) const {
|
||||
StorePointer(&raw_ptr()->dependencies_, deps.raw());
|
||||
}
|
||||
|
||||
void Library::set_metadata(const GrowableObjectArray& value) const {
|
||||
StorePointer(&raw_ptr()->metadata_, value.raw());
|
||||
}
|
||||
@@ -12943,6 +12926,7 @@ LibraryPrefixPtr LibraryPrefix::New(const String& name,
|
||||
result.set_num_imports(0);
|
||||
result.set_importer(importer);
|
||||
result.StoreNonPointer(&result.raw_ptr()->is_deferred_load_, deferred_load);
|
||||
result.StoreNonPointer(&result.raw_ptr()->is_loaded_, !deferred_load);
|
||||
result.set_imports(Array::Handle(Array::New(kInitialSize)));
|
||||
result.AddImport(import);
|
||||
return result.raw();
|
||||
@@ -12970,8 +12954,7 @@ void LibraryPrefix::set_importer(const Library& value) const {
|
||||
|
||||
const char* LibraryPrefix::ToCString() const {
|
||||
const String& prefix = String::Handle(name());
|
||||
return OS::SCreate(Thread::Current()->zone(), "LibraryPrefix:'%s'",
|
||||
prefix.ToCString());
|
||||
return prefix.ToCString();
|
||||
}
|
||||
|
||||
void Namespace::set_metadata_field(const Field& value) const {
|
||||
|
||||
+7
-11
@@ -4543,7 +4543,6 @@ class DictionaryIterator : public ValueObject {
|
||||
int next_ix_; // Index of next element.
|
||||
|
||||
friend class ClassDictionaryIterator;
|
||||
friend class LibraryPrefixIterator;
|
||||
DISALLOW_COPY_AND_ASSIGN(DictionaryIterator);
|
||||
};
|
||||
|
||||
@@ -4574,16 +4573,6 @@ class ClassDictionaryIterator : public DictionaryIterator {
|
||||
DISALLOW_COPY_AND_ASSIGN(ClassDictionaryIterator);
|
||||
};
|
||||
|
||||
class LibraryPrefixIterator : public DictionaryIterator {
|
||||
public:
|
||||
explicit LibraryPrefixIterator(const Library& library);
|
||||
LibraryPrefixPtr GetNext();
|
||||
|
||||
private:
|
||||
void Advance();
|
||||
DISALLOW_COPY_AND_ASSIGN(LibraryPrefixIterator);
|
||||
};
|
||||
|
||||
class Library : public Object {
|
||||
public:
|
||||
StringPtr name() const { return raw_ptr()->name_; }
|
||||
@@ -4738,6 +4727,9 @@ class Library : public Object {
|
||||
NamespacePtr ImportAt(intptr_t index) const;
|
||||
LibraryPtr ImportLibraryAt(intptr_t index) const;
|
||||
|
||||
ArrayPtr dependencies() const { return raw_ptr()->dependencies_; }
|
||||
void set_dependencies(const Array& deps) const;
|
||||
|
||||
void DropDependenciesAndCaches() const;
|
||||
|
||||
// Resolving native methods for script loaded in the library.
|
||||
@@ -7342,6 +7334,10 @@ class LibraryPrefix : public Instance {
|
||||
void AddImport(const Namespace& import) const;
|
||||
|
||||
bool is_deferred_load() const { return raw_ptr()->is_deferred_load_; }
|
||||
bool is_loaded() const { return raw_ptr()->is_loaded_; }
|
||||
void set_is_loaded(bool value) const {
|
||||
return StoreNonPointer(&raw_ptr()->is_loaded_, value);
|
||||
}
|
||||
|
||||
static intptr_t InstanceSize() {
|
||||
return RoundedAllocationSize(sizeof(LibraryPrefixLayout));
|
||||
|
||||
@@ -692,6 +692,29 @@ class InstanceSizeConflict : public ClassReasonForCancelling {
|
||||
}
|
||||
};
|
||||
|
||||
class UnimplementedDeferredLibrary : public ReasonForCancelling {
|
||||
public:
|
||||
UnimplementedDeferredLibrary(Zone* zone,
|
||||
const Library& from,
|
||||
const Library& to,
|
||||
const String& name)
|
||||
: ReasonForCancelling(zone), from_(from), to_(to), name_(name) {}
|
||||
|
||||
private:
|
||||
const Library& from_;
|
||||
const Library& to_;
|
||||
const String& name_;
|
||||
|
||||
StringPtr ToString() {
|
||||
const String& lib_url = String::Handle(to_.url());
|
||||
from_.ToCString();
|
||||
return String::NewFormatted(
|
||||
"Reloading support for deferred loading has not yet been implemented:"
|
||||
" library '%s' has deferred import '%s'",
|
||||
lib_url.ToCString(), name_.ToCString());
|
||||
}
|
||||
};
|
||||
|
||||
// This is executed before iterating over the instances.
|
||||
void Class::CheckReload(const Class& replacement,
|
||||
IsolateReloadContext* context) const {
|
||||
@@ -889,7 +912,23 @@ bool Class::CanReloadPreFinalized(const Class& replacement,
|
||||
|
||||
void Library::CheckReload(const Library& replacement,
|
||||
IsolateReloadContext* context) const {
|
||||
// Currently no library properties will prevent a reload.
|
||||
// TODO(26878): If the replacement library uses deferred loading,
|
||||
// reject it. We do not yet support reloading deferred libraries.
|
||||
Object& object = Object::Handle();
|
||||
LibraryPrefix& prefix = LibraryPrefix::Handle();
|
||||
DictionaryIterator it(replacement);
|
||||
while (it.HasNext()) {
|
||||
object = it.GetNext();
|
||||
if (!object.IsLibraryPrefix()) continue;
|
||||
prefix ^= object.raw();
|
||||
if (prefix.is_deferred_load()) {
|
||||
const String& prefix_name = String::Handle(prefix.name());
|
||||
context->group_reload_context()->AddReasonForCancelling(
|
||||
new (context->zone()) UnimplementedDeferredLibrary(
|
||||
context->zone(), *this, replacement, prefix_name));
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CallSiteResetter::Reset(const ICData& ic) {
|
||||
|
||||
@@ -1305,6 +1305,7 @@ class LibraryLayout : public ObjectLayout {
|
||||
GrowableObjectArrayPtr used_scripts_;
|
||||
ArrayPtr imports_; // List of Namespaces imported without prefix.
|
||||
ArrayPtr exports_; // List of re-exported Namespaces.
|
||||
ArrayPtr dependencies_;
|
||||
ExternalTypedDataPtr kernel_data_;
|
||||
ObjectPtr* to_snapshot(Snapshot::Kind kind) {
|
||||
switch (kind) {
|
||||
@@ -2130,6 +2131,7 @@ class LibraryPrefixLayout : public InstanceLayout {
|
||||
}
|
||||
uint16_t num_imports_; // Number of library entries in libraries_.
|
||||
bool is_deferred_load_;
|
||||
bool is_loaded_;
|
||||
};
|
||||
|
||||
class TypeArgumentsLayout : public InstanceLayout {
|
||||
|
||||
@@ -44,6 +44,7 @@ class ObjectPointerVisitor;
|
||||
V(Call, "call") \
|
||||
V(Cancel, "cancel") \
|
||||
V(CastError, "_CastError") \
|
||||
V(CheckLoaded, "_checkLoaded") \
|
||||
V(Class, "Class") \
|
||||
V(ClassID, "ClassID") \
|
||||
V(ClearAsyncThreadStackTrace, "_clearAsyncThreadStackTrace") \
|
||||
@@ -206,6 +207,7 @@ class ObjectPointerVisitor;
|
||||
V(ListFactory, "List.") \
|
||||
V(ListFilledFactory, "List.filled") \
|
||||
V(ListLiteralFactory, "List._fromLiteral") \
|
||||
V(LoadLibrary, "_loadLibrary") \
|
||||
V(LocalVarDescriptors, "LocalVarDescriptors") \
|
||||
V(Map, "Map") \
|
||||
V(MapLiteralFactory, "Map._fromLiteral") \
|
||||
|
||||
@@ -13,7 +13,32 @@ class _LibraryPrefix {
|
||||
throw "Unreachable";
|
||||
}
|
||||
|
||||
bool isLoaded() => true;
|
||||
|
||||
loadLibrary() => new Future.value(true);
|
||||
bool _isLoaded() native "LibraryPrefix_isLoaded";
|
||||
void _setLoaded() native "LibraryPrefix_setLoaded";
|
||||
}
|
||||
|
||||
class _DeferredNotLoadedError extends Error implements NoSuchMethodError {
|
||||
final _LibraryPrefix prefix;
|
||||
|
||||
_DeferredNotLoadedError(this.prefix);
|
||||
|
||||
String toString() {
|
||||
return "Deferred library $prefix was not loaded.";
|
||||
}
|
||||
}
|
||||
|
||||
@pragma("vm:entry-point")
|
||||
@pragma("vm:never-inline") // Don't duplicate prefix checking code.
|
||||
Future<void> _loadLibrary(_LibraryPrefix prefix) {
|
||||
return new Future<void>(() {
|
||||
prefix._setLoaded();
|
||||
});
|
||||
}
|
||||
|
||||
@pragma("vm:entry-point")
|
||||
@pragma("vm:never-inline") // Don't duplicate prefix checking code.
|
||||
void _checkLoaded(_LibraryPrefix prefix) {
|
||||
if (!prefix._isLoaded()) {
|
||||
throw new _DeferredNotLoadedError(prefix);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,7 +11,32 @@ class _LibraryPrefix {
|
||||
throw "Unreachable";
|
||||
}
|
||||
|
||||
bool isLoaded() => true;
|
||||
|
||||
loadLibrary() => new Future.value(true);
|
||||
bool _isLoaded() native "LibraryPrefix_isLoaded";
|
||||
void _setLoaded() native "LibraryPrefix_setLoaded";
|
||||
}
|
||||
|
||||
class _DeferredNotLoadedError extends Error implements NoSuchMethodError {
|
||||
final _LibraryPrefix prefix;
|
||||
|
||||
_DeferredNotLoadedError(this.prefix);
|
||||
|
||||
String toString() {
|
||||
return "Deferred library $prefix was not loaded.";
|
||||
}
|
||||
}
|
||||
|
||||
@pragma("vm:entry-point")
|
||||
@pragma("vm:never-inline") // Don't duplicate prefix checking code.
|
||||
Future<void> _loadLibrary(_LibraryPrefix prefix) {
|
||||
return new Future<void>(() {
|
||||
prefix._setLoaded();
|
||||
});
|
||||
}
|
||||
|
||||
@pragma("vm:entry-point")
|
||||
@pragma("vm:never-inline") // Don't duplicate prefix checking code.
|
||||
void _checkLoaded(_LibraryPrefix prefix) {
|
||||
if (!prefix._isLoaded()) {
|
||||
throw new _DeferredNotLoadedError(prefix);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user