| OLD | NEW |
| 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 667 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 678 } | 678 } |
| 679 | 679 |
| 680 // Find source and name for the requested script. | 680 // Find source and name for the requested script. |
| 681 Handle<String> source_code = Bootstrapper::NativesSourceLookup(index); | 681 Handle<String> source_code = Bootstrapper::NativesSourceLookup(index); |
| 682 Vector<const char> name = Natives::GetScriptName(index); | 682 Vector<const char> name = Natives::GetScriptName(index); |
| 683 Handle<String> script_name = Factory::NewStringFromAscii(name); | 683 Handle<String> script_name = Factory::NewStringFromAscii(name); |
| 684 | 684 |
| 685 // Compile the script. | 685 // Compile the script. |
| 686 bool allow_natives_syntax = FLAG_allow_natives_syntax; | 686 bool allow_natives_syntax = FLAG_allow_natives_syntax; |
| 687 FLAG_allow_natives_syntax = true; | 687 FLAG_allow_natives_syntax = true; |
| 688 Handle<JSFunction> boilerplate; | 688 Handle<SharedFunctionInfo> function_info; |
| 689 boilerplate = Compiler::Compile(source_code, | 689 function_info = Compiler::Compile(source_code, |
| 690 script_name, | 690 script_name, |
| 691 0, | 691 0, 0, NULL, NULL, |
| 692 0, | 692 Handle<String>::null(), |
| 693 NULL, | 693 NATIVES_CODE); |
| 694 NULL, | |
| 695 Handle<String>::null(), | |
| 696 NATIVES_CODE); | |
| 697 FLAG_allow_natives_syntax = allow_natives_syntax; | 694 FLAG_allow_natives_syntax = allow_natives_syntax; |
| 698 | 695 |
| 699 // Silently ignore stack overflows during compilation. | 696 // Silently ignore stack overflows during compilation. |
| 700 if (boilerplate.is_null()) { | 697 if (function_info.is_null()) { |
| 701 ASSERT(Top::has_pending_exception()); | 698 ASSERT(Top::has_pending_exception()); |
| 702 Top::clear_pending_exception(); | 699 Top::clear_pending_exception(); |
| 703 return false; | 700 return false; |
| 704 } | 701 } |
| 705 | 702 |
| 706 // Execute the boilerplate function in the debugger context. | 703 // Execute the shared function in the debugger context. |
| 707 Handle<Context> context = Top::global_context(); | 704 Handle<Context> context = Top::global_context(); |
| 708 bool caught_exception = false; | 705 bool caught_exception = false; |
| 709 Handle<JSFunction> function = | 706 Handle<JSFunction> function = |
| 710 Factory::NewFunctionFromBoilerplate(boilerplate, context); | 707 Factory::NewFunctionFromSharedFunctionInfo(function_info, context); |
| 711 Handle<Object> result = | 708 Handle<Object> result = |
| 712 Execution::TryCall(function, Handle<Object>(context->global()), | 709 Execution::TryCall(function, Handle<Object>(context->global()), |
| 713 0, NULL, &caught_exception); | 710 0, NULL, &caught_exception); |
| 714 | 711 |
| 715 // Check for caught exceptions. | 712 // Check for caught exceptions. |
| 716 if (caught_exception) { | 713 if (caught_exception) { |
| 717 Handle<Object> message = MessageHandler::MakeMessageObject( | 714 Handle<Object> message = MessageHandler::MakeMessageObject( |
| 718 "error_loading_debugger", NULL, Vector<Handle<Object> >::empty(), | 715 "error_loading_debugger", NULL, Vector<Handle<Object> >::empty(), |
| 719 Handle<String>()); | 716 Handle<String>()); |
| 720 MessageHandler::ReportMessage(NULL, message); | 717 MessageHandler::ReportMessage(NULL, message); |
| (...skipping 1313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2034 if (caught_exception) { | 2031 if (caught_exception) { |
| 2035 return; | 2032 return; |
| 2036 } | 2033 } |
| 2037 // Process debug event. | 2034 // Process debug event. |
| 2038 ProcessDebugEvent(v8::AfterCompile, | 2035 ProcessDebugEvent(v8::AfterCompile, |
| 2039 Handle<JSObject>::cast(event_data), | 2036 Handle<JSObject>::cast(event_data), |
| 2040 true); | 2037 true); |
| 2041 } | 2038 } |
| 2042 | 2039 |
| 2043 | 2040 |
| 2044 void Debugger::OnNewFunction(Handle<JSFunction> function) { | |
| 2045 return; | |
| 2046 HandleScope scope; | |
| 2047 | |
| 2048 // Bail out based on state or if there is no listener for this event | |
| 2049 if (Debug::InDebugger()) return; | |
| 2050 if (compiling_natives()) return; | |
| 2051 if (!Debugger::EventActive(v8::NewFunction)) return; | |
| 2052 | |
| 2053 // Enter the debugger. | |
| 2054 EnterDebugger debugger; | |
| 2055 if (debugger.FailedToEnter()) return; | |
| 2056 | |
| 2057 // Create the event object. | |
| 2058 bool caught_exception = false; | |
| 2059 Handle<Object> event_data = MakeNewFunctionEvent(function, &caught_exception); | |
| 2060 // Bail out and don't call debugger if exception. | |
| 2061 if (caught_exception) { | |
| 2062 return; | |
| 2063 } | |
| 2064 // Process debug event. | |
| 2065 ProcessDebugEvent(v8::NewFunction, Handle<JSObject>::cast(event_data), true); | |
| 2066 } | |
| 2067 | |
| 2068 | |
| 2069 void Debugger::OnScriptCollected(int id) { | 2041 void Debugger::OnScriptCollected(int id) { |
| 2070 HandleScope scope; | 2042 HandleScope scope; |
| 2071 | 2043 |
| 2072 // No more to do if not debugging. | 2044 // No more to do if not debugging. |
| 2073 if (!IsDebuggerActive()) return; | 2045 if (!IsDebuggerActive()) return; |
| 2074 if (!Debugger::EventActive(v8::ScriptCollected)) return; | 2046 if (!Debugger::EventActive(v8::ScriptCollected)) return; |
| 2075 | 2047 |
| 2076 // Enter the debugger. | 2048 // Enter the debugger. |
| 2077 EnterDebugger debugger; | 2049 EnterDebugger debugger; |
| 2078 if (debugger.FailedToEnter()) return; | 2050 if (debugger.FailedToEnter()) return; |
| (...skipping 726 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2805 { | 2777 { |
| 2806 Locker locker; | 2778 Locker locker; |
| 2807 Debugger::CallMessageDispatchHandler(); | 2779 Debugger::CallMessageDispatchHandler(); |
| 2808 } | 2780 } |
| 2809 } | 2781 } |
| 2810 } | 2782 } |
| 2811 | 2783 |
| 2812 #endif // ENABLE_DEBUGGER_SUPPORT | 2784 #endif // ENABLE_DEBUGGER_SUPPORT |
| 2813 | 2785 |
| 2814 } } // namespace v8::internal | 2786 } } // namespace v8::internal |
| OLD | NEW |