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

Side by Side Diff: src/compiler.cc

Issue 256653004: Always include debugger support. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Makefile Created 6 years, 8 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
« no previous file with comments | « src/compiler.h ('k') | src/d8.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 280 matching lines...) Expand 10 before | Expand all | Expand 10 after
291 291
292 // Determine whether to use the full compiler for all code. If the flag 292 // Determine whether to use the full compiler for all code. If the flag
293 // --always-full-compiler is specified this is the case. For the virtual frame 293 // --always-full-compiler is specified this is the case. For the virtual frame
294 // based compiler the full compiler is also used if a debugger is connected, as 294 // based compiler the full compiler is also used if a debugger is connected, as
295 // the code from the full compiler supports mode precise break points. For the 295 // the code from the full compiler supports mode precise break points. For the
296 // crankshaft adaptive compiler debugging the optimized code is not possible at 296 // crankshaft adaptive compiler debugging the optimized code is not possible at
297 // all. However crankshaft support recompilation of functions, so in this case 297 // all. However crankshaft support recompilation of functions, so in this case
298 // the full compiler need not be be used if a debugger is attached, but only if 298 // the full compiler need not be be used if a debugger is attached, but only if
299 // break points has actually been set. 299 // break points has actually been set.
300 static bool IsDebuggerActive(Isolate* isolate) { 300 static bool IsDebuggerActive(Isolate* isolate) {
301 #ifdef ENABLE_DEBUGGER_SUPPORT
302 return isolate->use_crankshaft() ? 301 return isolate->use_crankshaft() ?
303 isolate->debug()->has_break_points() : 302 isolate->debug()->has_break_points() :
304 isolate->debugger()->IsDebuggerActive(); 303 isolate->debugger()->IsDebuggerActive();
305 #else
306 return false;
307 #endif
308 } 304 }
309 305
310 306
311 OptimizedCompileJob::Status OptimizedCompileJob::CreateGraph() { 307 OptimizedCompileJob::Status OptimizedCompileJob::CreateGraph() {
312 ASSERT(isolate()->use_crankshaft()); 308 ASSERT(isolate()->use_crankshaft());
313 ASSERT(info()->IsOptimizing()); 309 ASSERT(info()->IsOptimizing());
314 ASSERT(!info()->IsCompilingForDebugging()); 310 ASSERT(!info()->IsCompilingForDebugging());
315 311
316 // We should never arrive here if there is no code object on the 312 // We should never arrive here if there is no code object on the
317 // shared function object. 313 // shared function object.
(...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after
739 if (!maybe_new_code.ToHandle(&new_code)) { 735 if (!maybe_new_code.ToHandle(&new_code)) {
740 isolate->clear_pending_exception(); 736 isolate->clear_pending_exception();
741 } else { 737 } else {
742 ASSERT_EQ(old_code->is_compiled_optimizable(), 738 ASSERT_EQ(old_code->is_compiled_optimizable(),
743 new_code->is_compiled_optimizable()); 739 new_code->is_compiled_optimizable());
744 } 740 }
745 return maybe_new_code; 741 return maybe_new_code;
746 } 742 }
747 743
748 744
749 #ifdef ENABLE_DEBUGGER_SUPPORT
750 void Compiler::CompileForLiveEdit(Handle<Script> script) { 745 void Compiler::CompileForLiveEdit(Handle<Script> script) {
751 // TODO(635): support extensions. 746 // TODO(635): support extensions.
752 CompilationInfoWithZone info(script); 747 CompilationInfoWithZone info(script);
753 PostponeInterruptsScope postpone(info.isolate()); 748 PostponeInterruptsScope postpone(info.isolate());
754 VMState<COMPILER> state(info.isolate()); 749 VMState<COMPILER> state(info.isolate());
755 750
756 info.MarkAsGlobal(); 751 info.MarkAsGlobal();
757 if (!Parser::Parse(&info)) return; 752 if (!Parser::Parse(&info)) return;
758 info.SetStrictMode(info.function()->strict_mode()); 753 info.SetStrictMode(info.function()->strict_mode());
759 754
760 LiveEditFunctionTracker tracker(info.isolate(), info.function()); 755 LiveEditFunctionTracker tracker(info.isolate(), info.function());
761 if (!CompileUnoptimizedCode(&info)) return; 756 if (!CompileUnoptimizedCode(&info)) return;
762 if (!info.shared_info().is_null()) { 757 if (!info.shared_info().is_null()) {
763 Handle<ScopeInfo> scope_info = ScopeInfo::Create(info.scope(), 758 Handle<ScopeInfo> scope_info = ScopeInfo::Create(info.scope(),
764 info.zone()); 759 info.zone());
765 info.shared_info()->set_scope_info(*scope_info); 760 info.shared_info()->set_scope_info(*scope_info);
766 } 761 }
767 tracker.RecordRootFunctionInfo(info.code()); 762 tracker.RecordRootFunctionInfo(info.code());
768 } 763 }
769 #endif
770 764
771 765
772 static bool DebuggerWantsEagerCompilation(CompilationInfo* info, 766 static bool DebuggerWantsEagerCompilation(CompilationInfo* info,
773 bool allow_lazy_without_ctx = false) { 767 bool allow_lazy_without_ctx = false) {
774 return LiveEditFunctionTracker::IsActive(info->isolate()) || 768 return LiveEditFunctionTracker::IsActive(info->isolate()) ||
775 (info->isolate()->DebuggerHasBreakPoints() && !allow_lazy_without_ctx); 769 (info->isolate()->DebuggerHasBreakPoints() && !allow_lazy_without_ctx);
776 } 770 }
777 771
778 772
779 static Handle<SharedFunctionInfo> CompileToplevel(CompilationInfo* info) { 773 static Handle<SharedFunctionInfo> CompileToplevel(CompilationInfo* info) {
780 Isolate* isolate = info->isolate(); 774 Isolate* isolate = info->isolate();
781 PostponeInterruptsScope postpone(isolate); 775 PostponeInterruptsScope postpone(isolate);
782 ASSERT(!isolate->native_context().is_null()); 776 ASSERT(!isolate->native_context().is_null());
783 Handle<Script> script = info->script(); 777 Handle<Script> script = info->script();
784 778
785 // TODO(svenpanne) Obscure place for this, perhaps move to OnBeforeCompile? 779 // TODO(svenpanne) Obscure place for this, perhaps move to OnBeforeCompile?
786 FixedArray* array = isolate->native_context()->embedder_data(); 780 FixedArray* array = isolate->native_context()->embedder_data();
787 script->set_context_data(array->get(0)); 781 script->set_context_data(array->get(0));
788 782
789 #ifdef ENABLE_DEBUGGER_SUPPORT
790 isolate->debugger()->OnBeforeCompile(script); 783 isolate->debugger()->OnBeforeCompile(script);
791 #endif
792 784
793 ASSERT(info->is_eval() || info->is_global()); 785 ASSERT(info->is_eval() || info->is_global());
794 786
795 bool parse_allow_lazy = 787 bool parse_allow_lazy =
796 (info->cached_data_mode() == CONSUME_CACHED_DATA || 788 (info->cached_data_mode() == CONSUME_CACHED_DATA ||
797 String::cast(script->source())->length() > FLAG_min_preparse_length) && 789 String::cast(script->source())->length() > FLAG_min_preparse_length) &&
798 !DebuggerWantsEagerCompilation(info); 790 !DebuggerWantsEagerCompilation(info);
799 791
800 if (!parse_allow_lazy && info->cached_data_mode() != NO_CACHED_DATA) { 792 if (!parse_allow_lazy && info->cached_data_mode() != NO_CACHED_DATA) {
801 // We are going to parse eagerly, but we either 1) have cached data produced 793 // We are going to parse eagerly, but we either 1) have cached data produced
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
857 // property space by setting the expected number of properties for 849 // property space by setting the expected number of properties for
858 // the instances of the function. 850 // the instances of the function.
859 SetExpectedNofPropertiesFromEstimate(result, 851 SetExpectedNofPropertiesFromEstimate(result,
860 lit->expected_property_count()); 852 lit->expected_property_count());
861 853
862 script->set_compilation_state(Script::COMPILATION_STATE_COMPILED); 854 script->set_compilation_state(Script::COMPILATION_STATE_COMPILED);
863 855
864 live_edit_tracker.RecordFunctionInfo(result, lit, info->zone()); 856 live_edit_tracker.RecordFunctionInfo(result, lit, info->zone());
865 } 857 }
866 858
867 #ifdef ENABLE_DEBUGGER_SUPPORT
868 isolate->debugger()->OnAfterCompile(script, Debugger::NO_AFTER_COMPILE_FLAGS); 859 isolate->debugger()->OnAfterCompile(script, Debugger::NO_AFTER_COMPILE_FLAGS);
869 #endif
870 860
871 return result; 861 return result;
872 } 862 }
873 863
874 864
875 MaybeHandle<JSFunction> Compiler::GetFunctionFromEval( 865 MaybeHandle<JSFunction> Compiler::GetFunctionFromEval(
876 Handle<String> source, 866 Handle<String> source,
877 Handle<Context> context, 867 Handle<Context> context,
878 StrictMode strict_mode, 868 StrictMode strict_mode,
879 ParseRestriction restriction, 869 ParseRestriction restriction,
(...skipping 11 matching lines...) Expand all
891 881
892 if (!maybe_shared_info.ToHandle(&shared_info)) { 882 if (!maybe_shared_info.ToHandle(&shared_info)) {
893 Handle<Script> script = isolate->factory()->NewScript(source); 883 Handle<Script> script = isolate->factory()->NewScript(source);
894 CompilationInfoWithZone info(script); 884 CompilationInfoWithZone info(script);
895 info.MarkAsEval(); 885 info.MarkAsEval();
896 if (context->IsNativeContext()) info.MarkAsGlobal(); 886 if (context->IsNativeContext()) info.MarkAsGlobal();
897 info.SetStrictMode(strict_mode); 887 info.SetStrictMode(strict_mode);
898 info.SetParseRestriction(restriction); 888 info.SetParseRestriction(restriction);
899 info.SetContext(context); 889 info.SetContext(context);
900 890
901 #if ENABLE_DEBUGGER_SUPPORT
902 Debug::RecordEvalCaller(script); 891 Debug::RecordEvalCaller(script);
903 #endif // ENABLE_DEBUGGER_SUPPORT
904 892
905 shared_info = CompileToplevel(&info); 893 shared_info = CompileToplevel(&info);
906 894
907 if (shared_info.is_null()) { 895 if (shared_info.is_null()) {
908 return MaybeHandle<JSFunction>(); 896 return MaybeHandle<JSFunction>();
909 } else { 897 } else {
910 // Explicitly disable optimization for eval code. We're not yet prepared 898 // Explicitly disable optimization for eval code. We're not yet prepared
911 // to handle eval-code in the optimizing compiler. 899 // to handle eval-code in the optimizing compiler.
912 shared_info->DisableOptimization(kEval); 900 shared_info->DisableOptimization(kEval);
913 901
(...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after
1314 AllowHandleDereference allow_deref; 1302 AllowHandleDereference allow_deref;
1315 bool tracing_on = info()->IsStub() 1303 bool tracing_on = info()->IsStub()
1316 ? FLAG_trace_hydrogen_stubs 1304 ? FLAG_trace_hydrogen_stubs
1317 : (FLAG_trace_hydrogen && 1305 : (FLAG_trace_hydrogen &&
1318 info()->closure()->PassesFilter(FLAG_trace_hydrogen_filter)); 1306 info()->closure()->PassesFilter(FLAG_trace_hydrogen_filter));
1319 return (tracing_on && 1307 return (tracing_on &&
1320 OS::StrChr(const_cast<char*>(FLAG_trace_phase), name_[0]) != NULL); 1308 OS::StrChr(const_cast<char*>(FLAG_trace_phase), name_[0]) != NULL);
1321 } 1309 }
1322 1310
1323 } } // namespace v8::internal 1311 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/compiler.h ('k') | src/d8.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698