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

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

Issue 9242035: Give isolates names to be used during debugging. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: '' Created 8 years, 11 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 | Annotate | Revision Log
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 "include/dart_api.h" 5 #include "include/dart_api.h"
6 #include "platform/assert.h" 6 #include "platform/assert.h"
7 #include "platform/utils.h" 7 #include "platform/utils.h"
8 #include "vm/dart_api_impl.h" 8 #include "vm/dart_api_impl.h"
9 #include "vm/dart_api_state.h" 9 #include "vm/dart_api_state.h"
10 #include "vm/thread.h" 10 #include "vm/thread.h"
(...skipping 2733 matching lines...) Expand 10 before | Expand all | Expand 10 after
2744 2744
2745 result = Dart_InvokeStatic(result, 2745 result = Dart_InvokeStatic(result,
2746 Dart_NewString(""), 2746 Dart_NewString(""),
2747 Dart_NewString("main"), 2747 Dart_NewString("main"),
2748 0, 2748 0,
2749 NULL); 2749 NULL);
2750 EXPECT_VALID(result); 2750 EXPECT_VALID(result);
2751 } 2751 }
2752 2752
2753 2753
2754 static bool RunLoopTestCallback(void* data, char** error) { 2754 static bool RunLoopTestCallback(const char* name_prefix,
2755 void* data, char** error) {
2755 const char* kScriptChars = 2756 const char* kScriptChars =
2756 "#import('builtin');\n" 2757 "#import('builtin');\n"
2757 "class MyIsolate extends Isolate {\n" 2758 "class MyIsolate extends Isolate {\n"
2758 " MyIsolate() : super() { }\n" 2759 " MyIsolate() : super() { }\n"
2759 " void main() {\n" 2760 " void main() {\n"
2760 " port.receive((message, replyTo) {\n" 2761 " port.receive((message, replyTo) {\n"
2761 " if (message) {\n" 2762 " if (message) {\n"
2762 " throw new Exception('MakeChildExit');\n" 2763 " throw new Exception('MakeChildExit');\n"
2763 " } else {\n" 2764 " } else {\n"
2764 " replyTo.call('hello');\n" 2765 " replyTo.call('hello');\n"
(...skipping 25 matching lines...) Expand all
2790 Dart_ExitScope(); 2791 Dart_ExitScope();
2791 return true; 2792 return true;
2792 } 2793 }
2793 2794
2794 2795
2795 // Common code for RunLoop_Success/RunLoop_Failure. 2796 // Common code for RunLoop_Success/RunLoop_Failure.
2796 static void RunLoopTest(bool throw_exception_child, 2797 static void RunLoopTest(bool throw_exception_child,
2797 bool throw_exception_parent) { 2798 bool throw_exception_parent) {
2798 Dart_IsolateCreateCallback saved = Isolate::CreateCallback(); 2799 Dart_IsolateCreateCallback saved = Isolate::CreateCallback();
2799 Isolate::SetCreateCallback(RunLoopTestCallback); 2800 Isolate::SetCreateCallback(RunLoopTestCallback);
2800 RunLoopTestCallback(NULL, NULL); 2801 RunLoopTestCallback(NULL, NULL, NULL);
2801 2802
2802 Dart_EnterScope(); 2803 Dart_EnterScope();
2803 Dart_Handle lib = Dart_LookupLibrary(Dart_NewString(TestCase::url())); 2804 Dart_Handle lib = Dart_LookupLibrary(Dart_NewString(TestCase::url()));
2804 EXPECT_VALID(lib); 2805 EXPECT_VALID(lib);
2805 2806
2806 Dart_Handle result; 2807 Dart_Handle result;
2807 Dart_Handle args[2]; 2808 Dart_Handle args[2];
2808 args[0] = (throw_exception_child ? Dart_True() : Dart_False()); 2809 args[0] = (throw_exception_child ? Dart_True() : Dart_False());
2809 args[1] = (throw_exception_parent ? Dart_True() : Dart_False()); 2810 args[1] = (throw_exception_parent ? Dart_True() : Dart_False());
2810 result = Dart_InvokeStatic(lib, 2811 result = Dart_InvokeStatic(lib,
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
2885 " function();\n" 2886 " function();\n"
2886 " }\n" 2887 " }\n"
2887 "}\n"; 2888 "}\n";
2888 2889
2889 2890
2890 // Tell the other thread that shared_isolate is created. 2891 // Tell the other thread that shared_isolate is created.
2891 Dart_Handle lib; 2892 Dart_Handle lib;
2892 { 2893 {
2893 sync->Enter(); 2894 sync->Enter();
2894 char* error = NULL; 2895 char* error = NULL;
2895 shared_isolate = Dart_CreateIsolate(NULL, NULL, &error); 2896 shared_isolate = Dart_CreateIsolate(NULL, NULL, NULL, &error);
2896 EXPECT(shared_isolate != NULL); 2897 EXPECT(shared_isolate != NULL);
2897 Dart_EnterScope(); 2898 Dart_EnterScope();
2898 Dart_Handle url = Dart_NewString(TestCase::url()); 2899 Dart_Handle url = Dart_NewString(TestCase::url());
2899 Dart_Handle source = Dart_NewString(kScriptChars); 2900 Dart_Handle source = Dart_NewString(kScriptChars);
2900 lib = Dart_LoadScript(url, source, TestCase::library_handler); 2901 lib = Dart_LoadScript(url, source, TestCase::library_handler);
2901 EXPECT_VALID(lib); 2902 EXPECT_VALID(lib);
2902 Dart_Handle result = Dart_SetNativeResolver( 2903 Dart_Handle result = Dart_SetNativeResolver(
2903 lib, &IsolateInterruptTestNativeLookup); 2904 lib, &IsolateInterruptTestNativeLookup);
2904 DART_CHECK_VALID(result); 2905 DART_CHECK_VALID(result);
2905 2906
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
3001 // We should have received the expected number of interrupts. 3002 // We should have received the expected number of interrupts.
3002 EXPECT_EQ(kInterruptCount, interrupt_count); 3003 EXPECT_EQ(kInterruptCount, interrupt_count);
3003 3004
3004 // Give the spawned thread enough time to properly exit. 3005 // Give the spawned thread enough time to properly exit.
3005 Isolate::SetInterruptCallback(saved); 3006 Isolate::SetInterruptCallback(saved);
3006 } 3007 }
3007 3008
3008 #endif // TARGET_ARCH_IA32. 3009 #endif // TARGET_ARCH_IA32.
3009 3010
3010 } // namespace dart 3011 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698