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

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

Issue 1541073002: Implement safepointing of threads (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: fix-typo 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/service.cc ('k') | runtime/vm/stack_frame_test.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"
(...skipping 1102 matching lines...) Expand 10 before | Expand all | Expand 10 after
1113 String& uri = String::Handle(); 1113 String& uri = String::Handle();
1114 for (intptr_t i = 0; i < lib_scripts.Length(); i++) { 1114 for (intptr_t i = 0; i < lib_scripts.Length(); i++) {
1115 script ^= lib_scripts.At(i); 1115 script ^= lib_scripts.At(i);
1116 EXPECT(!script.IsNull()); 1116 EXPECT(!script.IsNull());
1117 uri = script.url(); 1117 uri = script.url();
1118 OS::Print("Generating source for part: %s\n", uri.ToCString()); 1118 OS::Print("Generating source for part: %s\n", uri.ToCString());
1119 GenerateSourceAndCheck(script); 1119 GenerateSourceAndCheck(script);
1120 } 1120 }
1121 } 1121 }
1122 1122
1123 TEST_CASE(GenerateSource) { 1123 VM_TEST_CASE(GenerateSource) {
1124 Zone* zone = thread->zone(); 1124 Zone* zone = thread->zone();
1125 Isolate* isolate = thread->isolate(); 1125 Isolate* isolate = thread->isolate();
1126 const GrowableObjectArray& libs = GrowableObjectArray::Handle( 1126 const GrowableObjectArray& libs = GrowableObjectArray::Handle(
1127 zone, isolate->object_store()->libraries()); 1127 zone, isolate->object_store()->libraries());
1128 Library& lib = Library::Handle(); 1128 Library& lib = Library::Handle();
1129 String& uri = String::Handle(); 1129 String& uri = String::Handle();
1130 for (intptr_t i = 0; i < libs.Length(); i++) { 1130 for (intptr_t i = 0; i < libs.Length(); i++) {
1131 lib ^= libs.At(i); 1131 lib ^= libs.At(i);
1132 EXPECT(!lib.IsNull()); 1132 EXPECT(!lib.IsNull());
1133 uri = lib.url(); 1133 uri = lib.url();
(...skipping 700 matching lines...) Expand 10 before | Expand all | Expand 10 after
1834 EXPECT_VALID(surrogates_string_result); 1834 EXPECT_VALID(surrogates_string_result);
1835 EXPECT(Dart_IsString(surrogates_string_result)); 1835 EXPECT(Dart_IsString(surrogates_string_result));
1836 1836
1837 Dart_Handle crappy_string_result; 1837 Dart_Handle crappy_string_result;
1838 crappy_string_result = 1838 crappy_string_result =
1839 Dart_Invoke(lib, NewString("getCrappyString"), 0, NULL); 1839 Dart_Invoke(lib, NewString("getCrappyString"), 0, NULL);
1840 EXPECT_VALID(crappy_string_result); 1840 EXPECT_VALID(crappy_string_result);
1841 EXPECT(Dart_IsString(crappy_string_result)); 1841 EXPECT(Dart_IsString(crappy_string_result));
1842 1842
1843 { 1843 {
1844 DARTSCOPE(Thread::Current()); 1844 Thread* thread = Thread::Current();
1845 CHECK_API_SCOPE(thread);
1846 HANDLESCOPE(thread);
1845 1847
1846 { 1848 {
1847 StackZone zone(Thread::Current()); 1849 StackZone zone(thread);
1848 Smi& smi = Smi::Handle(); 1850 Smi& smi = Smi::Handle();
1849 smi ^= Api::UnwrapHandle(smi_result); 1851 smi ^= Api::UnwrapHandle(smi_result);
1850 uint8_t* buffer; 1852 uint8_t* buffer;
1851 MessageWriter writer(&buffer, &zone_allocator, false); 1853 MessageWriter writer(&buffer, &zone_allocator, false);
1852 writer.WriteMessage(smi); 1854 writer.WriteMessage(smi);
1853 intptr_t buffer_len = writer.BytesWritten(); 1855 intptr_t buffer_len = writer.BytesWritten();
1854 1856
1855 // Read object back from the snapshot into a C structure. 1857 // Read object back from the snapshot into a C structure.
1856 ApiNativeScope scope; 1858 ApiNativeScope scope;
1857 ApiMessageReader api_reader(buffer, buffer_len); 1859 ApiMessageReader api_reader(buffer, buffer_len);
1858 Dart_CObject* root = api_reader.ReadMessage(); 1860 Dart_CObject* root = api_reader.ReadMessage();
1859 EXPECT_NOTNULL(root); 1861 EXPECT_NOTNULL(root);
1860 EXPECT_EQ(Dart_CObject_kInt32, root->type); 1862 EXPECT_EQ(Dart_CObject_kInt32, root->type);
1861 EXPECT_EQ(42, root->value.as_int32); 1863 EXPECT_EQ(42, root->value.as_int32);
1862 CheckEncodeDecodeMessage(root); 1864 CheckEncodeDecodeMessage(root);
1863 } 1865 }
1864 { 1866 {
1865 StackZone zone(Thread::Current()); 1867 StackZone zone(thread);
1866 Bigint& bigint = Bigint::Handle(); 1868 Bigint& bigint = Bigint::Handle();
1867 bigint ^= Api::UnwrapHandle(bigint_result); 1869 bigint ^= Api::UnwrapHandle(bigint_result);
1868 uint8_t* buffer; 1870 uint8_t* buffer;
1869 MessageWriter writer(&buffer, &zone_allocator, false); 1871 MessageWriter writer(&buffer, &zone_allocator, false);
1870 writer.WriteMessage(bigint); 1872 writer.WriteMessage(bigint);
1871 intptr_t buffer_len = writer.BytesWritten(); 1873 intptr_t buffer_len = writer.BytesWritten();
1872 1874
1873 // Read object back from the snapshot into a C structure. 1875 // Read object back from the snapshot into a C structure.
1874 ApiNativeScope scope; 1876 ApiNativeScope scope;
1875 ApiMessageReader api_reader(buffer, buffer_len); 1877 ApiMessageReader api_reader(buffer, buffer_len);
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
1926 1928
1927 TestCase::CreateTestIsolate(); 1929 TestCase::CreateTestIsolate();
1928 Thread* thread = Thread::Current(); 1930 Thread* thread = Thread::Current();
1929 EXPECT(thread->isolate() != NULL); 1931 EXPECT(thread->isolate() != NULL);
1930 Dart_EnterScope(); 1932 Dart_EnterScope();
1931 1933
1932 Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); 1934 Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL);
1933 EXPECT_VALID(lib); 1935 EXPECT_VALID(lib);
1934 1936
1935 { 1937 {
1936 DARTSCOPE(thread); 1938 CHECK_API_SCOPE(thread);
1939 HANDLESCOPE(thread);
1937 StackZone zone(thread); 1940 StackZone zone(thread);
1938 intptr_t buf_len = 0; 1941 intptr_t buf_len = 0;
1939 { 1942 {
1940 // Generate a list of nulls from Dart code. 1943 // Generate a list of nulls from Dart code.
1941 uint8_t* buf = GetSerialized(lib, "getList", &buf_len); 1944 uint8_t* buf = GetSerialized(lib, "getList", &buf_len);
1942 ApiNativeScope scope; 1945 ApiNativeScope scope;
1943 Dart_CObject* root = GetDeserialized(buf, buf_len); 1946 Dart_CObject* root = GetDeserialized(buf, buf_len);
1944 EXPECT_NOTNULL(root); 1947 EXPECT_NOTNULL(root);
1945 EXPECT_EQ(Dart_CObject_kArray, root->type); 1948 EXPECT_EQ(Dart_CObject_kArray, root->type);
1946 EXPECT_EQ(kArrayLength, root->value.as_array.length); 1949 EXPECT_EQ(kArrayLength, root->value.as_array.length);
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
2050 2053
2051 TestCase::CreateTestIsolate(); 2054 TestCase::CreateTestIsolate();
2052 Thread* thread = Thread::Current(); 2055 Thread* thread = Thread::Current();
2053 EXPECT(thread->isolate() != NULL); 2056 EXPECT(thread->isolate() != NULL);
2054 Dart_EnterScope(); 2057 Dart_EnterScope();
2055 2058
2056 Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); 2059 Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL);
2057 EXPECT_VALID(lib); 2060 EXPECT_VALID(lib);
2058 2061
2059 { 2062 {
2060 DARTSCOPE(thread); 2063 CHECK_API_SCOPE(thread);
2064 HANDLESCOPE(thread);
2061 StackZone zone(thread); 2065 StackZone zone(thread);
2062 intptr_t buf_len = 0; 2066 intptr_t buf_len = 0;
2063 { 2067 {
2064 // Generate a list of nulls from Dart code. 2068 // Generate a list of nulls from Dart code.
2065 uint8_t* buf = GetSerialized(lib, "getList", &buf_len); 2069 uint8_t* buf = GetSerialized(lib, "getList", &buf_len);
2066 ApiNativeScope scope; 2070 ApiNativeScope scope;
2067 Dart_CObject* root = GetDeserialized(buf, buf_len); 2071 Dart_CObject* root = GetDeserialized(buf, buf_len);
2068 EXPECT_NOTNULL(root); 2072 EXPECT_NOTNULL(root);
2069 EXPECT_EQ(Dart_CObject_kArray, root->type); 2073 EXPECT_EQ(Dart_CObject_kArray, root->type);
2070 EXPECT_EQ(kArrayLength, root->value.as_array.length); 2074 EXPECT_EQ(kArrayLength, root->value.as_array.length);
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
2289 2293
2290 TestCase::CreateTestIsolate(); 2294 TestCase::CreateTestIsolate();
2291 Thread* thread = Thread::Current(); 2295 Thread* thread = Thread::Current();
2292 EXPECT(thread->isolate() != NULL); 2296 EXPECT(thread->isolate() != NULL);
2293 Dart_EnterScope(); 2297 Dart_EnterScope();
2294 2298
2295 Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); 2299 Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL);
2296 EXPECT_VALID(lib); 2300 EXPECT_VALID(lib);
2297 2301
2298 { 2302 {
2299 DARTSCOPE(thread); 2303 CHECK_API_SCOPE(thread);
2304 HANDLESCOPE(thread);
2300 StackZone zone(thread); 2305 StackZone zone(thread);
2301 intptr_t buf_len = 0; 2306 intptr_t buf_len = 0;
2302 { 2307 {
2303 // Generate a list of strings from Dart code. 2308 // Generate a list of strings from Dart code.
2304 uint8_t* buf = GetSerialized(lib, "getStringList", &buf_len); 2309 uint8_t* buf = GetSerialized(lib, "getStringList", &buf_len);
2305 ApiNativeScope scope; 2310 ApiNativeScope scope;
2306 Dart_CObject* root = GetDeserialized(buf, buf_len); 2311 Dart_CObject* root = GetDeserialized(buf, buf_len);
2307 EXPECT_NOTNULL(root); 2312 EXPECT_NOTNULL(root);
2308 EXPECT_EQ(Dart_CObject_kArray, root->type); 2313 EXPECT_EQ(Dart_CObject_kArray, root->type);
2309 EXPECT_EQ(kArrayLength, root->value.as_array.length); 2314 EXPECT_EQ(kArrayLength, root->value.as_array.length);
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
2514 2519
2515 TestCase::CreateTestIsolate(); 2520 TestCase::CreateTestIsolate();
2516 Thread* thread = Thread::Current(); 2521 Thread* thread = Thread::Current();
2517 EXPECT(thread->isolate() != NULL); 2522 EXPECT(thread->isolate() != NULL);
2518 Dart_EnterScope(); 2523 Dart_EnterScope();
2519 2524
2520 Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); 2525 Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL);
2521 EXPECT_VALID(lib); 2526 EXPECT_VALID(lib);
2522 2527
2523 { 2528 {
2524 DARTSCOPE(thread); 2529 CHECK_API_SCOPE(thread);
2530 HANDLESCOPE(thread);
2525 StackZone zone(thread); 2531 StackZone zone(thread);
2526 intptr_t buf_len = 0; 2532 intptr_t buf_len = 0;
2527 { 2533 {
2528 // Generate a list of strings from Dart code. 2534 // Generate a list of strings from Dart code.
2529 uint8_t* buf = GetSerialized(lib, "getStringList", &buf_len); 2535 uint8_t* buf = GetSerialized(lib, "getStringList", &buf_len);
2530 ApiNativeScope scope; 2536 ApiNativeScope scope;
2531 Dart_CObject* root = GetDeserialized(buf, buf_len); 2537 Dart_CObject* root = GetDeserialized(buf, buf_len);
2532 EXPECT_NOTNULL(root); 2538 EXPECT_NOTNULL(root);
2533 EXPECT_EQ(Dart_CObject_kArray, root->type); 2539 EXPECT_EQ(Dart_CObject_kArray, root->type);
2534 EXPECT_EQ(kArrayLength, root->value.as_array.length); 2540 EXPECT_EQ(kArrayLength, root->value.as_array.length);
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
2755 2761
2756 TestCase::CreateTestIsolate(); 2762 TestCase::CreateTestIsolate();
2757 Thread* thread = Thread::Current(); 2763 Thread* thread = Thread::Current();
2758 EXPECT(thread->isolate() != NULL); 2764 EXPECT(thread->isolate() != NULL);
2759 Dart_EnterScope(); 2765 Dart_EnterScope();
2760 2766
2761 Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); 2767 Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL);
2762 EXPECT_VALID(lib); 2768 EXPECT_VALID(lib);
2763 2769
2764 { 2770 {
2765 DARTSCOPE(thread); 2771 CHECK_API_SCOPE(thread);
2772 HANDLESCOPE(thread);
2766 StackZone zone(thread); 2773 StackZone zone(thread);
2767 intptr_t buf_len = 0; 2774 intptr_t buf_len = 0;
2768 { 2775 {
2769 // Generate a list of Uint8Lists from Dart code. 2776 // Generate a list of Uint8Lists from Dart code.
2770 uint8_t* buf = GetSerialized(lib, "getTypedDataList", &buf_len); 2777 uint8_t* buf = GetSerialized(lib, "getTypedDataList", &buf_len);
2771 ApiNativeScope scope; 2778 ApiNativeScope scope;
2772 Dart_CObject* root = GetDeserialized(buf, buf_len); 2779 Dart_CObject* root = GetDeserialized(buf, buf_len);
2773 EXPECT_NOTNULL(root); 2780 EXPECT_NOTNULL(root);
2774 EXPECT_EQ(Dart_CObject_kArray, root->type); 2781 EXPECT_EQ(Dart_CObject_kArray, root->type);
2775 struct { 2782 struct {
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
2998 StackZone zone(Thread::Current()); 3005 StackZone zone(Thread::Current());
2999 uint8_t* buffer; 3006 uint8_t* buffer;
3000 MessageWriter writer(&buffer, &zone_allocator, true); 3007 MessageWriter writer(&buffer, &zone_allocator, true);
3001 writer.WriteInlinedObjectHeader(kOmittedObjectId); 3008 writer.WriteInlinedObjectHeader(kOmittedObjectId);
3002 // For performance, we'd like single-byte headers when ids are omitted. 3009 // For performance, we'd like single-byte headers when ids are omitted.
3003 // If this starts failing, consider renumbering the snapshot ids. 3010 // If this starts failing, consider renumbering the snapshot ids.
3004 EXPECT_EQ(1, writer.BytesWritten()); 3011 EXPECT_EQ(1, writer.BytesWritten());
3005 } 3012 }
3006 3013
3007 } // namespace dart 3014 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/service.cc ('k') | runtime/vm/stack_frame_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698