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

Side by Side Diff: runtime/vm/snapshot_test.cc

Issue 1182673002: Add an assertion to ensure that the return type and types of parameters are canonical or a TypeParam (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: address code review comments Created 5 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 unified diff | Download patch
« no previous file with comments | « runtime/vm/raw_object.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "platform/globals.h" 5 #include "platform/globals.h"
6 6
7 #include "include/dart_debugger_api.h" 7 #include "include/dart_debugger_api.h"
8 #include "platform/assert.h" 8 #include "platform/assert.h"
9 #include "vm/class_finalizer.h" 9 #include "vm/class_finalizer.h"
10 #include "vm/dart_api_impl.h" 10 #include "vm/dart_api_impl.h"
11 #include "vm/dart_api_message.h" 11 #include "vm/dart_api_message.h"
12 #include "vm/dart_api_state.h" 12 #include "vm/dart_api_state.h"
13 #include "vm/flags.h" 13 #include "vm/flags.h"
14 #include "vm/snapshot.h" 14 #include "vm/snapshot.h"
15 #include "vm/symbols.h" 15 #include "vm/symbols.h"
16 #include "vm/unicode.h" 16 #include "vm/unicode.h"
17 #include "vm/unit_test.h" 17 #include "vm/unit_test.h"
18 18
19 namespace dart { 19 namespace dart {
20 20
21 DECLARE_FLAG(bool, enable_type_checks); 21 DECLARE_FLAG(bool, enable_type_checks);
22 DECLARE_FLAG(bool, load_deferred_eagerly); 22 DECLARE_FLAG(bool, load_deferred_eagerly);
23 DECLARE_FLAG(bool, concurrent_sweep);
23 24
24 // Check if serialized and deserialized objects are equal. 25 // Check if serialized and deserialized objects are equal.
25 static bool Equals(const Object& expected, const Object& actual) { 26 static bool Equals(const Object& expected, const Object& actual) {
26 if (expected.IsNull()) { 27 if (expected.IsNull()) {
27 return actual.IsNull(); 28 return actual.IsNull();
28 } 29 }
29 if (expected.IsSmi()) { 30 if (expected.IsSmi()) {
30 if (actual.IsSmi()) { 31 if (actual.IsSmi()) {
31 return expected.raw() == actual.raw(); 32 return expected.raw() == actual.raw();
32 } 33 }
(...skipping 1195 matching lines...) Expand 10 before | Expand all | Expand 10 after
1228 intptr_t vm_isolate_snapshot_size; 1229 intptr_t vm_isolate_snapshot_size;
1229 uint8_t* isolate_snapshot = NULL; 1230 uint8_t* isolate_snapshot = NULL;
1230 intptr_t isolate_snapshot_size; 1231 intptr_t isolate_snapshot_size;
1231 uint8_t* full_snapshot = NULL; 1232 uint8_t* full_snapshot = NULL;
1232 uint8_t* script_snapshot = NULL; 1233 uint8_t* script_snapshot = NULL;
1233 intptr_t expected_num_libs; 1234 intptr_t expected_num_libs;
1234 intptr_t actual_num_libs; 1235 intptr_t actual_num_libs;
1235 1236
1236 bool saved_load_deferred_eagerly_mode = FLAG_load_deferred_eagerly; 1237 bool saved_load_deferred_eagerly_mode = FLAG_load_deferred_eagerly;
1237 FLAG_load_deferred_eagerly = true; 1238 FLAG_load_deferred_eagerly = true;
1238 1239 // Workaround until issue 21620 is fixed.
1240 // (https://github.com/dart-lang/sdk/issues/21620)
1241 bool saved_concurrent_sweep_mode = FLAG_concurrent_sweep;
1242 FLAG_concurrent_sweep = false;
1239 { 1243 {
1240 // Start an Isolate, and create a full snapshot of it. 1244 // Start an Isolate, and create a full snapshot of it.
1241 TestIsolateScope __test_isolate__; 1245 TestIsolateScope __test_isolate__;
1242 Dart_EnterScope(); // Start a Dart API scope for invoking API functions. 1246 Dart_EnterScope(); // Start a Dart API scope for invoking API functions.
1243 1247
1244 // Write out the script snapshot. 1248 // Write out the script snapshot.
1245 result = Dart_CreateSnapshot(NULL, 1249 result = Dart_CreateSnapshot(NULL,
1246 &vm_isolate_snapshot_size, 1250 &vm_isolate_snapshot_size,
1247 &isolate_snapshot, 1251 &isolate_snapshot,
1248 &isolate_snapshot_size); 1252 &isolate_snapshot_size);
1249 EXPECT_VALID(result); 1253 EXPECT_VALID(result);
1250 full_snapshot = reinterpret_cast<uint8_t*>(malloc(isolate_snapshot_size)); 1254 full_snapshot = reinterpret_cast<uint8_t*>(malloc(isolate_snapshot_size));
1251 memmove(full_snapshot, isolate_snapshot, isolate_snapshot_size); 1255 memmove(full_snapshot, isolate_snapshot, isolate_snapshot_size);
1252 Dart_ExitScope(); 1256 Dart_ExitScope();
1253 } 1257 }
1254
1255 FLAG_load_deferred_eagerly = saved_load_deferred_eagerly_mode; 1258 FLAG_load_deferred_eagerly = saved_load_deferred_eagerly_mode;
1259 FLAG_concurrent_sweep = saved_concurrent_sweep_mode;
1256 1260
1257 // Test for Dart_CreateScriptSnapshot. 1261 // Test for Dart_CreateScriptSnapshot.
1258 { 1262 {
1259 // Create an Isolate using the full snapshot, load a script and create 1263 // Create an Isolate using the full snapshot, load a script and create
1260 // a script snapshot of the script. 1264 // a script snapshot of the script.
1261 TestCase::CreateTestIsolateFromSnapshot(full_snapshot); 1265 TestCase::CreateTestIsolateFromSnapshot(full_snapshot);
1262 Dart_EnterScope(); // Start a Dart API scope for invoking API functions. 1266 Dart_EnterScope(); // Start a Dart API scope for invoking API functions.
1263 1267
1264 // Load the library. 1268 // Load the library.
1265 Dart_Handle import_lib = Dart_LoadLibrary(NewString("dart_import_lib"), 1269 Dart_Handle import_lib = Dart_LoadLibrary(NewString("dart_import_lib"),
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
1372 uint8_t* buffer; 1376 uint8_t* buffer;
1373 intptr_t size; 1377 intptr_t size;
1374 intptr_t vm_isolate_snapshot_size; 1378 intptr_t vm_isolate_snapshot_size;
1375 uint8_t* isolate_snapshot = NULL; 1379 uint8_t* isolate_snapshot = NULL;
1376 intptr_t isolate_snapshot_size; 1380 intptr_t isolate_snapshot_size;
1377 uint8_t* full_snapshot = NULL; 1381 uint8_t* full_snapshot = NULL;
1378 uint8_t* script_snapshot = NULL; 1382 uint8_t* script_snapshot = NULL;
1379 1383
1380 bool saved_load_deferred_eagerly_mode = FLAG_load_deferred_eagerly; 1384 bool saved_load_deferred_eagerly_mode = FLAG_load_deferred_eagerly;
1381 FLAG_load_deferred_eagerly = true; 1385 FLAG_load_deferred_eagerly = true;
1386 bool saved_concurrent_sweep_mode = FLAG_concurrent_sweep;
1387 FLAG_concurrent_sweep = false;
1382 { 1388 {
1383 // Start an Isolate, and create a full snapshot of it. 1389 // Start an Isolate, and create a full snapshot of it.
1384 TestIsolateScope __test_isolate__; 1390 TestIsolateScope __test_isolate__;
1385 Dart_EnterScope(); // Start a Dart API scope for invoking API functions. 1391 Dart_EnterScope(); // Start a Dart API scope for invoking API functions.
1386 1392
1387 // Write out the script snapshot. 1393 // Write out the script snapshot.
1388 result = Dart_CreateSnapshot(NULL, 1394 result = Dart_CreateSnapshot(NULL,
1389 &vm_isolate_snapshot_size, 1395 &vm_isolate_snapshot_size,
1390 &isolate_snapshot, 1396 &isolate_snapshot,
1391 &isolate_snapshot_size); 1397 &isolate_snapshot_size);
1392 EXPECT_VALID(result); 1398 EXPECT_VALID(result);
1393 full_snapshot = reinterpret_cast<uint8_t*>(malloc(isolate_snapshot_size)); 1399 full_snapshot = reinterpret_cast<uint8_t*>(malloc(isolate_snapshot_size));
1394 memmove(full_snapshot, isolate_snapshot, isolate_snapshot_size); 1400 memmove(full_snapshot, isolate_snapshot, isolate_snapshot_size);
1395 Dart_ExitScope(); 1401 Dart_ExitScope();
1396 } 1402 }
1403 FLAG_concurrent_sweep = saved_concurrent_sweep_mode;
1397 1404
1398 { 1405 {
1399 // Create an Isolate using the full snapshot, load a script and create 1406 // Create an Isolate using the full snapshot, load a script and create
1400 // a script snapshot of the script. 1407 // a script snapshot of the script.
1401 TestCase::CreateTestIsolateFromSnapshot(full_snapshot); 1408 TestCase::CreateTestIsolateFromSnapshot(full_snapshot);
1402 Dart_EnterScope(); // Start a Dart API scope for invoking API functions. 1409 Dart_EnterScope(); // Start a Dart API scope for invoking API functions.
1403 1410
1404 // Create a test library and Load up a test script in it. 1411 // Create a test library and Load up a test script in it.
1405 TestCase::LoadTestScript(kScriptChars, NULL); 1412 TestCase::LoadTestScript(kScriptChars, NULL);
1406 1413
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
1462 uint8_t* isolate_snapshot = NULL; 1469 uint8_t* isolate_snapshot = NULL;
1463 intptr_t isolate_snapshot_size; 1470 intptr_t isolate_snapshot_size;
1464 uint8_t* full_snapshot = NULL; 1471 uint8_t* full_snapshot = NULL;
1465 uint8_t* script_snapshot = NULL; 1472 uint8_t* script_snapshot = NULL;
1466 1473
1467 // Force creation of snapshot in production mode. 1474 // Force creation of snapshot in production mode.
1468 bool saved_enable_type_checks_mode = FLAG_enable_type_checks; 1475 bool saved_enable_type_checks_mode = FLAG_enable_type_checks;
1469 FLAG_enable_type_checks = false; 1476 FLAG_enable_type_checks = false;
1470 bool saved_load_deferred_eagerly_mode = FLAG_load_deferred_eagerly; 1477 bool saved_load_deferred_eagerly_mode = FLAG_load_deferred_eagerly;
1471 FLAG_load_deferred_eagerly = true; 1478 FLAG_load_deferred_eagerly = true;
1472 1479 bool saved_concurrent_sweep_mode = FLAG_concurrent_sweep;
1480 FLAG_concurrent_sweep = false;
1473 { 1481 {
1474 // Start an Isolate, and create a full snapshot of it. 1482 // Start an Isolate, and create a full snapshot of it.
1475 TestIsolateScope __test_isolate__; 1483 TestIsolateScope __test_isolate__;
1476 Dart_EnterScope(); // Start a Dart API scope for invoking API functions. 1484 Dart_EnterScope(); // Start a Dart API scope for invoking API functions.
1477 1485
1478 // Write out the script snapshot. 1486 // Write out the script snapshot.
1479 result = Dart_CreateSnapshot(NULL, 1487 result = Dart_CreateSnapshot(NULL,
1480 &vm_isolate_snapshot_size, 1488 &vm_isolate_snapshot_size,
1481 &isolate_snapshot, 1489 &isolate_snapshot,
1482 &isolate_snapshot_size); 1490 &isolate_snapshot_size);
1483 EXPECT_VALID(result); 1491 EXPECT_VALID(result);
1484 full_snapshot = reinterpret_cast<uint8_t*>(malloc(isolate_snapshot_size)); 1492 full_snapshot = reinterpret_cast<uint8_t*>(malloc(isolate_snapshot_size));
1485 memmove(full_snapshot, isolate_snapshot, isolate_snapshot_size); 1493 memmove(full_snapshot, isolate_snapshot, isolate_snapshot_size);
1486 Dart_ExitScope(); 1494 Dart_ExitScope();
1487 } 1495 }
1496 FLAG_concurrent_sweep = saved_concurrent_sweep_mode;
1488 1497
1489 { 1498 {
1490 // Create an Isolate using the full snapshot, load a script and create 1499 // Create an Isolate using the full snapshot, load a script and create
1491 // a script snapshot of the script. 1500 // a script snapshot of the script.
1492 TestCase::CreateTestIsolateFromSnapshot(full_snapshot); 1501 TestCase::CreateTestIsolateFromSnapshot(full_snapshot);
1493 Dart_EnterScope(); // Start a Dart API scope for invoking API functions. 1502 Dart_EnterScope(); // Start a Dart API scope for invoking API functions.
1494 1503
1495 // Load the library. 1504 // Load the library.
1496 Dart_Handle import_lib = Dart_LoadLibrary(NewString("dart_import_lib"), 1505 Dart_Handle import_lib = Dart_LoadLibrary(NewString("dart_import_lib"),
1497 NewString(kLibScriptChars), 1506 NewString(kLibScriptChars),
(...skipping 1351 matching lines...) Expand 10 before | Expand all | Expand 10 after
2849 StackZone zone(Isolate::Current()); 2858 StackZone zone(Isolate::Current());
2850 uint8_t* buffer; 2859 uint8_t* buffer;
2851 MessageWriter writer(&buffer, &zone_allocator, true); 2860 MessageWriter writer(&buffer, &zone_allocator, true);
2852 writer.WriteInlinedObjectHeader(kOmittedObjectId); 2861 writer.WriteInlinedObjectHeader(kOmittedObjectId);
2853 // For performance, we'd like single-byte headers when ids are omitted. 2862 // For performance, we'd like single-byte headers when ids are omitted.
2854 // If this starts failing, consider renumbering the snapshot ids. 2863 // If this starts failing, consider renumbering the snapshot ids.
2855 EXPECT_EQ(1, writer.BytesWritten()); 2864 EXPECT_EQ(1, writer.BytesWritten());
2856 } 2865 }
2857 2866
2858 } // namespace dart 2867 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/raw_object.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698