52 kernel_buffer_ = kernel_buffer;
64 if (first_ ==
nullptr) {
74 while (
test !=
nullptr) {
75 if (
test->raw_test_) {
85 while (
test !=
nullptr) {
86 if (!
test->raw_test_) {
102 ASSERT(kernel_buffer !=
nullptr);
110Dart_Isolate TestCase::CreateIsolate(
const uint8_t* data_buffer,
112 const uint8_t* instr_buffer,
115 void* isolate_data) {
123 name,
name, data_buffer, instr_buffer,
124 &api_flags, group_data, isolate_data, &err);
128 &api_flags, group_data,
131 if (isolate ==
nullptr) {
136 EXPECT(isolate !=
nullptr);
142 void* isolate_data) {
146 group_data, isolate_data);
166 void* isolate_data) {
170 if (
error !=
nullptr) {
196 (*test_libs_)[
i].source =
source;
220@pragma("vm:external-name", "Test_Reload")
221external void reloadTest();
222@pragma("vm:external-name", "Test_CollectNewSpace")
223external void collectNewSpace();
224@pragma("vm:external-name", "Test_CollectOldSpace")
225external void collectOldSpace();
229 return "test:isolate_reload_helper";
232#define RELOAD_NATIVE_LIST(V) \
234 V(Test_CollectNewSpace, 0) \
235 V(Test_CollectOldSpace, 0)
248 bool* auto_setup_scope) {
253 ASSERT(auto_setup_scope !=
nullptr);
254 *auto_setup_scope =
true;
256 for (
int i = 0;
i < num_entries;
i++) {
276 GCTestHelper::CollectNewSpace();
281 GCTestHelper::CollectOldSpace();
299 const uint8_t** kernel_buffer,
300 intptr_t* kernel_buffer_size,
302 bool allow_compile_errors,
303 const char* multiroot_filepaths,
304 const char* multiroot_scheme) {
311 "file:///.packages",
""
316 kernel_buffer, kernel_buffer_size, incrementally, allow_compile_errors,
317 multiroot_filepaths, multiroot_scheme);
321 int sourcefiles_count,
323 const uint8_t** kernel_buffer,
324 intptr_t* kernel_buffer_size,
326 bool allow_compile_errors,
327 const char* multiroot_filepaths,
328 const char* multiroot_scheme) {
332 sourcefiles, incrementally,
false,
333 true,
nullptr, multiroot_filepaths, multiroot_scheme);
338 "An error occurred in the CFE while accepting the most recent"
339 " compilation results.");
342 return ValidateCompilationResult(zone,
result, kernel_buffer,
343 kernel_buffer_size, allow_compile_errors);
346char* TestCase::ValidateCompilationResult(
349 const uint8_t** kernel_buffer,
350 intptr_t* kernel_buffer_size,
351 bool allow_compile_errors) {
352 if (!allow_compile_errors &&
356 free(compilation_result.
error);
357 if (compilation_result.
kernel !=
nullptr) {
358 free(
const_cast<uint8_t*
>(compilation_result.
kernel));
360 *kernel_buffer =
nullptr;
361 *kernel_buffer_size = 0;
364 *kernel_buffer = compilation_result.
kernel;
365 *kernel_buffer_size = compilation_result.
kernel_size;
366 if (compilation_result.
error !=
nullptr) {
367 free(compilation_result.
error);
369 if (kernel_buffer ==
nullptr) {
370 return OS::SCreate(zone,
"front end generated a nullptr kernel file");
384 const char* library_url_cstr;
389 const char* url_cstr;
396 return DartUtils::NewError(
"%s: Unable to canonicalize uri '%s'.",
397 __FUNCTION__, url_cstr);
410 ASSERT(sourcefiles !=
nullptr);
413 intptr_t num_test_libs = 0;
419 (*sourcefiles)[0].
uri = script_url;
420 (*sourcefiles)[0].source =
script;
421 for (intptr_t
i = 0;
i < num_test_libs; ++
i) {
423 (*sourcefiles)[
i + 1].source =
test_libs_->At(
i).source;
425 return num_test_libs + 1;
432 bool finalize_classes) {
439 bool finalize_classes,
440 bool allow_compile_errors) {
446 finalize_classes,
true, allow_compile_errors);
447 delete[] sourcefiles;
459 const char* prefixed_lib_uri =
462 const uint8_t* kernel_buffer =
nullptr;
463 intptr_t kernel_buffer_size = 0;
466 sourcefiles[0].uri, sourcefiles_count, sourcefiles, &kernel_buffer,
467 &kernel_buffer_size,
true);
468 if ((kernel_buffer ==
nullptr) && (
error !=
nullptr)) {
474 kernel_buffer_size,
const_cast<uint8_t*
>(kernel_buffer),
495 bool allow_compile_errors,
496 const char* entry_script_uri,
497 const char* multiroot_filepaths,
498 const char* multiroot_scheme) {
502 const uint8_t* kernel_buffer =
nullptr;
503 intptr_t kernel_buffer_size = 0;
505 entry_script_uri !=
nullptr ? entry_script_uri : sourcefiles[0].uri,
506 sourcefiles_count, sourcefiles, &kernel_buffer, &kernel_buffer_size,
507 incrementally, allow_compile_errors, multiroot_filepaths,
509 if ((kernel_buffer ==
nullptr) &&
error !=
nullptr) {
515 kernel_buffer_size,
const_cast<uint8_t*
>(kernel_buffer),
523 entry_script_uri !=
nullptr ? entry_script_uri : sourcefiles[0].uri));
542 FLAG_gc_during_reload =
true;
543 FLAG_force_evacuation =
true;
549 delete[] sourcefiles;
552 free(compilation_result.
error);
563 bool success =
false;
566 success = do_reload(isolate_group, &
js);
578 TransitionNativeToVM transition(thread);
586 TransitionNativeToVM transition(thread);
597 false, root_script_url,
604 intptr_t kernel_buffer_size) {
607 false, kernel_buffer,
618 delete[] sourcefiles;
621 free(compilation_result.
error);
622 if (compilation_result.
kernel !=
nullptr) {
623 free(
const_cast<uint8_t*
>(compilation_result.
kernel));
632 intptr_t kernel_buffer_size) {
662 const Array& param_names,
663 const Array& param_values) {
673 expr.
ToCString(), param_names, Array::empty_array(),
674 Array::empty_array(), Array::empty_array(), Array::empty_array(),
678 TokenPosition::kNoSource,
687 const_cast<uint8_t*
>(compilation_result.
kernel),
690 val =
lib.EvaluateCompiledExpression(kernel_buffer, Array::empty_array(),
692 TypeArguments::null_type_arguments());
697#if !defined(PRODUCT) && (defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64))
698static bool IsHex(
int c) {
699 return (
'0' <= c && c <=
'9') || (
'a' <= c && c <=
'f');
709 const char* kDummyScript =
"assembler_test_dummy_function() {}";
717 signature,
function_name, UntaggedFunction::kRegularFunction,
true,
false,
728 if (FLAG_disassemble) {
735#if defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64)
740 bool in_hex_constant =
false;
741 for (
char*
p = disassembly_; *
p !=
'\0';
p++) {
742 if (in_hex_constant) {
746 in_hex_constant =
false;
749#if defined(TARGET_ARCH_IA32)
750 if (*
p ==
'[' && *(
p + 1) ==
'0' && *(
p + 2) ==
'x' && IsHex(*(
p + 3)) &&
753 in_hex_constant =
true;
756#if defined(TARGET_ARCH_X64)
757 if (*
p ==
'[' && *(
p + 1) ==
't' && *(
p + 2) ==
'h' && *(
p + 3) ==
'r' &&
758 *(
p + 4) ==
'+' && *(
p + 5) ==
'0' && *(
p + 6) ==
'x' &&
759 IsHex(*(
p + 7)) && IsHex(*(
p + 8))) {
761 in_hex_constant =
true;
783 ASSERT(thread !=
nullptr);
793 const char* postfix) {
795 while (
pos !=
nullptr) {
803 in += strcspn(in, postfix);
807 while (*in !=
'\0') {
static bool ok(int result)
#define RELEASE_ASSERT(cond)
#define FUNCTION_NAME(name)
static Dart_Handle Success()
static Dart_Handle NewHandle(Thread *thread, ObjectPtr raw)
static Dart_Isolate CastIsolate(Isolate *isolate)
static Dart_Handle NewError(const char *format,...) PRINTF_ATTRIBUTE(1
compiler::Assembler * assembler() const
static const Code & Generate(const char *name, const std::function< void(compiler::Assembler *assembler)> &generator)
static bool AllClassesFinalized()
static ClassPtr New(IsolateGroup *isolate_group, bool register_class=true)
void set_exception_handlers(const ExceptionHandlers &handlers) const
static CodePtr FinalizeCodeAndNotify(const Function &function, FlowGraphCompiler *compiler, compiler::Assembler *assembler, PoolAttachment pool_attachment, bool optimized=false, CodeStatistics *stats=nullptr)
uword PayloadStart() const
void set_owner(const Object &owner) const
static bool TestCompileFunction(const Function &function)
static ObjectPtr CompileFunction(Thread *thread, const Function &function)
static void Disassemble(uword start, uword end, DisassemblyFormatter *formatter, const Code &code, const CodeComments *comments=nullptr)
static ExternalTypedDataPtr NewFinalizeWithFree(uint8_t *data, intptr_t len)
static FunctionTypePtr New(intptr_t num_parent_type_arguments=0, Nullability nullability=Nullability::kNonNullable, Heap::Space space=Heap::kOld)
static FunctionPtr New(const FunctionType &signature, const String &name, UntaggedFunction::Kind kind, bool is_static, bool is_const, bool is_abstract, bool is_external, bool is_native, const Object &owner, TokenPosition token_pos, Heap::Space space=Heap::kOld)
bool reload_aborted() const
bool ReloadKernel(JSONStream *js, bool force_reload, const uint8_t *kernel_buffer=nullptr, intptr_t kernel_buffer_size=0, bool dont_delete_reload_context=false)
void DeleteReloadContext()
SafepointRwLock * program_lock()
IsolateGroupReloadContext * reload_context()
bool ReloadSources(JSONStream *js, bool force_reload, const char *root_script_url=nullptr, const char *packages_url=nullptr, bool dont_delete_reload_context=false)
ProgramReloadContext * program_reload_context()
static void FlagsInitialize(Dart_IsolateFlags *api_flags)
KernelBufferList(const uint8_t *kernel_buffer)
void AddBufferToList(const uint8_t *kernel_buffer)
static Dart_KernelCompilationResult UpdateInMemorySources(int source_files_count, Dart_SourceFile source_files[])
static Dart_KernelCompilationResult CompileToKernel(const char *script_uri, const uint8_t *platform_kernel, intptr_t platform_kernel_size, int source_files_count=0, Dart_SourceFile source_files[]=nullptr, bool incremental_compile=true, bool for_snapshot=false, bool embed_sources=true, const char *package_config=nullptr, const char *multiroot_filepaths=nullptr, const char *multiroot_scheme=nullptr, Dart_KernelCompilationVerbosityLevel verbosity=Dart_KernelCompilationVerbosityLevel_All)
static Dart_KernelCompilationResult CompileExpressionToKernel(const uint8_t *platform_kernel, intptr_t platform_kernel_size, const char *expression, const Array &definitions, const Array &definition_types, const Array &type_definitions, const Array &type_bounds, const Array &type_defaults, const char *library_url, const char *klass, const char *method, TokenPosition token_pos, char const *script_uri, bool is_static)
static Dart_KernelCompilationResult AcceptCompilation()
static LibraryPtr CoreLibrary()
static void static void PrintErr(const char *format,...) PRINTF_ATTRIBUTE(1
static char * SCreate(Zone *zone, const char *format,...) PRINTF_ATTRIBUTE(2
virtual const char * ToCString() const
static Object & ZoneHandle()
IsolateGroupReloadContext * group_reload_context()
static ScriptPtr New(const String &url, const String &source)
static StringPtr New(const char *cstr, Heap::Space space=Heap::kNew)
static const char * ToCString(Thread *thread, StringPtr ptr)
static StringPtr New(Thread *thread, const char *cstr)
static void CleanupState()
static void AddToKernelBuffers(const uint8_t *kernel_buffer)
const char * name() const
static KernelBufferList * current_kernel_buffers_
TestCaseBase(const char *name, const char *expectation)
static Dart_Handle TriggerReload(const uint8_t *kernel_buffer, intptr_t kernel_buffer_size)
static Dart_Handle LoadTestScriptWithDFE(int sourcefiles_count, Dart_SourceFile sourcefiles[], Dart_NativeEntryResolver resolver=nullptr, bool finalize=true, bool incrementally=true, bool allow_compile_errors=false, const char *entry_script_uri=nullptr, const char *multiroot_filepaths=nullptr, const char *multiroot_scheme=nullptr)
static void AddTestLib(const char *url, const char *source)
static Dart_Handle LoadTestScript(const char *script, Dart_NativeEntryResolver resolver, const char *lib_uri=RESOLVED_USER_TEST_URI, bool finalize=true, bool allow_compile_errors=false)
static Dart_Handle ReloadTestScript(const char *script)
static char * CompileTestScriptWithDFE(const char *url, const char *source, const uint8_t **kernel_buffer, intptr_t *kernel_buffer_size, bool incrementally=true, bool allow_compile_errors=false, const char *multiroot_filepaths=nullptr, const char *multiroot_scheme=nullptr)
static Dart_Isolate CreateTestIsolateInGroup(const char *name, Dart_Isolate parent, void *group_data=nullptr, void *isolate_data=nullptr)
static Dart_Handle SetReloadTestScript(const char *script)
static const char * url()
static Dart_Handle LoadTestScriptWithErrors(const char *script, Dart_NativeEntryResolver resolver=nullptr, const char *lib_uri=RESOLVED_USER_TEST_URI, bool finalize=true)
static Dart_Handle LoadTestLibrary(const char *lib_uri, const char *script, Dart_NativeEntryResolver resolver=nullptr)
static Dart_Handle ReloadTestKernel(const uint8_t *kernel_buffer, intptr_t kernel_buffer_size)
static Dart_Handle library_handler(Dart_LibraryTag tag, Dart_Handle library, Dart_Handle url)
static Dart_Handle EvaluateExpression(const Library &lib, const String &expr, const Array ¶m_names, const Array ¶m_values)
static Dart_Isolate CreateTestIsolate(const char *name=nullptr, void *isolate_group_data=nullptr, void *isolate_data=nullptr)
static const char * GetTestLib(const char *url)
static Dart_Handle LoadCoreTestScript(const char *script, Dart_NativeEntryResolver resolver)
static Dart_IsolateShutdownCallback shutdown_callback
static Dart_IsolateGroupCreateCallback create_callback
static const char ** argv
static Dart_IsolateGroupCleanupCallback group_cleanup_callback
static const uint8_t * vm_snapshot_data
static Thread * Current()
IsolateGroup * isolate_group() const
static const TokenPosition kMinSource
static bool SetOriginalWorkingDirectory()
static Dart_Handle PrepareForScriptLoading(bool is_service_isolate, bool trace_loading)
intptr_t CodeSize() const
void Ret(Condition cond=AL)
Dart_Isolate(* Dart_IsolateGroupCreateCallback)(const char *script_uri, const char *main, const char *package_root, const char *package_config, Dart_IsolateFlags *flags, void *isolate_data, char **error)
@ Dart_KernelCompilationStatus_Ok
struct _Dart_Handle * Dart_Handle
struct _Dart_Isolate * Dart_Isolate
Dart_NativeFunction(* Dart_NativeEntryResolver)(Dart_Handle name, int num_of_arguments, bool *auto_setup_scope)
struct _Dart_NativeArguments * Dart_NativeArguments
void(* Dart_IsolateGroupCleanupCallback)(void *isolate_group_data)
void(* Dart_IsolateShutdownCallback)(void *isolate_group_data, void *isolate_data)
void(* Dart_NativeFunction)(Dart_NativeArguments arguments)
const uint8_t uint32_t uint32_t GError ** error
Dart_NativeFunction function
#define REGISTER_FUNCTION(name, count)
#define DECLARE_FUNCTION(name, count)
const uint8_t * core_isolate_snapshot_data
const uint8_t * core_isolate_snapshot_instructions
DART_EXPORT bool Dart_IsLibrary(Dart_Handle object)
void ElideJSONSubstring(const char *prefix, const char *in, char *out, const char *postfix)
DART_EXPORT void Dart_EnterScope()
const uint8_t * platform_strong_dill
DART_EXPORT Dart_Handle Dart_FinalizeLoading(bool complete_futures)
static intptr_t BuildSourceFilesArray(Dart_SourceFile **sourcefiles, const char *script, const char *script_url=RESOLVED_USER_TEST_URI)
DART_EXPORT Dart_Handle Dart_RootLibrary()
void FUNCTION_NAME() Test_CollectNewSpace(Dart_NativeArguments native_args)
DART_EXPORT Dart_Handle Dart_NewExternalTypedDataWithFinalizer(Dart_TypedData_Type type, void *data, intptr_t length, void *peer, intptr_t external_allocation_size, Dart_HandleFinalizer callback)
static Dart_Handle LibraryTagHandler(Dart_LibraryTag tag, Dart_Handle library, Dart_Handle url)
DART_EXPORT void Dart_PropagateError(Dart_Handle handle)
void FUNCTION_NAME() Test_Reload(Dart_NativeArguments native_args)
static MallocGrowableArray< TestLibEntry > * test_libs_
static const char * IsolateReloadTestLibUri()
static struct dart::NativeEntries ReloadEntries[]
const intptr_t platform_strong_dill_size
static void LoadIsolateReloadTestLibIfNeeded(const char *script)
DART_EXPORT bool Dart_IsError(Dart_Handle handle)
static Dart_NativeFunction IsolateReloadTestNativeResolver(Dart_Handle name, int argument_count, bool *auto_setup_scope)
CStringUniquePtr ResolveUri(const char *ref_uri, const char *base_uri)
DART_EXPORT Dart_Handle Dart_SetNativeResolver(Dart_Handle library, Dart_NativeEntryResolver resolver, Dart_NativeEntrySymbol symbol)
DART_EXPORT Dart_Isolate Dart_CreateIsolateGroup(const char *script_uri, const char *name, const uint8_t *snapshot_data, const uint8_t *snapshot_instructions, Dart_IsolateFlags *flags, void *isolate_group_data, void *isolate_data, char **error)
Dart_Handle NewString(const char *str)
DART_EXPORT Dart_Handle Dart_LoadLibrary(Dart_Handle kernel_buffer)
DART_EXPORT Dart_Isolate Dart_CreateIsolateGroupFromKernel(const char *script_uri, const char *name, const uint8_t *kernel_buffer, intptr_t kernel_buffer_size, Dart_IsolateFlags *flags, void *isolate_group_data, void *isolate_data, char **error)
void SetupCoreLibrariesForUnitTest()
static const char * kIsolateReloadTestLibSource
DART_EXPORT Dart_Handle Dart_SetLibraryTagHandler(Dart_LibraryTagHandler handler)
DART_EXPORT void Dart_ExitScope()
DART_EXPORT Dart_Handle Dart_NewApiError(const char *error)
DART_EXPORT Dart_Handle Dart_LookupLibrary(Dart_Handle url)
DART_EXPORT Dart_Handle Dart_LibraryUrl(Dart_Handle library)
DART_EXPORT Dart_Handle Dart_Null()
Isolate * CreateWithinExistingIsolateGroup(IsolateGroup *group, const char *name, char **error)
const char *const function_name
DART_EXPORT Dart_Handle Dart_SetRootLibrary(Dart_Handle library)
static void MallocFinalizer(void *isolate_callback_data, void *peer)
DART_EXPORT Dart_Handle Dart_StringToCString(Dart_Handle object, const char **cstr)
void StripTokenPositions(char *buffer)
DART_EXPORT Dart_Handle Dart_NewStringFromCString(const char *str)
RELOAD_NATIVE_LIST(DECLARE_FUNCTION)
DECLARE_FLAG(bool, show_invisible_frames)
void FUNCTION_NAME() Test_CollectOldSpace(Dart_NativeArguments native_args)
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir Path to the cache directory This is different from the persistent_cache_path in embedder which is used for Skia shader cache icu native lib Path to the library file that exports the ICU data vm service The hostname IP address on which the Dart VM Service should be served If not defaults to or::depending on whether ipv6 is specified vm service A custom Dart VM Service port The default is to pick a randomly available open port disable vm Disable the Dart VM Service The Dart VM Service is never available in release mode disable vm service Disable mDNS Dart VM Service publication Bind to the IPv6 localhost address for the Dart VM Service Ignored if vm service host is set endless trace buffer
Dart_KernelCompilationStatus status
const int argument_count_
const uint8_t kPlatformStrongDill[]
intptr_t kPlatformStrongDillSize
#define RESOLVED_USER_TEST_URI
#define EXPECT_VALID(handle)