31const char* Benchmark::executable_ =
nullptr;
55 if (!
error.IsNull()) {
56 OS::PrintErr(
"Unexpected error in CorelibCompileAll benchmark:\n%s",
57 error.ToErrorCString());
68 char* kernel_service_path =
70 EXPECT(kernel_service_path !=
nullptr);
71 const char* compiler_path =
"%s%sgen%skernel_service.dill";
72 const char* path_separator = File::PathSeparator();
73 ASSERT(path_separator !=
nullptr && strlen(path_separator) == 1);
74 char* ptr = strrchr(kernel_service_path, *path_separator);
75 while (ptr !=
nullptr) {
78 kernel_service_path, path_separator, path_separator);
79 if (File::Exists(
nullptr,
buffer)) {
82 ptr = strrchr(kernel_service_path, *path_separator);
84 free(kernel_service_path);
95 const int kNumIterations = 1000;
97 Isolate* isolate = thread->isolate();
99 for (
int i = 0;
i < kNumIterations;
i++) {
129 intptr_t receiver_value;
132 EXPECT_EQ(7, receiver_value);
145 EXPECT_LE(0, value1);
146 EXPECT_LE(value1, 1000000);
154 bool* auto_setup_scope) {
155 ASSERT(auto_setup_scope !=
nullptr);
156 *auto_setup_scope =
true;
157 const char* cstr =
nullptr;
160 if (strcmp(cstr,
"init") == 0) {
168 const int kNumIterations = 1000000;
169 const char* kScriptChars = R
"(
170import 'dart:nativewrappers';
172base class Class extends NativeFieldWrapperClass1 {
173 @pragma("vm:external-name", "init")
174 external void init();
175 @pragma("vm:external-name", "method")
176 external int method(int param1, int param2);
179void benchmark(int count) {
182 for (int i = 0; i < count; i++) {
212 bool* auto_setup_scope) {
213 ASSERT(auto_setup_scope !=
nullptr);
214 *auto_setup_scope =
false;
230 intptr_t kernel_buffer_size =
file->Length();
231 uint8_t* kernel_buffer =
232 reinterpret_cast<uint8_t*
>(
malloc(kernel_buffer_size));
233 bool read_fully =
file->ReadFully(kernel_buffer, kernel_buffer_size);
247 const bool old_flag = FLAG_background_compilation;
248 FLAG_background_compilation =
false;
252 FLAG_background_compilation = old_flag;
271 const int kNumIterations = 100;
273 for (
int i = 0;
i < kNumIterations;
i++) {
277 while (
frame !=
nullptr) {
278 if (
frame->IsStubFrame()) {
281 }
else if (
frame->IsDartFrame()) {
296 bool* auto_setup_scope) {
297 ASSERT(auto_setup_scope !=
nullptr);
298 *auto_setup_scope =
false;
304 const char* kScriptChars =
307 @pragma('vm:external-name', 'StackFrame_accessFrame')
308 external static int accessFrame();
312 int method1(int param) {
314 param = method2(200);
316 param = method2(100);
320 int method2(int param) {
322 return First.staticmethod(this, param);
324 return First.staticmethod(this, 10);
327 static int staticmethod(First obj, int param) {
329 return obj.method3(10);
331 return obj.method3(200);
334 int method3(int param) {
335 return StackFrame.accessFrame();
338 class StackFrameTest {
339 static int testMain() {
340 First obj = new First();
341 return obj.method1(1);
350 int64_t elapsed_time = 0;
357 const char* kScriptChars =
358 "import 'dart:async';\n"
359 "import 'dart:core';\n"
360 "import 'dart:collection';\n"
361 "import 'dart:_internal';\n"
362 "import 'dart:math';\n"
363 "import 'dart:isolate';\n"
364 "import 'dart:mirrors';\n"
365 "import 'dart:typed_data';\n"
373 TransitionNativeToVM transition(thread);
374 StackZone zone(thread);
381 FullSnapshotWriter writer(
384 writer.WriteFullSnapshot();
385 const Snapshot* snapshot =
388 benchmark->set_score(snapshot->length());
392 const char* kScriptChars =
393 "import 'dart:async';\n"
394 "import 'dart:core';\n"
395 "import 'dart:collection';\n"
396 "import 'dart:convert';\n"
397 "import 'dart:math';\n"
398 "import 'dart:isolate';\n"
399 "import 'dart:mirrors';\n"
400 "import 'dart:typed_data';\n"
401 "import 'dart:io';\n"
402 "import 'dart:cli';\n"
421 writer.WriteFullSnapshot();
429 const char* kScriptChars =
430 "import 'dart:mirrors';\n"
432 "void benchmark() {\n"
433 " currentMirrorSystem();\n"
448 const char* kScriptChars =
449 "import 'dart:core';\n"
451 const intptr_t kLoopCount = 1000000;
461 for (intptr_t
i = 0;
i < kLoopCount;
i++) {
466 int64_t elapsed_time = timer.TotalElapsedTime();
471 TransitionNativeToVM transition(thread);
472 StackZone zone(thread);
474 const intptr_t kLoopCount = 1000000;
477 for (intptr_t
i = 0;
i < kLoopCount;
i++) {
479 std::unique_ptr<Message>
message =
492 TransitionNativeToVM transition(thread);
493 StackZone zone(thread);
495 const intptr_t kLoopCount = 1000000;
498 for (intptr_t
i = 0;
i < kLoopCount;
i++) {
500 std::unique_ptr<Message>
message =
513 TransitionNativeToVM transition(thread);
514 StackZone zone(thread);
518 const intptr_t kLoopCount = 1000000;
521 for (intptr_t
i = 0;
i < kLoopCount;
i++) {
522 StackZone zone(thread);
523 std::unique_ptr<Message>
message =
531 int64_t elapsed_time = timer.TotalElapsedTime();
536 const char* kScript =
539 " for (int i = 0; i < 100000; ++i) m[i*13+i*(i>>7)] = i;\n"
546 TransitionNativeToVM transition(thread);
547 StackZone zone(thread);
550 const intptr_t kLoopCount = 100;
553 for (intptr_t
i = 0;
i < kLoopCount;
i++) {
554 StackZone zone(thread);
562 int64_t elapsed_time = timer.TotalElapsedTime();
static ObjectPtr UnwrapHandle(Dart_Handle object)
static Dart_Handle CheckAndFinalizePendingClasses(Thread *thread)
static ArrayPtr New(intptr_t len, Heap::Space space=Heap::kNew)
static const char * Executable()
static void RunAll(const char *executable)
static void SetExecutable(const char *arg)
static constexpr intptr_t kInitialSize
static ErrorPtr CompileAll(bool ignore_error=false)
static void static void PrintErr(const char *format,...) PRINTF_ATTRIBUTE(1
static SmiPtr New(intptr_t value)
static const Snapshot * SetupFromBuffer(const void *raw_memory)
@ kNoCrossThreadIteration
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_Isolate CreateTestIsolate(const char *name=nullptr, void *isolate_group_data=nullptr, void *isolate_data=nullptr)
static Dart_Handle LoadCoreTestScript(const char *script, Dart_NativeEntryResolver resolver)
static Thread * Current()
int64_t TotalElapsedTime() const
static int SNPrint(char *str, size_t size, const char *format,...) PRINTF_ATTRIBUTE(3
static char * StrDup(const char *s)
static void SetNativeResolver(BuiltinLibraryId id)
struct _Dart_Handle * Dart_Handle
struct _Dart_Isolate * Dart_Isolate
struct _Dart_NativeArguments * Dart_NativeArguments
void(* Dart_NativeFunction)(Dart_NativeArguments arguments)
G_BEGIN_DECLS G_MODULE_EXPORT FlValue * args
const uint8_t uint32_t uint32_t GError ** error
const uint8_t * isolate_snapshot_data
const uint8_t * vm_snapshot_data
static Dart_NativeFunction NativeResolver(Dart_Handle name, int arg_count, bool *auto_setup_scope)
ObjectPtr ReadMessage(Thread *thread, Message *message)
DART_EXPORT Dart_Handle Dart_FinalizeLoading(bool complete_futures)
DART_EXPORT void Dart_EnterIsolate(Dart_Isolate isolate)
BENCHMARK(CorelibCompileAll)
DART_EXPORT Dart_Handle Dart_Invoke(Dart_Handle target, Dart_Handle name, int number_of_arguments, Dart_Handle *arguments)
DART_EXPORT Dart_Handle Dart_GetClass(Dart_Handle library, Dart_Handle class_name)
static void UseDartApi(Dart_NativeArguments args)
void * malloc(size_t size)
DART_EXPORT Dart_Handle Dart_NewInteger(int64_t value)
BENCHMARK_SIZE(CoreSnapshotSize)
DART_EXPORT void Dart_SetReturnValue(Dart_NativeArguments args, Dart_Handle retval)
static char * ComputeKernelServicePath(const char *arg)
DART_EXPORT Dart_Isolate Dart_CurrentIsolate()
DART_EXPORT bool Dart_IsError(Dart_Handle handle)
DART_EXPORT Dart_Handle Dart_SetNativeInstanceField(Dart_Handle obj, int index, intptr_t value)
static void InitNativeFields(Dart_NativeArguments args)
BENCHMARK_MEMORY(InitialRSS)
DART_EXPORT Dart_Handle Dart_SetNativeResolver(Dart_Handle library, Dart_NativeEntryResolver resolver, Dart_NativeEntrySymbol symbol)
static Dart_NativeFunction bm_uda_lookup(Dart_Handle name, int argument_count, bool *auto_setup_scope)
DART_EXPORT Dart_Handle Dart_GetNativeArgument(Dart_NativeArguments args, int index)
DART_EXPORT void Dart_ExitIsolate()
Dart_Handle NewString(const char *str)
static void vmservice_resolver(Dart_NativeArguments args)
DART_EXPORT Dart_Handle Dart_CompileAll()
std::unique_ptr< Message > WriteMessage(bool same_group, const Object &obj, Dart_Port dest_port, Message::Priority priority)
DART_EXPORT Dart_Handle Dart_IntegerFitsIntoInt64(Dart_Handle integer, bool *fits)
DART_EXPORT Dart_Handle Dart_LookupLibrary(Dart_Handle url)
DART_EXPORT int Dart_GetNativeArgumentCount(Dart_NativeArguments args)
DART_EXPORT Dart_Handle Dart_LoadScriptFromKernel(const uint8_t *buffer, intptr_t buffer_size)
DART_EXPORT bool Dart_IsInteger(Dart_Handle object)
DART_EXPORT Dart_Handle Dart_StringToCString(Dart_Handle object, const char **cstr)
DART_EXPORT void Dart_ShutdownIsolate()
DART_EXPORT Dart_Handle Dart_GetNativeReceiver(Dart_NativeArguments args, intptr_t *value)
static Dart_NativeFunction StackFrameNativeResolver(Dart_Handle name, int arg_count, bool *auto_setup_scope)
static void StackFrame_accessFrame(Dart_NativeArguments args)
DART_EXPORT Dart_Handle Dart_IntegerToInt64(Dart_Handle integer, int64_t *value)
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
SI auto map(std::index_sequence< I... >, Fn &&fn, const Args &... args) -> skvx::Vec< sizeof...(I), decltype(fn(args[0]...))>
#define RESOLVED_USER_TEST_URI
#define EXPECT_VALID(handle)
#define ARRAY_SIZE(array)