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

Side by Side Diff: runtime/vm/dart_api_impl_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 "bin/builtin.h" 5 #include "bin/builtin.h"
6 #include "include/dart_api.h" 6 #include "include/dart_api.h"
7 #include "include/dart_mirrors_api.h" 7 #include "include/dart_mirrors_api.h"
8 #include "include/dart_native_api.h" 8 #include "include/dart_native_api.h"
9 #include "include/dart_tools_api.h" 9 #include "include/dart_tools_api.h"
10 #include "platform/assert.h" 10 #include "platform/assert.h"
(...skipping 2363 matching lines...) Expand 10 before | Expand all | Expand 10 after
2374 Dart_ExitScope(); 2374 Dart_ExitScope();
2375 EXPECT(scope == state->top_scope()); 2375 EXPECT(scope == state->top_scope());
2376 } 2376 }
2377 2377
2378 2378
2379 // Unit test for creating and deleting persistent handles. 2379 // Unit test for creating and deleting persistent handles.
2380 UNIT_TEST_CASE(PersistentHandles) { 2380 UNIT_TEST_CASE(PersistentHandles) {
2381 const char* kTestString1 = "Test String1"; 2381 const char* kTestString1 = "Test String1";
2382 const char* kTestString2 = "Test String2"; 2382 const char* kTestString2 = "Test String2";
2383 TestCase::CreateTestIsolate(); 2383 TestCase::CreateTestIsolate();
2384 Isolate* isolate = Isolate::Current(); 2384 Thread* thread = Thread::Current();
2385 Isolate* isolate = thread->isolate();
2385 EXPECT(isolate != NULL); 2386 EXPECT(isolate != NULL);
2386 ApiState* state = isolate->api_state(); 2387 ApiState* state = isolate->api_state();
2387 EXPECT(state != NULL); 2388 EXPECT(state != NULL);
2388 ApiLocalScope* scope = state->top_scope(); 2389 ApiLocalScope* scope = state->top_scope();
2389 Dart_PersistentHandle handles[2000]; 2390 Dart_PersistentHandle handles[2000];
2390 Dart_EnterScope(); 2391 Dart_EnterScope();
2391 { 2392 {
2392 DARTSCOPE(Thread::Current()); 2393 DARTSCOPE(Thread::Current());
2393 Dart_Handle ref1 = Api::NewHandle(isolate, String::New(kTestString1)); 2394 Dart_Handle ref1 = Api::NewHandle(isolate, String::New(kTestString1));
2394 for (int i = 0; i < 1000; i++) { 2395 for (int i = 0; i < 1000; i++) {
(...skipping 11 matching lines...) Expand all
2406 handles[i] = Dart_NewPersistentHandle(ref2); 2407 handles[i] = Dart_NewPersistentHandle(ref2);
2407 } 2408 }
2408 for (int i = 1000; i < 1500; i++) { 2409 for (int i = 1000; i < 1500; i++) {
2409 handles[i] = Dart_NewPersistentHandle(ref1); 2410 handles[i] = Dart_NewPersistentHandle(ref1);
2410 } 2411 }
2411 VERIFY_ON_TRANSITION; 2412 VERIFY_ON_TRANSITION;
2412 Dart_ExitScope(); 2413 Dart_ExitScope();
2413 } 2414 }
2414 Dart_ExitScope(); 2415 Dart_ExitScope();
2415 { 2416 {
2416 StackZone zone(isolate); 2417 StackZone zone(thread);
2417 HANDLESCOPE(Thread::Current()); 2418 HANDLESCOPE(thread);
2418 for (int i = 0; i < 500; i++) { 2419 for (int i = 0; i < 500; i++) {
2419 String& str = String::Handle(); 2420 String& str = String::Handle();
2420 str ^= PersistentHandle::Cast(handles[i])->raw(); 2421 str ^= PersistentHandle::Cast(handles[i])->raw();
2421 EXPECT(str.Equals(kTestString1)); 2422 EXPECT(str.Equals(kTestString1));
2422 } 2423 }
2423 for (int i = 500; i < 1000; i++) { 2424 for (int i = 500; i < 1000; i++) {
2424 String& str = String::Handle(); 2425 String& str = String::Handle();
2425 str ^= PersistentHandle::Cast(handles[i])->raw(); 2426 str ^= PersistentHandle::Cast(handles[i])->raw();
2426 EXPECT(str.Equals(kTestString2)); 2427 EXPECT(str.Equals(kTestString2));
2427 } 2428 }
(...skipping 1253 matching lines...) Expand 10 before | Expand all | Expand 10 after
3681 EXPECT_EQ(3, global_prologue_callback_status); 3682 EXPECT_EQ(3, global_prologue_callback_status);
3682 EXPECT_EQ(7, global_epilogue_callback_status); 3683 EXPECT_EQ(7, global_epilogue_callback_status);
3683 } 3684 }
3684 3685
3685 3686
3686 // Unit test for creating multiple scopes and local handles within them. 3687 // Unit test for creating multiple scopes and local handles within them.
3687 // Ensure that the local handles get all cleaned out when exiting the 3688 // Ensure that the local handles get all cleaned out when exiting the
3688 // scope. 3689 // scope.
3689 UNIT_TEST_CASE(LocalHandles) { 3690 UNIT_TEST_CASE(LocalHandles) {
3690 TestCase::CreateTestIsolate(); 3691 TestCase::CreateTestIsolate();
3691 Isolate* isolate = Isolate::Current(); 3692 Thread* thread = Thread::Current();
3693 Isolate* isolate = thread->isolate();
3692 EXPECT(isolate != NULL); 3694 EXPECT(isolate != NULL);
3693 ApiState* state = isolate->api_state(); 3695 ApiState* state = isolate->api_state();
3694 EXPECT(state != NULL); 3696 EXPECT(state != NULL);
3695 ApiLocalScope* scope = state->top_scope(); 3697 ApiLocalScope* scope = state->top_scope();
3696 Dart_Handle handles[300]; 3698 Dart_Handle handles[300];
3697 { 3699 {
3698 StackZone zone(isolate); 3700 StackZone zone(thread);
3699 HANDLESCOPE(Thread::Current()); 3701 HANDLESCOPE(thread);
3700 Smi& val = Smi::Handle(); 3702 Smi& val = Smi::Handle();
3701 3703
3702 // Start a new scope and allocate some local handles. 3704 // Start a new scope and allocate some local handles.
3703 Dart_EnterScope(); 3705 Dart_EnterScope();
3704 for (int i = 0; i < 100; i++) { 3706 for (int i = 0; i < 100; i++) {
3705 handles[i] = Api::NewHandle(isolate, Smi::New(i)); 3707 handles[i] = Api::NewHandle(isolate, Smi::New(i));
3706 } 3708 }
3707 EXPECT_EQ(100, state->CountLocalHandles()); 3709 EXPECT_EQ(100, state->CountLocalHandles());
3708 for (int i = 0; i < 100; i++) { 3710 for (int i = 0; i < 100; i++) {
3709 val ^= Api::UnwrapHandle(handles[i]); 3711 val ^= Api::UnwrapHandle(handles[i]);
(...skipping 5701 matching lines...) Expand 10 before | Expand all | Expand 10 after
9411 // Heartbeat test. 9413 // Heartbeat test.
9412 EXPECT_SUBSTRING("\"cat\":\"Compiler\"", buffer); 9414 EXPECT_SUBSTRING("\"cat\":\"Compiler\"", buffer);
9413 EXPECT_SUBSTRING("\"name\":\"CompileFunction\"", buffer); 9415 EXPECT_SUBSTRING("\"name\":\"CompileFunction\"", buffer);
9414 EXPECT_SUBSTRING("\"function\":\"::_main\"", buffer); 9416 EXPECT_SUBSTRING("\"function\":\"::_main\"", buffer);
9415 9417
9416 // Free buffer allocated by AppendStreamConsumer 9418 // Free buffer allocated by AppendStreamConsumer
9417 free(data.buffer); 9419 free(data.buffer);
9418 } 9420 }
9419 9421
9420 } // namespace dart 9422 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/dart.cc ('k') | runtime/vm/find_code_object_test.cc » ('j') | runtime/vm/service.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698