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

Side by Side Diff: src/compiler.cc

Issue 1420963009: [Interpreter]: Add ignition blacklist to mjsunit.status and test262.status. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Move TopLevelFunctionPassesFilter Created 5 years, 1 month 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') | tools/run-tests.py » ('J')
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 673 matching lines...) Expand 10 before | Expand all | Expand 10 after
684 ? String::cast(script->name()) 684 ? String::cast(script->name())
685 : info->isolate()->heap()->empty_string(); 685 : info->isolate()->heap()->empty_string();
686 Logger::LogEventsAndTags log_tag = Logger::ToNativeByScript(tag, *script); 686 Logger::LogEventsAndTags log_tag = Logger::ToNativeByScript(tag, *script);
687 PROFILE(info->isolate(), 687 PROFILE(info->isolate(),
688 CodeCreateEvent(log_tag, *code, *shared, info, script_name, 688 CodeCreateEvent(log_tag, *code, *shared, info, script_name,
689 line_num, column_num)); 689 line_num, column_num));
690 } 690 }
691 } 691 }
692 692
693 693
694 // Checks whether top level functions should be passed by {raw_filter}.
695 // TODO(rmcilroy): Remove filtering once ignition can handle test262 harness.
696 static bool TopLevelFunctionPassesFilter(const char* raw_filter) {
697 Vector<const char> filter = CStrVector(raw_filter);
698 return (filter.length() == 0) || (filter.length() == 1 && filter[0] == '*');
699 }
700
701
702 // Checks whether the passed {raw_filter} is a prefix of the given scripts name.
703 // TODO(rmcilroy): Remove filtering once ignition can handle test262 harness.
704 static bool ScriptPassesFilter(const char* raw_filter, Handle<Script> script) {
705 Vector<const char> filter = CStrVector(raw_filter);
706 if (!script->name()->IsString()) return filter.length() == 0;
707 String* name = String::cast(script->name());
708 return name->IsUtf8EqualTo(filter, true);
709 }
710
711
712 static bool CompileUnoptimizedCode(CompilationInfo* info) { 694 static bool CompileUnoptimizedCode(CompilationInfo* info) {
713 DCHECK(AllowCompilation::IsAllowed(info->isolate())); 695 DCHECK(AllowCompilation::IsAllowed(info->isolate()));
714 if (!Compiler::Analyze(info->parse_info()) || 696 if (!Compiler::Analyze(info->parse_info()) ||
715 !FullCodeGenerator::MakeCode(info)) { 697 !FullCodeGenerator::MakeCode(info)) {
716 Isolate* isolate = info->isolate(); 698 Isolate* isolate = info->isolate();
717 if (!isolate->has_pending_exception()) isolate->StackOverflow(); 699 if (!isolate->has_pending_exception()) isolate->StackOverflow();
718 return false; 700 return false;
719 } 701 }
720 return true; 702 return true;
721 } 703 }
722 704
723 705
706 // TODO(rmcilroy): Remove this temporary work-around when ignition supports
707 // catch and eval.
708 static bool IgnitionShouldFallbackToFullCodeGen(Scope* scope) {
709 if (!FLAG_ignition_fallback_on_eval_and_catch) return false;
710
711 if (scope->is_eval_scope() || scope->is_catch_scope() ||
712 scope->calls_eval()) {
713 return true;
714 }
715 for (auto inner_scope : *scope->inner_scopes()) {
716 if (IgnitionShouldFallbackToFullCodeGen(inner_scope)) return true;
717 }
718 return false;
719 }
720
721
724 static bool GenerateBytecode(CompilationInfo* info) { 722 static bool GenerateBytecode(CompilationInfo* info) {
725 DCHECK(AllowCompilation::IsAllowed(info->isolate())); 723 DCHECK(AllowCompilation::IsAllowed(info->isolate()));
726 if (!Compiler::Analyze(info->parse_info()) || 724 bool success = false;
727 !interpreter::Interpreter::MakeBytecode(info)) { 725 if (Compiler::Analyze(info->parse_info())) {
726 if (IgnitionShouldFallbackToFullCodeGen(info->scope())) {
727 success = FullCodeGenerator::MakeCode(info);
728 } else {
729 success = interpreter::Interpreter::MakeBytecode(info);
730 }
731 }
732 if (!success) {
728 Isolate* isolate = info->isolate(); 733 Isolate* isolate = info->isolate();
729 if (!isolate->has_pending_exception()) isolate->StackOverflow(); 734 if (!isolate->has_pending_exception()) isolate->StackOverflow();
730 return false;
731 } 735 }
732 return true; 736 return success;
733 } 737 }
734 738
735 739
736 MUST_USE_RESULT static MaybeHandle<Code> GetUnoptimizedCodeCommon( 740 MUST_USE_RESULT static MaybeHandle<Code> GetUnoptimizedCodeCommon(
737 CompilationInfo* info) { 741 CompilationInfo* info) {
738 VMState<COMPILER> state(info->isolate()); 742 VMState<COMPILER> state(info->isolate());
739 PostponeInterruptsScope postpone(info->isolate()); 743 PostponeInterruptsScope postpone(info->isolate());
740 744
741 // Parse and update CompilationInfo with the results. 745 // Parse and update CompilationInfo with the results.
742 if (!Parser::ParseStatic(info->parse_info())) return MaybeHandle<Code>(); 746 if (!Parser::ParseStatic(info->parse_info())) return MaybeHandle<Code>();
743 Handle<SharedFunctionInfo> shared = info->shared_info(); 747 Handle<SharedFunctionInfo> shared = info->shared_info();
744 FunctionLiteral* lit = info->literal(); 748 FunctionLiteral* lit = info->literal();
745 shared->set_language_mode(lit->language_mode()); 749 shared->set_language_mode(lit->language_mode());
746 SetExpectedNofPropertiesFromEstimate(shared, lit->expected_property_count()); 750 SetExpectedNofPropertiesFromEstimate(shared, lit->expected_property_count());
747 MaybeDisableOptimization(shared, lit->dont_optimize_reason()); 751 MaybeDisableOptimization(shared, lit->dont_optimize_reason());
748 752
749 if (FLAG_ignition && !shared->HasBuiltinFunctionId() && 753 if (FLAG_ignition && !shared->HasBuiltinFunctionId() &&
750 info->closure()->PassesFilter(FLAG_ignition_filter) && 754 info->closure()->PassesFilter(FLAG_ignition_filter)) {
751 ScriptPassesFilter(FLAG_ignition_script_filter, info->script())) {
752 // Compile bytecode for the interpreter. 755 // Compile bytecode for the interpreter.
753 if (!GenerateBytecode(info)) return MaybeHandle<Code>(); 756 if (!GenerateBytecode(info)) return MaybeHandle<Code>();
754 } else { 757 } else {
755 // Compile unoptimized code. 758 // Compile unoptimized code.
756 if (!CompileUnoptimizedCode(info)) return MaybeHandle<Code>(); 759 if (!CompileUnoptimizedCode(info)) return MaybeHandle<Code>();
757 760
758 CHECK_EQ(Code::FUNCTION, info->code()->kind()); 761 CHECK_EQ(Code::FUNCTION, info->code()->kind());
759 RecordFunctionCompilation(Logger::LAZY_COMPILE_TAG, info, shared); 762 RecordFunctionCompilation(Logger::LAZY_COMPILE_TAG, info, shared);
760 } 763 }
761 764
(...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after
1166 if (!CompileUnoptimizedCode(&info)) return; 1169 if (!CompileUnoptimizedCode(&info)) return;
1167 if (info.has_shared_info()) { 1170 if (info.has_shared_info()) {
1168 Handle<ScopeInfo> scope_info = 1171 Handle<ScopeInfo> scope_info =
1169 ScopeInfo::Create(info.isolate(), info.zone(), info.scope()); 1172 ScopeInfo::Create(info.isolate(), info.zone(), info.scope());
1170 info.shared_info()->set_scope_info(*scope_info); 1173 info.shared_info()->set_scope_info(*scope_info);
1171 } 1174 }
1172 tracker.RecordRootFunctionInfo(info.code()); 1175 tracker.RecordRootFunctionInfo(info.code());
1173 } 1176 }
1174 1177
1175 1178
1179 // Checks whether top level functions should be passed by {raw_filter}.
1180 static bool TopLevelFunctionPassesFilter(const char* raw_filter) {
1181 Vector<const char> filter = CStrVector(raw_filter);
1182 return (filter.length() == 0) || (filter.length() == 1 && filter[0] == '*');
1183 }
1184
1185
1176 static Handle<SharedFunctionInfo> CompileToplevel(CompilationInfo* info) { 1186 static Handle<SharedFunctionInfo> CompileToplevel(CompilationInfo* info) {
1177 Isolate* isolate = info->isolate(); 1187 Isolate* isolate = info->isolate();
1178 PostponeInterruptsScope postpone(isolate); 1188 PostponeInterruptsScope postpone(isolate);
1179 DCHECK(!isolate->native_context().is_null()); 1189 DCHECK(!isolate->native_context().is_null());
1180 ParseInfo* parse_info = info->parse_info(); 1190 ParseInfo* parse_info = info->parse_info();
1181 Handle<Script> script = parse_info->script(); 1191 Handle<Script> script = parse_info->script();
1182 1192
1183 // TODO(svenpanne) Obscure place for this, perhaps move to OnBeforeCompile? 1193 // TODO(svenpanne) Obscure place for this, perhaps move to OnBeforeCompile?
1184 FixedArray* array = isolate->native_context()->embedder_data(); 1194 FixedArray* array = isolate->native_context()->embedder_data();
1185 script->set_context_data(array->get(v8::Context::kDebugIdIndex)); 1195 script->set_context_data(array->get(v8::Context::kDebugIdIndex));
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
1229 1239
1230 // Measure how long it takes to do the compilation; only take the 1240 // Measure how long it takes to do the compilation; only take the
1231 // rest of the function into account to avoid overlap with the 1241 // rest of the function into account to avoid overlap with the
1232 // parsing statistics. 1242 // parsing statistics.
1233 HistogramTimer* rate = info->is_eval() 1243 HistogramTimer* rate = info->is_eval()
1234 ? info->isolate()->counters()->compile_eval() 1244 ? info->isolate()->counters()->compile_eval()
1235 : info->isolate()->counters()->compile(); 1245 : info->isolate()->counters()->compile();
1236 HistogramTimerScope timer(rate); 1246 HistogramTimerScope timer(rate);
1237 1247
1238 // Compile the code. 1248 // Compile the code.
1239 if (FLAG_ignition && TopLevelFunctionPassesFilter(FLAG_ignition_filter) && 1249 if (FLAG_ignition && TopLevelFunctionPassesFilter(FLAG_ignition_filter)) {
1240 ScriptPassesFilter(FLAG_ignition_script_filter, script)) {
1241 if (!GenerateBytecode(info)) { 1250 if (!GenerateBytecode(info)) {
1242 return Handle<SharedFunctionInfo>::null(); 1251 return Handle<SharedFunctionInfo>::null();
1243 } 1252 }
1244 } else { 1253 } else {
1245 if (!CompileUnoptimizedCode(info)) { 1254 if (!CompileUnoptimizedCode(info)) {
1246 return Handle<SharedFunctionInfo>::null(); 1255 return Handle<SharedFunctionInfo>::null();
1247 } 1256 }
1248 } 1257 }
1249 1258
1250 // Allocate function. 1259 // Allocate function.
(...skipping 542 matching lines...) Expand 10 before | Expand all | Expand 10 after
1793 } 1802 }
1794 1803
1795 #if DEBUG 1804 #if DEBUG
1796 void CompilationInfo::PrintAstForTesting() { 1805 void CompilationInfo::PrintAstForTesting() {
1797 PrintF("--- Source from AST ---\n%s\n", 1806 PrintF("--- Source from AST ---\n%s\n",
1798 PrettyPrinter(isolate()).PrintProgram(literal())); 1807 PrettyPrinter(isolate()).PrintProgram(literal()));
1799 } 1808 }
1800 #endif 1809 #endif
1801 } // namespace internal 1810 } // namespace internal
1802 } // namespace v8 1811 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | src/flag-definitions.h » ('j') | tools/run-tests.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698