| 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 984 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 995 // Check if we are able to generate the source from the token stream. | 995 // 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 | 996 // Rescan this source and compare the token stream to see if they are |
| 997 // the same. | 997 // the same. |
| 998 GenerateSourceAndCheck(serialized_script); | 998 GenerateSourceAndCheck(serialized_script); |
| 999 | 999 |
| 1000 free(buffer); | 1000 free(buffer); |
| 1001 } | 1001 } |
| 1002 | 1002 |
| 1003 | 1003 |
| 1004 #if !defined(PRODUCT) // Uses deferred loading. | 1004 #if !defined(PRODUCT) // Uses deferred loading. |
| 1005 UNIT_TEST_CASE(CanonicalizationInScriptSnapshots) { | 1005 VM_UNIT_TEST_CASE(CanonicalizationInScriptSnapshots) { |
| 1006 const char* kScriptChars = | 1006 const char* kScriptChars = |
| 1007 "\n" | 1007 "\n" |
| 1008 "import 'dart:mirrors';" | 1008 "import 'dart:mirrors';" |
| 1009 "import 'dart:isolate';" | 1009 "import 'dart:isolate';" |
| 1010 "void main() {" | 1010 "void main() {" |
| 1011 " if (reflectClass(MyException).superclass.reflectedType != " | 1011 " if (reflectClass(MyException).superclass.reflectedType != " |
| 1012 " IsolateSpawnException) {" | 1012 " IsolateSpawnException) {" |
| 1013 " throw new Exception('Canonicalization failure');" | 1013 " throw new Exception('Canonicalization failure');" |
| 1014 " }" | 1014 " }" |
| 1015 " if (reflectClass(IsolateSpawnException).reflectedType != " | 1015 " if (reflectClass(IsolateSpawnException).reflectedType != " |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1114 String& uri = String::Handle(); | 1114 String& uri = String::Handle(); |
| 1115 for (intptr_t i = 0; i < lib_scripts.Length(); i++) { | 1115 for (intptr_t i = 0; i < lib_scripts.Length(); i++) { |
| 1116 script ^= lib_scripts.At(i); | 1116 script ^= lib_scripts.At(i); |
| 1117 EXPECT(!script.IsNull()); | 1117 EXPECT(!script.IsNull()); |
| 1118 uri = script.url(); | 1118 uri = script.url(); |
| 1119 OS::Print("Generating source for part: %s\n", uri.ToCString()); | 1119 OS::Print("Generating source for part: %s\n", uri.ToCString()); |
| 1120 GenerateSourceAndCheck(script); | 1120 GenerateSourceAndCheck(script); |
| 1121 } | 1121 } |
| 1122 } | 1122 } |
| 1123 | 1123 |
| 1124 VM_TEST_CASE(GenerateSource) { | 1124 ISOLATE_UNIT_TEST_CASE(GenerateSource) { |
| 1125 Zone* zone = thread->zone(); | 1125 Zone* zone = thread->zone(); |
| 1126 Isolate* isolate = thread->isolate(); | 1126 Isolate* isolate = thread->isolate(); |
| 1127 const GrowableObjectArray& libs = | 1127 const GrowableObjectArray& libs = |
| 1128 GrowableObjectArray::Handle(zone, isolate->object_store()->libraries()); | 1128 GrowableObjectArray::Handle(zone, isolate->object_store()->libraries()); |
| 1129 Library& lib = Library::Handle(); | 1129 Library& lib = Library::Handle(); |
| 1130 String& uri = String::Handle(); | 1130 String& uri = String::Handle(); |
| 1131 for (intptr_t i = 0; i < libs.Length(); i++) { | 1131 for (intptr_t i = 0; i < libs.Length(); i++) { |
| 1132 lib ^= libs.At(i); | 1132 lib ^= libs.At(i); |
| 1133 EXPECT(!lib.IsNull()); | 1133 EXPECT(!lib.IsNull()); |
| 1134 uri = lib.url(); | 1134 uri = lib.url(); |
| 1135 OS::Print("Generating source for library: %s\n", uri.ToCString()); | 1135 OS::Print("Generating source for library: %s\n", uri.ToCString()); |
| 1136 IterateScripts(lib); | 1136 IterateScripts(lib); |
| 1137 } | 1137 } |
| 1138 } | 1138 } |
| 1139 | 1139 |
| 1140 | 1140 |
| 1141 UNIT_TEST_CASE(FullSnapshot) { | 1141 VM_UNIT_TEST_CASE(FullSnapshot) { |
| 1142 const char* kScriptChars = | 1142 const char* kScriptChars = |
| 1143 "class Fields {\n" | 1143 "class Fields {\n" |
| 1144 " Fields(int i, int j) : fld1 = i, fld2 = j {}\n" | 1144 " Fields(int i, int j) : fld1 = i, fld2 = j {}\n" |
| 1145 " int fld1;\n" | 1145 " int fld1;\n" |
| 1146 " final int fld2;\n" | 1146 " final int fld2;\n" |
| 1147 " final int bigint_fld = 0xfffffffffff;\n" | 1147 " final int bigint_fld = 0xfffffffffff;\n" |
| 1148 " static int fld3;\n" | 1148 " static int fld3;\n" |
| 1149 " static const int smi_sfld = 10;\n" | 1149 " static const int smi_sfld = 10;\n" |
| 1150 " static const int bigint_sfld = 0xfffffffffff;\n" | 1150 " static const int bigint_sfld = 0xfffffffffff;\n" |
| 1151 "}\n" | 1151 "}\n" |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1205 Dart_Handle cls = Dart_GetClass(TestCase::lib(), NewString("FieldsTest")); | 1205 Dart_Handle cls = Dart_GetClass(TestCase::lib(), NewString("FieldsTest")); |
| 1206 result = Dart_Invoke(cls, NewString("testMain"), 0, NULL); | 1206 result = Dart_Invoke(cls, NewString("testMain"), 0, NULL); |
| 1207 EXPECT_VALID(result); | 1207 EXPECT_VALID(result); |
| 1208 Dart_ExitScope(); | 1208 Dart_ExitScope(); |
| 1209 } | 1209 } |
| 1210 Dart_ShutdownIsolate(); | 1210 Dart_ShutdownIsolate(); |
| 1211 free(isolate_snapshot_data_buffer); | 1211 free(isolate_snapshot_data_buffer); |
| 1212 } | 1212 } |
| 1213 | 1213 |
| 1214 | 1214 |
| 1215 UNIT_TEST_CASE(FullSnapshot1) { | 1215 VM_UNIT_TEST_CASE(FullSnapshot1) { |
| 1216 // This buffer has to be static for this to compile with Visual Studio. | 1216 // This buffer has to be static for this to compile with Visual Studio. |
| 1217 // If it is not static compilation of this file with Visual Studio takes | 1217 // If it is not static compilation of this file with Visual Studio takes |
| 1218 // more than 30 minutes! | 1218 // more than 30 minutes! |
| 1219 static const char kFullSnapshotScriptChars[] = { | 1219 static const char kFullSnapshotScriptChars[] = { |
| 1220 #include "snapshot_test.dat" | 1220 #include "snapshot_test.dat" |
| 1221 }; | 1221 }; |
| 1222 const char* kScriptChars = kFullSnapshotScriptChars; | 1222 const char* kScriptChars = kFullSnapshotScriptChars; |
| 1223 | 1223 |
| 1224 uint8_t* isolate_snapshot_data_buffer; | 1224 uint8_t* isolate_snapshot_data_buffer; |
| 1225 | 1225 |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1274 Dart_ExitScope(); | 1274 Dart_ExitScope(); |
| 1275 } | 1275 } |
| 1276 Dart_ShutdownIsolate(); | 1276 Dart_ShutdownIsolate(); |
| 1277 free(isolate_snapshot_data_buffer); | 1277 free(isolate_snapshot_data_buffer); |
| 1278 } | 1278 } |
| 1279 | 1279 |
| 1280 | 1280 |
| 1281 #ifndef PRODUCT | 1281 #ifndef PRODUCT |
| 1282 | 1282 |
| 1283 | 1283 |
| 1284 UNIT_TEST_CASE(ScriptSnapshot) { | 1284 VM_UNIT_TEST_CASE(ScriptSnapshot) { |
| 1285 const char* kLibScriptChars = | 1285 const char* kLibScriptChars = |
| 1286 "library dart_import_lib;" | 1286 "library dart_import_lib;" |
| 1287 "class LibFields {" | 1287 "class LibFields {" |
| 1288 " LibFields(int i, int j) : fld1 = i, fld2 = j {}" | 1288 " LibFields(int i, int j) : fld1 = i, fld2 = j {}" |
| 1289 " int fld1;" | 1289 " int fld1;" |
| 1290 " final int fld2;" | 1290 " final int fld2;" |
| 1291 "}"; | 1291 "}"; |
| 1292 const char* kScriptChars = | 1292 const char* kScriptChars = |
| 1293 "class TestTrace implements StackTrace {" | 1293 "class TestTrace implements StackTrace {" |
| 1294 " TestTrace();" | 1294 " TestTrace();" |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1409 result = Dart_Invoke(cls, NewString("testMain"), 0, NULL); | 1409 result = Dart_Invoke(cls, NewString("testMain"), 0, NULL); |
| 1410 EXPECT_VALID(result); | 1410 EXPECT_VALID(result); |
| 1411 Dart_ExitScope(); | 1411 Dart_ExitScope(); |
| 1412 Dart_ShutdownIsolate(); | 1412 Dart_ShutdownIsolate(); |
| 1413 } | 1413 } |
| 1414 free(full_snapshot); | 1414 free(full_snapshot); |
| 1415 free(script_snapshot); | 1415 free(script_snapshot); |
| 1416 } | 1416 } |
| 1417 | 1417 |
| 1418 | 1418 |
| 1419 UNIT_TEST_CASE(ScriptSnapshot1) { | 1419 VM_UNIT_TEST_CASE(ScriptSnapshot1) { |
| 1420 const char* kScriptChars = | 1420 const char* kScriptChars = |
| 1421 "class _SimpleNumEnumerable<T extends num> {" | 1421 "class _SimpleNumEnumerable<T extends num> {" |
| 1422 "final Iterable<T> _source;" | 1422 "final Iterable<T> _source;" |
| 1423 "const _SimpleNumEnumerable(this._source) : super();" | 1423 "const _SimpleNumEnumerable(this._source) : super();" |
| 1424 "}"; | 1424 "}"; |
| 1425 | 1425 |
| 1426 Dart_Handle result; | 1426 Dart_Handle result; |
| 1427 uint8_t* buffer; | 1427 uint8_t* buffer; |
| 1428 intptr_t size; | 1428 intptr_t size; |
| 1429 intptr_t vm_isolate_snapshot_size; | 1429 intptr_t vm_isolate_snapshot_size; |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1482 Dart_ExitScope(); | 1482 Dart_ExitScope(); |
| 1483 } | 1483 } |
| 1484 | 1484 |
| 1485 FLAG_load_deferred_eagerly = saved_load_deferred_eagerly_mode; | 1485 FLAG_load_deferred_eagerly = saved_load_deferred_eagerly_mode; |
| 1486 Dart_ShutdownIsolate(); | 1486 Dart_ShutdownIsolate(); |
| 1487 free(full_snapshot); | 1487 free(full_snapshot); |
| 1488 free(script_snapshot); | 1488 free(script_snapshot); |
| 1489 } | 1489 } |
| 1490 | 1490 |
| 1491 | 1491 |
| 1492 UNIT_TEST_CASE(ScriptSnapshot2) { | 1492 VM_UNIT_TEST_CASE(ScriptSnapshot2) { |
| 1493 // The snapshot of this library is always created in production mode, but | 1493 // The snapshot of this library is always created in production mode, but |
| 1494 // loaded and executed in both production and checked modes. | 1494 // loaded and executed in both production and checked modes. |
| 1495 // This test verifies that type information is still contained in the snapshot | 1495 // This test verifies that type information is still contained in the snapshot |
| 1496 // although it was created in production mode and that type errors and | 1496 // although it was created in production mode and that type errors and |
| 1497 // compilation errors (for const fields) are correctly reported according to | 1497 // compilation errors (for const fields) are correctly reported according to |
| 1498 // the execution mode. | 1498 // the execution mode. |
| 1499 const char* kLibScriptChars = | 1499 const char* kLibScriptChars = |
| 1500 "library dart_import_lib;" | 1500 "library dart_import_lib;" |
| 1501 "const String s = 1.0;" | 1501 "const String s = 1.0;" |
| 1502 "final int i = true;" | 1502 "final int i = true;" |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1598 result = Dart_Invoke(lib, NewString("test_b"), 0, NULL); | 1598 result = Dart_Invoke(lib, NewString("test_b"), 0, NULL); |
| 1599 EXPECT(Dart_IsError(result) == saved_enable_type_checks_mode); | 1599 EXPECT(Dart_IsError(result) == saved_enable_type_checks_mode); |
| 1600 Dart_ExitScope(); | 1600 Dart_ExitScope(); |
| 1601 } | 1601 } |
| 1602 Dart_ShutdownIsolate(); | 1602 Dart_ShutdownIsolate(); |
| 1603 free(full_snapshot); | 1603 free(full_snapshot); |
| 1604 free(script_snapshot); | 1604 free(script_snapshot); |
| 1605 } | 1605 } |
| 1606 | 1606 |
| 1607 | 1607 |
| 1608 UNIT_TEST_CASE(MismatchedSnapshotKinds) { | 1608 VM_UNIT_TEST_CASE(MismatchedSnapshotKinds) { |
| 1609 const char* kScriptChars = "main() { print('Hello, world!'); }"; | 1609 const char* kScriptChars = "main() { print('Hello, world!'); }"; |
| 1610 Dart_Handle result; | 1610 Dart_Handle result; |
| 1611 | 1611 |
| 1612 uint8_t* buffer; | 1612 uint8_t* buffer; |
| 1613 intptr_t size; | 1613 intptr_t size; |
| 1614 intptr_t vm_isolate_snapshot_size; | 1614 intptr_t vm_isolate_snapshot_size; |
| 1615 uint8_t* isolate_snapshot = NULL; | 1615 uint8_t* isolate_snapshot = NULL; |
| 1616 intptr_t isolate_snapshot_size; | 1616 intptr_t isolate_snapshot_size; |
| 1617 uint8_t* full_snapshot = NULL; | 1617 uint8_t* full_snapshot = NULL; |
| 1618 uint8_t* script_snapshot = NULL; | 1618 uint8_t* script_snapshot = NULL; |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1774 | 1774 |
| 1775 // Read object back from the snapshot into a C structure. | 1775 // Read object back from the snapshot into a C structure. |
| 1776 ApiNativeScope scope; | 1776 ApiNativeScope scope; |
| 1777 ApiMessageReader api_reader(buffer, buffer_len); | 1777 ApiMessageReader api_reader(buffer, buffer_len); |
| 1778 Dart_CObject* root = api_reader.ReadMessage(); | 1778 Dart_CObject* root = api_reader.ReadMessage(); |
| 1779 EXPECT_NOTNULL(root); | 1779 EXPECT_NOTNULL(root); |
| 1780 EXPECT_EQ(Dart_CObject_kUnsupported, root->type); | 1780 EXPECT_EQ(Dart_CObject_kUnsupported, root->type); |
| 1781 } | 1781 } |
| 1782 | 1782 |
| 1783 | 1783 |
| 1784 UNIT_TEST_CASE(DartGeneratedMessages) { | 1784 VM_UNIT_TEST_CASE(DartGeneratedMessages) { |
| 1785 static const char* kCustomIsolateScriptChars = | 1785 static const char* kCustomIsolateScriptChars = |
| 1786 "getSmi() {\n" | 1786 "getSmi() {\n" |
| 1787 " return 42;\n" | 1787 " return 42;\n" |
| 1788 "}\n" | 1788 "}\n" |
| 1789 "getBigint() {\n" | 1789 "getBigint() {\n" |
| 1790 " return -0x424242424242424242424242424242424242;\n" | 1790 " return -0x424242424242424242424242424242424242;\n" |
| 1791 "}\n" | 1791 "}\n" |
| 1792 "getAsciiString() {\n" | 1792 "getAsciiString() {\n" |
| 1793 " return \"Hello, world!\";\n" | 1793 " return \"Hello, world!\";\n" |
| 1794 "}\n" | 1794 "}\n" |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1922 CheckStringInvalid(lead_surrogate_string_result); | 1922 CheckStringInvalid(lead_surrogate_string_result); |
| 1923 CheckStringInvalid(trail_surrogate_string_result); | 1923 CheckStringInvalid(trail_surrogate_string_result); |
| 1924 CheckStringInvalid(crappy_string_result); | 1924 CheckStringInvalid(crappy_string_result); |
| 1925 CheckStringInvalid(surrogates_string_result); | 1925 CheckStringInvalid(surrogates_string_result); |
| 1926 } | 1926 } |
| 1927 Dart_ExitScope(); | 1927 Dart_ExitScope(); |
| 1928 Dart_ShutdownIsolate(); | 1928 Dart_ShutdownIsolate(); |
| 1929 } | 1929 } |
| 1930 | 1930 |
| 1931 | 1931 |
| 1932 UNIT_TEST_CASE(DartGeneratedListMessages) { | 1932 VM_UNIT_TEST_CASE(DartGeneratedListMessages) { |
| 1933 const int kArrayLength = 10; | 1933 const int kArrayLength = 10; |
| 1934 static const char* kScriptChars = | 1934 static const char* kScriptChars = |
| 1935 "final int kArrayLength = 10;\n" | 1935 "final int kArrayLength = 10;\n" |
| 1936 "getList() {\n" | 1936 "getList() {\n" |
| 1937 " return new List(kArrayLength);\n" | 1937 " return new List(kArrayLength);\n" |
| 1938 "}\n" | 1938 "}\n" |
| 1939 "getIntList() {\n" | 1939 "getIntList() {\n" |
| 1940 " var list = new List<int>(kArrayLength);\n" | 1940 " var list = new List<int>(kArrayLength);\n" |
| 1941 " for (var i = 0; i < kArrayLength; i++) list[i] = i;\n" | 1941 " for (var i = 0; i < kArrayLength; i++) list[i] = i;\n" |
| 1942 " return list;\n" | 1942 " return list;\n" |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2033 EXPECT_EQ(Dart_CObject_kNull, root->value.as_array.values[i]->type); | 2033 EXPECT_EQ(Dart_CObject_kNull, root->value.as_array.values[i]->type); |
| 2034 } | 2034 } |
| 2035 } | 2035 } |
| 2036 } | 2036 } |
| 2037 } | 2037 } |
| 2038 Dart_ExitScope(); | 2038 Dart_ExitScope(); |
| 2039 Dart_ShutdownIsolate(); | 2039 Dart_ShutdownIsolate(); |
| 2040 } | 2040 } |
| 2041 | 2041 |
| 2042 | 2042 |
| 2043 UNIT_TEST_CASE(DartGeneratedArrayLiteralMessages) { | 2043 VM_UNIT_TEST_CASE(DartGeneratedArrayLiteralMessages) { |
| 2044 const int kArrayLength = 10; | 2044 const int kArrayLength = 10; |
| 2045 static const char* kScriptChars = | 2045 static const char* kScriptChars = |
| 2046 "final int kArrayLength = 10;\n" | 2046 "final int kArrayLength = 10;\n" |
| 2047 "getList() {\n" | 2047 "getList() {\n" |
| 2048 " return [null, null, null, null, null, null, null, null, null, null];\n" | 2048 " return [null, null, null, null, null, null, null, null, null, null];\n" |
| 2049 "}\n" | 2049 "}\n" |
| 2050 "getIntList() {\n" | 2050 "getIntList() {\n" |
| 2051 " return [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];\n" | 2051 " return [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];\n" |
| 2052 "}\n" | 2052 "}\n" |
| 2053 "getStringList() {\n" | 2053 "getStringList() {\n" |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2254 EXPECT_EQ(Dart_CObject_kInt32, e->type); | 2254 EXPECT_EQ(Dart_CObject_kInt32, e->type); |
| 2255 EXPECT_EQ(i + 1, e->value.as_int32); | 2255 EXPECT_EQ(i + 1, e->value.as_int32); |
| 2256 } | 2256 } |
| 2257 } | 2257 } |
| 2258 } | 2258 } |
| 2259 Dart_ExitScope(); | 2259 Dart_ExitScope(); |
| 2260 Dart_ShutdownIsolate(); | 2260 Dart_ShutdownIsolate(); |
| 2261 } | 2261 } |
| 2262 | 2262 |
| 2263 | 2263 |
| 2264 UNIT_TEST_CASE(DartGeneratedListMessagesWithBackref) { | 2264 VM_UNIT_TEST_CASE(DartGeneratedListMessagesWithBackref) { |
| 2265 const int kArrayLength = 10; | 2265 const int kArrayLength = 10; |
| 2266 static const char* kScriptChars = | 2266 static const char* kScriptChars = |
| 2267 "import 'dart:typed_data';\n" | 2267 "import 'dart:typed_data';\n" |
| 2268 "final int kArrayLength = 10;\n" | 2268 "final int kArrayLength = 10;\n" |
| 2269 "getStringList() {\n" | 2269 "getStringList() {\n" |
| 2270 " var s = 'Hello, world!';\n" | 2270 " var s = 'Hello, world!';\n" |
| 2271 " var list = new List<String>(kArrayLength);\n" | 2271 " var list = new List<String>(kArrayLength);\n" |
| 2272 " for (var i = 0; i < kArrayLength; i++) list[i] = s;\n" | 2272 " for (var i = 0; i < kArrayLength; i++) list[i] = s;\n" |
| 2273 " return list;\n" | 2273 " return list;\n" |
| 2274 "}\n" | 2274 "}\n" |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2474 EXPECT_EQ(Dart_CObject_kArray, element->type); | 2474 EXPECT_EQ(Dart_CObject_kArray, element->type); |
| 2475 EXPECT_EQ(root, element); | 2475 EXPECT_EQ(root, element); |
| 2476 } | 2476 } |
| 2477 } | 2477 } |
| 2478 } | 2478 } |
| 2479 Dart_ExitScope(); | 2479 Dart_ExitScope(); |
| 2480 Dart_ShutdownIsolate(); | 2480 Dart_ShutdownIsolate(); |
| 2481 } | 2481 } |
| 2482 | 2482 |
| 2483 | 2483 |
| 2484 UNIT_TEST_CASE(DartGeneratedArrayLiteralMessagesWithBackref) { | 2484 VM_UNIT_TEST_CASE(DartGeneratedArrayLiteralMessagesWithBackref) { |
| 2485 const int kArrayLength = 10; | 2485 const int kArrayLength = 10; |
| 2486 static const char* kScriptChars = | 2486 static const char* kScriptChars = |
| 2487 "import 'dart:typed_data';\n" | 2487 "import 'dart:typed_data';\n" |
| 2488 "final int kArrayLength = 10;\n" | 2488 "final int kArrayLength = 10;\n" |
| 2489 "getStringList() {\n" | 2489 "getStringList() {\n" |
| 2490 " var s = 'Hello, world!';\n" | 2490 " var s = 'Hello, world!';\n" |
| 2491 " var list = [s, s, s, s, s, s, s, s, s, s];\n" | 2491 " var list = [s, s, s, s, s, s, s, s, s, s];\n" |
| 2492 " return list;\n" | 2492 " return list;\n" |
| 2493 "}\n" | 2493 "}\n" |
| 2494 "getMintList() {\n" | 2494 "getMintList() {\n" |
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2709 | 2709 |
| 2710 | 2710 |
| 2711 static void CheckTypedData(Dart_CObject* object, | 2711 static void CheckTypedData(Dart_CObject* object, |
| 2712 Dart_TypedData_Type typed_data_type, | 2712 Dart_TypedData_Type typed_data_type, |
| 2713 int len) { | 2713 int len) { |
| 2714 EXPECT_EQ(Dart_CObject_kTypedData, object->type); | 2714 EXPECT_EQ(Dart_CObject_kTypedData, object->type); |
| 2715 EXPECT_EQ(typed_data_type, object->value.as_typed_data.type); | 2715 EXPECT_EQ(typed_data_type, object->value.as_typed_data.type); |
| 2716 EXPECT_EQ(len, object->value.as_typed_data.length); | 2716 EXPECT_EQ(len, object->value.as_typed_data.length); |
| 2717 } | 2717 } |
| 2718 | 2718 |
| 2719 UNIT_TEST_CASE(DartGeneratedListMessagesWithTypedData) { | 2719 VM_UNIT_TEST_CASE(DartGeneratedListMessagesWithTypedData) { |
| 2720 static const char* kScriptChars = | 2720 static const char* kScriptChars = |
| 2721 "import 'dart:typed_data';\n" | 2721 "import 'dart:typed_data';\n" |
| 2722 "getTypedDataList() {\n" | 2722 "getTypedDataList() {\n" |
| 2723 " var list = new List(10);\n" | 2723 " var list = new List(10);\n" |
| 2724 " var index = 0;\n" | 2724 " var index = 0;\n" |
| 2725 " list[index++] = new Int8List(256);\n" | 2725 " list[index++] = new Int8List(256);\n" |
| 2726 " list[index++] = new Uint8List(256);\n" | 2726 " list[index++] = new Uint8List(256);\n" |
| 2727 " list[index++] = new Int16List(256);\n" | 2727 " list[index++] = new Int16List(256);\n" |
| 2728 " list[index++] = new Uint16List(256);\n" | 2728 " list[index++] = new Uint16List(256);\n" |
| 2729 " list[index++] = new Int32List(256);\n" | 2729 " list[index++] = new Int32List(256);\n" |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2896 i++; | 2896 i++; |
| 2897 } | 2897 } |
| 2898 EXPECT_EQ(i, root->value.as_array.length); | 2898 EXPECT_EQ(i, root->value.as_array.length); |
| 2899 } | 2899 } |
| 2900 } | 2900 } |
| 2901 Dart_ExitScope(); | 2901 Dart_ExitScope(); |
| 2902 Dart_ShutdownIsolate(); | 2902 Dart_ShutdownIsolate(); |
| 2903 } | 2903 } |
| 2904 | 2904 |
| 2905 | 2905 |
| 2906 UNIT_TEST_CASE(PostCObject) { | 2906 VM_UNIT_TEST_CASE(PostCObject) { |
| 2907 // Create a native port for posting from C to Dart | 2907 // Create a native port for posting from C to Dart |
| 2908 TestIsolateScope __test_isolate__; | 2908 TestIsolateScope __test_isolate__; |
| 2909 const char* kScriptChars = | 2909 const char* kScriptChars = |
| 2910 "import 'dart:isolate';\n" | 2910 "import 'dart:isolate';\n" |
| 2911 "main() {\n" | 2911 "main() {\n" |
| 2912 " var messageCount = 0;\n" | 2912 " var messageCount = 0;\n" |
| 2913 " var exception = '';\n" | 2913 " var exception = '';\n" |
| 2914 " var port = new RawReceivePort();\n" | 2914 " var port = new RawReceivePort();\n" |
| 2915 " var sendPort = port.sendPort;\n" | 2915 " var sendPort = port.sendPort;\n" |
| 2916 " port.handler = (message) {\n" | 2916 " port.handler = (message) {\n" |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3003 StackZone zone(Thread::Current()); | 3003 StackZone zone(Thread::Current()); |
| 3004 uint8_t* buffer; | 3004 uint8_t* buffer; |
| 3005 MessageWriter writer(&buffer, &zone_allocator, &zone_deallocator, true); | 3005 MessageWriter writer(&buffer, &zone_allocator, &zone_deallocator, true); |
| 3006 writer.WriteInlinedObjectHeader(kOmittedObjectId); | 3006 writer.WriteInlinedObjectHeader(kOmittedObjectId); |
| 3007 // For performance, we'd like single-byte headers when ids are omitted. | 3007 // For performance, we'd like single-byte headers when ids are omitted. |
| 3008 // If this starts failing, consider renumbering the snapshot ids. | 3008 // If this starts failing, consider renumbering the snapshot ids. |
| 3009 EXPECT_EQ(1, writer.BytesWritten()); | 3009 EXPECT_EQ(1, writer.BytesWritten()); |
| 3010 } | 3010 } |
| 3011 | 3011 |
| 3012 } // namespace dart | 3012 } // namespace dart |
| OLD | NEW |