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

Side by Side Diff: src/compiler.cc

Issue 13450007: Refactor parser mode configuration for correctness (Closed) Base URL: git://github.com/v8/v8.git@master
Patch Set: Created 7 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
« no previous file with comments | « src/api.cc ('k') | src/hydrogen.cc » ('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 502 matching lines...) Expand 10 before | Expand all | Expand 10 after
513 } 513 }
514 } 514 }
515 } 515 }
516 516
517 // Notify debugger 517 // Notify debugger
518 isolate->debugger()->OnBeforeCompile(script); 518 isolate->debugger()->OnBeforeCompile(script);
519 #endif 519 #endif
520 520
521 // Only allow non-global compiles for eval. 521 // Only allow non-global compiles for eval.
522 ASSERT(info->is_eval() || info->is_global()); 522 ASSERT(info->is_eval() || info->is_global());
523 ParsingFlags flags = kNoParsingFlags; 523 {
524 if ((info->pre_parse_data() != NULL || 524 Parser parser(info);
525 String::cast(script->source())->length() > FLAG_min_preparse_length) && 525 if ((info->pre_parse_data() != NULL ||
526 !DebuggerWantsEagerCompilation(info)) { 526 String::cast(script->source())->length() > FLAG_min_preparse_length) &&
527 flags = kAllowLazy; 527 !DebuggerWantsEagerCompilation(info))
528 } 528 parser.set_allow_lazy(true);
529 if (!ParserApi::Parse(info, flags)) { 529 if (!parser.Parse()) {
530 return Handle<SharedFunctionInfo>::null(); 530 return Handle<SharedFunctionInfo>::null();
531 }
531 } 532 }
532 533
533 // Measure how long it takes to do the compilation; only take the 534 // Measure how long it takes to do the compilation; only take the
534 // rest of the function into account to avoid overlap with the 535 // rest of the function into account to avoid overlap with the
535 // parsing statistics. 536 // parsing statistics.
536 HistogramTimer* rate = info->is_eval() 537 HistogramTimer* rate = info->is_eval()
537 ? info->isolate()->counters()->compile_eval() 538 ? info->isolate()->counters()->compile_eval()
538 : info->isolate()->counters()->compile(); 539 : info->isolate()->counters()->compile();
539 HistogramTimerScope timer(rate); 540 HistogramTimerScope timer(rate);
540 541
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after
857 858
858 PostponeInterruptsScope postpone(isolate); 859 PostponeInterruptsScope postpone(isolate);
859 860
860 Handle<SharedFunctionInfo> shared = info->shared_info(); 861 Handle<SharedFunctionInfo> shared = info->shared_info();
861 int compiled_size = shared->end_position() - shared->start_position(); 862 int compiled_size = shared->end_position() - shared->start_position();
862 isolate->counters()->total_compile_size()->Increment(compiled_size); 863 isolate->counters()->total_compile_size()->Increment(compiled_size);
863 864
864 if (InstallCodeFromOptimizedCodeMap(info)) return true; 865 if (InstallCodeFromOptimizedCodeMap(info)) return true;
865 866
866 // Generate the AST for the lazily compiled function. 867 // Generate the AST for the lazily compiled function.
867 if (ParserApi::Parse(info, kNoParsingFlags)) { 868 if (Parser::Parse(info)) {
868 // Measure how long it takes to do the lazy compilation; only take the 869 // Measure how long it takes to do the lazy compilation; only take the
869 // rest of the function into account to avoid overlap with the lazy 870 // rest of the function into account to avoid overlap with the lazy
870 // parsing statistics. 871 // parsing statistics.
871 HistogramTimerScope timer(isolate->counters()->compile_lazy()); 872 HistogramTimerScope timer(isolate->counters()->compile_lazy());
872 873
873 // After parsing we know the function's language mode. Remember it. 874 // After parsing we know the function's language mode. Remember it.
874 LanguageMode language_mode = info->function()->language_mode(); 875 LanguageMode language_mode = info->function()->language_mode();
875 info->SetLanguageMode(language_mode); 876 info->SetLanguageMode(language_mode);
876 shared->set_language_mode(language_mode); 877 shared->set_language_mode(language_mode);
877 878
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
925 isolate->counters()->total_compile_size()->Increment(compiled_size); 926 isolate->counters()->total_compile_size()->Increment(compiled_size);
926 info->SetOptimizing(BailoutId::None()); 927 info->SetOptimizing(BailoutId::None());
927 928
928 { 929 {
929 CompilationHandleScope handle_scope(*info); 930 CompilationHandleScope handle_scope(*info);
930 931
931 if (InstallCodeFromOptimizedCodeMap(*info)) { 932 if (InstallCodeFromOptimizedCodeMap(*info)) {
932 return; 933 return;
933 } 934 }
934 935
935 if (ParserApi::Parse(*info, kNoParsingFlags)) { 936 if (Parser::Parse(*info)) {
936 LanguageMode language_mode = info->function()->language_mode(); 937 LanguageMode language_mode = info->function()->language_mode();
937 info->SetLanguageMode(language_mode); 938 info->SetLanguageMode(language_mode);
938 shared->set_language_mode(language_mode); 939 shared->set_language_mode(language_mode);
939 info->SaveHandles(); 940 info->SaveHandles();
940 941
941 if (Rewriter::Rewrite(*info) && Scope::Analyze(*info)) { 942 if (Rewriter::Rewrite(*info) && Scope::Analyze(*info)) {
942 OptimizingCompiler* compiler = 943 OptimizingCompiler* compiler =
943 new(info->zone()) OptimizingCompiler(*info); 944 new(info->zone()) OptimizingCompiler(*info);
944 OptimizingCompiler::Status status = compiler->CreateGraph(); 945 OptimizingCompiler::Status status = compiler->CreateGraph();
945 if (status == OptimizingCompiler::SUCCEEDED) { 946 if (status == OptimizingCompiler::SUCCEEDED) {
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
1158 } 1159 }
1159 } 1160 }
1160 1161
1161 GDBJIT(AddCode(Handle<String>(shared->DebugName()), 1162 GDBJIT(AddCode(Handle<String>(shared->DebugName()),
1162 Handle<Script>(info->script()), 1163 Handle<Script>(info->script()),
1163 Handle<Code>(info->code()), 1164 Handle<Code>(info->code()),
1164 info)); 1165 info));
1165 } 1166 }
1166 1167
1167 } } // namespace v8::internal 1168 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/api.cc ('k') | src/hydrogen.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698