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

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: Fix compilation issues 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
« no previous file with comments | « src/compiler.h ('k') | src/compiler/arm/linkage-arm.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 // 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(),
766 info->function())) {
767 return false;
768 }
765 if (!info->shared_info().is_null()) { 769 if (!info->shared_info().is_null()) {
766 FunctionLiteral* lit = info->function(); 770 FunctionLiteral* lit = info->function();
767 info->shared_info()->set_ast_node_count(lit->ast_node_count()); 771 info->shared_info()->set_ast_node_count(lit->ast_node_count());
768 MaybeDisableOptimization(info->shared_info(), lit->dont_optimize_reason()); 772 MaybeDisableOptimization(info->shared_info(), lit->dont_optimize_reason());
769 info->shared_info()->set_dont_cache(lit->flags()->Contains(kDontCache)); 773 info->shared_info()->set_dont_cache(lit->flags()->Contains(kDontCache));
770 } 774 }
771 return true; 775 return true;
772 } 776 }
773 777
774 778
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
822 return false; 826 return false;
823 } 827 }
824 828
825 if (!callExpr->expression()->IsSuperReference()) { 829 if (!callExpr->expression()->IsSuperReference()) {
826 ThrowSuperConstructorCheckError(info, stmt); 830 ThrowSuperConstructorCheckError(info, stmt);
827 return false; 831 return false;
828 } 832 }
829 833
830 ZoneList<Expression*>* arguments = callExpr->arguments(); 834 ZoneList<Expression*>* arguments = callExpr->arguments();
831 835
832 AstThisAccessVisitor this_access_visitor(info->zone()); 836 AstThisAccessVisitor this_access_visitor(info->isolate(), info->zone());
833 this_access_visitor.VisitExpressions(arguments); 837 this_access_visitor.VisitExpressions(arguments);
834 838
835 if (this_access_visitor.HasStackOverflow()) return false; 839 if (this_access_visitor.HasStackOverflow()) return false;
836 if (this_access_visitor.UsesThis()) { 840 if (this_access_visitor.UsesThis()) {
837 ThrowSuperConstructorCheckError(info, stmt); 841 ThrowSuperConstructorCheckError(info, stmt);
838 return false; 842 return false;
839 } 843 }
840 return true; 844 return true;
841 } 845 }
842 846
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
1030 } 1034 }
1031 if (!FullCodeGenerator::MakeCode(&unoptimized)) return false; 1035 if (!FullCodeGenerator::MakeCode(&unoptimized)) return false;
1032 1036
1033 shared->EnableDeoptimizationSupport(*unoptimized.code()); 1037 shared->EnableDeoptimizationSupport(*unoptimized.code());
1034 shared->set_feedback_vector(*unoptimized.feedback_vector()); 1038 shared->set_feedback_vector(*unoptimized.feedback_vector());
1035 1039
1036 // The scope info might not have been set if a lazily compiled 1040 // The scope info might not have been set if a lazily compiled
1037 // function is inlined before being called for the first time. 1041 // function is inlined before being called for the first time.
1038 if (shared->scope_info() == ScopeInfo::Empty(info->isolate())) { 1042 if (shared->scope_info() == ScopeInfo::Empty(info->isolate())) {
1039 Handle<ScopeInfo> target_scope_info = 1043 Handle<ScopeInfo> target_scope_info =
1040 ScopeInfo::Create(info->scope(), info->zone()); 1044 ScopeInfo::Create(info->isolate(), info->zone(), info->scope());
1041 shared->set_scope_info(*target_scope_info); 1045 shared->set_scope_info(*target_scope_info);
1042 } 1046 }
1043 1047
1044 // The existing unoptimized code was replaced with the new one. 1048 // The existing unoptimized code was replaced with the new one.
1045 RecordFunctionCompilation(Logger::LAZY_COMPILE_TAG, &unoptimized, shared); 1049 RecordFunctionCompilation(Logger::LAZY_COMPILE_TAG, &unoptimized, shared);
1046 } 1050 }
1047 return true; 1051 return true;
1048 } 1052 }
1049 1053
1050 1054
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
1092 CompilationInfoWithZone info(script); 1096 CompilationInfoWithZone info(script);
1093 PostponeInterruptsScope postpone(info.isolate()); 1097 PostponeInterruptsScope postpone(info.isolate());
1094 VMState<COMPILER> state(info.isolate()); 1098 VMState<COMPILER> state(info.isolate());
1095 1099
1096 info.MarkAsGlobal(); 1100 info.MarkAsGlobal();
1097 if (!Parser::Parse(&info)) return; 1101 if (!Parser::Parse(&info)) return;
1098 1102
1099 LiveEditFunctionTracker tracker(info.isolate(), info.function()); 1103 LiveEditFunctionTracker tracker(info.isolate(), info.function());
1100 if (!CompileUnoptimizedCode(&info)) return; 1104 if (!CompileUnoptimizedCode(&info)) return;
1101 if (!info.shared_info().is_null()) { 1105 if (!info.shared_info().is_null()) {
1102 Handle<ScopeInfo> scope_info = ScopeInfo::Create(info.scope(), 1106 Handle<ScopeInfo> scope_info =
1103 info.zone()); 1107 ScopeInfo::Create(info.isolate(), info.zone(), info.scope());
1104 info.shared_info()->set_scope_info(*scope_info); 1108 info.shared_info()->set_scope_info(*scope_info);
1105 } 1109 }
1106 tracker.RecordRootFunctionInfo(info.code()); 1110 tracker.RecordRootFunctionInfo(info.code());
1107 } 1111 }
1108 1112
1109 1113
1110 static Handle<SharedFunctionInfo> CompileToplevel(CompilationInfo* info) { 1114 static Handle<SharedFunctionInfo> CompileToplevel(CompilationInfo* info) {
1111 Isolate* isolate = info->isolate(); 1115 Isolate* isolate = info->isolate();
1112 PostponeInterruptsScope postpone(isolate); 1116 PostponeInterruptsScope postpone(isolate);
1113 DCHECK(!isolate->native_context().is_null()); 1117 DCHECK(!isolate->native_context().is_null());
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
1162 1166
1163 // Compile the code. 1167 // Compile the code.
1164 if (!CompileUnoptimizedCode(info)) { 1168 if (!CompileUnoptimizedCode(info)) {
1165 return Handle<SharedFunctionInfo>::null(); 1169 return Handle<SharedFunctionInfo>::null();
1166 } 1170 }
1167 1171
1168 // Allocate function. 1172 // Allocate function.
1169 DCHECK(!info->code().is_null()); 1173 DCHECK(!info->code().is_null());
1170 result = isolate->factory()->NewSharedFunctionInfo( 1174 result = isolate->factory()->NewSharedFunctionInfo(
1171 lit->name(), lit->materialized_literal_count(), lit->kind(), 1175 lit->name(), lit->materialized_literal_count(), lit->kind(),
1172 info->code(), ScopeInfo::Create(info->scope(), info->zone()), 1176 info->code(),
1177 ScopeInfo::Create(info->isolate(), info->zone(), info->scope()),
1173 info->feedback_vector()); 1178 info->feedback_vector());
1174 1179
1175 DCHECK_EQ(RelocInfo::kNoPosition, lit->function_token_position()); 1180 DCHECK_EQ(RelocInfo::kNoPosition, lit->function_token_position());
1176 SetFunctionInfo(result, lit, true, script); 1181 SetFunctionInfo(result, lit, true, script);
1177 1182
1178 Handle<String> script_name = script->name()->IsString() 1183 Handle<String> script_name = script->name()->IsString()
1179 ? Handle<String>(String::cast(script->name())) 1184 ? Handle<String>(String::cast(script->name()))
1180 : isolate->factory()->empty_string(); 1185 : isolate->factory()->empty_string();
1181 Logger::LogEventsAndTags log_tag = info->is_eval() 1186 Logger::LogEventsAndTags log_tag = info->is_eval()
1182 ? Logger::EVAL_TAG 1187 ? 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 1423 // 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. 1424 // 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 1425 // In that case the vector will be replaced the next time MakeCode is
1421 // called. 1426 // called.
1422 info.EnsureFeedbackVector(); 1427 info.EnsureFeedbackVector();
1423 scope_info = Handle<ScopeInfo>(ScopeInfo::Empty(isolate)); 1428 scope_info = Handle<ScopeInfo>(ScopeInfo::Empty(isolate));
1424 } else if (Renumber(&info) && FullCodeGenerator::MakeCode(&info)) { 1429 } else if (Renumber(&info) && FullCodeGenerator::MakeCode(&info)) {
1425 // MakeCode will ensure that the feedback vector is present and 1430 // MakeCode will ensure that the feedback vector is present and
1426 // appropriately sized. 1431 // appropriately sized.
1427 DCHECK(!info.code().is_null()); 1432 DCHECK(!info.code().is_null());
1428 scope_info = ScopeInfo::Create(info.scope(), info.zone()); 1433 scope_info = ScopeInfo::Create(info.isolate(), info.zone(), info.scope());
1429 } else { 1434 } else {
1430 return Handle<SharedFunctionInfo>::null(); 1435 return Handle<SharedFunctionInfo>::null();
1431 } 1436 }
1432 1437
1433 // Create a shared function info object. 1438 // Create a shared function info object.
1434 Handle<SharedFunctionInfo> result = factory->NewSharedFunctionInfo( 1439 Handle<SharedFunctionInfo> result = factory->NewSharedFunctionInfo(
1435 literal->name(), literal->materialized_literal_count(), literal->kind(), 1440 literal->name(), literal->materialized_literal_count(), literal->kind(),
1436 info.code(), scope_info, info.feedback_vector()); 1441 info.code(), scope_info, info.feedback_vector());
1437 SetFunctionInfo(result, literal, false, script); 1442 SetFunctionInfo(result, literal, false, script);
1438 RecordFunctionCompilation(Logger::FUNCTION_TAG, &info, result); 1443 RecordFunctionCompilation(Logger::FUNCTION_TAG, &info, result);
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
1549 bool Compiler::DebuggerWantsEagerCompilation(CompilationInfo* info, 1554 bool Compiler::DebuggerWantsEagerCompilation(CompilationInfo* info,
1550 bool allow_lazy_without_ctx) { 1555 bool allow_lazy_without_ctx) {
1551 if (LiveEditFunctionTracker::IsActive(info->isolate())) return true; 1556 if (LiveEditFunctionTracker::IsActive(info->isolate())) return true;
1552 Debug* debug = info->isolate()->debug(); 1557 Debug* debug = info->isolate()->debug();
1553 bool debugging = debug->is_active() || debug->has_break_points(); 1558 bool debugging = debug->is_active() || debug->has_break_points();
1554 return debugging && !allow_lazy_without_ctx; 1559 return debugging && !allow_lazy_without_ctx;
1555 } 1560 }
1556 1561
1557 1562
1558 CompilationPhase::CompilationPhase(const char* name, CompilationInfo* info) 1563 CompilationPhase::CompilationPhase(const char* name, CompilationInfo* info)
1559 : name_(name), info_(info), zone_(info->isolate()) { 1564 : name_(name), info_(info) {
1560 if (FLAG_hydrogen_stats) { 1565 if (FLAG_hydrogen_stats) {
1561 info_zone_start_allocation_size_ = info->zone()->allocation_size(); 1566 info_zone_start_allocation_size_ = info->zone()->allocation_size();
1562 timer_.Start(); 1567 timer_.Start();
1563 } 1568 }
1564 } 1569 }
1565 1570
1566 1571
1567 CompilationPhase::~CompilationPhase() { 1572 CompilationPhase::~CompilationPhase() {
1568 if (FLAG_hydrogen_stats) { 1573 if (FLAG_hydrogen_stats) {
1569 unsigned size = zone()->allocation_size(); 1574 unsigned size = zone()->allocation_size();
1570 size += info_->zone()->allocation_size() - info_zone_start_allocation_size_; 1575 size += info_->zone()->allocation_size() - info_zone_start_allocation_size_;
1571 isolate()->GetHStatistics()->SaveTiming(name_, timer_.Elapsed(), size); 1576 isolate()->GetHStatistics()->SaveTiming(name_, timer_.Elapsed(), size);
1572 } 1577 }
1573 } 1578 }
1574 1579
1575 1580
1576 bool CompilationPhase::ShouldProduceTraceOutput() const { 1581 bool CompilationPhase::ShouldProduceTraceOutput() const {
1577 // Trace if the appropriate trace flag is set and the phase name's first 1582 // 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. 1583 // character is in the FLAG_trace_phase command line parameter.
1579 AllowHandleDereference allow_deref; 1584 AllowHandleDereference allow_deref;
1580 bool tracing_on = info()->IsStub() 1585 bool tracing_on = info()->IsStub()
1581 ? FLAG_trace_hydrogen_stubs 1586 ? FLAG_trace_hydrogen_stubs
1582 : (FLAG_trace_hydrogen && 1587 : (FLAG_trace_hydrogen &&
1583 info()->closure()->PassesFilter(FLAG_trace_hydrogen_filter)); 1588 info()->closure()->PassesFilter(FLAG_trace_hydrogen_filter));
1584 return (tracing_on && 1589 return (tracing_on &&
1585 base::OS::StrChr(const_cast<char*>(FLAG_trace_phase), name_[0]) != NULL); 1590 base::OS::StrChr(const_cast<char*>(FLAG_trace_phase), name_[0]) != NULL);
1586 } 1591 }
1587 1592
1588 } } // namespace v8::internal 1593 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/compiler.h ('k') | src/compiler/arm/linkage-arm.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698