diff --git a/runtime/bin/BUILD.gn b/runtime/bin/BUILD.gn index efc087b18d2..27c5806691a 100644 --- a/runtime/bin/BUILD.gn +++ b/runtime/bin/BUILD.gn @@ -1137,8 +1137,6 @@ executable("run_vm_tests") { sources = [ "builtin_nolib.cc", - "dfe.cc", - "dfe.h", "error_exit.cc", "error_exit.h", "run_vm_tests.cc", diff --git a/runtime/bin/run_vm_tests.cc b/runtime/bin/run_vm_tests.cc index 9cc4adabb45..6246c4a6425 100644 --- a/runtime/bin/run_vm_tests.cc +++ b/runtime/bin/run_vm_tests.cc @@ -28,10 +28,6 @@ extern const uint8_t kDartCoreIsolateSnapshotInstructions[]; // TODO(iposva, asiva): This is a placeholder for the real unittest framework. namespace dart { -namespace bin { -DFE dfe; -} - // Defined in vm/os_thread_win.cc extern bool private_flag_windows_run_tls_destructors; diff --git a/runtime/tests/vm/vm.status b/runtime/tests/vm/vm.status index 8f854daf233..146f773a827 100644 --- a/runtime/tests/vm/vm.status +++ b/runtime/tests/vm/vm.status @@ -163,7 +163,7 @@ cc/Dart2JSCompileAll: SkipSlow # Timeout. [ $compiler == dartk && $mode == debug && $runtime == vm ] cc/InjectNativeFields1: Crash -cc/InjectNativeFields3: Crash +cc/PrintJSON: Crash cc/Service_TokenStream: Crash # Enabling of dartk for sim{arm,arm64,dbc64} revelaed these test failures, which @@ -174,20 +174,18 @@ cc/StackTraceMallocHookLengthTest: Fail # Please triage. [ $compiler == dartk && $mode == release && $runtime == vm ] cc/InjectNativeFields1: Fail -cc/InjectNativeFields3: Fail cc/Service_TokenStream: Fail [ $compiler == dartk && $runtime == vm ] cc/CanonicalizationInScriptSnapshots: Fail cc/Class_ComputeEndTokenPos: Crash +cc/CorelibCompileAll: Crash +cc/CorelibCompilerStats: Crash cc/DartAPI_CurrentStackTraceInfo: Fail -cc/DartAPI_ImplicitNativeFieldAccess: Crash cc/DartAPI_InjectNativeFields1: Skip -cc/DartAPI_InjectNativeFields3: Crash -cc/DartAPI_InjectNativeFields4: Crash -cc/DartAPI_InjectNativeFieldsSuperClass: Crash cc/DartAPI_InvokeNoSuchMethod: Fail cc/DartAPI_Invoke_CrossLibrary: Crash +cc/DartAPI_IsolateSetCheckedMode: Skip # Checked mode is not relevant for dart 2? cc/DartAPI_IsolateShutdownRunDartCode: Skip # Flaky cc/DartAPI_LazyLoadDeoptimizes: Fail cc/DartAPI_LoadLibrary: Crash @@ -200,13 +198,11 @@ cc/DartAPI_LoadSource: Crash cc/DartAPI_LoadSource_LateLoad: Crash cc/DartAPI_LookupLibrary: Crash cc/DartAPI_NativeFieldAccess: Fail -cc/DartAPI_NegativeNativeFieldInIsolateMessage: Crash cc/DartAPI_ParsePatchLibrary: Crash cc/DartAPI_PropagateError: Fail cc/DartAPI_StackOverflowStackTraceInfoArrowFunction: Fail cc/DartAPI_StackOverflowStackTraceInfoBraceFunction1: Fail cc/DartAPI_StackOverflowStackTraceInfoBraceFunction2: Fail -cc/DartAPI_TestNativeFieldsAccess: Crash cc/DebuggerAPI_BreakpointStubPatching: Fail cc/DebuggerAPI_GetClosureInfo: Fail cc/DebuggerAPI_InterruptIsolate: SkipSlow @@ -217,6 +213,7 @@ cc/Debugger_PrintBreakpointsToJSONArray: Fail cc/Debugger_Rewind_Optimized: SkipSlow cc/Debugger_SetBreakpointInPartOfLibrary: Crash cc/FunctionSourceFingerprint: Fail +cc/GenerateSource: Skip # Cannot generate source from a kernel binary. cc/IsolateReload_DanglingGetter_Library: Fail cc/IsolateReload_DanglingSetter_Class: Fail cc/IsolateReload_DanglingSetter_Instance: Fail @@ -274,7 +271,7 @@ cc/SourcePosition_WhileContinueBreak: Crash cc/SourceReport_CallSites_PolymorphicCall: Fail cc/SourceReport_CallSites_SimpleCall: Fail cc/SourceReport_Coverage_AllFunctions: Fail -cc/SourceReport_Coverage_AllFunctions_ForceCompile: Fail +cc/SourceReport_Coverage_AllFunctions_ForceCompile: Crash cc/SourceReport_Coverage_ForceCompile: Fail cc/SourceReport_Coverage_NestedFunctions: Fail cc/SourceReport_Coverage_NoCalls: Fail @@ -351,6 +348,19 @@ cc/Service_Address: Fail cc/Service_Code: Fail [ $compiler == dartk && $strong ] +cc/DartAPI_ImportLibrary3: Fail # Issue 32190 +cc/DartAPI_LazyLoadDeoptimizes: Crash # Issue 32190 +cc/DartAPI_NativePortPostInteger: Crash # Issue 32190 +cc/DartAPI_NativePortReceiveInteger: Timeout # Issue 32190 +cc/DartAPI_NativePortReceiveNull: Timeout # Issue 32190 +cc/DartAPI_NewNativePort: Crash # Issue 32190 +cc/DartGeneratedArrayLiteralMessages: Crash # Issue 32190 +cc/FullSnapshot1: Crash # Issue 32190 +cc/IsolateReload_LibraryImportAdded: Crash # Issue 32190 +cc/IsolateReload_LibraryImportRemoved: Fail # Issue 32190 +cc/IsolateReload_LibraryLookup: Crash # Issue 32190 +cc/Mixin_PrivateSuperResolutionCrossLibraryShouldFail: Fail # Issue 32190 +cc/StackMapGC: Crash # Issue 32190 dart/optimized_stacktrace_line_and_column_test: CompileTimeError # Issue 31586 dart/optimized_stacktrace_line_test: CompileTimeError # Issue 31586 diff --git a/runtime/vm/benchmark_test.cc b/runtime/vm/benchmark_test.cc index c29a1446241..84b433b5762 100644 --- a/runtime/vm/benchmark_test.cc +++ b/runtime/vm/benchmark_test.cc @@ -16,13 +16,13 @@ #include "vm/compiler_stats.h" #include "vm/dart_api_impl.h" #include "vm/stack_frame.h" -#include "vm/unit_test.h" using dart::bin::File; namespace dart { DECLARE_FLAG(bool, use_dart_frontend); +DECLARE_FLAG(bool, strong); Benchmark* Benchmark::first_ = NULL; Benchmark* Benchmark::tail_ = NULL; @@ -92,19 +92,6 @@ void Benchmark::RunAll(const char* executable) { } } -Dart_Isolate Benchmark::CreateIsolate(const uint8_t* snapshot_data, - const uint8_t* snapshot_instructions) { - char* err = NULL; - Dart_IsolateFlags api_flags; - Isolate::FlagsInitialize(&api_flags); - api_flags.use_dart_frontend = FLAG_use_dart_frontend; - isolate_ = Dart_CreateIsolate(NULL, NULL, snapshot_data, - snapshot_instructions, &api_flags, NULL, &err); - EXPECT(isolate_ != NULL); - free(err); - return isolate_; -} - // // Measure compile of all functions in dart core lib classes. // @@ -522,13 +509,11 @@ BENCHMARK_SIZE(StandaloneSnapshotSize) { "import 'dart:async';\n" "import 'dart:core';\n" "import 'dart:collection';\n" - "import 'dart:_internal';\n" "import 'dart:convert';\n" "import 'dart:math';\n" "import 'dart:isolate';\n" "import 'dart:mirrors';\n" "import 'dart:typed_data';\n" - "import 'dart:_builtin';\n" "import 'dart:io';\n" "import 'dart:cli';\n" "\n"; diff --git a/runtime/vm/benchmark_test.h b/runtime/vm/benchmark_test.h index 928537342bb..58f4eee6ba5 100644 --- a/runtime/vm/benchmark_test.h +++ b/runtime/vm/benchmark_test.h @@ -13,6 +13,7 @@ #include "vm/isolate.h" #include "vm/malloc_hooks.h" #include "vm/object.h" +#include "vm/unit_test.h" #include "vm/zone.h" namespace dart { @@ -85,9 +86,6 @@ class Benchmark { int64_t score() const { return score_; } Isolate* isolate() const { return reinterpret_cast(isolate_); } - Dart_Isolate CreateIsolate(const uint8_t* snapshot_data, - const uint8_t* snapshot_instructions); - void Run() { (*run_)(this); } void RunBenchmark(); @@ -95,6 +93,11 @@ class Benchmark { static void SetExecutable(const char* arg) { executable_ = arg; } static const char* Executable() { return executable_; } + void CreateIsolate() { + isolate_ = TestCase::CreateTestIsolate(); + EXPECT(isolate_ != NULL); + } + private: static Benchmark* first_; static Benchmark* tail_; @@ -113,8 +116,7 @@ class Benchmark { class BenchmarkIsolateScope { public: explicit BenchmarkIsolateScope(Benchmark* benchmark) : benchmark_(benchmark) { - benchmark_->CreateIsolate(bin::core_isolate_snapshot_data, - bin::core_isolate_snapshot_instructions); + benchmark->CreateIsolate(); Dart_EnterScope(); // Create a Dart API scope for unit benchmarks. } ~BenchmarkIsolateScope() { diff --git a/runtime/vm/clustered_snapshot.cc b/runtime/vm/clustered_snapshot.cc index 0ad0be6abb0..e57816e84ee 100644 --- a/runtime/vm/clustered_snapshot.cc +++ b/runtime/vm/clustered_snapshot.cc @@ -5586,7 +5586,6 @@ class SeedVMIsolateVisitor : public ClassVisitor, public FunctionVisitor { } void Visit(const Script& script) { - objects_->Add(&Object::Handle(zone_, script_.tokens())); kernel_program_info_ = script_.kernel_program_info(); if (!kernel_program_info_.IsNull()) { objects_->Add( @@ -5599,6 +5598,8 @@ class SeedVMIsolateVisitor : public ClassVisitor, public FunctionVisitor { objects_->Add( &Object::Handle(zone_, kernel_program_info_.metadata_mappings())); objects_->Add(&Object::Handle(zone_, kernel_program_info_.constants())); + } else { + objects_->Add(&Object::Handle(zone_, script_.tokens())); } } diff --git a/runtime/vm/dart_api_impl_test.cc b/runtime/vm/dart_api_impl_test.cc index 0fb48190d38..d2507e8b5ca 100644 --- a/runtime/vm/dart_api_impl_test.cc +++ b/runtime/vm/dart_api_impl_test.cc @@ -3287,11 +3287,8 @@ VM_UNIT_TEST_CASE(DartAPI_Isolates) { VM_UNIT_TEST_CASE(DartAPI_CurrentIsolateData) { intptr_t mydata = 12345; - char* err; Dart_Isolate isolate = - Dart_CreateIsolate(NULL, NULL, bin::core_isolate_snapshot_data, - bin::core_isolate_snapshot_instructions, NULL, - reinterpret_cast(mydata), &err); + TestCase::CreateTestIsolate(NULL, reinterpret_cast(mydata)); EXPECT(isolate != NULL); EXPECT_EQ(mydata, reinterpret_cast(Dart_CurrentIsolateData())); EXPECT_EQ(mydata, reinterpret_cast(Dart_IsolateData(isolate))); @@ -3338,13 +3335,12 @@ VM_UNIT_TEST_CASE(DartAPI_IsolateSetCheckedMode) { api_flags.enable_error_on_bad_type = true; api_flags.enable_error_on_bad_override = true; api_flags.use_dart_frontend = FLAG_use_dart_frontend; - char* err; Dart_Isolate isolate = Dart_CreateIsolate( NULL, NULL, bin::core_isolate_snapshot_data, bin::core_isolate_snapshot_instructions, &api_flags, NULL, &err); if (isolate == NULL) { - OS::Print("Creation of isolate failed '%s'\n", err); + OS::PrintErr("Creation of isolate failed '%s'\n", err); free(err); } EXPECT(isolate != NULL); @@ -5167,7 +5163,7 @@ TEST_CASE(DartAPI_InvokeClosure) { " return f;\n" " }\n" " static Function method2(int i) {\n" - " n(int j) => true + i + fld4; \n" + " n(int j) { throw new Exception('I am an exception'); return 1; }\n" " return n;\n" " }\n" " int fld1;\n" @@ -5937,7 +5933,7 @@ TEST_CASE(DartAPI_LibraryGetClassNames) { "class _B {}\n" "abstract class _C {}\n" "\n" - "_compare(String a, String b) => a.compareTo(b);\n" + "int _compare(dynamic a, dynamic b) => a.compareTo(b);\n" "sort(list) => list.sort(_compare);\n"; Dart_Handle lib = TestCase::LoadTestLibrary("library_url", kLibraryChars); @@ -5986,7 +5982,7 @@ TEST_CASE(DartAPI_GetFunctionNames) { " var _D2;\n" "}\n" "\n" - "_compare(String a, String b) => a.compareTo(b);\n" + "int _compare(dynamic a, dynamic b) => a.compareTo(b);\n" "sort(list) => list.sort(_compare);\n"; // Get the functions from a library. @@ -7268,13 +7264,7 @@ void BusyLoop_start(uword unused) { Dart_Handle lib; { MonitorLocker ml(sync); - char* error = NULL; - Dart_IsolateFlags api_flags; - Isolate::FlagsInitialize(&api_flags); - api_flags.use_dart_frontend = FLAG_use_dart_frontend; - shared_isolate = Dart_CreateIsolate( - NULL, NULL, bin::core_isolate_snapshot_data, - bin::core_isolate_snapshot_instructions, &api_flags, NULL, &error); + TestCase::CreateTestIsolate(); EXPECT(shared_isolate != NULL); Dart_EnterScope(); Dart_Handle url = NewString(TestCase::url()); @@ -7318,18 +7308,9 @@ VM_UNIT_TEST_CASE(DartAPI_IsolateShutdown) { Isolate::SetShutdownCallback(IsolateShutdownTestCallback); saved_callback_data = NULL; - void* my_data = reinterpret_cast(12345); - // Create an isolate. - char* err; - Dart_Isolate isolate = Dart_CreateIsolate( - NULL, NULL, bin::core_isolate_snapshot_data, - bin::core_isolate_snapshot_instructions, NULL, my_data, &err); - if (isolate == NULL) { - OS::Print("Creation of isolate failed '%s'\n", err); - free(err); - } + Dart_Isolate isolate = TestCase::CreateTestIsolate(NULL, my_data); EXPECT(isolate != NULL); // The shutdown callback has not been called. @@ -7372,17 +7353,7 @@ VM_UNIT_TEST_CASE(DartAPI_IsolateShutdownRunDartCode) { "}\n"; // Create an isolate. - char* err; - Dart_IsolateFlags api_flags; - Isolate::FlagsInitialize(&api_flags); - api_flags.use_dart_frontend = FLAG_use_dart_frontend; - Dart_Isolate isolate = Dart_CreateIsolate( - NULL, NULL, bin::core_isolate_snapshot_data, - bin::core_isolate_snapshot_instructions, &api_flags, NULL, &err); - if (isolate == NULL) { - OS::Print("Creation of isolate failed '%s'\n", err); - free(err); - } + Dart_Isolate isolate = TestCase::CreateTestIsolate(); EXPECT(isolate != NULL); Isolate::SetShutdownCallback(IsolateShutdownRunDartCodeTestCallback); diff --git a/runtime/vm/guard_field_test.cc b/runtime/vm/guard_field_test.cc index 098825541f3..0feabcc9093 100644 --- a/runtime/vm/guard_field_test.cc +++ b/runtime/vm/guard_field_test.cc @@ -30,7 +30,7 @@ TEST_CASE(GuardFieldSimpleTest) { const char* script_chars = "class A {\n" " var f1 = 3.0;\n" - " var f2 = 3;\n" + " dynamic f2 = 3;\n" " var f3 = new List(4);\n" " foo() {\n" " f1 = f1 + f1;\n" @@ -80,7 +80,7 @@ TEST_CASE(GuardFieldFinalListTest) { const char* script_chars = "class A {\n" " var f1 = 3.0;\n" - " var f2 = 3;\n" + " dynamic f2 = 3;\n" " final f3 = new List(4);\n" " foo() {\n" " f1 = f1 + f1;\n" @@ -132,7 +132,7 @@ TEST_CASE(GuardFieldFinalVariableLengthListTest) { const char* script_chars = "class A {\n" " var f1 = 3.0;\n" - " var f2 = 3;\n" + " dynamic f2 = 3;\n" " final f3 = new List();\n" " foo() {\n" " f1 = f1 + f1;\n" @@ -185,7 +185,7 @@ TEST_CASE(GuardFieldConstructorTest) { "import 'dart:typed_data';\n" "class A {\n" " var f1 = 3.0;\n" - " var f2 = 3;\n" + " dynamic f2 = 3;\n" " final f3;\n" " A(x) : f3 = x;\n" " foo() {\n" diff --git a/runtime/vm/isolate_reload_test.cc b/runtime/vm/isolate_reload_test.cc index 35ff7b2b56a..249b504995d 100644 --- a/runtime/vm/isolate_reload_test.cc +++ b/runtime/vm/isolate_reload_test.cc @@ -867,7 +867,7 @@ TEST_CASE(IsolateReload_ComplexInheritanceChange) { "class C extends B {\n" " C(name) : super(name);\n" "}\n" - "var list = [ new A('a'), new B('b'), new C('c') ];\n" + "var list = [ new A('a'), new B('b'), new C('c') ];\n" "main() {\n" " return (list.map((x) {\n" " return '${x.name} is A(${x is A})/ B(${x is B})/ C(${x is C})';\n" diff --git a/runtime/vm/isolate_test.cc b/runtime/vm/isolate_test.cc index ef07817fc95..a9d3a85c1b8 100644 --- a/runtime/vm/isolate_test.cc +++ b/runtime/vm/isolate_test.cc @@ -14,12 +14,8 @@ namespace dart { VM_UNIT_TEST_CASE(IsolateCurrent) { - char* error; - Dart_Isolate isolate = Dart_CreateIsolate( - NULL, NULL, bin::core_isolate_snapshot_data, - bin::core_isolate_snapshot_instructions, NULL, NULL, &error); + Dart_Isolate isolate = TestCase::CreateTestIsolate(); EXPECT_EQ(isolate, Dart_CurrentIsolate()); - EXPECT_EQ(error, static_cast(NULL)); Dart_ShutdownIsolate(); EXPECT_EQ(reinterpret_cast(NULL), Dart_CurrentIsolate()); } diff --git a/runtime/vm/metrics_test.cc b/runtime/vm/metrics_test.cc index 6d2e69c48df..1e208667659 100644 --- a/runtime/vm/metrics_test.cc +++ b/runtime/vm/metrics_test.cc @@ -16,8 +16,7 @@ namespace dart { #ifndef PRODUCT VM_UNIT_TEST_CASE(Metric_Simple) { - Dart_CreateIsolate(NULL, NULL, bin::core_isolate_snapshot_data, - bin::core_isolate_snapshot_instructions, NULL, NULL, NULL); + TestCase::CreateTestIsolate(); { Metric metric; @@ -45,8 +44,7 @@ class MyMetric : public Metric { }; VM_UNIT_TEST_CASE(Metric_OnDemand) { - Dart_CreateIsolate(NULL, NULL, bin::core_isolate_snapshot_data, - bin::core_isolate_snapshot_instructions, NULL, NULL, NULL); + TestCase::CreateTestIsolate(); { Thread* thread = Thread::Current(); StackZone zone(thread); diff --git a/runtime/vm/service_test.cc b/runtime/vm/service_test.cc index c0aec6d8924..46424c76bd4 100644 --- a/runtime/vm/service_test.cc +++ b/runtime/vm/service_test.cc @@ -655,7 +655,7 @@ TEST_CASE(Service_EmbedderRootHandler) { "var x = 7;\n" "main() {\n" " x = x * x;\n" - " x = x / 13;\n" + " x = (x / 13).floor();\n" "}"; Dart_RegisterRootServiceRequestCallback("alpha", alpha_callback, NULL); @@ -692,7 +692,7 @@ TEST_CASE(Service_EmbedderIsolateHandler) { "var x = 7;\n" "main() {\n" " x = x * x;\n" - " x = x / 13;\n" + " x = (x / 13).floor();\n" "}"; Dart_RegisterIsolateServiceRequestCallback("alpha", alpha_callback, NULL); @@ -742,7 +742,7 @@ TEST_CASE(Service_Profile) { "var x = 7;\n" "main() {\n" " x = x * x;\n" - " x = x / 13;\n" + " x = (x / 13).floor();\n" "}"; Isolate* isolate = thread->isolate(); diff --git a/runtime/vm/snapshot_test.cc b/runtime/vm/snapshot_test.cc index 30b5dff3103..3bfe58983a6 100644 --- a/runtime/vm/snapshot_test.cc +++ b/runtime/vm/snapshot_test.cc @@ -1879,6 +1879,7 @@ static void CheckStringInvalid(Dart_Handle dart_string) { VM_UNIT_TEST_CASE(DartGeneratedMessages) { static const char* kCustomIsolateScriptCommonChars = + "final int kArrayLength = 10;\n" "getSmi() {\n" " return 42;\n" "}\n" diff --git a/runtime/vm/stack_frame_test.cc b/runtime/vm/stack_frame_test.cc index e6bcb67ef07..eadc9bfa7d7 100644 --- a/runtime/vm/stack_frame_test.cc +++ b/runtime/vm/stack_frame_test.cc @@ -279,7 +279,9 @@ TEST_CASE(ValidateNoSuchMethodStackFrameIteration) { " return 5;" " }" " static testMain() {" - " var obj = new StackFrame2Test();" + " /* Declare |obj| dynamic so that noSuchMethod can be" + " * called in strong mode. */" + " dynamic obj = new StackFrame2Test();" " StackFrame.equals(5, obj.foo(101, 202));" " }" "}"; @@ -314,7 +316,9 @@ TEST_CASE(ValidateNoSuchMethodStackFrameIteration) { " return 5;" " }" " static testMain() {" - " var obj = new StackFrame2Test();" + " /* Declare |obj| dynamic so that noSuchMethod can be" + " * called in strong mode. */" + " dynamic obj = new StackFrame2Test();" " StackFrame.equals(5, obj.foo(101, 202));" " }" "}"; diff --git a/runtime/vm/thread_test.cc b/runtime/vm/thread_test.cc index 4c6482206cc..492e26d1336 100644 --- a/runtime/vm/thread_test.cc +++ b/runtime/vm/thread_test.cc @@ -15,9 +15,7 @@ namespace dart { VM_UNIT_TEST_CASE(Mutex) { // This unit test case needs a running isolate. - Dart_CreateIsolate(NULL, NULL, bin::core_isolate_snapshot_data, - bin::core_isolate_snapshot_instructions, NULL, NULL, NULL); - + TestCase::CreateTestIsolate(); Mutex* mutex = new Mutex(); mutex->Lock(); EXPECT_EQ(false, mutex->TryLock()); @@ -36,8 +34,7 @@ VM_UNIT_TEST_CASE(Mutex) { VM_UNIT_TEST_CASE(Monitor) { // This unit test case needs a running isolate. - Dart_CreateIsolate(NULL, NULL, bin::core_isolate_snapshot_data, - bin::core_isolate_snapshot_instructions, NULL, NULL, NULL); + TestCase::CreateTestIsolate(); OSThread* thread = OSThread::Current(); // Thread interrupter interferes with this test, disable interrupts. thread->DisableThreadInterrupts(); @@ -368,14 +365,12 @@ TEST_CASE(ThreadRegistry) { char* orig_str = orig_zone->PrintToString("foo"); Dart_ExitIsolate(); // Create and enter a new isolate. - Dart_CreateIsolate(NULL, NULL, bin::core_isolate_snapshot_data, - bin::core_isolate_snapshot_instructions, NULL, NULL, NULL); + TestCase::CreateTestIsolate(); Zone* zone0 = Thread::Current()->zone(); EXPECT(zone0 != orig_zone); Dart_ShutdownIsolate(); // Create and enter yet another isolate. - Dart_CreateIsolate(NULL, NULL, bin::core_isolate_snapshot_data, - bin::core_isolate_snapshot_instructions, NULL, NULL, NULL); + TestCase::CreateTestIsolate(); { // Create a stack resource this time, and exercise it. StackZone stack_zone(Thread::Current()); diff --git a/runtime/vm/unit_test.cc b/runtime/vm/unit_test.cc index 85447d38629..adb692fcdd9 100644 --- a/runtime/vm/unit_test.cc +++ b/runtime/vm/unit_test.cc @@ -27,13 +27,27 @@ using dart::bin::Builtin; using dart::bin::DartUtils; +extern "C" { +extern const uint8_t kPlatformDill[]; +extern const uint8_t kPlatformStrongDill[]; +extern intptr_t kPlatformDillSize; +extern intptr_t kPlatformStrongDillSize; +} + namespace dart { +const uint8_t* platform_dill = kPlatformDill; +const uint8_t* platform_strong_dill = kPlatformStrongDill; +const intptr_t platform_dill_size = kPlatformDillSize; +const intptr_t platform_strong_dill_size = kPlatformStrongDillSize; + DEFINE_FLAG(bool, use_dart_frontend, false, "Parse scripts with Dart-to-Kernel parser"); +DECLARE_FLAG(bool, strong); + TestCaseBase* TestCaseBase::first_ = NULL; TestCaseBase* TestCaseBase::tail_ = NULL; @@ -67,21 +81,52 @@ void TestCaseBase::RunAll() { } } -Dart_Isolate TestCase::CreateIsolate(const uint8_t* buffer, const char* name) { +static void NoopRelease(uint8_t* data) {} + +Dart_Isolate TestCase::CreateIsolate(const uint8_t* data_buffer, + intptr_t len, + const uint8_t* instr_buffer, + const char* name, + void* data) { char* err; Dart_IsolateFlags api_flags; Isolate::FlagsInitialize(&api_flags); api_flags.use_dart_frontend = FLAG_use_dart_frontend; - Dart_Isolate isolate = - Dart_CreateIsolate(name, NULL, buffer, NULL, &api_flags, NULL, &err); + Dart_Isolate isolate = NULL; + if (len == 0) { + isolate = Dart_CreateIsolate(name, NULL, data_buffer, instr_buffer, + &api_flags, data, &err); + } else { + kernel::Program* program = reinterpret_cast( + Dart_ReadKernelBinary(data_buffer, len, NoopRelease)); + if (program != NULL) { + isolate = Dart_CreateIsolateFromKernel(name, NULL, program, &api_flags, + data, &err); + delete program; + } + } if (isolate == NULL) { - OS::Print("Creation of isolate failed '%s'\n", err); + OS::PrintErr("Creation of isolate failed '%s'\n", err); free(err); } EXPECT(isolate != NULL); return isolate; } +Dart_Isolate TestCase::CreateTestIsolate(const char* name, void* data) { + if (FLAG_use_dart_frontend) { + return CreateIsolate( + FLAG_strong ? platform_strong_dill : platform_dill, + FLAG_strong ? platform_strong_dill_size : platform_dill_size, + NULL, /* There is no instr buffer in case of dill buffers. */ + name, data); + } else { + return CreateIsolate(bin::core_isolate_snapshot_data, + 0 /* Snapshots have length encoded within them. */, + bin::core_isolate_snapshot_instructions, name, data); + } +} + static const char* kPackageScheme = "package:"; static bool IsPackageSchemeURL(const char* url_name) { @@ -203,7 +248,8 @@ char* TestCase::CompileTestScriptWithDFE(const char* url, bool incrementally) { Zone* zone = Thread::Current()->zone(); Dart_KernelCompilationResult compilation_result = Dart_CompileSourcesToKernel( - url, NULL /* platform binary can be found at the default location */, 0, + url, FLAG_strong ? platform_strong_dill : platform_dill, + FLAG_strong ? platform_strong_dill_size : platform_dill_size, sourcefiles_count, sourcefiles, incrementally); if (compilation_result.status != Dart_KernelCompilationStatus_Ok) { diff --git a/runtime/vm/unit_test.h b/runtime/vm/unit_test.h index 970de8ff965..00e2cbefcb5 100644 --- a/runtime/vm/unit_test.h +++ b/runtime/vm/unit_test.h @@ -270,6 +270,11 @@ extern const uint8_t* core_isolate_snapshot_data; extern const uint8_t* core_isolate_snapshot_instructions; } // namespace bin +extern const uint8_t* platform_dill; +extern const uint8_t* platform_strong_dill; +extern const intptr_t platform_dill_size; +extern const intptr_t platform_strong_dill_size; + class TestCaseBase { public: explicit TestCaseBase(const char* name); @@ -334,11 +339,10 @@ class TestCase : TestCaseBase { static const char* url(); static Dart_Isolate CreateTestIsolateFromSnapshot(uint8_t* buffer, const char* name = NULL) { - return CreateIsolate(buffer, name); - } - static Dart_Isolate CreateTestIsolate(const char* name = NULL) { - return CreateIsolate(bin::core_isolate_snapshot_data, name); + return CreateIsolate(buffer, 0, NULL, name); } + static Dart_Isolate CreateTestIsolate(const char* name = NULL, + void* data = NULL); static Dart_Handle library_handler(Dart_LibraryTag tag, Dart_Handle library, Dart_Handle url); @@ -363,7 +367,16 @@ class TestCase : TestCaseBase { static const char* GetTestLib(const char* url); private: - static Dart_Isolate CreateIsolate(const uint8_t* buffer, const char* name); + // |data_buffer| can either be snapshot data, or kernel binary data. + // If |data_buffer| is snapshot data, then |len| should be zero as snapshot + // size is encoded within them. If |len| is non-zero, then |data_buffer| + // will be treated as a kernel binary (but CreateIsolate will not + // take ownership of the buffer) and |instr_buffer| will be ignored. + static Dart_Isolate CreateIsolate(const uint8_t* data_buffer, + intptr_t len, + const uint8_t* instr_buffer, + const char* name, + void* data = NULL); RunEntry* const run_; }; diff --git a/runtime/vm/zone_test.cc b/runtime/vm/zone_test.cc index 4a3aeacea89..5f8f78305e7 100644 --- a/runtime/vm/zone_test.cc +++ b/runtime/vm/zone_test.cc @@ -14,8 +14,7 @@ VM_UNIT_TEST_CASE(AllocateZone) { #if defined(DEBUG) FLAG_trace_zones = true; #endif - Dart_CreateIsolate(NULL, NULL, bin::core_isolate_snapshot_data, - bin::core_isolate_snapshot_instructions, NULL, NULL, NULL); + TestCase::CreateTestIsolate(); Thread* thread = Thread::Current(); EXPECT(thread->zone() == NULL); { @@ -75,8 +74,7 @@ VM_UNIT_TEST_CASE(AllocGeneric_Success) { #if defined(DEBUG) FLAG_trace_zones = true; #endif - Dart_CreateIsolate(NULL, NULL, bin::core_isolate_snapshot_data, - bin::core_isolate_snapshot_instructions, NULL, NULL, NULL); + TestCase::CreateTestIsolate(); Thread* thread = Thread::Current(); EXPECT(thread->zone() == NULL); { @@ -98,8 +96,7 @@ VM_UNIT_TEST_CASE(AllocGeneric_Overflow) { #if defined(DEBUG) FLAG_trace_zones = true; #endif - Dart_CreateIsolate(NULL, NULL, bin::core_isolate_snapshot_data, - bin::core_isolate_snapshot_instructions, NULL, NULL, NULL); + TestCase::CreateTestIsolate(); Thread* thread = Thread::Current(); EXPECT(thread->zone() == NULL); { @@ -116,8 +113,7 @@ VM_UNIT_TEST_CASE(ZoneAllocated) { #if defined(DEBUG) FLAG_trace_zones = true; #endif - Dart_CreateIsolate(NULL, NULL, bin::core_isolate_snapshot_data, - bin::core_isolate_snapshot_instructions, NULL, NULL, NULL); + TestCase::CreateTestIsolate(); Thread* thread = Thread::Current(); EXPECT(thread->zone() == NULL); static int marker; diff --git a/tools/testing/dart/test_suite.dart b/tools/testing/dart/test_suite.dart index e82a6506998..8d9b5dfee75 100644 --- a/tools/testing/dart/test_suite.dart +++ b/tools/testing/dart/test_suite.dart @@ -494,6 +494,10 @@ class VMTestSuite extends TestSuite { args.insert(0, '--dfe=$buildDir/gen/kernel-service.dart.snapshot'); } + if (configuration.isStrong) { + args.add('--strong'); + } + args.add(testName); var command = Command.process(