VM: Support bootstrapping core libraries from Kernel binaries instead of source.

BUG=http://dartbug.com/27590
R=asiva@google.com

Review URL: https://codereview.chromium.org/2485993002 .
This commit is contained in:
Vyacheslav Egorov 2016-11-16 13:56:20 +01:00
parent 12e2244310
commit 23fd1a184b
45 changed files with 1206 additions and 763 deletions

View file

@ -110,7 +110,17 @@ Dart_Handle Builtin::GetSource(const char** source_paths, const char* uri) {
void Builtin::SetNativeResolver(BuiltinLibraryId id) {
UNREACHABLE();
ASSERT(static_cast<int>(id) >= 0);
ASSERT(static_cast<int>(id) < num_libs_);
if (builtin_libraries_[id].has_natives_) {
Dart_Handle url = DartUtils::NewString(builtin_libraries_[id].url_);
Dart_Handle library = Dart_LookupLibrary(url);
ASSERT(!Dart_IsError(library));
// Setup the native resolver for built in library functions.
DART_CHECK_VALID(
Dart_SetNativeResolver(library, NativeLookup, NativeSymbol));
}
}

View file

@ -1266,8 +1266,16 @@ int main(int argc, char** argv) {
// Now we create an isolate into which we load all the code that needs to
// be in the snapshot.
isolate_data = new IsolateData(NULL, NULL, NULL);
if (Dart_CreateIsolate(NULL, NULL, NULL, NULL, isolate_data, &error) ==
NULL) {
const uint8_t* kernel = NULL;
intptr_t kernel_length = 0;
const bool is_kernel_file =
TryReadKernel(app_script_name, &kernel, &kernel_length);
Dart_Isolate isolate =
is_kernel_file
? Dart_CreateIsolateFromKernel(NULL, NULL, kernel, kernel_length,
NULL, isolate_data, &error)
: Dart_CreateIsolate(NULL, NULL, NULL, NULL, isolate_data, &error);
if (isolate == NULL) {
fprintf(stderr, "%s", error);
free(error);
exit(255);
@ -1284,14 +1292,9 @@ int main(int argc, char** argv) {
Dart_QualifiedFunctionName* entry_points =
ParseEntryPointsManifestIfPresent();
intptr_t payload_bytes = 0;
const uint8_t* payload = NULL;
const bool is_kernel_file =
TryReadKernel(app_script_name, &payload, &payload_bytes);
if (is_kernel_file) {
Dart_Handle library = Dart_LoadKernel(payload, payload_bytes);
free(const_cast<uint8_t*>(payload));
Dart_Handle library = Dart_LoadKernel(kernel, kernel_length);
free(const_cast<uint8_t*>(kernel));
if (Dart_IsError(library)) FATAL("Failed to load app from Kernel IR");
} else {
// Set up the library tag handler in such a manner that it will use the

View file

@ -799,10 +799,26 @@ static Dart_Isolate CreateIsolateAndSetupHelper(const char* script_uri,
return NULL;
}
// If the script is a Kernel binary, then we will try to bootstrap from the
// script.
const uint8_t* kernel_file = NULL;
intptr_t kernel_length = -1;
const bool is_kernel =
!run_app_snapshot &&
TryReadKernel(script_uri, &kernel_file, &kernel_length);
IsolateData* isolate_data =
new IsolateData(script_uri, package_root, packages_config);
Dart_Isolate isolate = Dart_CreateIsolate(
script_uri, main, isolate_snapshot_buffer, flags, isolate_data, error);
Dart_Isolate isolate =
is_kernel ? Dart_CreateIsolateFromKernel(script_uri, main, kernel_file,
kernel_length, flags,
isolate_data, error)
: Dart_CreateIsolate(script_uri, main, isolate_snapshot_buffer,
flags, isolate_data, error);
if (is_kernel) {
free(const_cast<uint8_t*>(kernel_file));
}
if (isolate == NULL) {
delete isolate_data;
return NULL;
@ -810,7 +826,20 @@ static Dart_Isolate CreateIsolateAndSetupHelper(const char* script_uri,
Dart_EnterScope();
if (isolate_snapshot_buffer != NULL) {
// Set up the library tag handler for this isolate.
Dart_Handle result = Dart_SetLibraryTagHandler(Loader::LibraryTagHandler);
CHECK_RESULT(result);
if (is_kernel) {
// TODO(27590): We should not read the kernel file again!
if (!TryReadKernel(script_uri, &kernel_file, &kernel_length)) {
FATAL("Failed to read kernel second time");
}
Dart_Handle result = Dart_LoadKernel(kernel_file, kernel_length);
free(const_cast<uint8_t*>(kernel_file));
CHECK_RESULT(result);
}
if (is_kernel || (isolate_snapshot_buffer != NULL)) {
// Setup the native resolver as the snapshot does not carry it.
Builtin::SetNativeResolver(Builtin::kBuiltinLibrary);
Builtin::SetNativeResolver(Builtin::kIOLibrary);
@ -820,10 +849,6 @@ static Dart_Isolate CreateIsolateAndSetupHelper(const char* script_uri,
CHECK_RESULT(result);
}
// Set up the library tag handler for this isolate.
Dart_Handle result = Dart_SetLibraryTagHandler(Loader::LibraryTagHandler);
CHECK_RESULT(result);
if (Dart_IsServiceIsolate(isolate)) {
// If this is the service isolate, load embedder specific bits and return.
bool skip_library_load = run_app_snapshot;
@ -872,8 +897,10 @@ static Dart_Isolate CreateIsolateAndSetupHelper(const char* script_uri,
Dart_Handle uri =
DartUtils::ResolveScript(Dart_NewStringFromCString(script_uri));
CHECK_RESULT(uri);
result = Loader::LibraryTagHandler(Dart_kScriptTag, Dart_Null(), uri);
CHECK_RESULT(result);
if (!is_kernel) {
result = Loader::LibraryTagHandler(Dart_kScriptTag, Dart_Null(), uri);
CHECK_RESULT(result);
}
Dart_TimelineEvent("LoadScript", Dart_TimelineGetMicros(),
Dart_GetMainPortId(), Dart_Timeline_Event_Async_End, 0,

View file

@ -34,7 +34,7 @@
return null;
}
@patch static int _nativeSocketType(_NativeSocket nativeSocket) {
static int _nativeSocketType(_NativeSocket nativeSocket) {
var result = _getSocketType(nativeSocket);
if (result is OSError) {
throw new FileSystemException(

View file

@ -155,7 +155,8 @@ char VmService::server_uri_[kServerUriStringBufferSize];
bool VmService::LoadForGenPrecompiled() {
Dart_Handle result;
Dart_SetLibraryTagHandler(LibraryTagHandler);
Dart_Handle library = LoadLibrary(kVMServiceIOLibraryScriptResourceName);
Dart_Handle library =
LookupOrLoadLibrary(kVMServiceIOLibraryScriptResourceName);
ASSERT(library != Dart_Null());
SHUTDOWN_ON_ERROR(library);
result = Dart_SetNativeResolver(library, VmServiceIONativeResolver, NULL);
@ -314,10 +315,14 @@ Dart_Handle VmService::LoadScript(const char* name) {
}
Dart_Handle VmService::LoadLibrary(const char* name) {
Dart_Handle VmService::LookupOrLoadLibrary(const char* name) {
Dart_Handle uri = Dart_NewStringFromCString(kVMServiceIOLibraryUri);
Dart_Handle source = GetSource(name);
return Dart_LoadLibrary(uri, Dart_Null(), source, 0, 0);
Dart_Handle library = Dart_LookupLibrary(uri);
if (!Dart_IsLibrary(library)) {
Dart_Handle source = GetSource(name);
library = Dart_LoadLibrary(uri, Dart_Null(), source, 0, 0);
}
return library;
}

View file

@ -34,7 +34,7 @@ class VmService {
static void SetServerAddress(const char* server_uri_);
static Dart_Handle GetSource(const char* name);
static Dart_Handle LoadScript(const char* name);
static Dart_Handle LoadLibrary(const char* name);
static Dart_Handle LookupOrLoadLibrary(const char* name);
static Dart_Handle LoadSource(Dart_Handle library, const char* name);
static Dart_Handle LoadResources(Dart_Handle library);
static Dart_Handle LoadResource(Dart_Handle library, const char* name);

View file

@ -873,7 +873,7 @@ DART_EXPORT bool Dart_IsVMFlagSet(const char* flag_name);
* \param error DOCUMENT
*
* \return The new isolate is returned. May be NULL if an error
* occurs duing isolate initialization.
* occurs during isolate initialization.
*/
DART_EXPORT Dart_Isolate Dart_CreateIsolate(const char* script_uri,
const char* main,
@ -884,6 +884,34 @@ DART_EXPORT Dart_Isolate Dart_CreateIsolate(const char* script_uri,
/* TODO(turnidge): Document behavior when there is already a current
* isolate. */
/**
* Creates a new isolate from a Dart Kernel file. The new isolate
* becomes the current isolate.
*
* Requires there to be no current isolate.
*
* \param script_uri The name of the script this isolate will load.
* Provided only for advisory purposes to improve debugging messages.
* \param main The name of the main entry point this isolate will run.
* Provided only for advisory purposes to improve debugging messages.
* \param kernel A buffer containing the Dart Kernel binary.
* \param kernel_length The length of the Kernel buffer.
* \param flags Pointer to VM specific flags or NULL for default flags.
* \param callback_data Embedder data. This data will be passed to
* the Dart_IsolateCreateCallback when new isolates are spawned from
* this parent isolate.
* \param error DOCUMENT
*
* \return The new isolate is returned. May be NULL if an error
* occurs during isolate initialization.
*/
DART_EXPORT Dart_Isolate Dart_CreateIsolateFromKernel(const char* script_uri,
const char* main,
const uint8_t* kernel,
intptr_t kernel_length,
Dart_IsolateFlags* flags,
void* callback_data,
char** error);
/**
* Shuts down the current isolate. After this call, the current isolate
* is NULL. Invokes the shutdown callback and any callbacks of remaining

View file

@ -13,4 +13,24 @@ DEFINE_NATIVE_ENTRY(ClassID_getID, 1) {
return Smi::New(instance.GetClassId());
}
DEFINE_NATIVE_ENTRY(ClassID_byName, 1) {
GET_NON_NULL_NATIVE_ARGUMENT(String, name, arguments->NativeArgAt(0));
#define CLASS_LIST_WITH_NULL(V) \
V(Null) \
CLASS_LIST_NO_OBJECT(V)
#define COMPARE(clazz) \
if (name.Equals(#clazz)) return Smi::New(k##clazz##Cid);
CLASS_LIST_WITH_NULL(COMPARE)
#undef COMPARE
#undef CLASS_LIST_WITH_NULL
UNREACHABLE();
return Smi::New(-1);
}
} // namespace dart

View file

@ -4,4 +4,14 @@
class ClassID {
static int getID(Object value) native "ClassID_getID";
static int _lookup(String name) native "ClassID_byName";
static final int cidArray = _lookup('Array');
static final int cidExternalOneByteString = _lookup('ExternalOneByteString');
static final int cidGrowableObjectArray = _lookup('GrowableObjectArray');
static final int cidImmutableArray = _lookup('ImmutableArray');
static final int cidOneByteString = _lookup('OneByteString');
static final int cidTwoByteString = _lookup('TwoByteString');
static final int cidBigint = _lookup('Bigint');
}

View file

@ -103,7 +103,7 @@ class _CastError extends Error implements CastError {
static _throwNew(int case_clause_pos) native "FallThroughError_throwNew";
@patch String toString() {
String toString() {
return "'$_url': Switch case fall-through at line $_line.";
}

View file

@ -10,6 +10,8 @@
#include "vm/class_finalizer.h"
#include "vm/compiler.h"
#include "vm/dart_api_impl.h"
#include "vm/kernel.h"
#include "vm/kernel_reader.h"
#include "vm/object.h"
#include "vm/object_store.h"
#include "vm/symbols.h"
@ -244,6 +246,24 @@ static RawError* LoadPatchFiles(Thread* thread,
}
static void Finish(Thread* thread, bool from_kernel) {
Bootstrap::SetupNativeResolver();
if (!ClassFinalizer::ProcessPendingClasses(from_kernel)) {
FATAL("Error in class finalization during bootstrapping.");
}
// Eagerly compile the _Closure class as it is the class of all closure
// instances. This allows us to just finalize function types without going
// through the hoops of trying to compile their scope class.
ObjectStore* object_store = thread->isolate()->object_store();
Class& cls = Class::Handle(thread->zone(), object_store->closure_class());
Compiler::CompileClass(cls);
// Eagerly compile Bool class, bool constants are used from within compiler.
cls = object_store->bool_class();
Compiler::CompileClass(cls);
}
static RawError* BootstrapFromSource(Thread* thread) {
Isolate* isolate = thread->isolate();
Zone* zone = thread->zone();
@ -285,19 +305,8 @@ static RawError* BootstrapFromSource(Thread* thread) {
}
if (error.IsNull()) {
Bootstrap::SetupNativeResolver();
ClassFinalizer::ProcessPendingClasses();
// Eagerly compile the _Closure class as it is the class of all closure
// instances. This allows us to just finalize function types
// without going through the hoops of trying to compile their scope class.
Class& cls = Class::Handle(zone, isolate->object_store()->closure_class());
Compiler::CompileClass(cls);
// Eagerly compile Bool class, bool constants are used from within compiler.
cls = isolate->object_store()->bool_class();
Compiler::CompileClass(cls);
Finish(thread, /*from_kernel=*/false);
}
// Restore the library tag handler for the isolate.
isolate->set_library_tag_handler(saved_tag_handler);
@ -305,7 +314,56 @@ static RawError* BootstrapFromSource(Thread* thread) {
}
RawError* Bootstrap::DoBootstrapping() {
static RawError* BootstrapFromKernel(Thread* thread,
const uint8_t* buffer,
intptr_t buffer_size) {
Zone* zone = thread->zone();
kernel::Program* program =
ReadPrecompiledKernelFromBuffer(buffer, buffer_size);
if (program == NULL) {
const String& message =
String::Handle(zone, String::New("Failed to read Kernel file"));
return ApiError::New(message);
}
Isolate* isolate = thread->isolate();
// Mark the already-pending classes. This mark bit will be used to avoid
// adding classes to the list more than once.
GrowableObjectArray& pending_classes = GrowableObjectArray::Handle(
zone, isolate->object_store()->pending_classes());
dart::Class& pending = dart::Class::Handle(zone);
for (intptr_t i = 0; i < pending_classes.Length(); ++i) {
pending ^= pending_classes.At(i);
pending.set_is_marked_for_parsing();
}
Library& library = Library::Handle(zone);
String& dart_name = String::Handle(zone);
String& kernel_name = String::Handle(zone);
kernel::KernelReader reader(NULL, -1, true);
for (intptr_t i = 0; i < kBootstrapLibraryCount; ++i) {
ObjectStore::BootstrapLibraryId id = bootstrap_libraries[i].index;
library = isolate->object_store()->bootstrap_library(id);
dart_name = library.url();
for (intptr_t j = 0; j < program->libraries().length(); ++j) {
kernel::Library* kernel_library = program->libraries()[j];
kernel::String* uri = kernel_library->import_uri();
kernel_name = Symbols::FromUTF8(thread, uri->buffer(), uri->size());
if (kernel_name.Equals(dart_name)) {
reader.ReadLibrary(kernel_library);
library.SetLoaded();
break;
}
}
}
Finish(thread, /*from_kernel=*/true);
return Error::null();
}
RawError* Bootstrap::DoBootstrapping(const uint8_t* kernel_buffer,
intptr_t kernel_buffer_length) {
Thread* thread = Thread::Current();
Isolate* isolate = thread->isolate();
Zone* zone = thread->zone();
@ -328,7 +386,9 @@ RawError* Bootstrap::DoBootstrapping() {
}
}
return BootstrapFromSource(thread);
return (kernel_buffer == NULL)
? BootstrapFromSource(thread)
: BootstrapFromKernel(thread, kernel_buffer, kernel_buffer_length);
}
} // namespace dart

View file

@ -15,7 +15,15 @@ class RawError;
class Bootstrap : public AllStatic {
public:
static RawError* DoBootstrapping();
// Compile the bootstrap libraries, either from sources or a Kernel binary.
// If kernel_buffer is NULL, compile from sources or source paths linked into
// the VM. If it is non-NULL it represents a buffer holding a Kernel binary.
// The caller of this function is responsible for managing the kernel
// buffer's memory, and is welcome to deallocate it after this function
// returns.
static RawError* DoBootstrapping(const uint8_t* kernel_buffer,
intptr_t kernel_buffer_length);
static void SetupNativeResolver();
static bool IsBootstapResolver(Dart_NativeEntryResolver resolver);

View file

@ -346,6 +346,7 @@ namespace dart {
V(UserTag_makeCurrent, 1) \
V(Profiler_getCurrentTag, 0) \
V(ClassID_getID, 1) \
V(ClassID_byName, 1) \
V(VMService_SendIsolateServiceMessage, 2) \
V(VMService_SendRootServiceMessage, 1) \
V(VMService_SendObjectRootServiceMessage, 1) \

View file

@ -6,15 +6,136 @@
#include "include/dart_api.h"
#if !defined(DART_PRECOMPILED_RUNTIME)
#include "vm/class_finalizer.h"
#include "vm/compiler.h"
#include "vm/kernel_reader.h"
#endif
#include "vm/object.h"
#if !defined(DART_PRECOMPILED_RUNTIME)
#include "vm/object_store.h"
#endif
namespace dart {
#if !defined(DART_PRECOMPILED_RUNTIME)
#define MAKE_PROPERTIES(CamelName, name) \
{ObjectStore::k##CamelName, "dart:" #name},
RawError* Bootstrap::DoBootstrapping() {
UNREACHABLE();
struct BootstrapLibProps {
ObjectStore::BootstrapLibraryId index;
const char* uri;
};
static BootstrapLibProps bootstrap_libraries[] = {
FOR_EACH_BOOTSTRAP_LIBRARY(MAKE_PROPERTIES)};
#undef MAKE_PROPERTIES
static const intptr_t bootstrap_library_count = ARRAY_SIZE(bootstrap_libraries);
void Finish(Thread* thread, bool from_kernel) {
Bootstrap::SetupNativeResolver();
ClassFinalizer::ProcessPendingClasses(from_kernel);
// Eagerly compile the _Closure class as it is the class of all closure
// instances. This allows us to just finalize function types without going
// through the hoops of trying to compile their scope class.
ObjectStore* object_store = thread->isolate()->object_store();
Class& cls = Class::Handle(thread->zone(), object_store->closure_class());
Compiler::CompileClass(cls);
// Eagerly compile Bool class, bool constants are used from within compiler.
cls = object_store->bool_class();
Compiler::CompileClass(cls);
}
RawError* BootstrapFromKernel(Thread* thread,
const uint8_t* buffer,
intptr_t buffer_length) {
Zone* zone = thread->zone();
kernel::Program* program =
ReadPrecompiledKernelFromBuffer(buffer, buffer_length);
if (program == NULL) {
const String& message =
String::Handle(zone, String::New("Failed to read Kernel file"));
return ApiError::New(message);
}
Isolate* isolate = thread->isolate();
// Mark the already-pending classes. This mark bit will be used to avoid
// adding classes to the list more than once.
GrowableObjectArray& pending_classes = GrowableObjectArray::Handle(
zone, isolate->object_store()->pending_classes());
dart::Class& pending = dart::Class::Handle(zone);
for (intptr_t i = 0; i < pending_classes.Length(); ++i) {
pending ^= pending_classes.At(i);
pending.set_is_marked_for_parsing();
}
Library& library = Library::Handle(zone);
String& dart_name = String::Handle(zone);
String& kernel_name = String::Handle(zone);
kernel::KernelReader reader(NULL, -1, true);
for (intptr_t i = 0; i < bootstrap_library_count; ++i) {
ObjectStore::BootstrapLibraryId id = bootstrap_libraries[i].index;
library = isolate->object_store()->bootstrap_library(id);
dart_name = library.url();
for (intptr_t j = 0; j < program->libraries().length(); ++j) {
kernel::Library* kernel_library = program->libraries()[j];
kernel::String* uri = kernel_library->import_uri();
kernel_name = Symbols::FromUTF8(thread, uri->buffer(), uri->size());
if (kernel_name.Equals(dart_name)) {
reader.ReadLibrary(kernel_library);
library.SetLoaded();
break;
}
}
}
Finish(thread, /*from_kernel=*/true);
return Error::null();
}
RawError* Bootstrap::DoBootstrapping(const uint8_t* kernel_buffer,
intptr_t kernel_buffer_length) {
Thread* thread = Thread::Current();
Isolate* isolate = thread->isolate();
Zone* zone = thread->zone();
String& uri = String::Handle(zone);
Library& lib = Library::Handle(zone);
HANDLESCOPE(thread);
// Ensure there are library objects for all the bootstrap libraries.
for (intptr_t i = 0; i < bootstrap_library_count; ++i) {
ObjectStore::BootstrapLibraryId id = bootstrap_libraries[i].index;
uri = Symbols::New(thread, bootstrap_libraries[i].uri);
lib = isolate->object_store()->bootstrap_library(id);
ASSERT(lib.raw() == Library::LookupLibrary(thread, uri));
if (lib.IsNull()) {
lib = Library::NewLibraryHelper(uri, false);
lib.SetLoadRequested();
lib.Register(thread);
isolate->object_store()->set_bootstrap_library(id, lib);
}
}
ASSERT(kernel_buffer != NULL);
return BootstrapFromKernel(thread, kernel_buffer, kernel_buffer_length);
}
#else
RawError* Bootstrap::DoBootstrapping(const uint8_t* kernel_buffer,
intptr_t kernel_buffer_length) {
UNREACHABLE();
return Error::null();
}
#endif // !defined(DART_PRECOMPILED_RUNTIME)
} // namespace dart

View file

@ -118,7 +118,7 @@ static void CollectImmediateSuperInterfaces(const Class& cls,
// Processing ObjectStore::pending_classes_ occurs:
// a) when bootstrap process completes (VerifyBootstrapClasses).
// b) after the user classes are loaded (dart_api).
bool ClassFinalizer::ProcessPendingClasses() {
bool ClassFinalizer::ProcessPendingClasses(bool from_kernel) {
Thread* thread = Thread::Current();
NOT_IN_PRODUCT(TimelineDurationScope tds(thread, Timeline::GetIsolateStream(),
"ProcessPendingClasses"));
@ -150,6 +150,12 @@ bool ClassFinalizer::ProcessPendingClasses() {
for (intptr_t i = 0; i < class_array.Length(); i++) {
cls ^= class_array.At(i);
FinalizeTypesInClass(cls);
// Classes compiled from Dart sources are finalized more lazily, classes
// compiled from Kernel binaries can be finalized now (and should be,
// since we will not revisit them).
if (from_kernel) {
FinalizeClass(cls);
}
}
if (FLAG_print_classes) {
for (intptr_t i = 0; i < class_array.Length(); i++) {
@ -188,7 +194,7 @@ void ClassFinalizer::CollectInterfaces(const Class& cls,
}
#if defined(DART_NO_SNAPSHOT)
#if !defined(DART_PRECOMPILED_RUNTIME)
void ClassFinalizer::VerifyBootstrapClasses() {
if (FLAG_trace_class_finalization) {
OS::Print("VerifyBootstrapClasses START.\n");
@ -254,7 +260,7 @@ void ClassFinalizer::VerifyBootstrapClasses() {
}
Isolate::Current()->heap()->Verify();
}
#endif // defined(DART_NO_SNAPSHOT).
#endif // !defined(DART_PRECOMPILED_RUNTIME)
static bool IsLoaded(const Type& type) {
@ -263,9 +269,15 @@ static bool IsLoaded(const Type& type) {
}
const UnresolvedClass& unresolved_class =
UnresolvedClass::Handle(type.unresolved_class());
const LibraryPrefix& prefix =
LibraryPrefix::Handle(unresolved_class.library_prefix());
return prefix.IsNull() || prefix.is_loaded();
const Object& prefix =
Object::Handle(unresolved_class.library_or_library_prefix());
if (prefix.IsNull()) {
return true;
} else if (prefix.IsLibraryPrefix()) {
return LibraryPrefix::Cast(prefix).is_loaded();
} else {
return true;
}
}
@ -276,15 +288,19 @@ RawClass* ClassFinalizer::ResolveClass(
const String& class_name = String::Handle(unresolved_class.ident());
Library& lib = Library::Handle();
Class& resolved_class = Class::Handle();
if (unresolved_class.library_prefix() == LibraryPrefix::null()) {
if (unresolved_class.library_or_library_prefix() == Object::null()) {
lib = cls.library();
ASSERT(!lib.IsNull());
resolved_class = lib.LookupClass(class_name);
} else {
LibraryPrefix& lib_prefix = LibraryPrefix::Handle();
lib_prefix = unresolved_class.library_prefix();
ASSERT(!lib_prefix.IsNull());
resolved_class = lib_prefix.LookupClass(class_name);
const Object& prefix =
Object::Handle(unresolved_class.library_or_library_prefix());
if (prefix.IsLibraryPrefix()) {
resolved_class = LibraryPrefix::Cast(prefix).LookupClass(class_name);
} else {
resolved_class = Library::Cast(prefix).LookupClass(class_name);
}
}
return resolved_class.raw();
}
@ -2189,12 +2205,25 @@ void ClassFinalizer::ApplyMixinMembers(const Class& cls) {
const GrowableObjectArray& cloned_funcs =
GrowableObjectArray::Handle(zone, GrowableObjectArray::New());
CreateForwardingConstructors(cls, mixin_cls, cloned_funcs);
Array& functions = Array::Handle(zone);
Function& func = Function::Handle(zone);
// The parser creates the mixin application class with no functions.
ASSERT((functions = cls.functions(), functions.Length() == 0));
// But the Kernel frontend will generate mixin classes with only
// constructors inside them, which forward to the base class constructors.
//
// => We generate the constructors if they are not already there.
functions = cls.functions();
if (functions.Length() == 0) {
CreateForwardingConstructors(cls, mixin_cls, cloned_funcs);
} else {
for (intptr_t i = 0; i < functions.Length(); i++) {
func ^= functions.At(i);
ASSERT(func.kernel_function() != 0);
cloned_funcs.Add(func);
}
}
// Now clone the functions from the mixin class.
functions = mixin_cls.functions();
const intptr_t num_functions = functions.Length();
@ -2384,8 +2413,20 @@ void ClassFinalizer::FinalizeTypesInClass(const Class& cls) {
// if the class is being refinalized because a patch is being applied
// after the class has been finalized then it is ok for the class to have
// functions.
ASSERT((Array::Handle(cls.functions()).Length() == 0) ||
cls.is_refinalize_after_patch());
//
// TODO(kmillikin): This ASSERT will fail when bootstrapping from Kernel
// because classes are first created, methods are added, and then classes
// are finalized. It is not easy to finalize classes earlier because not
// all bootstrap classes have been created yet. It would be possible to
// create all classes, delay adding methods, finalize the classes, and then
// reprocess all classes to add methods, but that seems unnecessary.
// Marking the bootstrap classes as is_refinalize_after_patch seems cute but
// it causes other things to fail by violating their assumptions. Reenable
// this ASSERT if it's important, remove it if it's just a sanity check and
// not required for correctness.
//
// ASSERT((Array::Handle(cls.functions()).Length() == 0) ||
// cls.is_refinalize_after_patch());
}
}

View file

@ -70,7 +70,7 @@ class ClassFinalizer : public AllStatic {
// failed. The function returns true if the processing was successful.
// If processing fails, an error message is set in the sticky error field
// in the object store.
static bool ProcessPendingClasses();
static bool ProcessPendingClasses(bool from_kernel = false);
// Finalize the types appearing in the declaration of class 'cls', i.e. its
// type parameters and their upper bounds, its super type and interfaces.
@ -81,11 +81,11 @@ class ClassFinalizer : public AllStatic {
// Finalize the class including its fields and functions.
static void FinalizeClass(const Class& cls);
#if defined(DART_NO_SNAPSHOT)
#if !defined(DART_PRECOMPILED_RUNTIME)
// Verify that the classes have been properly prefinalized. This is
// needed during bootstrapping where the classes have been preloaded.
static void VerifyBootstrapClasses();
#endif // defined(DART_NO_SNAPSHOT).
#endif // !defined(DART_PRECOMPILED_RUNTIME)
// Resolve the class of the type, but not the type's type arguments.
// May promote the type to function type by setting its signature field.

View file

@ -491,7 +491,10 @@ Isolate* Dart::CreateIsolate(const char* name_prefix,
}
RawError* Dart::InitializeIsolate(const uint8_t* snapshot_buffer, void* data) {
RawError* Dart::InitializeIsolate(const uint8_t* snapshot_buffer,
intptr_t snapshot_length,
bool from_kernel,
void* data) {
// Initialize the new isolate.
Thread* T = Thread::Current();
Isolate* I = T->isolate();
@ -508,11 +511,18 @@ RawError* Dart::InitializeIsolate(const uint8_t* snapshot_buffer, void* data) {
ObjectStore::Init(I);
}
const Error& error = Error::Handle(Object::Init(I));
Error& error = Error::Handle(T->zone());
if (from_kernel) {
ASSERT(snapshot_buffer != NULL);
ASSERT(snapshot_length > 0);
error = Object::Init(I, snapshot_buffer, snapshot_length);
} else {
error = Object::Init(I, NULL, -1);
}
if (!error.IsNull()) {
return error.raw();
}
if (snapshot_buffer != NULL) {
if ((snapshot_buffer != NULL) && !from_kernel) {
// Read the snapshot and setup the initial state.
NOT_IN_PRODUCT(TimelineDurationScope tds(T, Timeline::GetIsolateStream(),
"IsolateSnapshotReader"));
@ -553,7 +563,7 @@ RawError* Dart::InitializeIsolate(const uint8_t* snapshot_buffer, void* data) {
MegamorphicCacheTable::PrintSizes(I);
}
} else {
if (snapshot_kind_ != Snapshot::kNone) {
if ((snapshot_kind_ != Snapshot::kNone) && !from_kernel) {
const String& message =
String::Handle(String::New("Missing isolate snapshot"));
return ApiError::New(message);
@ -581,7 +591,7 @@ RawError* Dart::InitializeIsolate(const uint8_t* snapshot_buffer, void* data) {
Code::Handle(I->object_store()->megamorphic_miss_code());
I->set_ic_miss_code(miss_code);
if (snapshot_buffer == NULL) {
if ((snapshot_buffer == NULL) || from_kernel) {
const Error& error = Error::Handle(I->object_store()->PreallocateObjects());
if (!error.IsNull()) {
return error.raw();

View file

@ -37,7 +37,15 @@ class Dart : public AllStatic {
static Isolate* CreateIsolate(const char* name_prefix,
const Dart_IsolateFlags& api_flags);
static RawError* InitializeIsolate(const uint8_t* snapshot, void* data);
// Initialize an isolate, either from a snapshot, from a Kernel binary, or
// from SDK library sources. If the snapshot_buffer is non-NULL,
// initialize from a snapshot or a Kernel binary depending on the value of
// from_kernel. Otherwise, initialize from sources.
static RawError* InitializeIsolate(const uint8_t* snapshot_buffer,
intptr_t snapshot_length,
bool from_kernel,
void* data);
static void RunShutdownCallback();
static void ShutdownIsolate(Isolate* isolate);
static void ShutdownIsolate();

View file

@ -1236,12 +1236,15 @@ static char* BuildIsolateName(const char* script_uri, const char* main) {
}
DART_EXPORT Dart_Isolate Dart_CreateIsolate(const char* script_uri,
const char* main,
const uint8_t* snapshot,
Dart_IsolateFlags* flags,
void* callback_data,
char** error) {
static Dart_Isolate CreateIsolate(const char* script_uri,
const char* main,
const uint8_t* snapshot_buffer,
intptr_t snapshot_length,
bool from_kernel,
Dart_IsolateFlags* flags,
void* callback_data,
char** error) {
ASSERT(!from_kernel || (snapshot_buffer != NULL));
CHECK_NO_ISOLATE(Isolate::Current());
char* isolate_name = BuildIsolateName(script_uri, main);
@ -1265,11 +1268,12 @@ DART_EXPORT Dart_Isolate Dart_CreateIsolate(const char* script_uri,
// bootstrap library files which call out to a tag handler that may create
// Api Handles when an error is encountered.
Dart_EnterScope();
const Error& error_obj =
Error::Handle(Z, Dart::InitializeIsolate(snapshot, callback_data));
const Error& error_obj = Error::Handle(
Z, Dart::InitializeIsolate(snapshot_buffer, snapshot_length,
from_kernel, callback_data));
if (error_obj.IsNull()) {
#if defined(DART_NO_SNAPSHOT) && !defined(PRODUCT)
if (FLAG_check_function_fingerprints) {
if (FLAG_check_function_fingerprints && !from_kernel) {
Library::CheckFunctionFingerprints();
}
#endif // defined(DART_NO_SNAPSHOT) && !defined(PRODUCT).
@ -1292,6 +1296,30 @@ DART_EXPORT Dart_Isolate Dart_CreateIsolate(const char* script_uri,
}
DART_EXPORT Dart_Isolate Dart_CreateIsolate(const char* script_uri,
const char* main,
const uint8_t* snapshot_buffer,
Dart_IsolateFlags* flags,
void* callback_data,
char** error) {
return CreateIsolate(script_uri, main, snapshot_buffer, -1, false, flags,
callback_data, error);
}
DART_EXPORT Dart_Isolate
Dart_CreateIsolateFromKernel(const char* script_uri,
const char* main,
const uint8_t* kernel_file,
intptr_t kernel_length,
Dart_IsolateFlags* flags,
void* callback_data,
char** error) {
return CreateIsolate(script_uri, main, kernel_file, kernel_length, true,
flags, callback_data, error);
}
DART_EXPORT void Dart_ShutdownIsolate() {
Thread* T = Thread::Current();
Isolate* I = T->isolate();
@ -5327,7 +5355,7 @@ DART_EXPORT Dart_Handle Dart_LoadKernel(const uint8_t* buffer,
DARTSCOPE(Thread::Current());
StackZone zone(T);
#if defined(DART_PRECOMPILED_RUNTIME) && !defined(DART_PRECOMPILER)
#if defined(DART_PRECOMPILED_RUNTIME)
return Api::NewError("%s: Can't load Kernel files from precompiled runtime.",
CURRENT_FUNC);
#else

View file

@ -84,6 +84,7 @@ static void PrecompilationModeHandler(bool value) {
FATAL("Precompilation not supported on IA32");
#endif
#if !defined(DART_PRECOMPILED_RUNTIME)
// Flags affecting compilation only:
// There is no counter feedback in precompilation, so ignore the counter
// when making inlining decisions.
@ -97,6 +98,7 @@ static void PrecompilationModeHandler(bool value) {
FLAG_inlining_caller_size_threshold = 1000;
FLAG_inlining_constant_arguments_max_size_threshold = 100;
FLAG_inlining_constant_arguments_min_size_threshold = 30;
#endif
FLAG_background_compilation = false;
FLAG_fields_may_be_reset = true;

View file

@ -1,7 +1,7 @@
// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
#if !defined(DART_PRECOMPILED_RUNTIME)
#include "vm/flow_graph_inliner.h"
#include "vm/aot_optimizer.h"
@ -3598,3 +3598,4 @@ bool FlowGraphInliner::TryInlineRecognizedMethod(FlowGraph* flow_graph,
} // namespace dart
#endif // !defined(DART_PRECOMPILED_RUNTIME)

View file

@ -58,7 +58,7 @@ bool Intrinsifier::CanIntrinsify(const Function& function) {
}
#if defined(DART_NO_SNAPSHOT)
#if !defined(DART_PRECOMPILED_RUNTIME)
void Intrinsifier::InitializeState() {
Thread* thread = Thread::Current();
Zone* zone = thread->zone();
@ -117,7 +117,7 @@ void Intrinsifier::InitializeState() {
#undef SETUP_FUNCTION
}
#endif // defined(DART_NO_SNAPSHOT).
#endif // !defined(DART_PRECOMPILED_RUNTIME)
// DBC does not use graph intrinsics.

View file

@ -23,7 +23,7 @@ class Intrinsifier : public AllStatic {
public:
static bool Intrinsify(const ParsedFunction& parsed_function,
FlowGraphCompiler* compiler);
#if defined(DART_NO_SNAPSHOT)
#if !defined(DART_PRECOMPILED_RUNTIME)
static void InitializeState();
#endif

View file

@ -1551,7 +1551,12 @@ void Intrinsifier::Random_nextState(Assembler* assembler) {
random_class.LookupStaticFieldAllowPrivate(Symbols::_A()));
ASSERT(!random_A_field.IsNull());
ASSERT(random_A_field.is_const());
const Instance& a_value = Instance::Handle(random_A_field.StaticValue());
Instance& a_value = Instance::Handle(random_A_field.StaticValue());
if (a_value.raw() == Object::sentinel().raw() ||
a_value.raw() == Object::transition_sentinel().raw()) {
random_A_field.EvaluateInitializer();
a_value = random_A_field.StaticValue();
}
const int64_t a_int_value = Integer::Cast(a_value).AsInt64Value();
// 'a_int_value' is a mask.
ASSERT(Utils::IsUint(32, a_int_value));

View file

@ -1625,7 +1625,12 @@ void Intrinsifier::Random_nextState(Assembler* assembler) {
random_class.LookupStaticFieldAllowPrivate(Symbols::_A()));
ASSERT(!random_A_field.IsNull());
ASSERT(random_A_field.is_const());
const Instance& a_value = Instance::Handle(random_A_field.StaticValue());
Instance& a_value = Instance::Handle(random_A_field.StaticValue());
if (a_value.raw() == Object::sentinel().raw() ||
a_value.raw() == Object::transition_sentinel().raw()) {
random_A_field.EvaluateInitializer();
a_value = random_A_field.StaticValue();
}
const int64_t a_int_value = Integer::Cast(a_value).AsInt64Value();
// Receiver.

View file

@ -1666,7 +1666,12 @@ void Intrinsifier::Random_nextState(Assembler* assembler) {
random_class.LookupStaticFieldAllowPrivate(Symbols::_A()));
ASSERT(!random_A_field.IsNull());
ASSERT(random_A_field.is_const());
const Instance& a_value = Instance::Handle(random_A_field.StaticValue());
Instance& a_value = Instance::Handle(random_A_field.StaticValue());
if (a_value.raw() == Object::sentinel().raw() ||
a_value.raw() == Object::transition_sentinel().raw()) {
random_A_field.EvaluateInitializer();
a_value = random_A_field.StaticValue();
}
const int64_t a_int_value = Integer::Cast(a_value).AsInt64Value();
// 'a_int_value' is a mask.
ASSERT(Utils::IsUint(32, a_int_value));

View file

@ -1668,7 +1668,12 @@ void Intrinsifier::Random_nextState(Assembler* assembler) {
random_class.LookupStaticFieldAllowPrivate(Symbols::_A()));
ASSERT(!random_A_field.IsNull());
ASSERT(random_A_field.is_const());
const Instance& a_value = Instance::Handle(random_A_field.StaticValue());
Instance& a_value = Instance::Handle(random_A_field.StaticValue());
if (a_value.raw() == Object::sentinel().raw() ||
a_value.raw() == Object::transition_sentinel().raw()) {
random_A_field.EvaluateInitializer();
a_value = random_A_field.StaticValue();
}
const int64_t a_int_value = Integer::Cast(a_value).AsInt64Value();
// 'a_int_value' is a mask.
ASSERT(Utils::IsUint(32, a_int_value));

View file

@ -1533,7 +1533,12 @@ void Intrinsifier::Random_nextState(Assembler* assembler) {
random_class.LookupStaticFieldAllowPrivate(Symbols::_A()));
ASSERT(!random_A_field.IsNull());
ASSERT(random_A_field.is_const());
const Instance& a_value = Instance::Handle(random_A_field.StaticValue());
Instance& a_value = Instance::Handle(random_A_field.StaticValue());
if (a_value.raw() == Object::sentinel().raw() ||
a_value.raw() == Object::transition_sentinel().raw()) {
random_A_field.EvaluateInitializer();
a_value = random_A_field.StaticValue();
}
const int64_t a_int_value = Integer::Cast(a_value).AsInt64Value();
// Receiver.
__ movq(RAX, Address(RSP, +1 * kWordSize));

View file

@ -4,6 +4,7 @@
#include "vm/kernel.h"
#if !defined(DART_PRECOMPILED_RUNTIME)
namespace dart {
namespace kernel {
@ -1207,3 +1208,4 @@ void Program::VisitChildren(Visitor* visitor) {
} // namespace kernel
} // namespace dart
#endif // !defined(DART_PRECOMPILED_RUNTIME)

View file

@ -5,10 +5,12 @@
#ifndef RUNTIME_VM_KERNEL_H_
#define RUNTIME_VM_KERNEL_H_
#if !defined(DART_PRECOMPILED_RUNTIME)
#include "platform/assert.h"
#include "vm/allocation.h"
#include "vm/globals.h"
#define KERNEL_NODES_DO(M) \
M(Name) \
M(InferredValue) \
@ -3243,4 +3245,5 @@ void WritePrecompiledKernel(ByteWriter* out, kernel::Program* program);
} // namespace dart
#endif // !defined(DART_PRECOMPILED_RUNTIME)
#endif // RUNTIME_VM_KERNEL_H_

View file

@ -1,6 +1,7 @@
// Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
#if !defined(DART_PRECOMPILED_RUNTIME)
#include <map>
#include <vector>
@ -2901,3 +2902,4 @@ void WritePrecompiledKernel(ByteWriter* byte_writer, kernel::Program* program) {
} // namespace dart
#endif // !defined(DART_PRECOMPILED_RUNTIME)

View file

@ -12,6 +12,7 @@
#include "vm/parser.h"
#include "vm/symbols.h"
#if !defined(DART_PRECOMPILED_RUNTIME)
namespace dart {
namespace kernel {
@ -81,19 +82,18 @@ class SimpleExpressionConverter : public ExpressionVisitor {
dart::Instance* simple_value_;
};
void BuildingTranslationHelper::SetFinalize(bool finalize) {
reader_->finalize_ = finalize;
}
RawLibrary* BuildingTranslationHelper::LookupLibraryByKernelLibrary(
Library* library) {
return reader_->LookupLibrary(library).raw();
}
RawClass* BuildingTranslationHelper::LookupClassByKernelClass(Class* klass) {
return reader_->LookupClass(klass).raw();
}
Object& KernelReader::ReadProgram() {
ASSERT(!bootstrapping_);
Program* program = ReadPrecompiledKernelFromBuffer(buffer_, buffer_length_);
@ -113,29 +113,13 @@ Object& KernelReader::ReadProgram() {
ReadLibrary(kernel_library);
}
// We finalize classes after we've constructed all classes since we
// currently don't construct them in pre-order of the class hierarchy (and
// finalization of a class needs all of its superclasses to be finalized).
dart::String& name = dart::String::Handle(Z);
for (intptr_t i = 0; i < length; i++) {
Library* kernel_library = program->libraries()[i];
dart::Library& library = LookupLibrary(kernel_library);
name = library.url();
dart::Library& library = LookupLibrary(program->libraries()[i]);
if (!library.Loaded()) library.SetLoaded();
}
// TODO(27590) unskip this library when we fix underlying issue.
if (name.Equals("dart:vmservice_io")) {
continue;
}
if (!library.Loaded()) {
dart::Class& klass = dart::Class::Handle(Z);
for (intptr_t i = 0; i < kernel_library->classes().length(); i++) {
klass = LookupClass(kernel_library->classes()[i]).raw();
ClassFinalizer::FinalizeTypesInClass(klass);
ClassFinalizer::FinalizeClass(klass);
}
library.SetLoaded();
}
if (!ClassFinalizer::ProcessPendingClasses(/*from_kernel=*/true)) {
FATAL("Error in class finalization during bootstrapping.");
}
dart::Library& library = LookupLibrary(kernel_main_library);
@ -161,6 +145,7 @@ Object& KernelReader::ReadProgram() {
}
}
void KernelReader::ReadLibrary(Library* kernel_library) {
dart::Library& library = LookupLibrary(kernel_library);
if (library.Loaded()) return;
@ -217,13 +202,17 @@ void KernelReader::ReadLibrary(Library* kernel_library) {
ReadProcedure(library, toplevel_class, kernel_procedure);
}
const GrowableObjectArray& classes =
GrowableObjectArray::Handle(I->object_store()->pending_classes());
// Load all classes.
for (intptr_t i = 0; i < kernel_library->classes().length(); i++) {
Class* kernel_klass = kernel_library->classes()[i];
ReadClass(library, kernel_klass);
classes.Add(ReadClass(library, kernel_klass), Heap::kOld);
}
}
void KernelReader::ReadPreliminaryClass(dart::Class* klass,
Class* kernel_klass) {
ASSERT(kernel_klass->IsNormalClass());
@ -284,7 +273,6 @@ void KernelReader::ReadPreliminaryClass(dart::Class* klass,
intptr_t interface_count = kernel_klass->implemented_classes().length();
const dart::Array& interfaces =
dart::Array::Handle(Z, dart::Array::New(interface_count));
dart::Class& interface_class = dart::Class::Handle(Z);
for (intptr_t i = 0; i < interface_count; i++) {
InterfaceType* kernel_interface_type =
kernel_klass->implemented_classes()[i];
@ -292,33 +280,14 @@ void KernelReader::ReadPreliminaryClass(dart::Class* klass,
T.TranslateTypeWithoutFinalization(kernel_interface_type);
if (type.IsMalformed()) H.ReportError("Malformed interface type.");
interfaces.SetAt(i, type);
// NOTE: Normally the DartVM keeps a list of pending classes and iterates
// through them later on using `ClassFinalizer::ProcessPendingClasses()`.
// This involes calling `ClassFinalizer::ResolveSuperTypeAndInterfaces()`
// which does a lot of error validation (e.g. cycle checks) which we don't
// need here. But we do need to do one thing which this resolving phase
// normally does for us: set the `is_implemented` boolean.
// TODO(27590): Maybe we can do this differently once we have
// "bootstrapping from kernel"-support.
interface_class = type.type_class();
interface_class.set_is_implemented();
}
klass->set_interfaces(interfaces);
if (kernel_klass->is_abstract()) klass->set_is_abstract();
klass->set_is_cycle_free();
// When bootstrapping we should not finalize types yet because they will be
// finalized when the object store's pending_classes list is drained by
// ClassFinalizer::ProcessPendingClasses. Even when not bootstrapping we are
// careful not to eagerly finalize types that may introduce a circularity
// (such as type arguments, interface types, field types, etc.).
if (finalize_) ClassFinalizer::FinalizeTypesInClass(*klass);
}
void KernelReader::ReadClass(const dart::Library& library,
Class* kernel_klass) {
dart::Class& KernelReader::ReadClass(const dart::Library& library,
Class* kernel_klass) {
// This will trigger a call to [ReadPreliminaryClass] if not already done.
dart::Class& klass = LookupClass(kernel_klass);
@ -383,8 +352,11 @@ void KernelReader::ReadClass(const dart::Library& library,
GrowableObjectArray::Handle(Z, I->object_store()->pending_classes())
.Add(klass, Heap::kOld);
}
return klass;
}
void KernelReader::ReadProcedure(const dart::Library& library,
const dart::Class& owner,
Procedure* kernel_procedure,
@ -524,6 +496,7 @@ void KernelReader::GenerateFieldAccessors(const dart::Class& klass,
}
}
void KernelReader::SetupFunctionParameters(TranslationHelper translation_helper,
DartTypeTranslator type_translator,
const dart::Class& klass,
@ -594,6 +567,7 @@ void KernelReader::SetupFunctionParameters(TranslationHelper translation_helper,
: return_type);
}
void KernelReader::SetupFieldAccessorFunction(const dart::Class& klass,
const dart::Function& function) {
bool is_setter = function.IsImplicitSetterFunction();
@ -679,6 +653,7 @@ dart::Class& KernelReader::LookupClass(Class* klass) {
return *handle;
}
RawFunction::Kind KernelReader::GetFunctionType(Procedure* kernel_procedure) {
intptr_t lookuptable[] = {
RawFunction::kRegularFunction, // Procedure::kMethod
@ -696,5 +671,7 @@ RawFunction::Kind KernelReader::GetFunctionType(Procedure* kernel_procedure) {
}
}
} // namespace kernel
} // namespace dart
#endif // !defined(DART_PRECOMPILED_RUNTIME)

View file

@ -5,6 +5,7 @@
#ifndef RUNTIME_VM_KERNEL_READER_H_
#define RUNTIME_VM_KERNEL_READER_H_
#if !defined(DART_PRECOMPILED_RUNTIME)
#include <map>
#include "vm/kernel.h"
@ -25,8 +26,6 @@ class BuildingTranslationHelper : public TranslationHelper {
: TranslationHelper(thread, zone, isolate), reader_(reader) {}
virtual ~BuildingTranslationHelper() {}
virtual void SetFinalize(bool finalize);
virtual RawLibrary* LookupLibraryByKernelLibrary(Library* library);
virtual RawClass* LookupClassByKernelClass(Class* klass);
@ -60,9 +59,10 @@ class KernelReader {
zone_(thread_->zone()),
isolate_(thread_->isolate()),
translation_helper_(this, thread_, zone_, isolate_),
type_translator_(&translation_helper_, &active_class_, !bootstrapping),
type_translator_(&translation_helper_,
&active_class_,
/*finalize=*/false),
bootstrapping_(bootstrapping),
finalize_(!bootstrapping),
buffer_(buffer),
buffer_length_(len) {}
@ -83,7 +83,7 @@ class KernelReader {
friend class BuildingTranslationHelper;
void ReadPreliminaryClass(dart::Class* klass, Class* kernel_klass);
void ReadClass(const dart::Library& library, Class* kernel_klass);
dart::Class& ReadClass(const dart::Library& library, Class* kernel_klass);
void ReadProcedure(const dart::Library& library,
const dart::Class& owner,
Procedure* procedure,
@ -110,9 +110,6 @@ class KernelReader {
bool bootstrapping_;
// Should created classes be finalized when they are created?
bool finalize_;
const uint8_t* buffer_;
intptr_t buffer_length_;
@ -123,4 +120,5 @@ class KernelReader {
} // namespace kernel
} // namespace dart
#endif // !defined(DART_PRECOMPILED_RUNTIME)
#endif // RUNTIME_VM_KERNEL_READER_H_

View file

@ -18,6 +18,7 @@
#include "vm/resolver.h"
#include "vm/stack_frame.h"
#if !defined(DART_PRECOMPILED_RUNTIME)
namespace dart {
DECLARE_FLAG(bool, support_externalizable_strings);
@ -645,6 +646,16 @@ void ScopeBuilder::VisitFunctionNode(FunctionNode* node) {
for (intptr_t i = 0; i < type_parameters.length(); ++i) {
VisitTypeParameter(type_parameters[i]);
}
if (node->async_marker() == FunctionNode::kSyncYielding) {
LocalScope* scope = parsed_function_->node_sequence()->scope();
for (intptr_t i = 0;
i < parsed_function_->function().NumOptionalPositionalParameters();
i++) {
scope->VariableAt(i)->set_is_forced_stack();
}
}
// Do not visit the positional and named parameters, because they've
// already been added to the scope.
if (node->body() != NULL) {
@ -1109,6 +1120,21 @@ dart::RawClass* TranslationHelper::LookupClassByKernelClass(
}
dart::RawUnresolvedClass* TranslationHelper::ToUnresolvedClass(
Class* kernel_klass) {
dart::RawClass* klass = NULL;
const dart::String& class_name = DartClassName(kernel_klass);
Library* kernel_library = Library::Cast(kernel_klass->parent());
dart::Library& library =
dart::Library::Handle(Z, LookupLibraryByKernelLibrary(kernel_library));
ASSERT(klass != Object::null());
return dart::UnresolvedClass::New(library, class_name,
TokenPosition::kNoSource);
}
dart::RawField* TranslationHelper::LookupFieldByKernelField(
Field* kernel_field) {
TreeNode* node = kernel_field->parent();
@ -1843,7 +1869,9 @@ FlowGraphBuilder::FlowGraphBuilder(
try_catch_block_(NULL),
next_used_try_index_(0),
catch_block_(NULL),
type_translator_(&translation_helper_, &active_class_),
type_translator_(&translation_helper_,
&active_class_,
/* finalize= */ true),
constant_evaluator_(this,
zone_,
&translation_helper_,
@ -3861,10 +3889,8 @@ AbstractType& DartTypeTranslator::TranslateTypeWithoutFinalization(
DartType* node) {
bool saved_finalize = finalize_;
finalize_ = false;
H.SetFinalize(false);
AbstractType& result = TranslateType(node);
finalize_ = saved_finalize;
H.SetFinalize(saved_finalize);
return result;
}
@ -4020,13 +4046,13 @@ void DartTypeTranslator::VisitInterfaceType(InterfaceType* node) {
const TypeArguments& type_arguments = TranslateTypeArguments(
node->type_arguments().raw_array(), node->type_arguments().length());
const dart::Class& klass =
dart::Class::Handle(Z, H.LookupClassByKernelClass(node->klass()));
dart::Object& klass =
dart::Object::Handle(Z, H.ToUnresolvedClass(node->klass()));
result_ = Type::New(klass, type_arguments, TokenPosition::kNoSource);
result_.SetIsResolved();
if (finalize_) {
result_ = ClassFinalizer::FinalizeType(klass, result_,
ASSERT(active_class_->klass != NULL);
result_ = ClassFinalizer::FinalizeType(*active_class_->klass, result_,
ClassFinalizer::kCanonicalize);
}
}
@ -5653,9 +5679,6 @@ void FlowGraphBuilder::VisitYieldStatement(YieldStatement* node) {
ASSERT(stack_trace_var->name().raw() ==
Symbols::StackTraceParameter().raw());
exception_var->set_is_forced_stack();
stack_trace_var->set_is_forced_stack();
TargetEntryInstr* no_error;
TargetEntryInstr* error;
@ -5745,3 +5768,4 @@ Fragment FlowGraphBuilder::TranslateFunctionNode(FunctionNode* node,
} // namespace kernel
} // namespace dart
#endif // !defined(DART_PRECOMPILED_RUNTIME)

View file

@ -5,6 +5,8 @@
#ifndef RUNTIME_VM_KERNEL_TO_IL_H_
#define RUNTIME_VM_KERNEL_TO_IL_H_
#if !defined(DART_PRECOMPILED_RUNTIME)
#include "vm/growable_array.h"
#include "vm/hash_map.h"
@ -202,11 +204,6 @@ class TranslationHelper {
Heap::Space allocation_space() { return allocation_space_; }
// Set whether unfinalized classes should be finalized. The base class
// implementation used at flow graph construction time looks up classes in the
// VM's heap, all of which should already be finalized.
virtual void SetFinalize(bool finalize) {}
RawInstance* Canonicalize(const Instance& instance);
const dart::String& DartString(const char* content) {
@ -241,6 +238,8 @@ class TranslationHelper {
virtual RawLibrary* LookupLibraryByKernelLibrary(Library* library);
virtual RawClass* LookupClassByKernelClass(Class* klass);
RawUnresolvedClass* ToUnresolvedClass(Class* klass);
RawField* LookupFieldByKernelField(Field* field);
RawFunction* LookupStaticMethodByKernelProcedure(Procedure* procedure);
RawFunction* LookupConstructorByKernelConstructor(Constructor* constructor);
@ -282,7 +281,7 @@ class DartTypeTranslator : public DartTypeVisitor {
public:
DartTypeTranslator(TranslationHelper* helper,
ActiveClass* active_class,
bool finalize = true)
bool finalize = false)
: translation_helper_(*helper),
active_class_(active_class),
zone_(helper->zone()),
@ -501,7 +500,9 @@ class ScopeBuilder : public RecursiveVisitor {
node_(node),
zone_(Thread::Current()->zone()),
translation_helper_(Thread::Current(), zone_, Isolate::Current()),
type_translator_(&translation_helper_, &active_class_),
type_translator_(&translation_helper_,
&active_class_,
/*finalize=*/true),
current_function_scope_(NULL),
scope_(NULL),
depth_(0),
@ -919,5 +920,5 @@ class FlowGraphBuilder : public TreeVisitor {
} // namespace kernel
} // namespace dart
#endif // !defined(DART_PRECOMPILED_RUNTIME)
#endif // RUNTIME_VM_KERNEL_TO_IL_H_

View file

@ -132,7 +132,7 @@ const char* MethodRecognizer::KindToCString(Kind kind) {
}
#if defined(DART_NO_SNAPSHOT)
#if !defined(DART_PRECOMPILED_RUNTIME)
void MethodRecognizer::InitializeState() {
GrowableArray<Library*> libs(3);
libs.Add(&Library::ZoneHandle(Library::CoreLibrary()));
@ -182,6 +182,7 @@ void MethodRecognizer::InitializeState() {
#undef SET_IS_POLYMORPHIC_TARGET
#undef SET_FUNCTION_BIT
}
#endif // defined(DART_NO_SNAPSHOT).
#endif // !defined(DART_PRECOMPILED_RUNTIME)
} // namespace dart

View file

@ -518,19 +518,20 @@ class MethodRecognizer : public AllStatic {
static intptr_t ResultCid(const Function& function);
static intptr_t MethodKindToReceiverCid(Kind kind);
static const char* KindToCString(Kind kind);
#if defined(DART_NO_SNAPSHOT)
#if !defined(DART_PRECOMPILED_RUNTIME)
static void InitializeState();
#endif // defined(DART_NO_SNAPSHOT).
#endif // !defined(DART_PRECOMPILED_RUNTIME)
};
#if defined(DART_NO_SNAPSHOT)
#if !defined(DART_PRECOMPILED_RUNTIME)
#define CHECK_FINGERPRINT2(f, p0, p1, fp) \
ASSERT(f.CheckSourceFingerprint(#p0 ", " #p1, fp))
#define CHECK_FINGERPRINT3(f, p0, p1, p2, fp) \
ASSERT(f.CheckSourceFingerprint(#p0 ", " #p1 ", " #p2, fp))
#endif // defined(DART_NO_SNAPSHOT).
#endif // !defined(DART_PRECOMPILED_RUNTIME)
// clang-format off

File diff suppressed because it is too large Load diff

View file

@ -525,8 +525,11 @@ class Object {
static void InitOnce(Isolate* isolate);
static void FinalizeVMIsolate(Isolate* isolate);
// Initialize a new isolate either from source or from a snapshot.
static RawError* Init(Isolate* isolate);
// Initialize a new isolate either from a Kernel IR, from source, or from a
// snapshot.
static RawError* Init(Isolate* isolate,
const uint8_t* kernel,
intptr_t kernel_length);
static void MakeUnusedSpaceTraversable(const Object& obj,
intptr_t original_size,
@ -1509,8 +1512,8 @@ class Class : public Object {
// to a class after all classes have been loaded and finalized.
class UnresolvedClass : public Object {
public:
RawLibraryPrefix* library_prefix() const {
return raw_ptr()->library_prefix_;
RawObject* library_or_library_prefix() const {
return raw_ptr()->library_or_library_prefix_;
}
RawString* ident() const { return raw_ptr()->ident_; }
TokenPosition token_pos() const { return raw_ptr()->token_pos_; }
@ -1521,12 +1524,12 @@ class UnresolvedClass : public Object {
return RoundedAllocationSize(sizeof(RawUnresolvedClass));
}
static RawUnresolvedClass* New(const LibraryPrefix& library_prefix,
static RawUnresolvedClass* New(const Object& library_prefix,
const String& ident,
TokenPosition token_pos);
private:
void set_library_prefix(const LibraryPrefix& library_prefix) const;
void set_library_or_library_prefix(const Object& library_prefix) const;
void set_ident(const String& ident) const;
void set_token_pos(TokenPosition token_pos) const;
@ -3780,7 +3783,7 @@ class Library : public Object {
static RawLibrary* GetLibrary(intptr_t index);
static void InitCoreLibrary(Isolate* isolate);
static void InitNativeWrappersLibrary(Isolate* isolate);
static void InitNativeWrappersLibrary(Isolate* isolate, bool is_kernel_file);
static RawLibrary* AsyncLibrary();
static RawLibrary* ConvertLibrary();

View file

@ -11881,7 +11881,7 @@ void Parser::ResolveType(ClassFinalizer::FinalizationKind finalization,
const String& unresolved_class_name =
String::Handle(Z, unresolved_class.ident());
Class& resolved_type_class = Class::Handle(Z);
if (unresolved_class.library_prefix() == LibraryPrefix::null()) {
if (unresolved_class.library_or_library_prefix() == Object::null()) {
// First check if the type is a function type parameter.
if (!innermost_function().IsNull()) {
// TODO(regis): Shortcut this lookup if no generic functions in scope.
@ -11931,9 +11931,11 @@ void Parser::ResolveType(ClassFinalizer::FinalizationKind finalization,
}
} else {
// Resolve class name in the scope of the library prefix.
const LibraryPrefix& lib_prefix =
LibraryPrefix::Handle(Z, unresolved_class.library_prefix());
resolved_type_class = lib_prefix.LookupClass(unresolved_class_name);
const Object& prefix =
Object::Handle(Z, unresolved_class.library_or_library_prefix());
ASSERT(prefix.IsLibraryPrefix());
resolved_type_class =
LibraryPrefix::Cast(prefix).LookupClass(unresolved_class_name);
}
// At this point, we can only have a parameterized_type.
const Type& parameterized_type = Type::Cast(*type);
@ -13478,8 +13480,8 @@ AstNode* Parser::ParseNewOperator(Token::Kind op_kind) {
// into throwing a type error.
const UnresolvedClass& cls =
UnresolvedClass::Handle(Z, redirect_type.unresolved_class());
const LibraryPrefix& prefix =
LibraryPrefix::Handle(Z, cls.library_prefix());
const LibraryPrefix& prefix = LibraryPrefix::Cast(
Object::Handle(Z, cls.library_or_library_prefix()));
if (!prefix.IsNull() && !prefix.is_loaded() &&
!FLAG_load_deferred_eagerly) {
// If the redirection type is unresolved because it refers to

View file

@ -706,10 +706,11 @@ class RawUnresolvedClass : public RawObject {
RAW_HEAP_OBJECT_IMPLEMENTATION(UnresolvedClass);
RawObject** from() {
return reinterpret_cast<RawObject**>(&ptr()->library_prefix_);
return reinterpret_cast<RawObject**>(&ptr()->library_or_library_prefix_);
}
RawLibraryPrefix* library_prefix_; // Library prefix qualifier for the ident.
RawString* ident_; // Name of the unresolved identifier.
RawObject* library_or_library_prefix_; // Library or library prefix qualifier
// for the ident.
RawString* ident_; // Name of the unresolved identifier.
RawObject** to() { return reinterpret_cast<RawObject**>(&ptr()->ident_); }
TokenPosition token_pos_;
};

View file

@ -11,6 +11,8 @@ class _Platform {
external static _localHostname();
external static _executable();
external static _resolvedExecutable();
external static void set _nativeScript(String path);
/**
* Retrieve the entries of the process environment.
*

View file

@ -32,17 +32,13 @@ Language/Classes/Setters/name_t12: CompileTimeError
Language/Classes/Setters/name_t13: CompileTimeError
Language/Classes/Setters/name_t14: CompileTimeError
Language/Classes/Setters/name_t15: CompileTimeError
Language/Classes/definition_t23: CompileTimeError
Language/Classes/definition_t23: Crash
Language/Enums/declaration_equivalent_t01: RuntimeError
Language/Enums/syntax_t08: MissingCompileTimeError
Language/Enums/syntax_t09: MissingCompileTimeError
Language/Expressions/Assignment/indexed_expression_super_t01: RuntimeError
Language/Expressions/Assignment/indexed_expression_super_t02: RuntimeError
Language/Expressions/Assignment/indexed_expression_super_t04: RuntimeError
Language/Expressions/Assignment/super_assignment_failed_t01: RuntimeError
Language/Expressions/Assignment/super_assignment_failed_t02: RuntimeError
Language/Expressions/Assignment/super_assignment_t06: RuntimeError
Language/Expressions/Assignment/super_assignment_value_t02: RuntimeError
Language/Expressions/Await_Expressions/syntax_t01: RuntimeError
Language/Expressions/Await_Expressions/syntax_t02: RuntimeError
Language/Expressions/Await_Expressions/syntax_t10: RuntimeError
Language/Expressions/Constants/exception_t01: MissingCompileTimeError
Language/Expressions/Constants/exception_t02: MissingCompileTimeError
Language/Expressions/Constants/string_length_t01: Crash
@ -53,6 +49,15 @@ Language/Expressions/Function_Invocation/Unqualified_Invocation/function_expr_in
Language/Expressions/Function_Invocation/Unqualified_Invocation/instance_context_invocation_t03: MissingCompileTimeError
Language/Expressions/Function_Invocation/Unqualified_Invocation/instance_context_invocation_t04: MissingCompileTimeError
Language/Expressions/Function_Invocation/Unqualified_Invocation/static_method_invocation_t02: RuntimeError
Language/Expressions/Function_Invocation/async_cleanup_t01: RuntimeError
Language/Expressions/Function_Invocation/async_cleanup_t02: RuntimeError
Language/Expressions/Function_Invocation/async_cleanup_t04: Crash
Language/Expressions/Function_Invocation/async_cleanup_t07: Fail
Language/Expressions/Function_Invocation/async_cleanup_t08: Fail
Language/Expressions/Function_Invocation/async_generator_invokation_t05: RuntimeError
Language/Expressions/Function_Invocation/async_generator_invokation_t06: RuntimeError
Language/Expressions/Function_Invocation/async_generator_invokation_t09: RuntimeError
Language/Expressions/Function_Invocation/async_invokation_t05: RuntimeError
Language/Expressions/Identifier_Reference/built_in_identifier_t35: Pass
Language/Expressions/Identifier_Reference/built_in_identifier_t36: Pass
Language/Expressions/Identifier_Reference/built_in_identifier_t37: Pass
@ -84,11 +89,6 @@ Language/Expressions/Method_Invocation/Ordinary_Invocation/evaluation_t07: Runti
Language/Expressions/Method_Invocation/Ordinary_Invocation/method_lookup_failed_t18: RuntimeError
Language/Expressions/Method_Invocation/Ordinary_Invocation/syntax_t05: MissingCompileTimeError
Language/Expressions/Method_Invocation/Ordinary_Invocation/syntax_t10: MissingCompileTimeError
Language/Expressions/Method_Invocation/Super_Invocation/evaluation_t05: Crash
Language/Expressions/Method_Invocation/Super_Invocation/getter_lookup_failed_t01: RuntimeError
Language/Expressions/Method_Invocation/Super_Invocation/getter_lookup_failed_t02: RuntimeError
Language/Expressions/Method_Invocation/Super_Invocation/getter_lookup_failed_t03: RuntimeError
Language/Expressions/Method_Invocation/Super_Invocation/getter_lookup_failed_t04: RuntimeError
Language/Expressions/Method_Invocation/Super_Invocation/syntax_t05: MissingCompileTimeError
Language/Expressions/Object_Identity/string_t01: RuntimeError
Language/Expressions/Property_Extraction/Anonymous_Constructor_Closurization/identical_t01: CompileTimeError
@ -225,9 +225,6 @@ Language/Expressions/Property_Extraction/Ordinary_Member_Closurization/setter_cl
Language/Expressions/Property_Extraction/Ordinary_Member_Closurization/setter_closurization_t06: CompileTimeError
Language/Expressions/Property_Extraction/Ordinary_Member_Closurization/setter_closurization_t07: CompileTimeError
Language/Expressions/Property_Extraction/Ordinary_Member_Closurization/setter_closurization_t08: CompileTimeError
Language/Expressions/Property_Extraction/Super_Getter_Access_and_Method_Closurization/no_such_method_t01: RuntimeError
Language/Expressions/Property_Extraction/Super_Getter_Access_and_Method_Closurization/no_such_method_t02: RuntimeError
Language/Expressions/Spawning_an_Isolate/new_isolate_t01: Crash
Language/Expressions/Strings/adjacent_strings_t02: RuntimeError
Language/Expressions/Type_Test/evaluation_t10: RuntimeError
Language/Functions/External_Functions/not_connected_to_a_body_t01: RuntimeError
@ -242,15 +239,14 @@ Language/Libraries_and_Scripts/Exports/syntax_t04: MissingCompileTimeError
Language/Libraries_and_Scripts/Exports/syntax_t05: MissingCompileTimeError
Language/Libraries_and_Scripts/Exports/syntax_t06: MissingCompileTimeError
Language/Libraries_and_Scripts/Imports/deferred_import_t01: RuntimeError
Language/Libraries_and_Scripts/Imports/deferred_import_t02: RuntimeError
Language/Libraries_and_Scripts/Imports/deferred_import_t02: CompileTimeError
Language/Libraries_and_Scripts/Imports/invalid_uri_deferred_t01/01: MissingRuntimeError
Language/Libraries_and_Scripts/Imports/invalid_uri_deferred_t02: CompileTimeError
Language/Libraries_and_Scripts/Imports/invalid_uri_t02: Pass
Language/Libraries_and_Scripts/Imports/static_type_t01: RuntimeError
Language/Libraries_and_Scripts/Parts/compilation_t02: Crash
Language/Libraries_and_Scripts/Parts/syntax_t06: Pass
Language/Libraries_and_Scripts/Scripts/top_level_main_t01: Crash
Language/Libraries_and_Scripts/Scripts/top_level_main_t02: Crash
Language/Libraries_and_Scripts/Scripts/top_level_main_t05: Crash
Language/Libraries_and_Scripts/definition_syntax_t01: MissingCompileTimeError
Language/Libraries_and_Scripts/definition_syntax_t03: MissingCompileTimeError
Language/Libraries_and_Scripts/definition_syntax_t04: MissingCompileTimeError
@ -300,26 +296,38 @@ Language/Statements/Labels/syntax_t03: Pass
Language/Statements/Rethrow/execution_t04: RuntimeError
Language/Statements/Switch/syntax_t02: Pass
Language/Statements/Try/catch_scope_t01: RuntimeError
Language/Statements/Yield_and_Yield_Each/Yield/execution_async_t04: Fail
Language/Statements/Yield_and_Yield_Each/Yield/execution_async_t05: Fail
Language/Statements/Yield_and_Yield_Each/Yield/execution_async_t06: Fail
Language/Statements/Yield_and_Yield_Each/Yield_Each/execution_async_t01: RuntimeError
Language/Types/Interface_Types/subtype_t44: RuntimeError
Language/Types/Static_Types/deferred_type_t01: RuntimeError
Language/Variables/final_or_static_initialization_t01: MissingCompileTimeError
Language/Variables/final_or_static_initialization_t02: MissingCompileTimeError
Language/Variables/final_or_static_initialization_t03: MissingCompileTimeError
Language/Variables/final_t01/01: MissingRuntimeError
Language/Variables/final_t02/01: MissingRuntimeError
Language/Variables/final_t04: MissingCompileTimeError
Language/Variables/final_t05: MissingCompileTimeError
Language/Variables/final_t06: MissingCompileTimeError
Language/Variables/final_t07: MissingCompileTimeError
LibTest/core/Invocation/isAccessor_A01_t01: RuntimeError
LibTest/core/Invocation/isAccessor_A01_t02: RuntimeError
LibTest/core/Invocation/isGetter_A01_t01: RuntimeError
LibTest/core/Invocation/isGetter_A01_t02: RuntimeError
LibTest/core/Invocation/isMethod_A01_t01: RuntimeError
LibTest/core/Invocation/isMethod_A01_t02: RuntimeError
LibTest/core/Invocation/isSetter_A01_t01: RuntimeError
LibTest/core/Invocation/isSetter_A01_t02: RuntimeError
LibTest/core/Invocation/memberName_A01_t01: RuntimeError
LibTest/core/Invocation/namedArguments_A01_t01: RuntimeError
LibTest/core/Invocation/positionalArguments_A01_t01: RuntimeError
# These tests should throw RuntimeError but they Pass instead.
Language/Libraries_and_Scripts/Imports/static_type_t01/04: Pass
Language/Libraries_and_Scripts/Imports/static_type_t01/06: Pass
Language/Libraries_and_Scripts/Imports/static_type_t01/01: Pass
Language/Libraries_and_Scripts/Imports/static_type_t01/05: Pass
Language/Libraries_and_Scripts/Imports/static_type_t01/03: Pass
Language/Libraries_and_Scripts/Imports/static_type_t01/07: Pass
Language/Libraries_and_Scripts/Imports/static_type_t01/02: Pass
Language/Libraries_and_Scripts/Imports/static_type_t01/04: Pass
Language/Libraries_and_Scripts/Imports/static_type_t01/06: Pass
Language/Libraries_and_Scripts/Imports/static_type_t01/01: Pass
Language/Libraries_and_Scripts/Imports/static_type_t01/05: Pass
Language/Libraries_and_Scripts/Imports/static_type_t01/03: Pass
Language/Libraries_and_Scripts/Imports/static_type_t01/07: Pass
Language/Libraries_and_Scripts/Imports/static_type_t01/02: Pass
# dartk: precompilation failures
[ $compiler == dartkp && $runtime == dart_precompiled ]
@ -623,4 +631,4 @@ LibTest/core/Invocation/isSetter_A01_t01: RuntimeError
LibTest/core/Invocation/isSetter_A01_t02: Crash
LibTest/core/Invocation/memberName_A01_t01: RuntimeError
LibTest/core/Invocation/namedArguments_A01_t01: Crash
LibTest/core/Invocation/positionalArguments_A01_t01: Crash
LibTest/core/Invocation/positionalArguments_A01_t01: Crash

View file

@ -17,14 +17,16 @@ accessor_conflict_import_prefixed2_test: RuntimeError
accessor_conflict_import_prefixed_test: RuntimeError
accessor_conflict_import_test: RuntimeError
assertion_test: RuntimeError
async_await_test: Crash
async_break_in_finally_test: RuntimeError
async_control_structures_test: RuntimeError
async_star_cancel_and_throw_in_finally_test: RuntimeError
async_star_cancel_while_paused_test: RuntimeError
async_star_regression_fisk_test: Crash
async_star_pause_test: RuntimeError
async_star_regression_fisk_test: RuntimeError
async_star_stream_take_test: Timeout
async_star_take_reyield_test: Timeout
async_star_test: Crash
async_star_test: Timeout
async_throw_in_catch_test/forceAwait: RuntimeError
async_throw_in_catch_test/none: RuntimeError
asyncstar_throw_in_catch_test: Timeout
@ -46,6 +48,8 @@ compile_time_constant_k_test/02: RuntimeError
compile_time_constant_k_test/03: RuntimeError
compile_time_constant_o_test/01: RuntimeError
compile_time_constant_o_test/02: RuntimeError
conditional_import_string_test: CompileTimeError
conditional_import_test: CompileTimeError
config_import_test: RuntimeError
conflicting_type_variable_and_setter_test: CompileTimeError
const_dynamic_type_literal_test/02: RuntimeError
@ -64,12 +68,13 @@ constructor_duplicate_final_test/01: MissingRuntimeError
constructor_duplicate_final_test/02: MissingRuntimeError
constructor_duplicate_final_test/03: MissingCompileTimeError
constructor_named_arguments_test/01: Crash
cyclic_type2_test: CompileTimeError
custom_await_stack_trace_test: RuntimeError
cyclic_type2_test: Crash
cyclic_type_test/00: RuntimeError
cyclic_type_test/01: RuntimeError
cyclic_type_test/02: CompileTimeError
cyclic_type_test/02: Crash
cyclic_type_test/03: RuntimeError
cyclic_type_test/04: CompileTimeError
cyclic_type_test/04: Crash
cyclic_type_variable_test/01: Crash
cyclic_type_variable_test/02: Crash
cyclic_type_variable_test/03: Crash
@ -149,7 +154,6 @@ external_test/25: MissingCompileTimeError
f_bounded_equality_test: RuntimeError
field_initialization_order_test: RuntimeError
final_field_initialization_order_test: RuntimeError
final_super_field_set_test/01: RuntimeError
final_syntax_test/01: MissingCompileTimeError
final_syntax_test/02: MissingCompileTimeError
final_syntax_test/03: MissingCompileTimeError
@ -165,7 +169,6 @@ fixed_type_variable_test/05: RuntimeError
fixed_type_variable_test/06: RuntimeError
for2_test: RuntimeError
for_variable_capture_test: RuntimeError
forwarding_factory_constructor_default_values_test: RuntimeError
function_subtype2_test: RuntimeError
function_subtype_bound_closure3_test: RuntimeError
function_subtype_bound_closure4_test: RuntimeError
@ -187,6 +190,7 @@ generic_functions_test: CompileTimeError
generic_inheritance_test: RuntimeError
generic_local_functions_test: CompileTimeError
generic_methods_function_type_test: CompileTimeError
generic_methods_generic_function_parameter_test: CompileTimeError
generic_methods_new_test: CompileTimeError
generic_methods_test: CompileTimeError
generic_methods_type_expression_test: CompileTimeError
@ -198,26 +202,25 @@ inferrer_closure_test: RuntimeError
initializing_formal_access_test: CompileTimeError
initializing_formal_capture_test: CompileTimeError
initializing_formal_final_test: CompileTimeError
initializing_formal_promotion_test: CompileTimeError
initializing_formal_type_test: CompileTimeError
instance_creation_in_function_annotation_test: RuntimeError
invocation_mirror_test: RuntimeError
is_not_class2_test: RuntimeError
issue13474_test: RuntimeError
issue23244_test: Crash
issue_1751477_test: RuntimeError
least_upper_bound_expansive_test/01: CompileTimeError
least_upper_bound_expansive_test/02: CompileTimeError
least_upper_bound_expansive_test/03: CompileTimeError
least_upper_bound_expansive_test/04: CompileTimeError
least_upper_bound_expansive_test/05: CompileTimeError
least_upper_bound_expansive_test/06: CompileTimeError
least_upper_bound_expansive_test/07: CompileTimeError
least_upper_bound_expansive_test/08: CompileTimeError
least_upper_bound_expansive_test/09: CompileTimeError
least_upper_bound_expansive_test/10: CompileTimeError
least_upper_bound_expansive_test/11: CompileTimeError
least_upper_bound_expansive_test/12: CompileTimeError
least_upper_bound_expansive_test/none: CompileTimeError
least_upper_bound_expansive_test/01: Crash
least_upper_bound_expansive_test/02: Crash
least_upper_bound_expansive_test/03: Crash
least_upper_bound_expansive_test/04: Crash
least_upper_bound_expansive_test/05: Crash
least_upper_bound_expansive_test/06: Crash
least_upper_bound_expansive_test/07: Crash
least_upper_bound_expansive_test/08: Crash
least_upper_bound_expansive_test/09: Crash
least_upper_bound_expansive_test/10: Crash
least_upper_bound_expansive_test/11: Crash
least_upper_bound_expansive_test/12: Crash
least_upper_bound_expansive_test/none: Crash
library_env_test/has_html_support: RuntimeError
library_env_test/has_no_io_support: RuntimeError
library_env_test/has_no_mirror_support: RuntimeError
@ -295,23 +298,22 @@ named_parameters_type_test/02: MissingRuntimeError
named_parameters_type_test/03: MissingRuntimeError
no_main_test/01: Crash
not_enough_positional_arguments_test/01: CompileTimeError
not_enough_positional_arguments_test/02: Crash
not_enough_positional_arguments_test/05: Crash
not_enough_positional_arguments_test/02: MissingRuntimeError
not_enough_positional_arguments_test/05: MissingRuntimeError
null_test/none: RuntimeError
number_identifier_test/05: RuntimeError
positional_parameters_type_test/01: MissingRuntimeError
positional_parameters_type_test/02: MissingRuntimeError
prefix10_negative_test: Fail
prefix16_test: RuntimeError
prefix21_test: RuntimeError
redirecting_constructor_initializer_test: RuntimeError
redirecting_factory_default_values_test/none: RuntimeError
redirecting_factory_reflection_test: RuntimeError
regress_18713_test: RuntimeError
regress_22443_test: RuntimeError
regress_22700_test: RuntimeError
regress_23408_test: RuntimeError
regress_27164_test: CompileTimeError
regress_27617_test/1: MissingCompileTimeError
regress_r24720_test: RuntimeError
reify_typevar_static_test/00: MissingCompileTimeError
reify_typevar_test: RuntimeError
@ -320,26 +322,12 @@ script2_negative_test: Fail
setter_no_getter_call_test/none: RuntimeError
static_setter_get_test/01: RuntimeError
super_call3_test/01: Crash
super_call4_test: RuntimeError
super_getter_setter_test: RuntimeError
super_no_such_method1_test/01: RuntimeError
super_no_such_method2_test/01: RuntimeError
super_no_such_method3_test/01: RuntimeError
super_no_such_method4_test/01: RuntimeError
super_no_such_method5_test/01: RuntimeError
super_operator_index3_test: RuntimeError
super_operator_index4_test: RuntimeError
super_operator_index5_test: RuntimeError
super_operator_index6_test: RuntimeError
super_operator_index7_test: RuntimeError
super_operator_index8_test: RuntimeError
super_test: RuntimeError
switch7_negative_test: Fail
switch_try_catch_test: RuntimeError
sync_generator3_test/test2: RuntimeError
tearoff_basic_test: CompileTimeError
tearoff_constructor_basic_test: CompileTimeError
throw8_test: RuntimeError
try_catch_on_syntax_test/10: MissingRuntimeError
try_catch_on_syntax_test/11: MissingRuntimeError
try_finally_regress_25654_test: RuntimeError
@ -482,8 +470,6 @@ enum_syntax_test/06: MissingCompileTimeError
enum_test: RuntimeError
evaluation_redirecting_constructor_test: RuntimeError
example_constructor_test: RuntimeError
execute_finally8_test: RuntimeError
execute_finally9_test: RuntimeError
export_double_same_main_test: Crash
export_main_test: Crash
external_test/10: MissingRuntimeError
@ -711,4 +697,4 @@ vm/debug_break_enabled_vm_test/01: CompileTimeError
vm/debug_break_enabled_vm_test/none: CompileTimeError
vm/reflect_core_vm_test: CompileTimeError
vm/type_cast_vm_test: RuntimeError
vm/type_vm_test: RuntimeError
vm/type_vm_test: RuntimeError

View file

@ -264,6 +264,17 @@ List<String> _patchLibrary(String name,
partUnit.accept(new PatchApplier(partEdits, patchFinder));
results.add(partEdits);
}
if (patchFinder.patches.length != patchFinder.applied.length) {
print('Some elements marked as @patch do not have corresponding elements:');
for (var patched in patchFinder.patches.keys) {
if (!patchFinder.applied.contains(patched)) {
print('*** ${patched}');
}
}
throw "Failed to apply all @patch-es";
}
return new List<String>.from(results.map((e) => e.toString()));
}
@ -343,14 +354,16 @@ class PatchApplier extends GeneralizingAstVisitor {
if (node is FieldDeclaration) return;
var externalKeyword = (node as dynamic).externalKeyword;
if (externalKeyword == null) return;
var name = _qualifiedName(node);
var patchNode = patch.patches[name];
if (patchNode == null) {
print('warning: patch not found for $name: $node');
if (externalKeyword != null) {
print('warning: patch not found for $name: $node');
}
return;
}
patch.applied.add(name);
Annotation patchMeta = patchNode.metadata.lastWhere(_isPatchAnnotation);
int start = patchMeta.endToken.next.offset;
@ -359,7 +372,7 @@ class PatchApplier extends GeneralizingAstVisitor {
// For some node like static fields, the node's offset doesn't include
// the external keyword. Also starting from the keyword lets us preserve
// documentation comments.
edits.replace(externalKeyword.offset, node.end, code);
edits.replace(externalKeyword?.offset ?? node.offset, node.end, code);
}
}
@ -370,6 +383,7 @@ class PatchFinder extends GeneralizingAstVisitor {
final Map patches = <String, Declaration>{};
final Map mergeMembers = <String, List<ClassMember>>{};
final List mergeDeclarations = <CompilationUnitMember>[];
final Set<String> applied = new Set<String>();
PatchFinder.parseAndVisit(String name, String contents)
: contents = contents,