mirror of
https://github.com/dart-lang/sdk
synced 2024-10-14 12:58:05 +00:00
1. Correctly set root_library based on the application script URI instead of looking for the library that has the 'main' method.
2. Adjust the Dart front end to not require a 'main' method when the in memory filesystem is used, this allows execution of VM unit tests which all do not necessarily have a 'main' method (integrated CL from siggi) 3. Change kernel reader to not look for a 'main' methos when Dart_LoadKernel is called. 4. Change Dart_LoadScript to also support loading of dart programs when Dart front end is used R=aam@google.com, sigmund@google.com Review-Url: https://codereview.chromium.org/2948273002 .
This commit is contained in:
parent
bff25c89fe
commit
33c50e9374
|
@ -77,7 +77,9 @@ Dart_Handle DFE::ReloadScript(Dart_Isolate isolate, const char* url_string) {
|
|||
}
|
||||
void* kernel_program = Dart_ReadKernelBinary(kernel_ir, kernel_ir_size);
|
||||
ASSERT(kernel_program != NULL);
|
||||
Dart_Handle result = Dart_LoadKernel(kernel_program);
|
||||
Dart_Handle url = Dart_NewStringFromCString(url_string);
|
||||
Dart_Handle result = Dart_LoadScript(
|
||||
url, Dart_Null(), reinterpret_cast<Dart_Handle>(kernel_program), 0, 0);
|
||||
if (Dart_IsError(result)) {
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -1749,8 +1749,12 @@ int main(int argc, char** argv) {
|
|||
ParseEntryPointsManifestIfPresent();
|
||||
|
||||
if (kernel_program != NULL) {
|
||||
Dart_Handle library = Dart_LoadKernel(kernel_program);
|
||||
if (Dart_IsError(library)) FATAL("Failed to load app from Kernel IR");
|
||||
Dart_Handle resolved_uri = ResolveUriInWorkingDirectory(app_script_name);
|
||||
CHECK_RESULT(resolved_uri);
|
||||
Dart_Handle library =
|
||||
Dart_LoadScript(resolved_uri, Dart_Null(),
|
||||
reinterpret_cast<Dart_Handle>(kernel_program), 0, 0);
|
||||
CHECK_RESULT(library);
|
||||
} else {
|
||||
// Set up the library tag handler in such a manner that it will use the
|
||||
// URL mapping specified on the command line to load the libraries.
|
||||
|
|
|
@ -431,8 +431,9 @@ bool Loader::ProcessResultLocked(Loader* loader, Loader::IOResult* result) {
|
|||
// isolates. We currently do not have support for neither
|
||||
// `Isolate.spawn()` nor `Isolate.spawnUri()` with kernel-based
|
||||
// frontend.
|
||||
void* kernel_binary = Dart_ReadKernelBinary(payload, payload_length);
|
||||
dart_result = Dart_LoadKernel(kernel_binary);
|
||||
Dart_Handle kernel_binary = reinterpret_cast<Dart_Handle>(
|
||||
Dart_ReadKernelBinary(payload, payload_length));
|
||||
dart_result = Dart_LoadScript(uri, resolved_uri, kernel_binary, 0, 0);
|
||||
} else {
|
||||
dart_result = Dart_LoadScript(uri, resolved_uri, source, 0, 0);
|
||||
}
|
||||
|
|
|
@ -838,8 +838,20 @@ static Dart_Isolate IsolateSetupHelper(Dart_Isolate isolate,
|
|||
Dart_Handle result = Dart_SetLibraryTagHandler(Loader::LibraryTagHandler);
|
||||
CHECK_RESULT(result);
|
||||
|
||||
// Prepare builtin and other core libraries for use to resolve URIs.
|
||||
// Set up various closures, e.g: printing, timers etc.
|
||||
// Set up 'package root' for URI resolution.
|
||||
result = DartUtils::PrepareForScriptLoading(false, trace_loading);
|
||||
CHECK_RESULT(result);
|
||||
|
||||
if (kernel_program != NULL) {
|
||||
Dart_Handle result = Dart_LoadKernel(kernel_program);
|
||||
Dart_Handle uri = Dart_NewStringFromCString(script_uri);
|
||||
CHECK_RESULT(uri);
|
||||
Dart_Handle resolved_script_uri = DartUtils::ResolveScript(uri);
|
||||
CHECK_RESULT(resolved_script_uri);
|
||||
result =
|
||||
Dart_LoadScript(uri, resolved_script_uri,
|
||||
reinterpret_cast<Dart_Handle>(kernel_program), 0, 0);
|
||||
CHECK_RESULT(result);
|
||||
}
|
||||
if (set_native_resolvers) {
|
||||
|
@ -852,12 +864,6 @@ static Dart_Isolate IsolateSetupHelper(Dart_Isolate isolate,
|
|||
CHECK_RESULT(result);
|
||||
}
|
||||
|
||||
// Prepare builtin and other core libraries for use to resolve URIs.
|
||||
// Set up various closures, e.g: printing, timers etc.
|
||||
// Set up 'package root' for URI resolution.
|
||||
result = DartUtils::PrepareForScriptLoading(false, trace_loading);
|
||||
CHECK_RESULT(result);
|
||||
|
||||
// Set up the load port provided by the service isolate so that we can
|
||||
// load scripts.
|
||||
result = DartUtils::SetupServiceLoadPort();
|
||||
|
|
|
@ -251,74 +251,43 @@ dart/spawn_shutdown_test: SkipSlow
|
|||
|
||||
[ ($compiler == dartk) && ($runtime == vm) ]
|
||||
cc/CanonicalizationInScriptSnapshots: Fail
|
||||
cc/ClassHierarchyAnalysis: Crash
|
||||
cc/Class_ComputeEndTokenPos: Crash
|
||||
cc/CurrentStackTraceInfo: Fail
|
||||
cc/CustomIsolates: Crash
|
||||
cc/DartGeneratedArrayLiteralMessages: Crash
|
||||
cc/DartGeneratedArrayLiteralMessagesWithBackref: Crash
|
||||
cc/DartGeneratedListMessages: Crash
|
||||
cc/DartGeneratedListMessagesWithBackref: Crash
|
||||
cc/DartGeneratedListMessagesWithTypedData: Crash
|
||||
cc/DartGeneratedMessages: Crash
|
||||
cc/Dart_LoadLibraryPatch_Error1: Fail
|
||||
cc/Dart_LoadLibraryPatch_Error2: Fail
|
||||
cc/Dart_LoadLibraryPatch_Error3: Fail
|
||||
cc/Dart_PropagateError: Fail
|
||||
cc/Debug_EvaluateExpr: Fail
|
||||
cc/Debug_EvaluateInActivationOfEvaluate: Fail
|
||||
cc/Debug_GetClosureInfo: Fail
|
||||
cc/Debug_InterruptIsolate: SkipSlow
|
||||
cc/Debug_IsolateID: Fail
|
||||
cc/Debug_ListSuperType: Fail
|
||||
cc/Debug_ScriptGetTokenInfo_Basic: Fail
|
||||
cc/Debug_ScriptGetTokenInfo_MultiLineInterpolation: Fail
|
||||
cc/Debugger_PrintBreakpointsToJSONArray: Fail
|
||||
cc/Debugger_Rewind_Optimized: SkipSlow
|
||||
cc/Debugger_SetBreakpointInPartOfLibrary: Crash
|
||||
cc/ErrorHandleBasics: Fail
|
||||
cc/EvalExpression: Crash
|
||||
cc/ExternalUint8ClampedArrayAccess: Fail
|
||||
cc/ExternalizeConstantStrings: Fail
|
||||
cc/FieldAccess: Crash
|
||||
cc/Float32x4List: Crash
|
||||
cc/FrameLookup: Fail
|
||||
cc/FullSnapshot1: Crash
|
||||
cc/FullSnapshot: Crash
|
||||
cc/FunctionSourceFingerprint: Crash
|
||||
cc/FunctionWithBreakpointNotInlined: Crash
|
||||
cc/GetField_CheckIsolate: Fail
|
||||
cc/GetFunctionNames: Crash
|
||||
cc/GetNativeArgumentCount: Fail
|
||||
cc/GetNativeArguments: Fail
|
||||
cc/GetStaticField_RunsInitializer: Fail
|
||||
cc/GetType: Fail
|
||||
cc/ImplicitNativeFieldAccess: Fail
|
||||
cc/ImplicitNativeFieldAccess: Crash
|
||||
cc/ImportLibrary2: Crash
|
||||
cc/ImportLibrary3: Crash
|
||||
cc/ImportLibrary4: Crash
|
||||
cc/ImportLibrary5: Crash
|
||||
cc/ImportLibraryWithPrefix: Crash
|
||||
cc/InjectNativeFieldsSuperClass: Fail
|
||||
cc/InstanceOf: Fail
|
||||
cc/InvokeClosure: Fail
|
||||
cc/InjectNativeFieldsSuperClass: Crash
|
||||
cc/InvokeNoSuchMethod: Fail
|
||||
cc/Invoke_CrossLibrary: Crash
|
||||
cc/Invoke_FunnyArgs: Crash
|
||||
cc/Invoke_PrivateStatic: Fail
|
||||
cc/IsFuture: Fail
|
||||
cc/IsolateReload_BadClass: Fail
|
||||
cc/IsolateReload_ChangeInstanceFormat0: Fail
|
||||
cc/IsolateReload_ChangeInstanceFormat1: Fail
|
||||
cc/IsolateReload_ChangeInstanceFormat3: Fail
|
||||
cc/IsolateReload_ChangeInstanceFormat4: Fail
|
||||
cc/IsolateReload_ChangeInstanceFormat5: Fail
|
||||
cc/IsolateReload_ChangeInstanceFormat6: Fail
|
||||
cc/IsolateReload_ChangeInstanceFormat7: Crash
|
||||
cc/IsolateReload_ChangeInstanceFormat8: Fail
|
||||
cc/IsolateReload_ComplexInheritanceChange: Fail
|
||||
cc/IsolateReload_ConstantIdentical: Fail
|
||||
cc/IsolateReload_ConstructorChanged: Fail
|
||||
cc/IsolateReload_ClassFieldAdded: Crash
|
||||
cc/IsolateReload_ClassFieldAdded2: Crash
|
||||
cc/IsolateReload_ChangeInstanceFormat1: Crash
|
||||
cc/IsolateReload_ChangeInstanceFormat3: Crash
|
||||
cc/IsolateReload_ChangeInstanceFormat7: Fail
|
||||
cc/IsolateReload_ChangeInstanceFormat8: Crash
|
||||
cc/IsolateReload_DanglingGetter_Class: Fail
|
||||
cc/IsolateReload_DanglingGetter_Instance: Fail
|
||||
cc/IsolateReload_DanglingGetter_Library: Fail
|
||||
|
@ -326,40 +295,31 @@ cc/IsolateReload_DanglingSetter_Class: Fail
|
|||
cc/IsolateReload_DanglingSetter_Instance: Fail
|
||||
cc/IsolateReload_DanglingSetter_Library: Fail
|
||||
cc/IsolateReload_DirectSubclasses_Failure: Fail
|
||||
cc/IsolateReload_DirectSubclasses_Success: Fail
|
||||
cc/IsolateReload_DirectSubclasses_Success: Skip
|
||||
cc/IsolateReload_EnumDelete: Fail
|
||||
cc/IsolateReload_EnumEquality: Fail
|
||||
cc/IsolateReload_EnumIdentical: Fail
|
||||
cc/IsolateReload_EnumIdentityReload: Fail
|
||||
cc/IsolateReload_EnumReorderIdentical: Fail
|
||||
cc/IsolateReload_EnumToNotEnum: Fail
|
||||
cc/IsolateReload_EnumToNotEnum: Crash
|
||||
cc/IsolateReload_ExportedLibModified: Crash
|
||||
cc/IsolateReload_ImplicitConstructorChanged: Fail
|
||||
cc/IsolateReload_ImportedLibModified: Crash
|
||||
cc/IsolateReload_ImportedMixinFunction: Crash
|
||||
cc/IsolateReload_LibraryDebuggable: Fail
|
||||
cc/IsolateReload_LibraryHide: Crash
|
||||
cc/IsolateReload_LibraryLookup: Fail
|
||||
cc/IsolateReload_LibraryShow: Crash
|
||||
cc/IsolateReload_LiveStack: Fail
|
||||
cc/IsolateReload_MainLibModified: Crash
|
||||
cc/IsolateReload_MixinChanged: Fail
|
||||
cc/IsolateReload_NoLibsModified: Crash
|
||||
cc/IsolateReload_NotEnumToEnum: Fail
|
||||
cc/IsolateReload_NotEnumToEnum: Skip
|
||||
cc/IsolateReload_NotTypedefToTypedef: Fail
|
||||
cc/IsolateReload_PendingSuperCall: Fail
|
||||
cc/IsolateReload_PrefixImportedLibModified: Crash
|
||||
cc/IsolateReload_RunNewFieldInitialiazersSuperClass: Fail
|
||||
cc/IsolateReload_RunNewFieldInitializers: Fail
|
||||
cc/IsolateReload_RunNewFieldInitializersMutateStaticField: Fail
|
||||
cc/IsolateReload_RunNewFieldInitializersReferenceStaticField: Fail
|
||||
cc/IsolateReload_RunNewFieldInitialiazersSuperClass: Crash
|
||||
cc/IsolateReload_RunNewFieldInitializers: Crash
|
||||
cc/IsolateReload_RunNewFieldInitializersMutateStaticField: Crash
|
||||
cc/IsolateReload_RunNewFieldInitializersReferenceStaticField: Crash
|
||||
cc/IsolateReload_RunNewFieldInitializersSyntaxError3: Fail
|
||||
cc/IsolateReload_RunNewFieldInitializersThrows: Fail
|
||||
cc/IsolateReload_SavedClosure: Fail
|
||||
cc/IsolateReload_ShapeChangeRetainsHash: Fail
|
||||
cc/IsolateReload_RunNewFieldInitializersThrows: Crash
|
||||
cc/IsolateReload_ShapeChangeRetainsHash: Crash
|
||||
cc/IsolateReload_SmiFastPathStubs: Fail
|
||||
cc/IsolateReload_StaticTearOffRetainsHash: Fail
|
||||
cc/IsolateReload_StaticValuePreserved: Fail
|
||||
cc/IsolateReload_TearOff_AddArguments2: Fail
|
||||
cc/IsolateReload_TearOff_AddArguments: Fail
|
||||
cc/IsolateReload_TearOff_Class_Identity: Fail
|
||||
|
@ -370,20 +330,13 @@ cc/IsolateReload_TopLevelParseError: Fail
|
|||
cc/IsolateReload_TypeIdentity: Fail
|
||||
cc/IsolateReload_TypeIdentityGeneric: Fail
|
||||
cc/IsolateReload_TypeIdentityParameter: Fail
|
||||
cc/IsolateReload_TypedefAddParameter: Fail
|
||||
cc/IsolateReload_TypedefToNotTypedef: Fail
|
||||
cc/IsolateShutdownRunDartCode: Skip # Flaky
|
||||
cc/IsolateSpawn: Crash
|
||||
cc/JSON_JSONStream_DartString: Crash
|
||||
cc/LazyLoadDeoptimizes: Crash
|
||||
cc/LazyLoadDeoptimizes: Fail
|
||||
cc/LibraryGetClassNames: Crash
|
||||
cc/LibraryId: Crash
|
||||
cc/LibraryImportLibrary: Crash
|
||||
cc/LibraryName: Crash
|
||||
cc/LibraryUrl: Crash
|
||||
cc/LinkedHashMap: Crash
|
||||
cc/LinkedHashMap_iteration: Crash
|
||||
cc/ListAccess: Crash
|
||||
cc/LoadPatch: Crash
|
||||
cc/LoadPatchSignatureMismatch: Crash
|
||||
cc/LoadSource: Crash
|
||||
|
@ -391,17 +344,9 @@ cc/LoadLibrary: Crash
|
|||
cc/LoadLibrary_CompileError: Crash
|
||||
cc/LoadSource_LateLoad: Crash
|
||||
cc/LookupLibrary: Crash
|
||||
cc/MalformedStringToUTF8: Crash
|
||||
cc/MapAccess: Crash
|
||||
cc/NativeFieldAccess: Fail
|
||||
cc/NativePortPostInteger: Fail
|
||||
cc/NativePortReceiveInteger: Fail
|
||||
cc/NativePortReceiveNull: Fail
|
||||
cc/NegativeNativeFieldAccess: Fail
|
||||
cc/NegativeNativeFieldInIsolateMessage: Crash
|
||||
cc/New: Fail
|
||||
cc/NewNativePort: Fail
|
||||
cc/NumberValues: Fail
|
||||
cc/New: Crash
|
||||
cc/ParsePatchLibrary: Crash
|
||||
cc/Parser_AllocateVariables_CaptureLoopVar: Fail
|
||||
cc/Parser_AllocateVariables_CapturedVar: Fail
|
||||
|
@ -410,12 +355,14 @@ cc/Parser_AllocateVariables_MiddleChain: Fail
|
|||
cc/Parser_AllocateVariables_NestedCapturedVar: Fail
|
||||
cc/Parser_AllocateVariables_TwoChains: Fail
|
||||
cc/Profiler_GetSourceReport: Fail
|
||||
cc/ScriptSnapshot1: Fail
|
||||
cc/Profiler_SourcePositionOptimized: Fail
|
||||
cc/Profiler_BasicSourcePositionOptimized: Skip
|
||||
cc/Profiler_BinaryOperatorSourcePositionOptimized: Skip
|
||||
cc/Profiler_GetSourceReport: Fail
|
||||
cc/Profiler_SourcePositionOptimized: Skip
|
||||
cc/ScriptSnapshot2: Crash
|
||||
cc/ScriptSnapshot: Crash
|
||||
cc/ScriptSnapshotsUpdateSubclasses: Crash # Issue 29850
|
||||
cc/SetField_CheckIsolate: Fail
|
||||
cc/SetField_FunnyValue: Fail
|
||||
cc/SourcePosition_Async: Crash
|
||||
cc/SourcePosition_BitwiseOperations: Crash
|
||||
cc/SourcePosition_ForLoop: Crash
|
||||
|
@ -443,19 +390,11 @@ cc/SourceReport_Coverage_UnusedClass_ForceCompileError: Crash
|
|||
cc/SourceReport_Coverage_UnusedClass_NoForceCompile: Fail
|
||||
cc/SourceReport_MultipleReports: Fail
|
||||
cc/SourceReport_PossibleBreakpoints_Simple: Fail
|
||||
cc/StackMapGC: Crash
|
||||
cc/StackOverflowStackTraceInfo: Crash
|
||||
cc/StackOverflowStackTraceInfo: Skip
|
||||
cc/StackTraceFormat: Fail
|
||||
cc/StackTraceInfo: Crash
|
||||
cc/StringFromExternalTypedData: Fail
|
||||
cc/TestNativeFieldsAccess: Fail
|
||||
cc/ThrowException: Fail
|
||||
cc/TypeGetNonParamtericTypes: Fail
|
||||
cc/TypeGetParameterizedTypes: Fail
|
||||
cc/UnhandledExceptions: Fail
|
||||
cc/TestNativeFieldsAccess: Crash
|
||||
cc/TypeGetParameterizedTypes: Crash
|
||||
cc/UseDartApi: Fail
|
||||
cc/ValidateNoSuchMethodStackFrameIteration: Fail
|
||||
cc/ValidateStackFrameIteration: Fail
|
||||
dart/data_uri_import_test/base64: CompileTimeError
|
||||
dart/data_uri_import_test/nocharset: CompileTimeError
|
||||
dart/data_uri_import_test/nomime: CompileTimeError
|
||||
|
@ -465,56 +404,25 @@ dart/data_uri_spawn_test: RuntimeError
|
|||
dart/redirection_type_shuffling_test/00: Crash
|
||||
dart/redirection_type_shuffling_test/none: Crash
|
||||
dart/spawn_shutdown_test: SkipSlow
|
||||
cc/InjectNativeFields1: Skip
|
||||
cc/InjectNativeFields3: Crash
|
||||
cc/InjectNativeFields4: Crash
|
||||
cc/IsolateShutdownRunDartCode: Skip # Flaky
|
||||
|
||||
[ ($compiler == dartk) && ($runtime == vm) && ($mode == release) ]
|
||||
cc/Debug_BreakpointStubPatching: Fail
|
||||
cc/Debug_InspectObject: Fail
|
||||
cc/Debug_InspectStackWithClosure_NotOptimized: Fail
|
||||
cc/Debug_InspectStackWithClosure_Optimized: Fail
|
||||
cc/Debug_InspectStack_NotOptimized: Fail
|
||||
cc/Debug_InspectStack_Optimized: Fail
|
||||
cc/DeepStackTraceInfo: Fail
|
||||
cc/HashCode: Fail
|
||||
cc/InjectNativeFields1: Fail
|
||||
cc/InjectNativeFields3: Fail
|
||||
cc/Invoke: Fail
|
||||
cc/LargeMap: Fail
|
||||
cc/Profiler_ArrayAllocation: Fail
|
||||
cc/Profiler_ClosureAllocation: Fail
|
||||
cc/Profiler_ContextAllocation: Fail
|
||||
cc/Profiler_IntrinsicAllocation: Fail
|
||||
cc/Profiler_StringAllocation: Fail
|
||||
cc/Profiler_StringInterpolation: Fail
|
||||
cc/Profiler_TypedArrayAllocation: Fail
|
||||
cc/Service_TokenStream: Fail
|
||||
|
||||
[ ($compiler == dartk) && ($runtime == vm) && ($mode == debug) ]
|
||||
cc/Debug_BreakpointStubPatching: Fail
|
||||
cc/Debug_InspectObject: Crash
|
||||
cc/Debug_InspectStackWithClosure_NotOptimized: Crash
|
||||
cc/Debug_InspectStackWithClosure_Optimized: Crash
|
||||
cc/Debug_InspectStack_NotOptimized: Crash
|
||||
cc/Debug_InspectStack_Optimized: Crash
|
||||
cc/DeepStackTraceInfo: Crash
|
||||
cc/HashCode: Crash
|
||||
cc/InjectNativeFields1: Crash
|
||||
cc/InjectNativeFields3: Crash
|
||||
cc/Invoke: Crash
|
||||
cc/LargeMap: Crash
|
||||
cc/Profiler_ArrayAllocation: Crash
|
||||
cc/Profiler_ClosureAllocation: Crash
|
||||
cc/Profiler_ContextAllocation: Crash
|
||||
cc/Profiler_IntrinsicAllocation: Crash
|
||||
cc/Profiler_StringAllocation: Crash
|
||||
cc/Profiler_StringInterpolation: Crash
|
||||
cc/Profiler_TypedArrayAllocation: Crash
|
||||
cc/Service_TokenStream: Crash
|
||||
|
||||
[ ($compiler == dartk) && ($runtime == vm) && ($system == macos) ]
|
||||
cc/DeepStackTraceInfo: Crash
|
||||
cc/Invoke_FunnyArgs: Fail
|
||||
cc/Invoke_PrivateStatic: Crash
|
||||
cc/IsolateReload_ComplexInheritanceChange: Crash
|
||||
cc/IsolateReload_DanglingGetter_Class: Crash
|
||||
cc/IsolateReload_DanglingGetter_Instance: Crash
|
||||
cc/IsolateReload_DanglingGetter_Library: Crash
|
||||
|
@ -522,7 +430,6 @@ cc/IsolateReload_DanglingSetter_Class: Crash
|
|||
cc/IsolateReload_DanglingSetter_Instance: Crash
|
||||
cc/IsolateReload_DanglingSetter_Library: Crash
|
||||
cc/IsolateReload_EnumDelete: Crash
|
||||
cc/IsolateReload_EnumIdentityReload: Crash
|
||||
cc/IsolateReload_LibraryLookup: Crash
|
||||
cc/IsolateReload_RunNewFieldInitialiazersSuperClass: Crash
|
||||
cc/IsolateReload_RunNewFieldInitializersThrows: Crash
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
namespace dart {
|
||||
|
||||
DECLARE_FLAG(bool, trace_shutdown);
|
||||
DECLARE_FLAG(bool, use_dart_frontend);
|
||||
|
||||
static void native_echo(Dart_NativeArguments args);
|
||||
static void CustomIsolateImpl_start(Dart_NativeArguments args);
|
||||
|
@ -308,7 +309,7 @@ VM_UNIT_TEST_CASE(CustomIsolates) {
|
|||
FLAG_trace_shutdown = true;
|
||||
FLAG_verify_handles = true;
|
||||
#ifdef DEBUG
|
||||
FLAG_verify_on_transition = true;
|
||||
FLAG_verify_on_transition = FLAG_use_dart_frontend ? false : true;
|
||||
#endif
|
||||
event_queue = new EventQueue();
|
||||
|
||||
|
|
|
@ -62,6 +62,7 @@ namespace dart {
|
|||
DECLARE_FLAG(bool, use_dart_frontend);
|
||||
DECLARE_FLAG(bool, print_class_table);
|
||||
DECLARE_FLAG(bool, verify_handles);
|
||||
DECLARE_FLAG(bool, use_dart_frontend);
|
||||
#if defined(DART_NO_SNAPSHOT)
|
||||
DEFINE_FLAG(bool,
|
||||
check_function_fingerprints,
|
||||
|
@ -423,6 +424,8 @@ RawObject* Api::UnwrapHandle(Dart_Handle object) {
|
|||
ASSERT(thread->IsMutatorThread());
|
||||
ASSERT(thread->isolate() != NULL);
|
||||
ASSERT(!FLAG_verify_handles || thread->IsValidLocalHandle(object) ||
|
||||
thread->isolate()->api_state()->IsActivePersistentHandle(
|
||||
reinterpret_cast<Dart_PersistentHandle>(object)) ||
|
||||
Dart::IsReadOnlyApiHandle(object));
|
||||
ASSERT(FinalizablePersistentHandle::raw_offset() == 0 &&
|
||||
PersistentHandle::raw_offset() == 0 && LocalHandle::raw_offset() == 0);
|
||||
|
@ -5054,6 +5057,22 @@ static void CompileSource(Thread* thread,
|
|||
}
|
||||
}
|
||||
|
||||
#if !defined(DART_PRECOMPILED_RUNTIME)
|
||||
static Dart_Handle LoadKernelProgram(Thread* T,
|
||||
const String& url,
|
||||
void* kernel) {
|
||||
// NOTE: Now the VM owns the [kernel_program] memory! Currently we do not
|
||||
// free it because (similar to the token stream) it will be used to repeatedly
|
||||
// run the `kernel::FlowGraphBuilder()`.
|
||||
kernel::KernelReader reader(reinterpret_cast<kernel::Program*>(kernel));
|
||||
const Object& tmp = reader.ReadProgram();
|
||||
if (tmp.IsError()) {
|
||||
return Api::NewHandle(T, tmp.raw());
|
||||
}
|
||||
return Dart_Null();
|
||||
}
|
||||
#endif
|
||||
|
||||
DART_EXPORT Dart_Handle Dart_LoadScript(Dart_Handle url,
|
||||
Dart_Handle resolved_url,
|
||||
Dart_Handle source,
|
||||
|
@ -5073,10 +5092,6 @@ DART_EXPORT Dart_Handle Dart_LoadScript(Dart_Handle url,
|
|||
if (resolved_url_str.IsNull()) {
|
||||
RETURN_TYPE_ERROR(Z, resolved_url, String);
|
||||
}
|
||||
const String& source_str = Api::UnwrapStringHandle(Z, source);
|
||||
if (source_str.IsNull()) {
|
||||
RETURN_TYPE_ERROR(Z, source, String);
|
||||
}
|
||||
Library& library = Library::Handle(Z, I->object_store()->root_library());
|
||||
if (!library.IsNull()) {
|
||||
const String& library_url = String::Handle(Z, library.url());
|
||||
|
@ -5094,6 +5109,32 @@ DART_EXPORT Dart_Handle Dart_LoadScript(Dart_Handle url,
|
|||
CHECK_CALLBACK_STATE(T);
|
||||
CHECK_COMPILATION_ALLOWED(I);
|
||||
|
||||
Dart_Handle result;
|
||||
#if !defined(DART_PRECOMPILED_RUNTIME)
|
||||
if (FLAG_use_dart_frontend && !KernelIsolate::IsKernelIsolate(I)) {
|
||||
if ((source == Api::Null()) || (source == NULL)) {
|
||||
RETURN_NULL_ERROR(source);
|
||||
}
|
||||
void* kernel_pgm = reinterpret_cast<void*>(source);
|
||||
result = LoadKernelProgram(T, resolved_url_str, kernel_pgm);
|
||||
if (Dart_IsError(result)) {
|
||||
return result;
|
||||
}
|
||||
library ^= Library::LookupLibrary(T, resolved_url_str);
|
||||
if (library.IsNull()) {
|
||||
return Api::NewError("%s: Unable to load script '%s' correctly.",
|
||||
CURRENT_FUNC, resolved_url_str.ToCString());
|
||||
}
|
||||
I->object_store()->set_root_library(library);
|
||||
return Api::NewHandle(T, library.raw());
|
||||
}
|
||||
#endif
|
||||
|
||||
const String& source_str = Api::UnwrapStringHandle(Z, source);
|
||||
if (source_str.IsNull()) {
|
||||
RETURN_TYPE_ERROR(Z, source, String);
|
||||
}
|
||||
|
||||
NoHeapGrowthControlScope no_growth_control;
|
||||
|
||||
library = Library::New(url_str);
|
||||
|
@ -5105,7 +5146,6 @@ DART_EXPORT Dart_Handle Dart_LoadScript(Dart_Handle url,
|
|||
Script::Handle(Z, Script::New(url_str, resolved_url_str, source_str,
|
||||
RawScript::kScriptTag));
|
||||
script.SetLocationOffset(line_offset, column_offset);
|
||||
Dart_Handle result;
|
||||
CompileSource(T, library, script, &result);
|
||||
return result;
|
||||
}
|
||||
|
@ -5410,21 +5450,6 @@ DART_EXPORT Dart_Handle Dart_LibraryHandleError(Dart_Handle library_in,
|
|||
return error_in;
|
||||
}
|
||||
|
||||
#if !defined(DART_PRECOMPILED_RUNTIME)
|
||||
static Dart_Handle LoadKernelProgram(Dart_Handle url, Thread* T, void* kernel) {
|
||||
kernel::KernelReader reader(reinterpret_cast<kernel::Program*>(kernel));
|
||||
const Object& tmp = reader.ReadProgram();
|
||||
if (tmp.IsError()) {
|
||||
return Api::NewHandle(T, tmp.raw());
|
||||
}
|
||||
|
||||
const String& url_str = Api::UnwrapStringHandle(Z, url);
|
||||
Library& library =
|
||||
Library::Handle(T->zone(), Library::LookupLibrary(T, url_str));
|
||||
return Api::NewHandle(T, library.raw());
|
||||
}
|
||||
#endif
|
||||
|
||||
DART_EXPORT Dart_Handle Dart_LoadLibrary(Dart_Handle url,
|
||||
Dart_Handle resolved_url,
|
||||
Dart_Handle source,
|
||||
|
@ -5434,19 +5459,23 @@ DART_EXPORT Dart_Handle Dart_LoadLibrary(Dart_Handle url,
|
|||
DARTSCOPE(Thread::Current());
|
||||
Isolate* I = T->isolate();
|
||||
|
||||
const String& url_str = Api::UnwrapStringHandle(Z, url);
|
||||
if (url_str.IsNull()) {
|
||||
RETURN_TYPE_ERROR(Z, url, String);
|
||||
}
|
||||
Dart_Handle result;
|
||||
#if !defined(DART_PRECOMPILED_RUNTIME)
|
||||
// Kernel isolate is loaded from script in case of dart_bootstrap
|
||||
// even when FLAG_use_dart_frontend is true. Hence, do not interpret
|
||||
// |source| as a kernel if the current isolate is the kernel isolate.
|
||||
if (FLAG_use_dart_frontend && !KernelIsolate::IsKernelIsolate(I)) {
|
||||
return LoadKernelProgram(url, T, reinterpret_cast<void*>(source));
|
||||
result = LoadKernelProgram(T, url_str, reinterpret_cast<void*>(source));
|
||||
if (Dart_IsError(result)) {
|
||||
return result;
|
||||
}
|
||||
return Api::NewHandle(T, Library::LookupLibrary(T, url_str));
|
||||
}
|
||||
#endif
|
||||
|
||||
const String& url_str = Api::UnwrapStringHandle(Z, url);
|
||||
if (url_str.IsNull()) {
|
||||
RETURN_TYPE_ERROR(Z, url, String);
|
||||
}
|
||||
if (::Dart_IsNull(resolved_url)) {
|
||||
resolved_url = url;
|
||||
}
|
||||
|
@ -5486,7 +5515,6 @@ DART_EXPORT Dart_Handle Dart_LoadLibrary(Dart_Handle url,
|
|||
Script::Handle(Z, Script::New(url_str, resolved_url_str, source_str,
|
||||
RawScript::kLibraryTag));
|
||||
script.SetLocationOffset(line_offset, column_offset);
|
||||
Dart_Handle result;
|
||||
CompileSource(T, library, script, &result);
|
||||
// Propagate the error out right now.
|
||||
if (::Dart_IsError(result)) {
|
||||
|
|
|
@ -24,6 +24,7 @@ namespace dart {
|
|||
DECLARE_FLAG(bool, verify_acquired_data);
|
||||
DECLARE_FLAG(bool, ignore_patch_signature_mismatch);
|
||||
DECLARE_FLAG(bool, support_externalizable_strings);
|
||||
DECLARE_FLAG(bool, use_dart_frontend);
|
||||
|
||||
#ifndef PRODUCT
|
||||
|
||||
|
@ -99,7 +100,7 @@ TEST_CASE(StackTraceInfo) {
|
|||
Dart_StringToCString(function_name, &cstr);
|
||||
EXPECT_STREQ("bar", cstr);
|
||||
Dart_StringToCString(script_url, &cstr);
|
||||
EXPECT_STREQ("test-lib", cstr);
|
||||
EXPECT_SUBSTRING("test-lib", cstr);
|
||||
EXPECT_EQ(1, line_number);
|
||||
EXPECT_EQ(10, column_number);
|
||||
|
||||
|
@ -111,7 +112,7 @@ TEST_CASE(StackTraceInfo) {
|
|||
Dart_StringToCString(function_name, &cstr);
|
||||
EXPECT_STREQ("foo", cstr);
|
||||
Dart_StringToCString(script_url, &cstr);
|
||||
EXPECT_STREQ("test-lib", cstr);
|
||||
EXPECT_SUBSTRING("test-lib", cstr);
|
||||
EXPECT_EQ(2, line_number);
|
||||
EXPECT_EQ(10, column_number);
|
||||
|
||||
|
@ -123,7 +124,7 @@ TEST_CASE(StackTraceInfo) {
|
|||
Dart_StringToCString(function_name, &cstr);
|
||||
EXPECT_STREQ("testMain", cstr);
|
||||
Dart_StringToCString(script_url, &cstr);
|
||||
EXPECT_STREQ("test-lib", cstr);
|
||||
EXPECT_SUBSTRING("test-lib", cstr);
|
||||
EXPECT_EQ(3, line_number);
|
||||
EXPECT_EQ(15, column_number);
|
||||
|
||||
|
@ -172,7 +173,7 @@ TEST_CASE(DeepStackTraceInfo) {
|
|||
Dart_StringToCString(function_name, &cstr);
|
||||
EXPECT_STREQ("foo", cstr);
|
||||
Dart_StringToCString(script_url, &cstr);
|
||||
EXPECT_STREQ("test-lib", cstr);
|
||||
EXPECT_SUBSTRING("test-lib", cstr);
|
||||
EXPECT_EQ(1, line_number);
|
||||
EXPECT_EQ(20, column_number);
|
||||
|
||||
|
@ -187,7 +188,7 @@ TEST_CASE(DeepStackTraceInfo) {
|
|||
Dart_StringToCString(function_name, &cstr);
|
||||
EXPECT_STREQ("foo", cstr);
|
||||
Dart_StringToCString(script_url, &cstr);
|
||||
EXPECT_STREQ("test-lib", cstr);
|
||||
EXPECT_SUBSTRING("test-lib", cstr);
|
||||
EXPECT_EQ(1, line_number);
|
||||
EXPECT_EQ(40, column_number);
|
||||
}
|
||||
|
@ -201,7 +202,7 @@ TEST_CASE(DeepStackTraceInfo) {
|
|||
Dart_StringToCString(function_name, &cstr);
|
||||
EXPECT_STREQ("testMain", cstr);
|
||||
Dart_StringToCString(script_url, &cstr);
|
||||
EXPECT_STREQ("test-lib", cstr);
|
||||
EXPECT_SUBSTRING("test-lib", cstr);
|
||||
EXPECT_EQ(2, line_number);
|
||||
EXPECT_EQ(15, column_number);
|
||||
|
||||
|
@ -3380,6 +3381,26 @@ VM_UNIT_TEST_CASE(CurrentIsolateData) {
|
|||
Dart_ShutdownIsolate();
|
||||
}
|
||||
|
||||
static Dart_Handle LoadScript(const char* url_str, const char* source) {
|
||||
Dart_Handle url = NewString(url_str);
|
||||
Dart_Handle result;
|
||||
Dart_Handle script;
|
||||
if (!FLAG_use_dart_frontend) {
|
||||
result = Dart_SetLibraryTagHandler(TestCase::library_handler);
|
||||
EXPECT_VALID(result);
|
||||
script = NewString(source);
|
||||
} else {
|
||||
void* kernel_pgm = NULL;
|
||||
char* error =
|
||||
TestCase::CompileTestScriptWithDFE(url_str, source, &kernel_pgm);
|
||||
if (error != NULL) {
|
||||
return Dart_NewApiError(error);
|
||||
}
|
||||
script = reinterpret_cast<Dart_Handle>(kernel_pgm);
|
||||
}
|
||||
return Dart_LoadScript(url, Dart_Null(), script, 0, 0);
|
||||
}
|
||||
|
||||
VM_UNIT_TEST_CASE(IsolateSetCheckedMode) {
|
||||
const char* kScriptChars =
|
||||
"int bad1() {\n"
|
||||
|
@ -3411,12 +3432,9 @@ VM_UNIT_TEST_CASE(IsolateSetCheckedMode) {
|
|||
EXPECT(isolate != NULL);
|
||||
|
||||
{
|
||||
Dart_Handle result;
|
||||
Dart_EnterScope();
|
||||
Dart_Handle url = NewString(TestCase::url());
|
||||
Dart_Handle source = NewString(kScriptChars);
|
||||
Dart_Handle result = Dart_SetLibraryTagHandler(TestCase::library_handler);
|
||||
EXPECT_VALID(result);
|
||||
Dart_Handle lib = Dart_LoadScript(url, Dart_Null(), source, 0, 0);
|
||||
Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL);
|
||||
EXPECT_VALID(lib);
|
||||
result = Dart_FinalizeLoading(false);
|
||||
EXPECT_VALID(result);
|
||||
|
@ -5655,23 +5673,25 @@ TEST_CASE(LoadScript) {
|
|||
EXPECT(Dart_IsError(result));
|
||||
EXPECT_STREQ("incoming error", Dart_GetError(result));
|
||||
|
||||
result = Dart_LoadScript(url, Dart_Null(), Dart_Null(), 0, 0);
|
||||
EXPECT(Dart_IsError(result));
|
||||
EXPECT_STREQ("Dart_LoadScript expects argument 'source' to be non-null.",
|
||||
Dart_GetError(result));
|
||||
if (!FLAG_use_dart_frontend) {
|
||||
result = Dart_LoadScript(url, Dart_Null(), Dart_Null(), 0, 0);
|
||||
EXPECT(Dart_IsError(result));
|
||||
EXPECT_STREQ("Dart_LoadScript expects argument 'source' to be non-null.",
|
||||
Dart_GetError(result));
|
||||
|
||||
result = Dart_LoadScript(url, Dart_Null(), Dart_True(), 0, 0);
|
||||
EXPECT(Dart_IsError(result));
|
||||
EXPECT_STREQ(
|
||||
"Dart_LoadScript expects argument 'source' to be of type String.",
|
||||
Dart_GetError(result));
|
||||
result = Dart_LoadScript(url, Dart_Null(), Dart_True(), 0, 0);
|
||||
EXPECT(Dart_IsError(result));
|
||||
EXPECT_STREQ(
|
||||
"Dart_LoadScript expects argument 'source' to be of type String.",
|
||||
Dart_GetError(result));
|
||||
|
||||
result = Dart_LoadScript(url, Dart_Null(), error, 0, 0);
|
||||
EXPECT(Dart_IsError(result));
|
||||
EXPECT_STREQ("incoming error", Dart_GetError(result));
|
||||
result = Dart_LoadScript(url, Dart_Null(), error, 0, 0);
|
||||
EXPECT(Dart_IsError(result));
|
||||
EXPECT_STREQ("incoming error", Dart_GetError(result));
|
||||
}
|
||||
|
||||
// Load a script successfully.
|
||||
result = Dart_LoadScript(url, Dart_Null(), source, 0, 0);
|
||||
result = TestCase::LoadTestScript(kScriptChars, NULL);
|
||||
EXPECT_VALID(result);
|
||||
Dart_FinalizeLoading(false);
|
||||
|
||||
|
@ -5685,10 +5705,8 @@ TEST_CASE(LoadScript) {
|
|||
// Further calls to LoadScript are errors.
|
||||
result = Dart_LoadScript(url, Dart_Null(), source, 0, 0);
|
||||
EXPECT(Dart_IsError(result));
|
||||
EXPECT_STREQ(
|
||||
"Dart_LoadScript: "
|
||||
"A script has already been loaded from 'test-lib'.",
|
||||
Dart_GetError(result));
|
||||
EXPECT_SUBSTRING("Dart_LoadScript: A script has already been loaded from",
|
||||
Dart_GetError(result));
|
||||
}
|
||||
|
||||
TEST_CASE(RootLibrary) {
|
||||
|
@ -5703,9 +5721,7 @@ TEST_CASE(RootLibrary) {
|
|||
EXPECT(Dart_IsNull(root_lib));
|
||||
|
||||
// Load a script.
|
||||
Dart_Handle url = NewString(TestCase::url());
|
||||
Dart_Handle source = NewString(kScriptChars);
|
||||
EXPECT_VALID(Dart_LoadScript(url, Dart_Null(), source, 0, 0));
|
||||
EXPECT_VALID(LoadScript(TestCase::url(), kScriptChars));
|
||||
|
||||
root_lib = Dart_RootLibrary();
|
||||
Dart_Handle lib_name = Dart_LibraryName(root_lib);
|
||||
|
@ -5784,13 +5800,13 @@ static Dart_Handle import_library_handler(Dart_LibraryTag tag,
|
|||
|
||||
TEST_CASE(LoadScript_CompileError) {
|
||||
const char* kScriptChars = ")";
|
||||
Dart_Handle url = NewString(TestCase::url());
|
||||
Dart_Handle source = NewString(kScriptChars);
|
||||
Dart_Handle result = Dart_SetLibraryTagHandler(import_library_handler);
|
||||
EXPECT_VALID(result);
|
||||
result = Dart_LoadScript(url, Dart_Null(), source, 0, 0);
|
||||
result = LoadScript(TestCase::url(), kScriptChars);
|
||||
EXPECT(Dart_IsError(result));
|
||||
EXPECT(strstr(Dart_GetError(result), "unexpected token ')'"));
|
||||
if (!FLAG_use_dart_frontend) {
|
||||
EXPECT(strstr(Dart_GetError(result), "unexpected token ')'"));
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE(LookupLibrary) {
|
||||
|
@ -6726,11 +6742,7 @@ TEST_CASE(SetNativeResolver) {
|
|||
Dart_Handle result;
|
||||
|
||||
// Load a test script.
|
||||
Dart_Handle url = NewString(TestCase::url());
|
||||
Dart_Handle source = NewString(kScriptChars);
|
||||
result = Dart_SetLibraryTagHandler(library_handler);
|
||||
EXPECT_VALID(result);
|
||||
Dart_Handle lib = Dart_LoadScript(url, Dart_Null(), source, 0, 0);
|
||||
Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL);
|
||||
EXPECT_VALID(lib);
|
||||
result = Dart_FinalizeLoading(false);
|
||||
EXPECT_VALID(result);
|
||||
|
@ -7224,7 +7236,6 @@ static Dart_Isolate RunLoopTestCallback(const char* script_name,
|
|||
void* data,
|
||||
char** error) {
|
||||
const char* kScriptChars =
|
||||
"import 'builtin';\n"
|
||||
"import 'dart:isolate';\n"
|
||||
"void main(shouldThrowException) {\n"
|
||||
" var rp = new RawReceivePort();\n"
|
||||
|
@ -7246,13 +7257,9 @@ static Dart_Isolate RunLoopTestCallback(const char* script_name,
|
|||
return isolate;
|
||||
}
|
||||
Dart_EnterScope();
|
||||
Dart_Handle url = NewString(TestCase::url());
|
||||
Dart_Handle source = NewString(kScriptChars);
|
||||
Dart_Handle result = Dart_SetLibraryTagHandler(TestCase::library_handler);
|
||||
EXPECT_VALID(result);
|
||||
Dart_Handle lib = Dart_LoadScript(url, Dart_Null(), source, 0, 0);
|
||||
Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL);
|
||||
EXPECT_VALID(lib);
|
||||
result = Dart_FinalizeLoading(false);
|
||||
Dart_Handle result = Dart_FinalizeLoading(false);
|
||||
EXPECT_VALID(result);
|
||||
Dart_ExitScope();
|
||||
Dart_ExitIsolate();
|
||||
|
@ -7626,11 +7633,7 @@ TEST_CASE(NativeFunctionClosure) {
|
|||
Dart_Handle result;
|
||||
|
||||
// Load a test script.
|
||||
Dart_Handle url = NewString(TestCase::url());
|
||||
Dart_Handle source = NewString(kScriptChars);
|
||||
result = Dart_SetLibraryTagHandler(library_handler);
|
||||
EXPECT_VALID(result);
|
||||
Dart_Handle lib = Dart_LoadScript(url, Dart_Null(), source, 0, 0);
|
||||
Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL);
|
||||
EXPECT_VALID(lib);
|
||||
EXPECT(Dart_IsLibrary(lib));
|
||||
result = Dart_SetNativeResolver(lib, &MyNativeClosureResolver, NULL);
|
||||
|
@ -7770,11 +7773,7 @@ TEST_CASE(NativeStaticFunctionClosure) {
|
|||
Dart_Handle result;
|
||||
|
||||
// Load a test script.
|
||||
Dart_Handle url = NewString(TestCase::url());
|
||||
Dart_Handle source = NewString(kScriptChars);
|
||||
result = Dart_SetLibraryTagHandler(library_handler);
|
||||
EXPECT_VALID(result);
|
||||
Dart_Handle lib = Dart_LoadScript(url, Dart_Null(), source, 0, 0);
|
||||
Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL);
|
||||
EXPECT_VALID(lib);
|
||||
EXPECT(Dart_IsLibrary(lib));
|
||||
result = Dart_SetNativeResolver(lib, &MyStaticNativeClosureResolver, NULL);
|
||||
|
|
|
@ -89,6 +89,10 @@ struct TestLibEntry {
|
|||
|
||||
static MallocGrowableArray<TestLibEntry>* test_libs_ = NULL;
|
||||
|
||||
const char* TestCase::url() {
|
||||
return (FLAG_use_dart_frontend) ? RESOLVED_USER_TEST_URI : USER_TEST_URI;
|
||||
}
|
||||
|
||||
void TestCase::AddTestLib(const char* url, const char* source) {
|
||||
if (test_libs_ == NULL) {
|
||||
test_libs_ = new MallocGrowableArray<TestLibEntry>();
|
||||
|
@ -155,15 +159,14 @@ static Dart_Handle ResolvePackageUri(const char* uri_chars) {
|
|||
|
||||
static ThreadLocalKey script_reload_key = kUnsetThreadLocalKey;
|
||||
|
||||
static char* CompileTestScriptWithDFE(const char* url,
|
||||
const char* source,
|
||||
void** kernel_pgm) {
|
||||
char* TestCase::CompileTestScriptWithDFE(const char* url,
|
||||
const char* source,
|
||||
void** kernel_pgm) {
|
||||
Zone* zone = Thread::Current()->zone();
|
||||
char* filename = OS::SCreate(zone, "file:///%s", url);
|
||||
// clang-format off
|
||||
Dart_SourceFile sourcefiles[] = {
|
||||
{
|
||||
filename, source,
|
||||
url, source,
|
||||
},
|
||||
{
|
||||
"file:///.packages", "untitled:/"
|
||||
|
@ -171,7 +174,7 @@ static char* CompileTestScriptWithDFE(const char* url,
|
|||
// clang-format on
|
||||
int sourcefiles_count = sizeof(sourcefiles) / sizeof(Dart_SourceFile);
|
||||
Dart_KernelCompilationResult compilation_result =
|
||||
Dart_CompileSourcesToKernel(filename, sourcefiles_count, sourcefiles);
|
||||
Dart_CompileSourcesToKernel(url, sourcefiles_count, sourcefiles);
|
||||
|
||||
if (compilation_result.status != Dart_KernelCompilationStatus_Ok) {
|
||||
return OS::SCreate(zone, "Compilation failed %s", compilation_result.error);
|
||||
|
@ -204,9 +207,11 @@ static Dart_Handle LibraryTagHandler(Dart_LibraryTag tag,
|
|||
return Dart_NewApiError("accessing url characters failed");
|
||||
}
|
||||
void* kernel_pgm;
|
||||
char* error = CompileTestScriptWithDFE(urlstr, script_source, &kernel_pgm);
|
||||
char* error =
|
||||
TestCase::CompileTestScriptWithDFE(urlstr, script_source, &kernel_pgm);
|
||||
if (error == NULL) {
|
||||
return Dart_LoadKernel(kernel_pgm);
|
||||
return Dart_LoadScript(url, Dart_Null(),
|
||||
reinterpret_cast<Dart_Handle>(kernel_pgm), 0, 0);
|
||||
} else {
|
||||
return Dart_NewApiError(error);
|
||||
}
|
||||
|
@ -321,12 +326,15 @@ static Dart_Handle LoadTestScriptWithDFE(const char* script,
|
|||
Dart_NativeEntryResolver resolver,
|
||||
const char* lib_url,
|
||||
bool finalize_classes) {
|
||||
Dart_Handle url = NewString(lib_url);
|
||||
Dart_Handle result = Dart_SetLibraryTagHandler(LibraryTagHandler);
|
||||
EXPECT_VALID(result);
|
||||
void* kernel_pgm = NULL;
|
||||
char* error = CompileTestScriptWithDFE(lib_url, script, &kernel_pgm);
|
||||
char* error =
|
||||
TestCase::CompileTestScriptWithDFE(lib_url, script, &kernel_pgm);
|
||||
if (error == NULL) {
|
||||
Dart_Handle lib = Dart_LoadKernel(kernel_pgm);
|
||||
Dart_Handle lib = Dart_LoadScript(
|
||||
url, Dart_Null(), reinterpret_cast<Dart_Handle>(kernel_pgm), 0, 0);
|
||||
DART_CHECK_VALID(lib);
|
||||
result = Dart_SetNativeResolver(lib, resolver, NULL);
|
||||
DART_CHECK_VALID(result);
|
||||
|
@ -348,7 +356,10 @@ Dart_Handle TestCase::LoadTestScript(const char* script,
|
|||
return LoadTestScriptWithVMParser(script, resolver, lib_url,
|
||||
finalize_classes);
|
||||
} else {
|
||||
return LoadTestScriptWithDFE(script, resolver, lib_url, finalize_classes);
|
||||
Zone* zone = Thread::Current()->zone();
|
||||
char* resolved_lib_url = OS::SCreate(zone, "file:///%s", lib_url);
|
||||
return LoadTestScriptWithDFE(script, resolver, resolved_lib_url,
|
||||
finalize_classes);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -275,6 +275,7 @@ class TestCaseBase {
|
|||
};
|
||||
|
||||
#define USER_TEST_URI "test-lib"
|
||||
#define RESOLVED_USER_TEST_URI "file:///test-lib"
|
||||
#define CORELIB_TEST_URI "dart:test-lib"
|
||||
|
||||
class TestCase : TestCaseBase {
|
||||
|
@ -283,6 +284,9 @@ class TestCase : TestCaseBase {
|
|||
|
||||
TestCase(RunEntry* run, const char* name) : TestCaseBase(name), run_(run) {}
|
||||
|
||||
static char* CompileTestScriptWithDFE(const char* url,
|
||||
const char* source,
|
||||
void** kernel_pgm);
|
||||
static Dart_Handle LoadTestScript(const char* script,
|
||||
Dart_NativeEntryResolver resolver,
|
||||
const char* lib_uri = USER_TEST_URI,
|
||||
|
@ -290,7 +294,7 @@ class TestCase : TestCaseBase {
|
|||
static Dart_Handle LoadCoreTestScript(const char* script,
|
||||
Dart_NativeEntryResolver resolver);
|
||||
static Dart_Handle lib();
|
||||
static const char* url() { return USER_TEST_URI; }
|
||||
static const char* url();
|
||||
static Dart_Isolate CreateTestIsolateFromSnapshot(uint8_t* buffer,
|
||||
const char* name = NULL) {
|
||||
return CreateIsolate(buffer, name);
|
||||
|
|
|
@ -210,3 +210,4 @@ Language/Types/Static_Types/malformed_type_t04: RuntimeError
|
|||
[ $compiler == dartk || $compiler == dartkp ]
|
||||
Language/Libraries_and_Scripts/Imports/deferred_import_t01: CompileTimeError # Deferred loading kernel issue 28335.
|
||||
Language/Libraries_and_Scripts/Imports/deferred_import_t02: CompileTimeError # Deferred loading kernel issue 28335.
|
||||
Language/Libraries_and_Scripts/Scripts/top_level_main_t02: RuntimeError
|
||||
|
|
|
@ -185,8 +185,8 @@ constructor_redirect_test/01: MissingCompileTimeError # Fasta bug: Initializer r
|
|||
|
||||
malformed_test/none: RuntimeError # Fasta bug: Leads to assertion error in Fasta.
|
||||
|
||||
export_double_same_main_test: CompileTimeError # Fasta bug: Main is exported.
|
||||
export_main_test: CompileTimeError # Fasta bug: Main is exported.
|
||||
export_double_same_main_test: CompileTimeError # Issue 29989
|
||||
export_main_test: CompileTimeError # Issue 29989
|
||||
|
||||
const_constructor_nonconst_field_test/01: MissingCompileTimeError # Fasta bug: Non-const expression in field initializer.
|
||||
|
||||
|
|
|
@ -48,9 +48,13 @@ Future _processLoadRequest(request) async {
|
|||
final String inputFileUri = request[2];
|
||||
final Uri script = Uri.base.resolve(inputFileUri);
|
||||
|
||||
FileSystem fileSystem = request.length > 3
|
||||
? _buildFileSystem(request[3])
|
||||
: PhysicalFileSystem.instance;
|
||||
FileSystem fileSystem = PhysicalFileSystem.instance;
|
||||
bool requireMain = true;
|
||||
|
||||
if (request.length > 3) {
|
||||
fileSystem = _buildFileSystem(request[3]);
|
||||
requireMain = false;
|
||||
}
|
||||
|
||||
Uri packagesUri = (Platform.packageConfig != null)
|
||||
? Uri.parse(Platform.packageConfig)
|
||||
|
@ -90,7 +94,10 @@ Future _processLoadRequest(request) async {
|
|||
|
||||
CompilationResult result;
|
||||
try {
|
||||
Program program = await kernelForProgram(script, options);
|
||||
Program program = requireMain
|
||||
? await kernelForProgram(script, options)
|
||||
: await kernelForBuildUnit([script], options..chaseDependencies = true);
|
||||
|
||||
if (errors.isNotEmpty) {
|
||||
// TODO(sigmund): the compiler prints errors to the console, so we
|
||||
// shouldn't print those messages again here.
|
||||
|
|
Loading…
Reference in a new issue