Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(637)

Unified Diff: runtime/vm/snapshot_test.cc

Issue 2933223002: Update subclasses array and is_implemented bit when loading script snapshots. (Closed)
Patch Set: . Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/vm/snapshot.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/snapshot_test.cc
diff --git a/runtime/vm/snapshot_test.cc b/runtime/vm/snapshot_test.cc
index 510e1eb5d7084bf8ca26fedca1ed149fdbcc469d..72e54f8065b4581c7b09bb8860f6f0cd59463621 100644
--- a/runtime/vm/snapshot_test.cc
+++ b/runtime/vm/snapshot_test.cc
@@ -1002,7 +1002,7 @@ TEST_CASE(SerializeScript) {
}
-#if !defined(PRODUCT) // Uses deferred loading.
+#if !defined(PRODUCT) // Uses mirrors.
VM_UNIT_TEST_CASE(CanonicalizationInScriptSnapshots) {
const char* kScriptChars =
"\n"
@@ -1109,6 +1109,120 @@ VM_UNIT_TEST_CASE(CanonicalizationInScriptSnapshots) {
#endif
+VM_UNIT_TEST_CASE(ScriptSnapshotsUpdateSubclasses) {
+ const char* kScriptChars =
+ "class _DebugDuration extends Duration {\n"
+ " const _DebugDuration() : super(milliseconds: 42);\n"
+ "}\n"
+ "foo(x, y) {\n"
+ " for (var i = 0; i < 1000000; i++) {\n"
+ " if (x != y) {\n"
+ " throw 'Boom!';\n"
+ " }\n"
+ " }\n"
+ "}\n"
+ "main() {\n"
+ " final v = const Duration(milliseconds: 42);\n"
+ " foo(v, new _DebugDuration());\n"
+ "}\n"
+ "\n";
+
+ Dart_Handle result;
+
+ uint8_t* buffer;
+ intptr_t size;
+ intptr_t vm_isolate_snapshot_size;
+ uint8_t* isolate_snapshot = NULL;
+ intptr_t isolate_snapshot_size;
+ uint8_t* full_snapshot = NULL;
+ uint8_t* script_snapshot = NULL;
+
+#if !defined(PRODUCT)
+ bool saved_load_deferred_eagerly_mode = FLAG_load_deferred_eagerly;
+ FLAG_load_deferred_eagerly = true;
+#endif
+ intptr_t saved_max_polymorphic_checks = FLAG_max_polymorphic_checks;
+ FLAG_max_polymorphic_checks = 0;
+
+ {
+ // Start an Isolate, and create a full snapshot of it.
+ TestIsolateScope __test_isolate__;
+ Dart_EnterScope(); // Start a Dart API scope for invoking API functions.
+
+ // Write out the script snapshot.
+ result = Dart_CreateSnapshot(NULL, &vm_isolate_snapshot_size,
+ &isolate_snapshot, &isolate_snapshot_size);
+ EXPECT_VALID(result);
+ full_snapshot = reinterpret_cast<uint8_t*>(malloc(isolate_snapshot_size));
+ memmove(full_snapshot, isolate_snapshot, isolate_snapshot_size);
+ Dart_ExitScope();
+ }
+
+ {
+ // Now Create an Isolate using the full snapshot and load the
+ // script and execute it.
+ TestCase::CreateTestIsolateFromSnapshot(full_snapshot);
+ Dart_EnterScope(); // Start a Dart API scope for invoking API functions.
+
+ // Create a test library and Load up a test script in it.
+ Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL);
+
+ EXPECT_VALID(lib);
+
+ // Invoke a function which returns an object.
+ result = Dart_Invoke(lib, NewString("main"), 0, NULL);
+ EXPECT_VALID(result);
+ Dart_ExitScope();
+ Dart_ShutdownIsolate();
+ }
+
+ {
+ // Create an Isolate using the full snapshot, load a script and create
+ // a script snapshot of the script.
+ TestCase::CreateTestIsolateFromSnapshot(full_snapshot);
+ Dart_EnterScope(); // Start a Dart API scope for invoking API functions.
+
+ // Create a test library and Load up a test script in it.
+ TestCase::LoadTestScript(kScriptChars, NULL);
+
+ EXPECT_VALID(Api::CheckAndFinalizePendingClasses(Thread::Current()));
+
+ // Write out the script snapshot.
+ result = Dart_CreateScriptSnapshot(&buffer, &size);
+ EXPECT_VALID(result);
+ script_snapshot = reinterpret_cast<uint8_t*>(malloc(size));
+ memmove(script_snapshot, buffer, size);
+ Dart_ExitScope();
+ Dart_ShutdownIsolate();
+ }
+
+ {
+ // Now Create an Isolate using the full snapshot and load the
+ // script snapshot created above and execute it.
+ TestCase::CreateTestIsolateFromSnapshot(full_snapshot);
+ Dart_EnterScope(); // Start a Dart API scope for invoking API functions.
+
+ // Load the test library from the snapshot.
+ EXPECT(script_snapshot != NULL);
+ result = Dart_LoadScriptFromSnapshot(script_snapshot, size);
+ EXPECT_VALID(result);
+
+ // Invoke a function which returns an object.
+ result = Dart_Invoke(result, NewString("main"), 0, NULL);
+ EXPECT_VALID(result);
+ Dart_ExitScope();
+ Dart_ShutdownIsolate();
+ }
+ free(script_snapshot);
+ free(full_snapshot);
+
+ FLAG_max_polymorphic_checks = saved_max_polymorphic_checks;
+#if !defined(PRODUCT)
+ FLAG_load_deferred_eagerly = saved_load_deferred_eagerly_mode;
+#endif
+}
+
+
static void IterateScripts(const Library& lib) {
const Array& lib_scripts = Array::Handle(lib.LoadedScripts());
Script& script = Script::Handle();
« no previous file with comments | « runtime/vm/snapshot.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698