| 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 672 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 683 | 683 |
| 684 // Find source and name for the requested script. | 684 // Find source and name for the requested script. |
| 685 Handle<String> source_code = Bootstrapper::NativesSourceLookup(index); | 685 Handle<String> source_code = Bootstrapper::NativesSourceLookup(index); |
| 686 Vector<const char> name = Natives::GetScriptName(index); | 686 Vector<const char> name = Natives::GetScriptName(index); |
| 687 Handle<String> script_name = Factory::NewStringFromAscii(name); | 687 Handle<String> script_name = Factory::NewStringFromAscii(name); |
| 688 | 688 |
| 689 // Compile the script. | 689 // Compile the script. |
| 690 bool allow_natives_syntax = FLAG_allow_natives_syntax; | 690 bool allow_natives_syntax = FLAG_allow_natives_syntax; |
| 691 FLAG_allow_natives_syntax = true; | 691 FLAG_allow_natives_syntax = true; |
| 692 Handle<JSFunction> boilerplate; | 692 Handle<JSFunction> boilerplate; |
| 693 boilerplate = Compiler::Compile(source_code, script_name, 0, 0, NULL, NULL); | 693 boilerplate = Compiler::Compile(source_code, |
| 694 script_name, |
| 695 0, |
| 696 0, |
| 697 NULL, |
| 698 NULL, |
| 699 NATIVES_CODE); |
| 694 FLAG_allow_natives_syntax = allow_natives_syntax; | 700 FLAG_allow_natives_syntax = allow_natives_syntax; |
| 695 | 701 |
| 696 // Silently ignore stack overflows during compilation. | 702 // Silently ignore stack overflows during compilation. |
| 697 if (boilerplate.is_null()) { | 703 if (boilerplate.is_null()) { |
| 698 ASSERT(Top::has_pending_exception()); | 704 ASSERT(Top::has_pending_exception()); |
| 699 Top::clear_pending_exception(); | 705 Top::clear_pending_exception(); |
| 700 return false; | 706 return false; |
| 701 } | 707 } |
| 702 | 708 |
| 703 // Execute the boilerplate function in the debugger context. | 709 // Execute the boilerplate function in the debugger context. |
| 704 Handle<Context> context = Top::global_context(); | 710 Handle<Context> context = Top::global_context(); |
| 705 bool caught_exception = false; | 711 bool caught_exception = false; |
| 706 Handle<JSFunction> function = | 712 Handle<JSFunction> function = |
| 707 Factory::NewFunctionFromBoilerplate(boilerplate, context); | 713 Factory::NewFunctionFromBoilerplate(boilerplate, context); |
| 708 Handle<Object> result = | 714 Handle<Object> result = |
| 709 Execution::TryCall(function, Handle<Object>(context->global()), | 715 Execution::TryCall(function, Handle<Object>(context->global()), |
| 710 0, NULL, &caught_exception); | 716 0, NULL, &caught_exception); |
| 711 | 717 |
| 712 // Check for caught exceptions. | 718 // Check for caught exceptions. |
| 713 if (caught_exception) { | 719 if (caught_exception) { |
| 714 Handle<Object> message = MessageHandler::MakeMessageObject( | 720 Handle<Object> message = MessageHandler::MakeMessageObject( |
| 715 "error_loading_debugger", NULL, Vector<Handle<Object> >::empty(), | 721 "error_loading_debugger", NULL, Vector<Handle<Object> >::empty(), |
| 716 Handle<String>()); | 722 Handle<String>()); |
| 717 MessageHandler::ReportMessage(NULL, message); | 723 MessageHandler::ReportMessage(NULL, message); |
| 718 return false; | 724 return false; |
| 719 } | 725 } |
| 720 | 726 |
| 721 // Mark this script as native and return successfully. | 727 // Mark this script as native and return successfully. |
| 722 Handle<Script> script(Script::cast(function->shared()->script())); | 728 Handle<Script> script(Script::cast(function->shared()->script())); |
| 723 script->set_type(Smi::FromInt(Script::TYPE_NATIVE)); | |
| 724 return true; | 729 return true; |
| 725 } | 730 } |
| 726 | 731 |
| 727 | 732 |
| 728 bool Debug::Load() { | 733 bool Debug::Load() { |
| 729 // Return if debugger is already loaded. | 734 // Return if debugger is already loaded. |
| 730 if (IsLoaded()) return true; | 735 if (IsLoaded()) return true; |
| 731 | 736 |
| 732 // Bail out if we're already in the process of compiling the native | 737 // Bail out if we're already in the process of compiling the native |
| 733 // JavaScript source code for the debugger. | 738 // JavaScript source code for the debugger. |
| (...skipping 1246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1980 // Store whether in debugger before entering debugger. | 1985 // Store whether in debugger before entering debugger. |
| 1981 bool in_debugger = Debug::InDebugger(); | 1986 bool in_debugger = Debug::InDebugger(); |
| 1982 | 1987 |
| 1983 // Enter the debugger. | 1988 // Enter the debugger. |
| 1984 EnterDebugger debugger; | 1989 EnterDebugger debugger; |
| 1985 if (debugger.FailedToEnter()) return; | 1990 if (debugger.FailedToEnter()) return; |
| 1986 | 1991 |
| 1987 // If debugging there might be script break points registered for this | 1992 // If debugging there might be script break points registered for this |
| 1988 // script. Make sure that these break points are set. | 1993 // script. Make sure that these break points are set. |
| 1989 | 1994 |
| 1990 // Get the function UpdateScriptBreakPoints (defined in debug-delay.js). | 1995 // Get the function UpdateScriptBreakPoints (defined in debug-debugger.js). |
| 1991 Handle<Object> update_script_break_points = | 1996 Handle<Object> update_script_break_points = |
| 1992 Handle<Object>(Debug::debug_context()->global()->GetProperty( | 1997 Handle<Object>(Debug::debug_context()->global()->GetProperty( |
| 1993 *Factory::LookupAsciiSymbol("UpdateScriptBreakPoints"))); | 1998 *Factory::LookupAsciiSymbol("UpdateScriptBreakPoints"))); |
| 1994 if (!update_script_break_points->IsJSFunction()) { | 1999 if (!update_script_break_points->IsJSFunction()) { |
| 1995 return; | 2000 return; |
| 1996 } | 2001 } |
| 1997 ASSERT(update_script_break_points->IsJSFunction()); | 2002 ASSERT(update_script_break_points->IsJSFunction()); |
| 1998 | 2003 |
| 1999 // Wrap the script object in a proper JS object before passing it | 2004 // Wrap the script object in a proper JS object before passing it |
| 2000 // to JavaScript. | 2005 // to JavaScript. |
| (...skipping 793 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2794 { | 2799 { |
| 2795 Locker locker; | 2800 Locker locker; |
| 2796 Debugger::CallMessageDispatchHandler(); | 2801 Debugger::CallMessageDispatchHandler(); |
| 2797 } | 2802 } |
| 2798 } | 2803 } |
| 2799 } | 2804 } |
| 2800 | 2805 |
| 2801 #endif // ENABLE_DEBUGGER_SUPPORT | 2806 #endif // ENABLE_DEBUGGER_SUPPORT |
| 2802 | 2807 |
| 2803 } } // namespace v8::internal | 2808 } } // namespace v8::internal |
| OLD | NEW |