| OLD | NEW |
| 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_tools_api.h" | 7 #include "include/dart_tools_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/clustered_snapshot.h" | 10 #include "vm/clustered_snapshot.h" |
| (...skipping 1355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1366 | 1366 |
| 1367 // Test for Dart_CreateScriptSnapshot. | 1367 // Test for Dart_CreateScriptSnapshot. |
| 1368 { | 1368 { |
| 1369 // Create an Isolate using the full snapshot, load a script and create | 1369 // Create an Isolate using the full snapshot, load a script and create |
| 1370 // a script snapshot of the script. | 1370 // a script snapshot of the script. |
| 1371 TestCase::CreateTestIsolateFromSnapshot(full_snapshot); | 1371 TestCase::CreateTestIsolateFromSnapshot(full_snapshot); |
| 1372 Dart_EnterScope(); // Start a Dart API scope for invoking API functions. | 1372 Dart_EnterScope(); // Start a Dart API scope for invoking API functions. |
| 1373 | 1373 |
| 1374 // Load the library. | 1374 // Load the library. |
| 1375 Dart_Handle import_lib = Dart_LoadLibrary(NewString("dart_import_lib"), | 1375 Dart_Handle import_lib = Dart_LoadLibrary(NewString("dart_import_lib"), |
| 1376 Dart_Null(), |
| 1376 NewString(kLibScriptChars), | 1377 NewString(kLibScriptChars), |
| 1377 0, 0); | 1378 0, 0); |
| 1378 EXPECT_VALID(import_lib); | 1379 EXPECT_VALID(import_lib); |
| 1379 | 1380 |
| 1380 // Create a test library and Load up a test script in it. | 1381 // Create a test library and Load up a test script in it. |
| 1381 TestCase::LoadTestScript(kScriptChars, NULL); | 1382 TestCase::LoadTestScript(kScriptChars, NULL); |
| 1382 | 1383 |
| 1383 EXPECT_VALID(Dart_LibraryImportLibrary(TestCase::lib(), | 1384 EXPECT_VALID(Dart_LibraryImportLibrary(TestCase::lib(), |
| 1384 import_lib, | 1385 import_lib, |
| 1385 Dart_Null())); | 1386 Dart_Null())); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1428 | 1429 |
| 1429 // Test for Dart_CreateLibrarySnapshot. | 1430 // Test for Dart_CreateLibrarySnapshot. |
| 1430 { | 1431 { |
| 1431 // Create an Isolate using the full snapshot, load a script and create | 1432 // Create an Isolate using the full snapshot, load a script and create |
| 1432 // a script snapshot of the script. | 1433 // a script snapshot of the script. |
| 1433 TestCase::CreateTestIsolateFromSnapshot(full_snapshot); | 1434 TestCase::CreateTestIsolateFromSnapshot(full_snapshot); |
| 1434 Dart_EnterScope(); // Start a Dart API scope for invoking API functions. | 1435 Dart_EnterScope(); // Start a Dart API scope for invoking API functions. |
| 1435 | 1436 |
| 1436 // Load the library. | 1437 // Load the library. |
| 1437 Dart_Handle lib = Dart_LoadLibrary(NewString("dart_lib"), | 1438 Dart_Handle lib = Dart_LoadLibrary(NewString("dart_lib"), |
| 1439 Dart_Null(), |
| 1438 NewString(kScriptChars), | 1440 NewString(kScriptChars), |
| 1439 0, 0); | 1441 0, 0); |
| 1440 EXPECT_VALID(lib); | 1442 EXPECT_VALID(lib); |
| 1441 | 1443 |
| 1442 // Write out the script snapshot. | 1444 // Write out the script snapshot. |
| 1443 result = Dart_CreateLibrarySnapshot(lib, &buffer, &size); | 1445 result = Dart_CreateLibrarySnapshot(lib, &buffer, &size); |
| 1444 EXPECT_VALID(result); | 1446 EXPECT_VALID(result); |
| 1445 script_snapshot = reinterpret_cast<uint8_t*>(malloc(size)); | 1447 script_snapshot = reinterpret_cast<uint8_t*>(malloc(size)); |
| 1446 memmove(script_snapshot, buffer, size); | 1448 memmove(script_snapshot, buffer, size); |
| 1447 Dart_ExitScope(); | 1449 Dart_ExitScope(); |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1603 FLAG_concurrent_sweep = saved_concurrent_sweep_mode; | 1605 FLAG_concurrent_sweep = saved_concurrent_sweep_mode; |
| 1604 | 1606 |
| 1605 { | 1607 { |
| 1606 // Create an Isolate using the full snapshot, load a script and create | 1608 // Create an Isolate using the full snapshot, load a script and create |
| 1607 // a script snapshot of the script. | 1609 // a script snapshot of the script. |
| 1608 TestCase::CreateTestIsolateFromSnapshot(full_snapshot); | 1610 TestCase::CreateTestIsolateFromSnapshot(full_snapshot); |
| 1609 Dart_EnterScope(); // Start a Dart API scope for invoking API functions. | 1611 Dart_EnterScope(); // Start a Dart API scope for invoking API functions. |
| 1610 | 1612 |
| 1611 // Load the library. | 1613 // Load the library. |
| 1612 Dart_Handle import_lib = Dart_LoadLibrary(NewString("dart_import_lib"), | 1614 Dart_Handle import_lib = Dart_LoadLibrary(NewString("dart_import_lib"), |
| 1615 Dart_Null(), |
| 1613 NewString(kLibScriptChars), | 1616 NewString(kLibScriptChars), |
| 1614 0, 0); | 1617 0, 0); |
| 1615 EXPECT_VALID(import_lib); | 1618 EXPECT_VALID(import_lib); |
| 1616 | 1619 |
| 1617 // Create a test library and Load up a test script in it. | 1620 // Create a test library and Load up a test script in it. |
| 1618 TestCase::LoadTestScript(kScriptChars, NULL); | 1621 TestCase::LoadTestScript(kScriptChars, NULL); |
| 1619 | 1622 |
| 1620 EXPECT_VALID(Dart_LibraryImportLibrary(TestCase::lib(), | 1623 EXPECT_VALID(Dart_LibraryImportLibrary(TestCase::lib(), |
| 1621 import_lib, | 1624 import_lib, |
| 1622 Dart_Null())); | 1625 Dart_Null())); |
| (...skipping 1388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3011 StackZone zone(Thread::Current()); | 3014 StackZone zone(Thread::Current()); |
| 3012 uint8_t* buffer; | 3015 uint8_t* buffer; |
| 3013 MessageWriter writer(&buffer, &zone_allocator, true); | 3016 MessageWriter writer(&buffer, &zone_allocator, true); |
| 3014 writer.WriteInlinedObjectHeader(kOmittedObjectId); | 3017 writer.WriteInlinedObjectHeader(kOmittedObjectId); |
| 3015 // For performance, we'd like single-byte headers when ids are omitted. | 3018 // For performance, we'd like single-byte headers when ids are omitted. |
| 3016 // If this starts failing, consider renumbering the snapshot ids. | 3019 // If this starts failing, consider renumbering the snapshot ids. |
| 3017 EXPECT_EQ(1, writer.BytesWritten()); | 3020 EXPECT_EQ(1, writer.BytesWritten()); |
| 3018 } | 3021 } |
| 3019 | 3022 |
| 3020 } // namespace dart | 3023 } // namespace dart |
| OLD | NEW |