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

Side by Side Diff: src/compiler.cc

Issue 868883002: Remove the dependency of Zone on Isolate (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: All platforms Created 5 years, 11 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
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/v8.h" 5 #include "src/v8.h"
6 6
7 #include "src/compiler.h" 7 #include "src/compiler.h"
8 8
9 #include "src/ast-numbering.h" 9 #include "src/ast-numbering.h"
10 #include "src/ast-this-access-visitor.h" 10 #include "src/ast-this-access-visitor.h"
(...skipping 682 matching lines...) Expand 10 before | Expand all | Expand 10 after
693 MaybeDisableOptimization(shared, lit->dont_optimize_reason()); 693 MaybeDisableOptimization(shared, lit->dont_optimize_reason());
694 694
695 // Compile unoptimized code. 695 // Compile unoptimized code.
696 if (!CompileUnoptimizedCode(info)) return MaybeHandle<Code>(); 696 if (!CompileUnoptimizedCode(info)) return MaybeHandle<Code>();
697 697
698 CHECK_EQ(Code::FUNCTION, info->code()->kind()); 698 CHECK_EQ(Code::FUNCTION, info->code()->kind());
699 RecordFunctionCompilation(Logger::LAZY_COMPILE_TAG, info, shared); 699 RecordFunctionCompilation(Logger::LAZY_COMPILE_TAG, info, shared);
700 700
701 // Update the shared function info with the scope info. Allocating the 701 // Update the shared function info with the scope info. Allocating the
702 // ScopeInfo object may cause a GC. 702 // ScopeInfo object may cause a GC.
703 Handle<ScopeInfo> scope_info = ScopeInfo::Create(info->scope(), info->zone()); 703 Handle<ScopeInfo> scope_info =
704 ScopeInfo::Create(info->isolate(), info->zone(), info->scope());
704 shared->set_scope_info(*scope_info); 705 shared->set_scope_info(*scope_info);
705 706
706 // Update the code and feedback vector for the shared function info. 707 // Update the code and feedback vector for the shared function info.
707 shared->ReplaceCode(*info->code()); 708 shared->ReplaceCode(*info->code());
708 if (shared->optimization_disabled()) info->code()->set_optimizable(false); 709 if (shared->optimization_disabled()) info->code()->set_optimizable(false);
709 shared->set_feedback_vector(*info->feedback_vector()); 710 shared->set_feedback_vector(*info->feedback_vector());
710 711
711 return info->code(); 712 return info->code();
712 } 713 }
713 714
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
754 if (shared->bound()) return; 755 if (shared->bound()) return;
755 Handle<FixedArray> literals(function->literals()); 756 Handle<FixedArray> literals(function->literals());
756 Handle<Context> native_context(function->context()->native_context()); 757 Handle<Context> native_context(function->context()->native_context());
757 SharedFunctionInfo::AddToOptimizedCodeMap(shared, native_context, code, 758 SharedFunctionInfo::AddToOptimizedCodeMap(shared, native_context, code,
758 literals, info->osr_ast_id()); 759 literals, info->osr_ast_id());
759 } 760 }
760 } 761 }
761 762
762 763
763 static bool Renumber(CompilationInfo* info) { 764 static bool Renumber(CompilationInfo* info) {
764 if (!AstNumbering::Renumber(info->function(), info->zone())) return false; 765 if (!AstNumbering::Renumber(info->isolate(), info->zone(), info->function()))
Michael Starzinger 2015/01/23 14:21:10 nit: Can we put curly braces around body since con
danno 2015/01/23 14:45:19 Done.
766 return false;
765 if (!info->shared_info().is_null()) { 767 if (!info->shared_info().is_null()) {
766 FunctionLiteral* lit = info->function(); 768 FunctionLiteral* lit = info->function();
767 info->shared_info()->set_ast_node_count(lit->ast_node_count()); 769 info->shared_info()->set_ast_node_count(lit->ast_node_count());
768 MaybeDisableOptimization(info->shared_info(), lit->dont_optimize_reason()); 770 MaybeDisableOptimization(info->shared_info(), lit->dont_optimize_reason());
769 info->shared_info()->set_dont_cache(lit->flags()->Contains(kDontCache)); 771 info->shared_info()->set_dont_cache(lit->flags()->Contains(kDontCache));
770 } 772 }
771 return true; 773 return true;
772 } 774 }
773 775
774 776
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
822 return false; 824 return false;
823 } 825 }
824 826
825 if (!callExpr->expression()->IsSuperReference()) { 827 if (!callExpr->expression()->IsSuperReference()) {
826 ThrowSuperConstructorCheckError(info, stmt); 828 ThrowSuperConstructorCheckError(info, stmt);
827 return false; 829 return false;
828 } 830 }
829 831
830 ZoneList<Expression*>* arguments = callExpr->arguments(); 832 ZoneList<Expression*>* arguments = callExpr->arguments();
831 833
832 AstThisAccessVisitor this_access_visitor(info->zone()); 834 AstThisAccessVisitor this_access_visitor(info->isolate(), info->zone());
833 this_access_visitor.VisitExpressions(arguments); 835 this_access_visitor.VisitExpressions(arguments);
834 836
835 if (this_access_visitor.HasStackOverflow()) return false; 837 if (this_access_visitor.HasStackOverflow()) return false;
836 if (this_access_visitor.UsesThis()) { 838 if (this_access_visitor.UsesThis()) {
837 ThrowSuperConstructorCheckError(info, stmt); 839 ThrowSuperConstructorCheckError(info, stmt);
838 return false; 840 return false;
839 } 841 }
840 return true; 842 return true;
841 } 843 }
842 844
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
1030 } 1032 }
1031 if (!FullCodeGenerator::MakeCode(&unoptimized)) return false; 1033 if (!FullCodeGenerator::MakeCode(&unoptimized)) return false;
1032 1034
1033 shared->EnableDeoptimizationSupport(*unoptimized.code()); 1035 shared->EnableDeoptimizationSupport(*unoptimized.code());
1034 shared->set_feedback_vector(*unoptimized.feedback_vector()); 1036 shared->set_feedback_vector(*unoptimized.feedback_vector());
1035 1037
1036 // The scope info might not have been set if a lazily compiled 1038 // The scope info might not have been set if a lazily compiled
1037 // function is inlined before being called for the first time. 1039 // function is inlined before being called for the first time.
1038 if (shared->scope_info() == ScopeInfo::Empty(info->isolate())) { 1040 if (shared->scope_info() == ScopeInfo::Empty(info->isolate())) {
1039 Handle<ScopeInfo> target_scope_info = 1041 Handle<ScopeInfo> target_scope_info =
1040 ScopeInfo::Create(info->scope(), info->zone()); 1042 ScopeInfo::Create(info->isolate(), info->zone(), info->scope());
1041 shared->set_scope_info(*target_scope_info); 1043 shared->set_scope_info(*target_scope_info);
1042 } 1044 }
1043 1045
1044 // The existing unoptimized code was replaced with the new one. 1046 // The existing unoptimized code was replaced with the new one.
1045 RecordFunctionCompilation(Logger::LAZY_COMPILE_TAG, &unoptimized, shared); 1047 RecordFunctionCompilation(Logger::LAZY_COMPILE_TAG, &unoptimized, shared);
1046 } 1048 }
1047 return true; 1049 return true;
1048 } 1050 }
1049 1051
1050 1052
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
1092 CompilationInfoWithZone info(script); 1094 CompilationInfoWithZone info(script);
1093 PostponeInterruptsScope postpone(info.isolate()); 1095 PostponeInterruptsScope postpone(info.isolate());
1094 VMState<COMPILER> state(info.isolate()); 1096 VMState<COMPILER> state(info.isolate());
1095 1097
1096 info.MarkAsGlobal(); 1098 info.MarkAsGlobal();
1097 if (!Parser::Parse(&info)) return; 1099 if (!Parser::Parse(&info)) return;
1098 1100
1099 LiveEditFunctionTracker tracker(info.isolate(), info.function()); 1101 LiveEditFunctionTracker tracker(info.isolate(), info.function());
1100 if (!CompileUnoptimizedCode(&info)) return; 1102 if (!CompileUnoptimizedCode(&info)) return;
1101 if (!info.shared_info().is_null()) { 1103 if (!info.shared_info().is_null()) {
1102 Handle<ScopeInfo> scope_info = ScopeInfo::Create(info.scope(), 1104 Handle<ScopeInfo> scope_info =
1103 info.zone()); 1105 ScopeInfo::Create(info.isolate(), info.zone(), info.scope());
1104 info.shared_info()->set_scope_info(*scope_info); 1106 info.shared_info()->set_scope_info(*scope_info);
1105 } 1107 }
1106 tracker.RecordRootFunctionInfo(info.code()); 1108 tracker.RecordRootFunctionInfo(info.code());
1107 } 1109 }
1108 1110
1109 1111
1110 static Handle<SharedFunctionInfo> CompileToplevel(CompilationInfo* info) { 1112 static Handle<SharedFunctionInfo> CompileToplevel(CompilationInfo* info) {
1111 Isolate* isolate = info->isolate(); 1113 Isolate* isolate = info->isolate();
1112 PostponeInterruptsScope postpone(isolate); 1114 PostponeInterruptsScope postpone(isolate);
1113 DCHECK(!isolate->native_context().is_null()); 1115 DCHECK(!isolate->native_context().is_null());
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
1162 1164
1163 // Compile the code. 1165 // Compile the code.
1164 if (!CompileUnoptimizedCode(info)) { 1166 if (!CompileUnoptimizedCode(info)) {
1165 return Handle<SharedFunctionInfo>::null(); 1167 return Handle<SharedFunctionInfo>::null();
1166 } 1168 }
1167 1169
1168 // Allocate function. 1170 // Allocate function.
1169 DCHECK(!info->code().is_null()); 1171 DCHECK(!info->code().is_null());
1170 result = isolate->factory()->NewSharedFunctionInfo( 1172 result = isolate->factory()->NewSharedFunctionInfo(
1171 lit->name(), lit->materialized_literal_count(), lit->kind(), 1173 lit->name(), lit->materialized_literal_count(), lit->kind(),
1172 info->code(), ScopeInfo::Create(info->scope(), info->zone()), 1174 info->code(),
1175 ScopeInfo::Create(info->isolate(), info->zone(), info->scope()),
1173 info->feedback_vector()); 1176 info->feedback_vector());
1174 1177
1175 DCHECK_EQ(RelocInfo::kNoPosition, lit->function_token_position()); 1178 DCHECK_EQ(RelocInfo::kNoPosition, lit->function_token_position());
1176 SetFunctionInfo(result, lit, true, script); 1179 SetFunctionInfo(result, lit, true, script);
1177 1180
1178 Handle<String> script_name = script->name()->IsString() 1181 Handle<String> script_name = script->name()->IsString()
1179 ? Handle<String>(String::cast(script->name())) 1182 ? Handle<String>(String::cast(script->name()))
1180 : isolate->factory()->empty_string(); 1183 : isolate->factory()->empty_string();
1181 Logger::LogEventsAndTags log_tag = info->is_eval() 1184 Logger::LogEventsAndTags log_tag = info->is_eval()
1182 ? Logger::EVAL_TAG 1185 ? Logger::EVAL_TAG
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
1418 // on how many feedback-needing nodes are in the tree, and when lazily 1421 // on how many feedback-needing nodes are in the tree, and when lazily
1419 // parsing we might not know that, if this function was never parsed before. 1422 // parsing we might not know that, if this function was never parsed before.
1420 // In that case the vector will be replaced the next time MakeCode is 1423 // In that case the vector will be replaced the next time MakeCode is
1421 // called. 1424 // called.
1422 info.EnsureFeedbackVector(); 1425 info.EnsureFeedbackVector();
1423 scope_info = Handle<ScopeInfo>(ScopeInfo::Empty(isolate)); 1426 scope_info = Handle<ScopeInfo>(ScopeInfo::Empty(isolate));
1424 } else if (Renumber(&info) && FullCodeGenerator::MakeCode(&info)) { 1427 } else if (Renumber(&info) && FullCodeGenerator::MakeCode(&info)) {
1425 // MakeCode will ensure that the feedback vector is present and 1428 // MakeCode will ensure that the feedback vector is present and
1426 // appropriately sized. 1429 // appropriately sized.
1427 DCHECK(!info.code().is_null()); 1430 DCHECK(!info.code().is_null());
1428 scope_info = ScopeInfo::Create(info.scope(), info.zone()); 1431 scope_info = ScopeInfo::Create(info.isolate(), info.zone(), info.scope());
1429 } else { 1432 } else {
1430 return Handle<SharedFunctionInfo>::null(); 1433 return Handle<SharedFunctionInfo>::null();
1431 } 1434 }
1432 1435
1433 // Create a shared function info object. 1436 // Create a shared function info object.
1434 Handle<SharedFunctionInfo> result = factory->NewSharedFunctionInfo( 1437 Handle<SharedFunctionInfo> result = factory->NewSharedFunctionInfo(
1435 literal->name(), literal->materialized_literal_count(), literal->kind(), 1438 literal->name(), literal->materialized_literal_count(), literal->kind(),
1436 info.code(), scope_info, info.feedback_vector()); 1439 info.code(), scope_info, info.feedback_vector());
1437 SetFunctionInfo(result, literal, false, script); 1440 SetFunctionInfo(result, literal, false, script);
1438 RecordFunctionCompilation(Logger::FUNCTION_TAG, &info, result); 1441 RecordFunctionCompilation(Logger::FUNCTION_TAG, &info, result);
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
1549 bool Compiler::DebuggerWantsEagerCompilation(CompilationInfo* info, 1552 bool Compiler::DebuggerWantsEagerCompilation(CompilationInfo* info,
1550 bool allow_lazy_without_ctx) { 1553 bool allow_lazy_without_ctx) {
1551 if (LiveEditFunctionTracker::IsActive(info->isolate())) return true; 1554 if (LiveEditFunctionTracker::IsActive(info->isolate())) return true;
1552 Debug* debug = info->isolate()->debug(); 1555 Debug* debug = info->isolate()->debug();
1553 bool debugging = debug->is_active() || debug->has_break_points(); 1556 bool debugging = debug->is_active() || debug->has_break_points();
1554 return debugging && !allow_lazy_without_ctx; 1557 return debugging && !allow_lazy_without_ctx;
1555 } 1558 }
1556 1559
1557 1560
1558 CompilationPhase::CompilationPhase(const char* name, CompilationInfo* info) 1561 CompilationPhase::CompilationPhase(const char* name, CompilationInfo* info)
1559 : name_(name), info_(info), zone_(info->isolate()) { 1562 : name_(name), info_(info), zone_() {
Michael Starzinger 2015/01/23 14:21:10 nit: Can we drop explicit initializer call?
danno 2015/01/23 14:45:19 Done.
1560 if (FLAG_hydrogen_stats) { 1563 if (FLAG_hydrogen_stats) {
1561 info_zone_start_allocation_size_ = info->zone()->allocation_size(); 1564 info_zone_start_allocation_size_ = info->zone()->allocation_size();
1562 timer_.Start(); 1565 timer_.Start();
1563 } 1566 }
1564 } 1567 }
1565 1568
1566 1569
1567 CompilationPhase::~CompilationPhase() { 1570 CompilationPhase::~CompilationPhase() {
1568 if (FLAG_hydrogen_stats) { 1571 if (FLAG_hydrogen_stats) {
1569 unsigned size = zone()->allocation_size(); 1572 unsigned size = zone()->allocation_size();
1570 size += info_->zone()->allocation_size() - info_zone_start_allocation_size_; 1573 size += info_->zone()->allocation_size() - info_zone_start_allocation_size_;
1571 isolate()->GetHStatistics()->SaveTiming(name_, timer_.Elapsed(), size); 1574 isolate()->GetHStatistics()->SaveTiming(name_, timer_.Elapsed(), size);
1572 } 1575 }
1573 } 1576 }
1574 1577
1575 1578
1576 bool CompilationPhase::ShouldProduceTraceOutput() const { 1579 bool CompilationPhase::ShouldProduceTraceOutput() const {
1577 // Trace if the appropriate trace flag is set and the phase name's first 1580 // Trace if the appropriate trace flag is set and the phase name's first
1578 // character is in the FLAG_trace_phase command line parameter. 1581 // character is in the FLAG_trace_phase command line parameter.
1579 AllowHandleDereference allow_deref; 1582 AllowHandleDereference allow_deref;
1580 bool tracing_on = info()->IsStub() 1583 bool tracing_on = info()->IsStub()
1581 ? FLAG_trace_hydrogen_stubs 1584 ? FLAG_trace_hydrogen_stubs
1582 : (FLAG_trace_hydrogen && 1585 : (FLAG_trace_hydrogen &&
1583 info()->closure()->PassesFilter(FLAG_trace_hydrogen_filter)); 1586 info()->closure()->PassesFilter(FLAG_trace_hydrogen_filter));
1584 return (tracing_on && 1587 return (tracing_on &&
1585 base::OS::StrChr(const_cast<char*>(FLAG_trace_phase), name_[0]) != NULL); 1588 base::OS::StrChr(const_cast<char*>(FLAG_trace_phase), name_[0]) != NULL);
1586 } 1589 }
1587 1590
1588 } } // namespace v8::internal 1591 } } // namespace v8::internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698