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/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #include "src/accessors.h" | 7 #include "src/accessors.h" |
8 #include "src/arguments.h" | 8 #include "src/arguments.h" |
9 #include "src/compiler.h" | 9 #include "src/compiler.h" |
10 #include "src/debug.h" | 10 #include "src/debug.h" |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 RUNTIME_ASSERT(args[0]->IsJSFunction() || args[0]->IsUndefined() || | 47 RUNTIME_ASSERT(args[0]->IsJSFunction() || args[0]->IsUndefined() || |
48 args[0]->IsNull()); | 48 args[0]->IsNull()); |
49 CONVERT_ARG_HANDLE_CHECKED(Object, callback, 0); | 49 CONVERT_ARG_HANDLE_CHECKED(Object, callback, 0); |
50 CONVERT_ARG_HANDLE_CHECKED(Object, data, 1); | 50 CONVERT_ARG_HANDLE_CHECKED(Object, data, 1); |
51 isolate->debug()->SetEventListener(callback, data); | 51 isolate->debug()->SetEventListener(callback, data); |
52 | 52 |
53 return isolate->heap()->undefined_value(); | 53 return isolate->heap()->undefined_value(); |
54 } | 54 } |
55 | 55 |
56 | 56 |
57 RUNTIME_FUNCTION(Runtime_Break) { | 57 RUNTIME_FUNCTION(Runtime_ScheduleBreak) { |
58 SealHandleScope shs(isolate); | 58 SealHandleScope shs(isolate); |
59 DCHECK(args.length() == 0); | 59 DCHECK(args.length() == 0); |
60 isolate->stack_guard()->RequestDebugBreak(); | 60 isolate->stack_guard()->RequestDebugBreak(); |
61 return isolate->heap()->undefined_value(); | 61 return isolate->heap()->undefined_value(); |
62 } | 62 } |
63 | 63 |
64 | 64 |
65 static Handle<Object> DebugGetProperty(LookupIterator* it, | 65 static Handle<Object> DebugGetProperty(LookupIterator* it, |
66 bool* has_caught = NULL) { | 66 bool* has_caught = NULL) { |
67 for (; it->IsFound(); it->Next()) { | 67 for (; it->IsFound(); it->Next()) { |
(...skipping 2495 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2563 Handle<Script> script(Script::cast(script_wrapper->value())); | 2563 Handle<Script> script(Script::cast(script_wrapper->value())); |
2564 | 2564 |
2565 int compilation_state = script->compilation_state(); | 2565 int compilation_state = script->compilation_state(); |
2566 RUNTIME_ASSERT(compilation_state == Script::COMPILATION_STATE_INITIAL); | 2566 RUNTIME_ASSERT(compilation_state == Script::COMPILATION_STATE_INITIAL); |
2567 script->set_source(*source); | 2567 script->set_source(*source); |
2568 | 2568 |
2569 return isolate->heap()->undefined_value(); | 2569 return isolate->heap()->undefined_value(); |
2570 } | 2570 } |
2571 | 2571 |
2572 | 2572 |
2573 RUNTIME_FUNCTION(Runtime_DebugDisassembleFunction) { | |
2574 HandleScope scope(isolate); | |
2575 #ifdef DEBUG | |
2576 DCHECK(args.length() == 1); | |
2577 // Get the function and make sure it is compiled. | |
2578 CONVERT_ARG_HANDLE_CHECKED(JSFunction, func, 0); | |
2579 if (!Compiler::EnsureCompiled(func, KEEP_EXCEPTION)) { | |
2580 return isolate->heap()->exception(); | |
2581 } | |
2582 OFStream os(stdout); | |
2583 func->code()->Print(os); | |
2584 os << std::endl; | |
2585 #endif // DEBUG | |
2586 return isolate->heap()->undefined_value(); | |
2587 } | |
2588 | |
2589 | |
2590 RUNTIME_FUNCTION(Runtime_DebugDisassembleConstructor) { | |
2591 HandleScope scope(isolate); | |
2592 #ifdef DEBUG | |
2593 DCHECK(args.length() == 1); | |
2594 // Get the function and make sure it is compiled. | |
2595 CONVERT_ARG_HANDLE_CHECKED(JSFunction, func, 0); | |
2596 if (!Compiler::EnsureCompiled(func, KEEP_EXCEPTION)) { | |
2597 return isolate->heap()->exception(); | |
2598 } | |
2599 OFStream os(stdout); | |
2600 func->shared()->construct_stub()->Print(os); | |
2601 os << std::endl; | |
2602 #endif // DEBUG | |
2603 return isolate->heap()->undefined_value(); | |
2604 } | |
2605 | |
2606 | |
2607 RUNTIME_FUNCTION(Runtime_FunctionGetInferredName) { | 2573 RUNTIME_FUNCTION(Runtime_FunctionGetInferredName) { |
2608 SealHandleScope shs(isolate); | 2574 SealHandleScope shs(isolate); |
2609 DCHECK(args.length() == 1); | 2575 DCHECK(args.length() == 1); |
2610 | 2576 |
2611 CONVERT_ARG_CHECKED(JSFunction, f, 0); | 2577 CONVERT_ARG_CHECKED(JSFunction, f, 0); |
2612 return f->shared()->inferred_name(); | 2578 return f->shared()->inferred_name(); |
2613 } | 2579 } |
2614 | 2580 |
2615 | 2581 |
2616 RUNTIME_FUNCTION(Runtime_FunctionGetDebugName) { | 2582 RUNTIME_FUNCTION(Runtime_FunctionGetDebugName) { |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2657 | 2623 |
2658 return Smi::FromInt(closest_pc); | 2624 return Smi::FromInt(closest_pc); |
2659 } | 2625 } |
2660 | 2626 |
2661 | 2627 |
2662 // Calls specified function with or without entering the debugger. | 2628 // Calls specified function with or without entering the debugger. |
2663 // This is used in unit tests to run code as if debugger is entered or simply | 2629 // This is used in unit tests to run code as if debugger is entered or simply |
2664 // to have a stack with C++ frame in the middle. | 2630 // to have a stack with C++ frame in the middle. |
2665 RUNTIME_FUNCTION(Runtime_ExecuteInDebugContext) { | 2631 RUNTIME_FUNCTION(Runtime_ExecuteInDebugContext) { |
2666 HandleScope scope(isolate); | 2632 HandleScope scope(isolate); |
2667 DCHECK(args.length() == 2); | 2633 DCHECK(args.length() == 1); |
2668 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); | 2634 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); |
2669 CONVERT_BOOLEAN_ARG_CHECKED(without_debugger, 1); | |
2670 | 2635 |
2671 MaybeHandle<Object> maybe_result; | 2636 DebugScope debug_scope(isolate->debug()); |
2672 if (without_debugger) { | |
2673 maybe_result = Execution::Call(isolate, function, | |
2674 handle(function->global_proxy()), 0, NULL); | |
2675 } else { | |
2676 DebugScope debug_scope(isolate->debug()); | |
2677 maybe_result = Execution::Call(isolate, function, | |
2678 handle(function->global_proxy()), 0, NULL); | |
2679 } | |
2680 Handle<Object> result; | 2637 Handle<Object> result; |
2681 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result, maybe_result); | 2638 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
| 2639 isolate, result, |
| 2640 Execution::Call(isolate, function, handle(function->global_proxy()), 0, |
| 2641 NULL)); |
2682 return *result; | 2642 return *result; |
2683 } | 2643 } |
2684 | 2644 |
2685 | 2645 |
2686 // Performs a GC. | 2646 // Performs a GC. |
2687 // Presently, it only does a full GC. | 2647 // Presently, it only does a full GC. |
2688 RUNTIME_FUNCTION(Runtime_CollectGarbage) { | 2648 RUNTIME_FUNCTION(Runtime_CollectGarbage) { |
2689 SealHandleScope shs(isolate); | 2649 SealHandleScope shs(isolate); |
2690 DCHECK(args.length() == 1); | 2650 DCHECK(args.length() == 1); |
2691 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, "%CollectGarbage"); | 2651 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, "%CollectGarbage"); |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2823 return Smi::FromInt(isolate->debug()->is_active()); | 2783 return Smi::FromInt(isolate->debug()->is_active()); |
2824 } | 2784 } |
2825 | 2785 |
2826 | 2786 |
2827 RUNTIME_FUNCTION(Runtime_DebugBreakInOptimizedCode) { | 2787 RUNTIME_FUNCTION(Runtime_DebugBreakInOptimizedCode) { |
2828 UNIMPLEMENTED(); | 2788 UNIMPLEMENTED(); |
2829 return NULL; | 2789 return NULL; |
2830 } | 2790 } |
2831 } | 2791 } |
2832 } // namespace v8::internal | 2792 } // namespace v8::internal |
OLD | NEW |