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

Side by Side Diff: src/compiler.cc

Issue 1396493002: [Interpreter] Add ignition-script-filter flag to filter scripts. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix cctests Created 5 years, 2 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 | « no previous file | src/flag-definitions.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 // 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/compiler.h" 5 #include "src/compiler.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "src/ast-numbering.h" 9 #include "src/ast-numbering.h"
10 #include "src/bootstrapper.h" 10 #include "src/bootstrapper.h"
(...skipping 676 matching lines...) Expand 10 before | Expand all | Expand 10 after
687 ? String::cast(script->name()) 687 ? String::cast(script->name())
688 : info->isolate()->heap()->empty_string(); 688 : info->isolate()->heap()->empty_string();
689 Logger::LogEventsAndTags log_tag = Logger::ToNativeByScript(tag, *script); 689 Logger::LogEventsAndTags log_tag = Logger::ToNativeByScript(tag, *script);
690 PROFILE(info->isolate(), 690 PROFILE(info->isolate(),
691 CodeCreateEvent(log_tag, *code, *shared, info, script_name, 691 CodeCreateEvent(log_tag, *code, *shared, info, script_name,
692 line_num, column_num)); 692 line_num, column_num));
693 } 693 }
694 } 694 }
695 695
696 696
697 // Checks whether top level functions should be passed by {raw_filter}.
698 // TODO(rmcilroy): Remove filtering once ignition can handle test262 harness.
699 static bool TopLevelFunctionPassesFilter(const char* raw_filter) {
700 Vector<const char> filter = CStrVector(raw_filter);
701 return (filter.length() == 0) || (filter.length() == 1 && filter[0] == '*');
702 }
703
704
705 // Checks whether the passed {raw_filter} is a prefix of the given scripts name.
706 // TODO(rmcilroy): Remove filtering once ignition can handle test262 harness.
707 static bool ScriptPassesFilter(const char* raw_filter, Handle<Script> script) {
708 Vector<const char> filter = CStrVector(raw_filter);
709 if (!script->name()->IsString()) return filter.length() == 0;
710 String* name = String::cast(script->name());
711 return name->IsUtf8EqualTo(filter, true);
712 }
713
714
697 static bool CompileUnoptimizedCode(CompilationInfo* info) { 715 static bool CompileUnoptimizedCode(CompilationInfo* info) {
698 DCHECK(AllowCompilation::IsAllowed(info->isolate())); 716 DCHECK(AllowCompilation::IsAllowed(info->isolate()));
699 if (!Compiler::Analyze(info->parse_info()) || 717 if (!Compiler::Analyze(info->parse_info()) ||
700 !FullCodeGenerator::MakeCode(info)) { 718 !FullCodeGenerator::MakeCode(info)) {
701 Isolate* isolate = info->isolate(); 719 Isolate* isolate = info->isolate();
702 if (!isolate->has_pending_exception()) isolate->StackOverflow(); 720 if (!isolate->has_pending_exception()) isolate->StackOverflow();
703 return false; 721 return false;
704 } 722 }
705 return true; 723 return true;
706 } 724 }
(...skipping 17 matching lines...) Expand all
724 PostponeInterruptsScope postpone(info->isolate()); 742 PostponeInterruptsScope postpone(info->isolate());
725 743
726 // Parse and update CompilationInfo with the results. 744 // Parse and update CompilationInfo with the results.
727 if (!Parser::ParseStatic(info->parse_info())) return MaybeHandle<Code>(); 745 if (!Parser::ParseStatic(info->parse_info())) return MaybeHandle<Code>();
728 Handle<SharedFunctionInfo> shared = info->shared_info(); 746 Handle<SharedFunctionInfo> shared = info->shared_info();
729 FunctionLiteral* lit = info->literal(); 747 FunctionLiteral* lit = info->literal();
730 shared->set_language_mode(lit->language_mode()); 748 shared->set_language_mode(lit->language_mode());
731 SetExpectedNofPropertiesFromEstimate(shared, lit->expected_property_count()); 749 SetExpectedNofPropertiesFromEstimate(shared, lit->expected_property_count());
732 MaybeDisableOptimization(shared, lit->dont_optimize_reason()); 750 MaybeDisableOptimization(shared, lit->dont_optimize_reason());
733 751
734 if (FLAG_ignition && info->closure()->PassesFilter(FLAG_ignition_filter)) { 752 if (FLAG_ignition && info->closure()->PassesFilter(FLAG_ignition_filter) &&
753 ScriptPassesFilter(FLAG_ignition_script_filter, info->script())) {
735 // Compile bytecode for the interpreter. 754 // Compile bytecode for the interpreter.
736 if (!GenerateBytecode(info)) return MaybeHandle<Code>(); 755 if (!GenerateBytecode(info)) return MaybeHandle<Code>();
737 } else { 756 } else {
738 // Compile unoptimized code. 757 // Compile unoptimized code.
739 if (!CompileUnoptimizedCode(info)) return MaybeHandle<Code>(); 758 if (!CompileUnoptimizedCode(info)) return MaybeHandle<Code>();
740 759
741 CHECK_EQ(Code::FUNCTION, info->code()->kind()); 760 CHECK_EQ(Code::FUNCTION, info->code()->kind());
742 RecordFunctionCompilation(Logger::LAZY_COMPILE_TAG, info, shared); 761 RecordFunctionCompilation(Logger::LAZY_COMPILE_TAG, info, shared);
743 } 762 }
744 763
(...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after
1146 if (!CompileUnoptimizedCode(&info)) return; 1165 if (!CompileUnoptimizedCode(&info)) return;
1147 if (info.has_shared_info()) { 1166 if (info.has_shared_info()) {
1148 Handle<ScopeInfo> scope_info = 1167 Handle<ScopeInfo> scope_info =
1149 ScopeInfo::Create(info.isolate(), info.zone(), info.scope()); 1168 ScopeInfo::Create(info.isolate(), info.zone(), info.scope());
1150 info.shared_info()->set_scope_info(*scope_info); 1169 info.shared_info()->set_scope_info(*scope_info);
1151 } 1170 }
1152 tracker.RecordRootFunctionInfo(info.code()); 1171 tracker.RecordRootFunctionInfo(info.code());
1153 } 1172 }
1154 1173
1155 1174
1156 // Checks whether the passed {raw_filter} is a script filter (i.e. it matches
1157 // the "s:{name}" pattern) and {name} is a prefix of the given scripts name.
1158 // TODO(rmcilroy): Remove filtering once ignition can handle test262 harness.
1159 static bool ScriptPassesFilter(const char* raw_filter, Handle<Script> script) {
1160 if (!script->name()->IsString()) return false;
1161 String* name = String::cast(script->name());
1162 Vector<const char> filter = CStrVector(raw_filter);
1163 if (filter.length() < 2 || filter[0] != 's' || filter[1] != ':') return false;
1164 return name->IsUtf8EqualTo(filter.SubVector(2, filter.length()), true);
1165 }
1166
1167
1168 static Handle<SharedFunctionInfo> CompileToplevel(CompilationInfo* info) { 1175 static Handle<SharedFunctionInfo> CompileToplevel(CompilationInfo* info) {
1169 Isolate* isolate = info->isolate(); 1176 Isolate* isolate = info->isolate();
1170 PostponeInterruptsScope postpone(isolate); 1177 PostponeInterruptsScope postpone(isolate);
1171 DCHECK(!isolate->native_context().is_null()); 1178 DCHECK(!isolate->native_context().is_null());
1172 ParseInfo* parse_info = info->parse_info(); 1179 ParseInfo* parse_info = info->parse_info();
1173 Handle<Script> script = parse_info->script(); 1180 Handle<Script> script = parse_info->script();
1174 1181
1175 // TODO(svenpanne) Obscure place for this, perhaps move to OnBeforeCompile? 1182 // TODO(svenpanne) Obscure place for this, perhaps move to OnBeforeCompile?
1176 FixedArray* array = isolate->native_context()->embedder_data(); 1183 FixedArray* array = isolate->native_context()->embedder_data();
1177 script->set_context_data(array->get(v8::Context::kDebugIdIndex)); 1184 script->set_context_data(array->get(v8::Context::kDebugIdIndex));
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
1221 1228
1222 // Measure how long it takes to do the compilation; only take the 1229 // Measure how long it takes to do the compilation; only take the
1223 // rest of the function into account to avoid overlap with the 1230 // rest of the function into account to avoid overlap with the
1224 // parsing statistics. 1231 // parsing statistics.
1225 HistogramTimer* rate = info->is_eval() 1232 HistogramTimer* rate = info->is_eval()
1226 ? info->isolate()->counters()->compile_eval() 1233 ? info->isolate()->counters()->compile_eval()
1227 : info->isolate()->counters()->compile(); 1234 : info->isolate()->counters()->compile();
1228 HistogramTimerScope timer(rate); 1235 HistogramTimerScope timer(rate);
1229 1236
1230 // Compile the code. 1237 // Compile the code.
1231 if (FLAG_ignition && ScriptPassesFilter(FLAG_ignition_filter, script)) { 1238 if (FLAG_ignition && TopLevelFunctionPassesFilter(FLAG_ignition_filter) &&
1239 ScriptPassesFilter(FLAG_ignition_script_filter, script)) {
1232 if (!GenerateBytecode(info)) { 1240 if (!GenerateBytecode(info)) {
1233 return Handle<SharedFunctionInfo>::null(); 1241 return Handle<SharedFunctionInfo>::null();
1234 } 1242 }
1235 } else { 1243 } else {
1236 if (!CompileUnoptimizedCode(info)) { 1244 if (!CompileUnoptimizedCode(info)) {
1237 return Handle<SharedFunctionInfo>::null(); 1245 return Handle<SharedFunctionInfo>::null();
1238 } 1246 }
1239 } 1247 }
1240 1248
1241 // Allocate function. 1249 // Allocate function.
(...skipping 549 matching lines...) Expand 10 before | Expand all | Expand 10 after
1791 } 1799 }
1792 1800
1793 #if DEBUG 1801 #if DEBUG
1794 void CompilationInfo::PrintAstForTesting() { 1802 void CompilationInfo::PrintAstForTesting() {
1795 PrintF("--- Source from AST ---\n%s\n", 1803 PrintF("--- Source from AST ---\n%s\n",
1796 PrettyPrinter(isolate(), zone()).PrintProgram(literal())); 1804 PrettyPrinter(isolate(), zone()).PrintProgram(literal()));
1797 } 1805 }
1798 #endif 1806 #endif
1799 } // namespace internal 1807 } // namespace internal
1800 } // namespace v8 1808 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | src/flag-definitions.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698