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

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

Issue 1312813006: - Remove deprecated StackZone constructor with Isolate parameter. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 3 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
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 1148 matching lines...) Expand 10 before | Expand all | Expand 10 after
1159 Dart_Handle result; 1159 Dart_Handle result;
1160 1160
1161 uint8_t* isolate_snapshot_buffer; 1161 uint8_t* isolate_snapshot_buffer;
1162 1162
1163 // Start an Isolate, load a script and create a full snapshot. 1163 // Start an Isolate, load a script and create a full snapshot.
1164 Timer timer1(true, "Snapshot_test"); 1164 Timer timer1(true, "Snapshot_test");
1165 timer1.Start(); 1165 timer1.Start();
1166 { 1166 {
1167 TestIsolateScope __test_isolate__; 1167 TestIsolateScope __test_isolate__;
1168 1168
1169 Isolate* isolate = Isolate::Current(); 1169 Thread* thread = Thread::Current();
1170 StackZone zone(isolate); 1170 StackZone zone(thread);
1171 HandleScope scope(Thread::Current()); 1171 HandleScope scope(thread);
1172 1172
1173 // Create a test library and Load up a test script in it. 1173 // Create a test library and Load up a test script in it.
1174 TestCase::LoadTestScript(kScriptChars, NULL); 1174 TestCase::LoadTestScript(kScriptChars, NULL);
1175 EXPECT_VALID(Api::CheckAndFinalizePendingClasses(isolate)); 1175 EXPECT_VALID(Api::CheckAndFinalizePendingClasses(thread->isolate()));
1176 timer1.Stop(); 1176 timer1.Stop();
1177 OS::PrintErr("Without Snapshot: %" Pd64 "us\n", timer1.TotalElapsedTime()); 1177 OS::PrintErr("Without Snapshot: %" Pd64 "us\n", timer1.TotalElapsedTime());
1178 1178
1179 // Write snapshot with object content. 1179 // Write snapshot with object content.
1180 { 1180 {
1181 FullSnapshotWriter writer(NULL, 1181 FullSnapshotWriter writer(NULL,
1182 &isolate_snapshot_buffer, 1182 &isolate_snapshot_buffer,
1183 &malloc_allocator, 1183 &malloc_allocator,
1184 false /* snapshot_code */); 1184 false /* snapshot_code */);
1185 writer.WriteFullSnapshot(); 1185 writer.WriteFullSnapshot();
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
1218 const char* kScriptChars = kFullSnapshotScriptChars; 1218 const char* kScriptChars = kFullSnapshotScriptChars;
1219 1219
1220 uint8_t* isolate_snapshot_buffer; 1220 uint8_t* isolate_snapshot_buffer;
1221 1221
1222 // Start an Isolate, load a script and create a full snapshot. 1222 // Start an Isolate, load a script and create a full snapshot.
1223 Timer timer1(true, "Snapshot_test"); 1223 Timer timer1(true, "Snapshot_test");
1224 timer1.Start(); 1224 timer1.Start();
1225 { 1225 {
1226 TestIsolateScope __test_isolate__; 1226 TestIsolateScope __test_isolate__;
1227 1227
1228 Isolate* isolate = Isolate::Current(); 1228 Thread* thread = Thread::Current();
1229 StackZone zone(isolate); 1229 StackZone zone(thread);
1230 HandleScope scope(Thread::Current()); 1230 HandleScope scope(thread);
1231 1231
1232 // Create a test library and Load up a test script in it. 1232 // Create a test library and Load up a test script in it.
1233 Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); 1233 Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL);
1234 EXPECT_VALID(Api::CheckAndFinalizePendingClasses(isolate)); 1234 EXPECT_VALID(Api::CheckAndFinalizePendingClasses(thread->isolate()));
1235 timer1.Stop(); 1235 timer1.Stop();
1236 OS::PrintErr("Without Snapshot: %" Pd64 "us\n", timer1.TotalElapsedTime()); 1236 OS::PrintErr("Without Snapshot: %" Pd64 "us\n", timer1.TotalElapsedTime());
1237 1237
1238 // Write snapshot with object content. 1238 // Write snapshot with object content.
1239 { 1239 {
1240 FullSnapshotWriter writer(NULL, 1240 FullSnapshotWriter writer(NULL,
1241 &isolate_snapshot_buffer, 1241 &isolate_snapshot_buffer,
1242 &malloc_allocator, 1242 &malloc_allocator,
1243 false /* snapshot_code */); 1243 false /* snapshot_code */);
1244 writer.WriteFullSnapshot(); 1244 writer.WriteFullSnapshot();
(...skipping 664 matching lines...) Expand 10 before | Expand all | Expand 10 after
1909 "getMixedList() {\n" 1909 "getMixedList() {\n"
1910 " var list = new List(kArrayLength);\n" 1910 " var list = new List(kArrayLength);\n"
1911 " list[0] = 0;\n" 1911 " list[0] = 0;\n"
1912 " list[1] = '1';\n" 1912 " list[1] = '1';\n"
1913 " list[2] = 2.2;\n" 1913 " list[2] = 2.2;\n"
1914 " list[3] = true;\n" 1914 " list[3] = true;\n"
1915 " return list;\n" 1915 " return list;\n"
1916 "}\n"; 1916 "}\n";
1917 1917
1918 TestCase::CreateTestIsolate(); 1918 TestCase::CreateTestIsolate();
1919 Isolate* isolate = Isolate::Current(); 1919 Thread* thread = Thread::Current();
1920 EXPECT(isolate != NULL); 1920 EXPECT(thread->isolate() != NULL);
1921 Dart_EnterScope(); 1921 Dart_EnterScope();
1922 1922
1923 Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); 1923 Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL);
1924 EXPECT_VALID(lib); 1924 EXPECT_VALID(lib);
1925 1925
1926 { 1926 {
1927 DARTSCOPE(Thread::Current()); 1927 DARTSCOPE(thread);
1928 StackZone zone(isolate); 1928 StackZone zone(thread);
1929 intptr_t buf_len = 0; 1929 intptr_t buf_len = 0;
1930 { 1930 {
1931 // Generate a list of nulls from Dart code. 1931 // Generate a list of nulls from Dart code.
1932 uint8_t* buf = GetSerialized(lib, "getList", &buf_len); 1932 uint8_t* buf = GetSerialized(lib, "getList", &buf_len);
1933 ApiNativeScope scope; 1933 ApiNativeScope scope;
1934 Dart_CObject* root = GetDeserialized(buf, buf_len); 1934 Dart_CObject* root = GetDeserialized(buf, buf_len);
1935 EXPECT_NOTNULL(root); 1935 EXPECT_NOTNULL(root);
1936 EXPECT_EQ(Dart_CObject_kArray, root->type); 1936 EXPECT_EQ(Dart_CObject_kArray, root->type);
1937 EXPECT_EQ(kArrayLength, root->value.as_array.length); 1937 EXPECT_EQ(kArrayLength, root->value.as_array.length);
1938 for (int i = 0; i < kArrayLength; i++) { 1938 for (int i = 0; i < kArrayLength; i++) {
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
2033 " list.add([]);\n" 2033 " list.add([]);\n"
2034 " list.add([[]]);\n" 2034 " list.add([[]]);\n"
2035 " list.add([[[]]]);\n" 2035 " list.add([[[]]]);\n"
2036 " list.add([1, [2, [3]]]);\n" 2036 " list.add([1, [2, [3]]]);\n"
2037 " list.add([1, [1, 2, [1, 2, 3]]]);\n" 2037 " list.add([1, [1, 2, [1, 2, 3]]]);\n"
2038 " list.add([1, 2, 3]);\n" 2038 " list.add([1, 2, 3]);\n"
2039 " return list;\n" 2039 " return list;\n"
2040 "}\n"; 2040 "}\n";
2041 2041
2042 TestCase::CreateTestIsolate(); 2042 TestCase::CreateTestIsolate();
2043 Isolate* isolate = Isolate::Current(); 2043 Thread* thread = Thread::Current();
2044 EXPECT(isolate != NULL); 2044 EXPECT(thread->isolate() != NULL);
2045 Dart_EnterScope(); 2045 Dart_EnterScope();
2046 2046
2047 Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); 2047 Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL);
2048 EXPECT_VALID(lib); 2048 EXPECT_VALID(lib);
2049 2049
2050 { 2050 {
2051 DARTSCOPE(Thread::Current()); 2051 DARTSCOPE(thread);
2052 StackZone zone(isolate); 2052 StackZone zone(thread);
2053 intptr_t buf_len = 0; 2053 intptr_t buf_len = 0;
2054 { 2054 {
2055 // Generate a list of nulls from Dart code. 2055 // Generate a list of nulls from Dart code.
2056 uint8_t* buf = GetSerialized(lib, "getList", &buf_len); 2056 uint8_t* buf = GetSerialized(lib, "getList", &buf_len);
2057 ApiNativeScope scope; 2057 ApiNativeScope scope;
2058 Dart_CObject* root = GetDeserialized(buf, buf_len); 2058 Dart_CObject* root = GetDeserialized(buf, buf_len);
2059 EXPECT_NOTNULL(root); 2059 EXPECT_NOTNULL(root);
2060 EXPECT_EQ(Dart_CObject_kArray, root->type); 2060 EXPECT_EQ(Dart_CObject_kArray, root->type);
2061 EXPECT_EQ(kArrayLength, root->value.as_array.length); 2061 EXPECT_EQ(kArrayLength, root->value.as_array.length);
2062 for (int i = 0; i < kArrayLength; i++) { 2062 for (int i = 0; i < kArrayLength; i++) {
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
2272 "}\n" 2272 "}\n"
2273 "getSelfRefList() {\n" 2273 "getSelfRefList() {\n"
2274 " var list = new List(kArrayLength);\n" 2274 " var list = new List(kArrayLength);\n"
2275 " for (var i = 0; i < kArrayLength; i++) {\n" 2275 " for (var i = 0; i < kArrayLength; i++) {\n"
2276 " list[i] = list;\n" 2276 " list[i] = list;\n"
2277 " }\n" 2277 " }\n"
2278 " return list;\n" 2278 " return list;\n"
2279 "}\n"; 2279 "}\n";
2280 2280
2281 TestCase::CreateTestIsolate(); 2281 TestCase::CreateTestIsolate();
2282 Isolate* isolate = Isolate::Current(); 2282 Thread* thread = Thread::Current();
2283 EXPECT(isolate != NULL); 2283 EXPECT(thread->isolate() != NULL);
2284 Dart_EnterScope(); 2284 Dart_EnterScope();
2285 2285
2286 Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); 2286 Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL);
2287 EXPECT_VALID(lib); 2287 EXPECT_VALID(lib);
2288 2288
2289 { 2289 {
2290 DARTSCOPE(Thread::Current()); 2290 DARTSCOPE(thread);
2291 StackZone zone(isolate); 2291 StackZone zone(thread);
2292 intptr_t buf_len = 0; 2292 intptr_t buf_len = 0;
2293 { 2293 {
2294 // Generate a list of strings from Dart code. 2294 // Generate a list of strings from Dart code.
2295 uint8_t* buf = GetSerialized(lib, "getStringList", &buf_len); 2295 uint8_t* buf = GetSerialized(lib, "getStringList", &buf_len);
2296 ApiNativeScope scope; 2296 ApiNativeScope scope;
2297 Dart_CObject* root = GetDeserialized(buf, buf_len); 2297 Dart_CObject* root = GetDeserialized(buf, buf_len);
2298 EXPECT_NOTNULL(root); 2298 EXPECT_NOTNULL(root);
2299 EXPECT_EQ(Dart_CObject_kArray, root->type); 2299 EXPECT_EQ(Dart_CObject_kArray, root->type);
2300 EXPECT_EQ(kArrayLength, root->value.as_array.length); 2300 EXPECT_EQ(kArrayLength, root->value.as_array.length);
2301 for (int i = 0; i < kArrayLength; i++) { 2301 for (int i = 0; i < kArrayLength; i++) {
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
2497 "}\n" 2497 "}\n"
2498 "getSelfRefList() {\n" 2498 "getSelfRefList() {\n"
2499 " var list = [];\n" 2499 " var list = [];\n"
2500 " for (var i = 0; i < kArrayLength; i++) {\n" 2500 " for (var i = 0; i < kArrayLength; i++) {\n"
2501 " list.add(list);\n" 2501 " list.add(list);\n"
2502 " }\n" 2502 " }\n"
2503 " return list;\n" 2503 " return list;\n"
2504 "}\n"; 2504 "}\n";
2505 2505
2506 TestCase::CreateTestIsolate(); 2506 TestCase::CreateTestIsolate();
2507 Isolate* isolate = Isolate::Current(); 2507 Thread* thread = Thread::Current();
2508 EXPECT(isolate != NULL); 2508 EXPECT(thread->isolate() != NULL);
2509 Dart_EnterScope(); 2509 Dart_EnterScope();
2510 2510
2511 Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); 2511 Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL);
2512 EXPECT_VALID(lib); 2512 EXPECT_VALID(lib);
2513 2513
2514 { 2514 {
2515 DARTSCOPE(Thread::Current()); 2515 DARTSCOPE(thread);
2516 StackZone zone(isolate); 2516 StackZone zone(thread);
2517 intptr_t buf_len = 0; 2517 intptr_t buf_len = 0;
2518 { 2518 {
2519 // Generate a list of strings from Dart code. 2519 // Generate a list of strings from Dart code.
2520 uint8_t* buf = GetSerialized(lib, "getStringList", &buf_len); 2520 uint8_t* buf = GetSerialized(lib, "getStringList", &buf_len);
2521 ApiNativeScope scope; 2521 ApiNativeScope scope;
2522 Dart_CObject* root = GetDeserialized(buf, buf_len); 2522 Dart_CObject* root = GetDeserialized(buf, buf_len);
2523 EXPECT_NOTNULL(root); 2523 EXPECT_NOTNULL(root);
2524 EXPECT_EQ(Dart_CObject_kArray, root->type); 2524 EXPECT_EQ(Dart_CObject_kArray, root->type);
2525 EXPECT_EQ(kArrayLength, root->value.as_array.length); 2525 EXPECT_EQ(kArrayLength, root->value.as_array.length);
2526 for (int i = 0; i < kArrayLength; i++) { 2526 for (int i = 0; i < kArrayLength; i++) {
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
2738 " list[index++] = new Int32List.view(data);\n" 2738 " list[index++] = new Int32List.view(data);\n"
2739 " list[index++] = new Uint32List.view(data);\n" 2739 " list[index++] = new Uint32List.view(data);\n"
2740 " list[index++] = new Int64List.view(data);\n" 2740 " list[index++] = new Int64List.view(data);\n"
2741 " list[index++] = new Uint64List.view(data);\n" 2741 " list[index++] = new Uint64List.view(data);\n"
2742 " list[index++] = new Float32List.view(data);\n" 2742 " list[index++] = new Float32List.view(data);\n"
2743 " list[index++] = new Float64List.view(data);\n" 2743 " list[index++] = new Float64List.view(data);\n"
2744 " return list;\n" 2744 " return list;\n"
2745 "}\n"; 2745 "}\n";
2746 2746
2747 TestCase::CreateTestIsolate(); 2747 TestCase::CreateTestIsolate();
2748 Isolate* isolate = Isolate::Current(); 2748 Thread* thread = Thread::Current();
2749 EXPECT(isolate != NULL); 2749 EXPECT(thread->isolate() != NULL);
2750 Dart_EnterScope(); 2750 Dart_EnterScope();
2751 2751
2752 Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); 2752 Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL);
2753 EXPECT_VALID(lib); 2753 EXPECT_VALID(lib);
2754 2754
2755 { 2755 {
2756 DARTSCOPE(Thread::Current()); 2756 DARTSCOPE(thread);
2757 StackZone zone(isolate); 2757 StackZone zone(thread);
2758 intptr_t buf_len = 0; 2758 intptr_t buf_len = 0;
2759 { 2759 {
2760 // Generate a list of Uint8Lists from Dart code. 2760 // Generate a list of Uint8Lists from Dart code.
2761 uint8_t* buf = GetSerialized(lib, "getTypedDataList", &buf_len); 2761 uint8_t* buf = GetSerialized(lib, "getTypedDataList", &buf_len);
2762 ApiNativeScope scope; 2762 ApiNativeScope scope;
2763 Dart_CObject* root = GetDeserialized(buf, buf_len); 2763 Dart_CObject* root = GetDeserialized(buf, buf_len);
2764 EXPECT_NOTNULL(root); 2764 EXPECT_NOTNULL(root);
2765 EXPECT_EQ(Dart_CObject_kArray, root->type); 2765 EXPECT_EQ(Dart_CObject_kArray, root->type);
2766 struct { 2766 struct {
2767 Dart_TypedData_Type type; 2767 Dart_TypedData_Type type;
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
2989 StackZone zone(Thread::Current()); 2989 StackZone zone(Thread::Current());
2990 uint8_t* buffer; 2990 uint8_t* buffer;
2991 MessageWriter writer(&buffer, &zone_allocator, true); 2991 MessageWriter writer(&buffer, &zone_allocator, true);
2992 writer.WriteInlinedObjectHeader(kOmittedObjectId); 2992 writer.WriteInlinedObjectHeader(kOmittedObjectId);
2993 // For performance, we'd like single-byte headers when ids are omitted. 2993 // For performance, we'd like single-byte headers when ids are omitted.
2994 // If this starts failing, consider renumbering the snapshot ids. 2994 // If this starts failing, consider renumbering the snapshot ids.
2995 EXPECT_EQ(1, writer.BytesWritten()); 2995 EXPECT_EQ(1, writer.BytesWritten());
2996 } 2996 }
2997 2997
2998 } // namespace dart 2998 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698