OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/runtime/runtime-utils.h" | 5 #include "src/runtime/runtime-utils.h" |
6 | 6 |
7 #include "src/arguments.h" | 7 #include "src/arguments.h" |
8 #include "src/compiler.h" | 8 #include "src/compiler.h" |
9 #include "src/debug/debug-evaluate.h" | 9 #include "src/debug/debug-evaluate.h" |
10 #include "src/debug/debug-frames.h" | 10 #include "src/debug/debug-frames.h" |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 // Adds a JavaScript function as a debug event listener. | 72 // Adds a JavaScript function as a debug event listener. |
73 // args[0]: debug event listener function to set or null or undefined for | 73 // args[0]: debug event listener function to set or null or undefined for |
74 // clearing the event listener function | 74 // clearing the event listener function |
75 // args[1]: object supplied during callback | 75 // args[1]: object supplied during callback |
76 RUNTIME_FUNCTION(Runtime_SetDebugEventListener) { | 76 RUNTIME_FUNCTION(Runtime_SetDebugEventListener) { |
77 SealHandleScope shs(isolate); | 77 SealHandleScope shs(isolate); |
78 DCHECK_EQ(2, args.length()); | 78 DCHECK_EQ(2, args.length()); |
79 CHECK(args[0]->IsJSFunction() || args[0]->IsNullOrUndefined(isolate)); | 79 CHECK(args[0]->IsJSFunction() || args[0]->IsNullOrUndefined(isolate)); |
80 CONVERT_ARG_HANDLE_CHECKED(Object, callback, 0); | 80 CONVERT_ARG_HANDLE_CHECKED(Object, callback, 0); |
81 CONVERT_ARG_HANDLE_CHECKED(Object, data, 1); | 81 CONVERT_ARG_HANDLE_CHECKED(Object, data, 1); |
82 isolate->debug()->SetEventListener(callback, data); | 82 if (callback->IsJSFunction()) { |
83 | 83 JavaScriptDebugDelegate* delegate = new JavaScriptDebugDelegate( |
| 84 isolate, Handle<JSFunction>::cast(callback), data); |
| 85 isolate->debug()->SetDebugDelegate(delegate, true); |
| 86 } else { |
| 87 isolate->debug()->SetDebugDelegate(nullptr, false); |
| 88 } |
84 return isolate->heap()->undefined_value(); | 89 return isolate->heap()->undefined_value(); |
85 } | 90 } |
86 | 91 |
87 | 92 |
88 RUNTIME_FUNCTION(Runtime_ScheduleBreak) { | 93 RUNTIME_FUNCTION(Runtime_ScheduleBreak) { |
89 SealHandleScope shs(isolate); | 94 SealHandleScope shs(isolate); |
90 DCHECK_EQ(0, args.length()); | 95 DCHECK_EQ(0, args.length()); |
91 isolate->stack_guard()->RequestDebugBreak(); | 96 isolate->stack_guard()->RequestDebugBreak(); |
92 return isolate->heap()->undefined_value(); | 97 return isolate->heap()->undefined_value(); |
93 } | 98 } |
(...skipping 1752 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1846 DCHECK_EQ(1, args.length()); | 1851 DCHECK_EQ(1, args.length()); |
1847 HandleScope scope(isolate); | 1852 HandleScope scope(isolate); |
1848 CONVERT_ARG_HANDLE_CHECKED(JSObject, promise, 0); | 1853 CONVERT_ARG_HANDLE_CHECKED(JSObject, promise, 0); |
1849 isolate->PushPromise(promise); | 1854 isolate->PushPromise(promise); |
1850 int id = isolate->debug()->NextAsyncTaskId(promise); | 1855 int id = isolate->debug()->NextAsyncTaskId(promise); |
1851 Handle<Symbol> async_stack_id_symbol = | 1856 Handle<Symbol> async_stack_id_symbol = |
1852 isolate->factory()->promise_async_stack_id_symbol(); | 1857 isolate->factory()->promise_async_stack_id_symbol(); |
1853 JSObject::SetProperty(promise, async_stack_id_symbol, | 1858 JSObject::SetProperty(promise, async_stack_id_symbol, |
1854 handle(Smi::FromInt(id), isolate), STRICT) | 1859 handle(Smi::FromInt(id), isolate), STRICT) |
1855 .Assert(); | 1860 .Assert(); |
1856 isolate->debug()->OnAsyncTaskEvent(debug::kDebugEnqueueAsyncFunction, id); | 1861 isolate->debug()->OnAsyncTaskEvent(debug::kDebugEnqueueAsyncFunction, id, 0); |
1857 return isolate->heap()->undefined_value(); | 1862 return isolate->heap()->undefined_value(); |
1858 } | 1863 } |
1859 | 1864 |
1860 RUNTIME_FUNCTION(Runtime_DebugPromiseReject) { | 1865 RUNTIME_FUNCTION(Runtime_DebugPromiseReject) { |
1861 HandleScope scope(isolate); | 1866 HandleScope scope(isolate); |
1862 DCHECK_EQ(2, args.length()); | 1867 DCHECK_EQ(2, args.length()); |
1863 CONVERT_ARG_HANDLE_CHECKED(JSPromise, rejected_promise, 0); | 1868 CONVERT_ARG_HANDLE_CHECKED(JSPromise, rejected_promise, 0); |
1864 CONVERT_ARG_HANDLE_CHECKED(Object, value, 1); | 1869 CONVERT_ARG_HANDLE_CHECKED(Object, value, 1); |
1865 | 1870 |
1866 isolate->debug()->OnPromiseReject(rejected_promise, value); | 1871 isolate->debug()->OnPromiseReject(rejected_promise, value); |
1867 return isolate->heap()->undefined_value(); | 1872 return isolate->heap()->undefined_value(); |
1868 } | 1873 } |
1869 | 1874 |
1870 RUNTIME_FUNCTION(Runtime_DebugAsyncEventEnqueueRecurring) { | 1875 RUNTIME_FUNCTION(Runtime_DebugAsyncEventEnqueueRecurring) { |
1871 HandleScope scope(isolate); | 1876 HandleScope scope(isolate); |
1872 DCHECK_EQ(2, args.length()); | 1877 DCHECK_EQ(2, args.length()); |
1873 CONVERT_ARG_HANDLE_CHECKED(JSPromise, promise, 0); | 1878 CONVERT_ARG_HANDLE_CHECKED(JSPromise, promise, 0); |
1874 CONVERT_SMI_ARG_CHECKED(status, 1); | 1879 CONVERT_SMI_ARG_CHECKED(status, 1); |
1875 if (isolate->debug()->is_active()) { | 1880 if (isolate->debug()->is_active()) { |
1876 isolate->debug()->OnAsyncTaskEvent( | 1881 isolate->debug()->OnAsyncTaskEvent( |
1877 status == v8::Promise::kFulfilled ? debug::kDebugEnqueuePromiseResolve | 1882 status == v8::Promise::kFulfilled ? debug::kDebugEnqueuePromiseResolve |
1878 : debug::kDebugEnqueuePromiseReject, | 1883 : debug::kDebugEnqueuePromiseReject, |
1879 isolate->debug()->NextAsyncTaskId(promise)); | 1884 isolate->debug()->NextAsyncTaskId(promise), 0); |
1880 } | 1885 } |
1881 return isolate->heap()->undefined_value(); | 1886 return isolate->heap()->undefined_value(); |
1882 } | 1887 } |
1883 | 1888 |
1884 RUNTIME_FUNCTION(Runtime_DebugIsActive) { | 1889 RUNTIME_FUNCTION(Runtime_DebugIsActive) { |
1885 SealHandleScope shs(isolate); | 1890 SealHandleScope shs(isolate); |
1886 return Smi::FromInt(isolate->debug()->is_active()); | 1891 return Smi::FromInt(isolate->debug()->is_active()); |
1887 } | 1892 } |
1888 | 1893 |
1889 | 1894 |
1890 RUNTIME_FUNCTION(Runtime_DebugBreakInOptimizedCode) { | 1895 RUNTIME_FUNCTION(Runtime_DebugBreakInOptimizedCode) { |
1891 UNIMPLEMENTED(); | 1896 UNIMPLEMENTED(); |
1892 return NULL; | 1897 return NULL; |
1893 } | 1898 } |
1894 | 1899 |
1895 } // namespace internal | 1900 } // namespace internal |
1896 } // namespace v8 | 1901 } // namespace v8 |
OLD | NEW |