43 if (_msg !=
nullptr) {
51 response_obj =
message->raw_obj();
56 if (response_obj.IsString()) {
58 response ^= response_obj.
ptr();
61 ASSERT(response_obj.IsArray());
63 response_array ^= response_obj.
ptr();
66 response ^= response_array.
At(0);
73 const char*
msg()
const {
return _msg; }
91 Api::UnwrapGrowableObjectArrayHandle(zone, expr_val);
96 growable.
Add(dummy_isolate_id);
101 growable.
Add(dummy_isolate_id);
108 va_list measure_args;
129static ClassPtr
GetClass(
const Library& lib,
const char*
name) {
145 const char* kScript =
"main() => throw 'HI THERE STICKY';\n";
147 Isolate* isolate = thread->isolate();
164 EXPECT_NOTSUBSTRING(
"\"error\":",
js.ToCString());
165 EXPECT_NOTSUBSTRING(
"HI THERE STICKY",
js.ToCString());
166 EXPECT_NOTSUBSTRING(
"PauseExit",
js.ToCString());
181 EXPECT_SUBSTRING(
"\"error\":",
js.ToCString());
182 EXPECT_SUBSTRING(
"HI THERE STICKY",
js.ToCString());
183 EXPECT_SUBSTRING(
"PauseExit",
js.ToCString());
188 Zone* zone = thread->zone();
189 Isolate* isolate = thread->isolate();
202 EXPECT_STREQ(
"objects/0", always_new_zone.
GetServiceId(test_a));
203 EXPECT_STREQ(
"objects/1", always_new_zone.
GetServiceId(test_a));
204 EXPECT_STREQ(
"objects/2", always_new_zone.
GetServiceId(test_a));
205 EXPECT_STREQ(
"objects/3", always_new_zone.
GetServiceId(test_b));
206 EXPECT_STREQ(
"objects/4", always_new_zone.
GetServiceId(test_c));
211 EXPECT_STREQ(
"objects/0", reuse_zone.
GetServiceId(test_a));
212 EXPECT_STREQ(
"objects/0", reuse_zone.
GetServiceId(test_a));
213 EXPECT_STREQ(
"objects/3", reuse_zone.
GetServiceId(test_b));
214 EXPECT_STREQ(
"objects/3", reuse_zone.
GetServiceId(test_b));
215 EXPECT_STREQ(
"objects/4", reuse_zone.
GetServiceId(test_c));
216 EXPECT_STREQ(
"objects/4", reuse_zone.
GetServiceId(test_c));
217 EXPECT_STREQ(
"objects/5", reuse_zone.
GetServiceId(test_d));
218 EXPECT_STREQ(
"objects/5", reuse_zone.
GetServiceId(test_d));
222 const char* kScript =
229 " var d = () { b(); };\n"
234 " var z = new A();\n"
239 Isolate* isolate = thread->isolate();
262 EXPECT_GT(code_c.
Size(), 16u);
279 Eval(lib,
"[0, port, '0', 'getObject', ['objectId'], ['code/0']]");
282 EXPECT_SUBSTRING(
"\"error\"", handler.
msg());
286 service_msg =
EvalF(lib,
287 "[0, port, '0', 'getObject', "
288 "['objectId'], ['code/%" Px64 "-%" Px "']]",
289 compile_timestamp, entry);
292 EXPECT_SUBSTRING(
"\"type\":\"Code\"", handler.
msg());
298 "\"fixedId\":true,\"id\":\"code\\/%" Px64 "-%" Px "\",",
299 compile_timestamp, entry);
305 uintptr_t address = entry + 16;
306 service_msg =
EvalF(lib,
307 "[0, port, '0', 'getObject', "
308 "['objectId'], ['code/%" Px64 "-%" Px "']]",
309 compile_timestamp, address);
312 EXPECT_SUBSTRING(
"\"error\"", handler.
msg());
317 service_msg =
EvalF(lib,
318 "[0, port, '0', 'getObject', "
319 "['objectId'], ['code/%" Px64 "-%" Px "']]",
320 compile_timestamp - 1, address);
323 EXPECT_SUBSTRING(
"\"error\"", handler.
msg());
327 service_msg =
EvalF(lib,
328 "[0, port, '0', 'getObject', "
329 "['objectId'], ['code/native-%" Px "']]",
334 EXPECT_SUBSTRING(
"\"kind\":\"Null\"", handler.
msg());
337 service_msg =
EvalF(lib,
338 "[0, port, '0', 'getObject', ['objectId'], "
339 "['code/native%" Px "']]",
343 EXPECT_SUBSTRING(
"\"error\"", handler.
msg());
347 const char* kScript =
354 " var d = () { b(); };\n"
359 " var z = new A();\n"
364 Isolate* isolate = thread->isolate();
404 service_msg =
EvalF(lib,
405 "[0, port, '0', 'getObject', "
406 "['objectId'], ['objects/%" Pd "']]",
411 EXPECT_SUBSTRING(
"\"type\":\"Object\"", handler.
msg());
412 EXPECT_SUBSTRING(
"\"_vmType\":\"PcDescriptors\"", handler.
msg());
414 EXPECT_SUBSTRING(
"\"members\":[", handler.
msg());
418 const char* kScript =
425 " var d = () { b(); };\n"
430 " var z = new A();\n"
435 Isolate* isolate = thread->isolate();
475 service_msg =
EvalF(lib,
476 "[0, port, '0', 'getObject', "
477 "['objectId'], ['objects/%" Pd "']]",
482 EXPECT_SUBSTRING(
"\"type\":\"Object\"", handler.
msg());
483 EXPECT_SUBSTRING(
"\"_vmType\":\"LocalVarDescriptors\"", handler.
msg());
485 EXPECT_SUBSTRING(
"\"members\":[", handler.
msg());
491 const char* kScript =
497 "var global = new A();\n"
502 Isolate* isolate = thread->isolate();
536 service_msg =
Eval(lib,
"[0, port, '0', '_getPersistentHandles', [], []]");
540 EXPECT_SUBSTRING(
"\"type\":\"_PersistentHandles\"", handler.
msg());
541 EXPECT_SUBSTRING(
"\"peer\":\"0xdeadbeef\"", handler.
msg());
542 EXPECT_SUBSTRING(
"\"name\":\"A\"", handler.
msg());
543 EXPECT_SUBSTRING(
"\"externalSize\":\"128\"", handler.
msg());
553 service_msg =
Eval(lib,
"[0, port, '0', '_getPersistentHandles', [], []]");
556 EXPECT_SUBSTRING(
"\"type\":\"_PersistentHandles\"", handler.
msg());
558 EXPECT_NOTSUBSTRING(
"\"peer\":\"0xdeadbeef\"", handler.
msg());
559 EXPECT_NOTSUBSTRING(
"\"name\":\"A\"", handler.
msg());
560 EXPECT_NOTSUBSTRING(
"\"externalSize\":\"128\"", handler.
msg());
564 const char** option_keys,
565 const char** option_values,
566 intptr_t num_options,
574 const char** option_keys,
575 const char** option_values,
576 intptr_t num_options,
584 const char* kScript =
590 " x = (x / 13).floor();\n"
617 service_msg =
Eval(lib,
"[0, port, '\"', 'alpha', [], []]");
620 EXPECT_STREQ(
"{\"jsonrpc\":\"2.0\", \"result\":alpha,\"id\":\"\\\"\"}",
622 service_msg =
Eval(lib,
"[0, port, 1, 'beta', [], []]");
625 EXPECT_STREQ(
"{\"jsonrpc\":\"2.0\", \"error\":beta,\"id\":1}", handler.
msg());
629 const char* kScript =
635 " x = (x / 13).floor();\n"
662 Isolate* isolate = thread->isolate();
664 service_msg =
Eval(lib,
"[0, port, '0', 'alpha', [], []]");
667 EXPECT_STREQ(
"{\"jsonrpc\":\"2.0\", \"result\":alpha,\"id\":\"0\"}",
669 service_msg =
Eval(lib,
"[0, port, '0', 'beta', [], []]");
672 EXPECT_STREQ(
"{\"jsonrpc\":\"2.0\", \"error\":beta,\"id\":\"0\"}",
677#if !defined(TARGET_ARCH_ARM64)
680 if (!FLAG_profiler) {
681 FLAG_profiler =
true;
688 const char* kScript =
694 " x = (x / 13).floor();\n"
697 Isolate* isolate = thread->isolate();
720 service_msg =
Eval(lib,
"[0, port, '0', 'getCpuSamples', [], []]");
724 EXPECT_SUBSTRING(
"\"type\":\"CpuSamples\"", handler.
msg());
731 const auto& elements =
738 const auto& elements =
741 EXPECT_EQ(0, elements.Length());
745 const auto& elements =
748 EXPECT_EQ(1, elements.Length());
750 element ^= elements.At(0);
751 EXPECT(element.Equals(
"a"));
755 const auto& elements =
758 EXPECT_EQ(2, elements.Length());
760 element ^= elements.At(0);
761 EXPECT(element.Equals(
"abc"));
762 element ^= elements.At(1);
763 EXPECT(element.Equals(
"def"));
767 const auto& elements =
769 EXPECT_EQ(0,
ParseJSONArray(thread,
"[abc, def, ghi]", elements));
770 EXPECT_EQ(3, elements.Length());
772 element ^= elements.At(0);
773 EXPECT(element.Equals(
"abc"));
774 element ^= elements.At(1);
775 EXPECT(element.Equals(
"def"));
776 element ^= elements.At(2);
777 EXPECT(element.Equals(
"ghi"));
781 const auto& elements =
784 EXPECT_EQ(3, elements.Length());
786 element ^= elements.At(0);
787 EXPECT(element.Equals(
"abc"));
788 element ^= elements.At(1);
789 EXPECT(element.Equals(
""));
790 element ^= elements.At(2);
791 EXPECT(element.Equals(
"ghi"));
static const size_t kBufferSize
static Dart_Handle NewHandle(Thread *thread, ObjectPtr raw)
static ObjectPtr UnwrapHandle(Dart_Handle object)
ObjectPtr At(intptr_t index) const
static ArrayPtr MakeFixedLength(const GrowableObjectArray &growable_array, bool unique=false)
PcDescriptorsPtr pc_descriptors() const
LocalVarDescriptorsPtr GetLocalVarDescriptors() const
uword PayloadStart() const
int64_t compile_timestamp() const
CodePtr CurrentCode() const
void Add(const Object &value, Heap::Space space=Heap::kNew) const
static GrowableObjectArrayPtr New(Heap::Space space=Heap::kNew)
static Isolate * Current()
void PrintJSON(JSONStream *stream, bool ref=true)
void set_is_runnable(bool value)
ObjectIdRing * EnsureObjectIdRing()
MessageStatus HandleNextMessage()
int32_t GetIdForObject(ObjectPtr raw_obj, IdPolicy policy=kAllocateId)
static void ClosePorts(MessageHandler *handler)
static Dart_Port CreatePort(MessageHandler *handler)
static FunctionPtr ResolveDynamicFunction(Zone *zone, const Class &receiver_class, const String &function_name)
void Init(ObjectIdRing *ring, ObjectIdRing::IdPolicy policy)
virtual char * GetServiceId(const Object &obj)
static SendPortPtr New(Dart_Port id, Heap::Space space=Heap::kNew)
ServiceTestMessageHandler()
MessageStatus HandleMessage(std::unique_ptr< Message > message)
~ServiceTestMessageHandler()
virtual Isolate * isolate() const
static ErrorPtr HandleRootMessage(const Array &message)
static ErrorPtr HandleIsolateMessage(Isolate *isolate, const Array &message)
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 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 Thread * Current()
void * DataAddr(intptr_t byte_offset) const
static int SNPrint(char *str, size_t size, const char *format,...) PRINTF_ATTRIBUTE(3
static char * StrDup(const char *s)
static int static int VSNPrint(char *str, size_t size, const char *format, va_list args)
ElementType * Alloc(intptr_t length)
struct _Dart_Handle * Dart_Handle
Dart_Handle Dart_PersistentHandle
struct _Dart_WeakPersistentHandle * Dart_WeakPersistentHandle
DART_EXPORT Dart_WeakPersistentHandle Dart_NewWeakPersistentHandle(Dart_Handle object, void *peer, intptr_t external_allocation_size, Dart_HandleFinalizer callback)
ObjectPtr ReadMessage(Thread *thread, Message *message)
static ArrayPtr EvalF(Dart_Handle lib, const char *fmt,...)
Dart_Handle Dart_EvaluateStaticExpr(Dart_Handle lib_handle, Dart_Handle expr_in)
static void HandleIsolateMessage(Isolate *isolate, const Array &msg)
DART_EXPORT Dart_Handle Dart_Invoke(Dart_Handle target, Dart_Handle name, int number_of_arguments, Dart_Handle *arguments)
DART_EXPORT bool Dart_HasStickyError()
DART_EXPORT bool Dart_IsUnhandledExceptionError(Dart_Handle object)
static ArrayPtr Eval(Dart_Handle lib, const char *expr)
FunctionPtr GetFunction(const Library &lib, const char *name)
DART_EXPORT void Dart_RegisterRootServiceRequestCallback(const char *name, Dart_ServiceRequestCallback callback, void *user_data)
DART_EXPORT void Dart_DeletePersistentHandle(Dart_PersistentHandle object)
DART_EXPORT void Dart_DeleteWeakPersistentHandle(Dart_WeakPersistentHandle object)
ISOLATE_UNIT_TEST_CASE(StackAllocatedDestruction)
DEFINE_FLAG(bool, print_cluster_information, false, "Print information about clusters written to snapshot")
static void WeakHandleFinalizer(void *isolate_callback_data, void *peer)
static void EnableProfiler()
ClassPtr GetClass(const Library &lib, const char *name)
DART_EXPORT Dart_Handle Dart_SetField(Dart_Handle container, Dart_Handle name, Dart_Handle value)
Dart_Handle NewString(const char *str)
DART_EXPORT void Dart_SetPausedOnExit(bool paused)
DART_EXPORT bool Dart_IsNull(Dart_Handle object)
DART_EXPORT void Dart_SetStickyError(Dart_Handle error)
DART_EXPORT void Dart_RegisterIsolateServiceRequestCallback(const char *name, Dart_ServiceRequestCallback callback, void *user_data)
static bool beta_callback(const char *name, const char **option_keys, const char **option_values, intptr_t num_options, void *user_data, const char **result)
intptr_t ParseJSONArray(Thread *thread, const char *str, const GrowableObjectArray &elements)
static bool alpha_callback(const char *name, const char **option_keys, const char **option_values, intptr_t num_options, void *user_data, const char **result)
static void HandleRootMessage(const Array &message)
DART_EXPORT Dart_PersistentHandle Dart_NewPersistentHandle(Dart_Handle object)
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 port
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
static SkString fmt(SkColor4f c)
#define EXPECT_VALID(handle)