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

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

Issue 1731743003: Move precompilation-related flags to flags list. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: make print_stop_message default false to fix build Created 4 years, 10 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/snapshot.cc ('k') | runtime/vm/stub_code_arm.cc » ('j') | 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_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/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);
23 DECLARE_FLAG(bool, concurrent_sweep); 22 DECLARE_FLAG(bool, concurrent_sweep);
24 23
25 // Check if serialized and deserialized objects are equal. 24 // Check if serialized and deserialized objects are equal.
26 static bool Equals(const Object& expected, const Object& actual) { 25 static bool Equals(const Object& expected, const Object& actual) {
27 if (expected.IsNull()) { 26 if (expected.IsNull()) {
28 return actual.IsNull(); 27 return actual.IsNull();
29 } 28 }
30 if (expected.IsSmi()) { 29 if (expected.IsSmi()) {
31 if (actual.IsSmi()) { 30 if (actual.IsSmi()) {
32 return expected.raw() == actual.raw(); 31 return expected.raw() == actual.raw();
(...skipping 961 matching lines...) Expand 10 before | Expand all | Expand 10 after
994 993
995 // Check if we are able to generate the source from the token stream. 994 // Check if we are able to generate the source from the token stream.
996 // Rescan this source and compare the token stream to see if they are 995 // Rescan this source and compare the token stream to see if they are
997 // the same. 996 // the same.
998 GenerateSourceAndCheck(serialized_script); 997 GenerateSourceAndCheck(serialized_script);
999 998
1000 free(buffer); 999 free(buffer);
1001 } 1000 }
1002 1001
1003 1002
1003 #if !defined(PRODUCT) // Uses deferred loading.
1004 UNIT_TEST_CASE(CanonicalizationInScriptSnapshots) { 1004 UNIT_TEST_CASE(CanonicalizationInScriptSnapshots) {
1005 const char* kScriptChars = 1005 const char* kScriptChars =
1006 "\n" 1006 "\n"
1007 "import 'dart:mirrors';" 1007 "import 'dart:mirrors';"
1008 "import 'dart:isolate';" 1008 "import 'dart:isolate';"
1009 "void main() {" 1009 "void main() {"
1010 " if (reflectClass(MyException).superclass.reflectedType != " 1010 " if (reflectClass(MyException).superclass.reflectedType != "
1011 " IsolateSpawnException) {" 1011 " IsolateSpawnException) {"
1012 " throw new Exception('Canonicalization failure');" 1012 " throw new Exception('Canonicalization failure');"
1013 " }" 1013 " }"
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
1099 1099
1100 // Invoke a function which returns an object. 1100 // Invoke a function which returns an object.
1101 result = Dart_Invoke(result, NewString("main"), 0, NULL); 1101 result = Dart_Invoke(result, NewString("main"), 0, NULL);
1102 EXPECT_VALID(result); 1102 EXPECT_VALID(result);
1103 Dart_ExitScope(); 1103 Dart_ExitScope();
1104 Dart_ShutdownIsolate(); 1104 Dart_ShutdownIsolate();
1105 } 1105 }
1106 free(script_snapshot); 1106 free(script_snapshot);
1107 free(full_snapshot); 1107 free(full_snapshot);
1108 } 1108 }
1109 #endif
1109 1110
1110 1111
1111 static void IterateScripts(const Library& lib) { 1112 static void IterateScripts(const Library& lib) {
1112 const Array& lib_scripts = Array::Handle(lib.LoadedScripts()); 1113 const Array& lib_scripts = Array::Handle(lib.LoadedScripts());
1113 Script& script = Script::Handle(); 1114 Script& script = Script::Handle();
1114 String& uri = String::Handle(); 1115 String& uri = String::Handle();
1115 for (intptr_t i = 0; i < lib_scripts.Length(); i++) { 1116 for (intptr_t i = 0; i < lib_scripts.Length(); i++) {
1116 script ^= lib_scripts.At(i); 1117 script ^= lib_scripts.At(i);
1117 EXPECT(!script.IsNull()); 1118 EXPECT(!script.IsNull());
1118 uri = script.url(); 1119 uri = script.url();
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after
1462 result = Dart_Invoke(cls, NewString("testMain"), 0, NULL); 1463 result = Dart_Invoke(cls, NewString("testMain"), 0, NULL);
1463 EXPECT_VALID(result); 1464 EXPECT_VALID(result);
1464 Dart_ExitScope(); 1465 Dart_ExitScope();
1465 Dart_ShutdownIsolate(); 1466 Dart_ShutdownIsolate();
1466 } 1467 }
1467 free(full_snapshot); 1468 free(full_snapshot);
1468 free(script_snapshot); 1469 free(script_snapshot);
1469 } 1470 }
1470 1471
1471 1472
1472 #endif // !PRODUCT
1473
1474
1475 UNIT_TEST_CASE(ScriptSnapshot1) { 1473 UNIT_TEST_CASE(ScriptSnapshot1) {
1476 const char* kScriptChars = 1474 const char* kScriptChars =
1477 "class _SimpleNumEnumerable<T extends num> {" 1475 "class _SimpleNumEnumerable<T extends num> {"
1478 "final Iterable<T> _source;" 1476 "final Iterable<T> _source;"
1479 "const _SimpleNumEnumerable(this._source) : super();" 1477 "const _SimpleNumEnumerable(this._source) : super();"
1480 "}"; 1478 "}";
1481 1479
1482 Dart_Handle result; 1480 Dart_Handle result;
1483 uint8_t* buffer; 1481 uint8_t* buffer;
1484 intptr_t size; 1482 intptr_t size;
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
1659 result = Dart_Invoke(lib, NewString("test_b"), 0, NULL); 1657 result = Dart_Invoke(lib, NewString("test_b"), 0, NULL);
1660 EXPECT(Dart_IsError(result) == saved_enable_type_checks_mode); 1658 EXPECT(Dart_IsError(result) == saved_enable_type_checks_mode);
1661 Dart_ExitScope(); 1659 Dart_ExitScope();
1662 } 1660 }
1663 Dart_ShutdownIsolate(); 1661 Dart_ShutdownIsolate();
1664 free(full_snapshot); 1662 free(full_snapshot);
1665 free(script_snapshot); 1663 free(script_snapshot);
1666 } 1664 }
1667 1665
1668 1666
1667 #endif // !PRODUCT
1668
1669
1669 TEST_CASE(IntArrayMessage) { 1670 TEST_CASE(IntArrayMessage) {
1670 StackZone zone(Thread::Current()); 1671 StackZone zone(Thread::Current());
1671 uint8_t* buffer = NULL; 1672 uint8_t* buffer = NULL;
1672 ApiMessageWriter writer(&buffer, &zone_allocator); 1673 ApiMessageWriter writer(&buffer, &zone_allocator);
1673 1674
1674 static const int kArrayLength = 2; 1675 static const int kArrayLength = 2;
1675 intptr_t data[kArrayLength] = {1, 2}; 1676 intptr_t data[kArrayLength] = {1, 2};
1676 int len = kArrayLength; 1677 int len = kArrayLength;
1677 writer.WriteMessage(len, data); 1678 writer.WriteMessage(len, data);
1678 1679
(...skipping 1330 matching lines...) Expand 10 before | Expand all | Expand 10 after
3009 StackZone zone(Thread::Current()); 3010 StackZone zone(Thread::Current());
3010 uint8_t* buffer; 3011 uint8_t* buffer;
3011 MessageWriter writer(&buffer, &zone_allocator, true); 3012 MessageWriter writer(&buffer, &zone_allocator, true);
3012 writer.WriteInlinedObjectHeader(kOmittedObjectId); 3013 writer.WriteInlinedObjectHeader(kOmittedObjectId);
3013 // For performance, we'd like single-byte headers when ids are omitted. 3014 // For performance, we'd like single-byte headers when ids are omitted.
3014 // If this starts failing, consider renumbering the snapshot ids. 3015 // If this starts failing, consider renumbering the snapshot ids.
3015 EXPECT_EQ(1, writer.BytesWritten()); 3016 EXPECT_EQ(1, writer.BytesWritten());
3016 } 3017 }
3017 3018
3018 } // namespace dart 3019 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/snapshot.cc ('k') | runtime/vm/stub_code_arm.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698