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

Side by Side Diff: src/compiler.cc

Issue 16542003: Enable map dependency to in-flight compilation info. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: put transition maps and initial maps dependency into a separate CL Created 7 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « src/compiler.h ('k') | src/hydrogen.h » ('j') | src/objects.cc » ('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 // 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 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 global_scope_ = NULL; 99 global_scope_ = NULL;
100 extension_ = NULL; 100 extension_ = NULL;
101 pre_parse_data_ = NULL; 101 pre_parse_data_ = NULL;
102 zone_ = zone; 102 zone_ = zone;
103 deferred_handles_ = NULL; 103 deferred_handles_ = NULL;
104 code_stub_ = NULL; 104 code_stub_ = NULL;
105 prologue_offset_ = kPrologueOffsetNotSet; 105 prologue_offset_ = kPrologueOffsetNotSet;
106 opt_count_ = shared_info().is_null() ? 0 : shared_info()->opt_count(); 106 opt_count_ = shared_info().is_null() ? 0 : shared_info()->opt_count();
107 no_frame_ranges_ = isolate->cpu_profiler()->is_profiling() 107 no_frame_ranges_ = isolate->cpu_profiler()->is_profiling()
108 ? new List<OffsetRange>(2) : NULL; 108 ? new List<OffsetRange>(2) : NULL;
109 for (int i = 0; i < DependentCode::kGroupCount; i++) {
110 dependent_maps_[i] = NULL;
111 }
109 if (mode == STUB) { 112 if (mode == STUB) {
110 mode_ = STUB; 113 mode_ = STUB;
111 return; 114 return;
112 } 115 }
113 mode_ = V8::UseCrankshaft() ? mode : NONOPT; 116 mode_ = V8::UseCrankshaft() ? mode : NONOPT;
114 if (script_->type()->value() == Script::TYPE_NATIVE) { 117 if (script_->type()->value() == Script::TYPE_NATIVE) {
115 MarkAsNative(); 118 MarkAsNative();
116 } 119 }
117 if (!shared_info_.is_null()) { 120 if (!shared_info_.is_null()) {
118 ASSERT(language_mode() == CLASSIC_MODE); 121 ASSERT(language_mode() == CLASSIC_MODE);
119 SetLanguageMode(shared_info_->language_mode()); 122 SetLanguageMode(shared_info_->language_mode());
120 } 123 }
121 set_bailout_reason("unknown"); 124 set_bailout_reason("unknown");
122 } 125 }
123 126
124 127
125 CompilationInfo::~CompilationInfo() { 128 CompilationInfo::~CompilationInfo() {
126 delete deferred_handles_; 129 delete deferred_handles_;
127 delete no_frame_ranges_; 130 delete no_frame_ranges_;
131 #ifdef DEBUG
132 // Check that no dependent maps have been added or added dependent maps have
133 // been rolled back or committed.
134 for (int i = 0; i < DependentCode::kGroupCount; i++) {
135 ASSERT_EQ(NULL, dependent_maps_[i]);
136 }
137 #endif // DEBUG
128 } 138 }
129 139
130 140
141 void CompilationInfo::CommitDependentMaps(Handle<Code> code) {
142 for (int i = 0; i < DependentCode::kGroupCount; i++) {
143 ZoneList<Handle<Map> >* group_maps = dependent_maps_[i];
144 if (group_maps == NULL) continue;
145 ASSERT(!object_wrapper_.is_null());
146 for (int j = 0; j < group_maps->length(); j++) {
ulan 2013/06/07 13:21:29 This has O(n^2) complexity. It is probably OK. I a
147 group_maps->at(j)->dependent_code()->UpdateToFinishedCode(
148 static_cast<DependentCode::DependencyGroup>(i), this, *code);
149 }
150 dependent_maps_[i] = NULL; // Zone-allocated, no need to delete.
151 }
152 }
153
154
155 void CompilationInfo::RollbackDependentMaps() {
156 // Unregister from all dependent maps if not yet committed.
157 for (int i = 0; i < DependentCode::kGroupCount; i++) {
158 ZoneList<Handle<Map> >* group_maps = dependent_maps_[i];
159 if (group_maps == NULL) continue;
160 for (int j = 0; j < group_maps->length(); j++) {
161 group_maps->at(j)->dependent_code()->RemoveCompilationInfo(
162 static_cast<DependentCode::DependencyGroup>(i), this);
163 }
164 dependent_maps_[i] = NULL; // Zone-allocated, no need to delete.
165 }
166 }
167
168
131 int CompilationInfo::num_parameters() const { 169 int CompilationInfo::num_parameters() const {
132 ASSERT(!IsStub()); 170 ASSERT(!IsStub());
133 return scope()->num_parameters(); 171 return scope()->num_parameters();
134 } 172 }
135 173
136 174
137 int CompilationInfo::num_heap_slots() const { 175 int CompilationInfo::num_heap_slots() const {
138 if (IsStub()) { 176 if (IsStub()) {
139 return 0; 177 return 0;
140 } else { 178 } else {
(...skipping 834 matching lines...) Expand 10 before | Expand all | Expand 10 after
975 1013
976 if (isolate->has_pending_exception()) isolate->clear_pending_exception(); 1014 if (isolate->has_pending_exception()) isolate->clear_pending_exception();
977 } 1015 }
978 1016
979 1017
980 void Compiler::InstallOptimizedCode(OptimizingCompiler* optimizing_compiler) { 1018 void Compiler::InstallOptimizedCode(OptimizingCompiler* optimizing_compiler) {
981 SmartPointer<CompilationInfo> info(optimizing_compiler->info()); 1019 SmartPointer<CompilationInfo> info(optimizing_compiler->info());
982 // The function may have already been optimized by OSR. Simply continue. 1020 // The function may have already been optimized by OSR. Simply continue.
983 // Except when OSR already disabled optimization for some reason. 1021 // Except when OSR already disabled optimization for some reason.
984 if (info->shared_info()->optimization_disabled()) { 1022 if (info->shared_info()->optimization_disabled()) {
985 info->SetCode(Handle<Code>(info->shared_info()->code())); 1023 info->AbortOptimization();
986 InstallFullCode(*info); 1024 InstallFullCode(*info);
987 if (FLAG_trace_parallel_recompilation) { 1025 if (FLAG_trace_parallel_recompilation) {
988 PrintF(" ** aborting optimization for "); 1026 PrintF(" ** aborting optimization for ");
989 info->closure()->PrintName(); 1027 info->closure()->PrintName();
990 PrintF(" as it has been disabled.\n"); 1028 PrintF(" as it has been disabled.\n");
991 } 1029 }
992 ASSERT(!info->closure()->IsMarkedForInstallingRecompiledCode()); 1030 ASSERT(!info->closure()->IsMarkedForInstallingRecompiledCode());
993 return; 1031 return;
994 } 1032 }
995 1033
996 Isolate* isolate = info->isolate(); 1034 Isolate* isolate = info->isolate();
997 VMState<COMPILER> state(isolate); 1035 VMState<COMPILER> state(isolate);
998 Logger::TimerEventScope timer( 1036 Logger::TimerEventScope timer(
999 isolate, Logger::TimerEventScope::v8_recompile_synchronous); 1037 isolate, Logger::TimerEventScope::v8_recompile_synchronous);
1000 // If crankshaft succeeded, install the optimized code else install 1038 // If crankshaft succeeded, install the optimized code else install
1001 // the unoptimized code. 1039 // the unoptimized code.
1002 OptimizingCompiler::Status status = optimizing_compiler->last_status(); 1040 OptimizingCompiler::Status status = optimizing_compiler->last_status();
1003 if (status != OptimizingCompiler::SUCCEEDED) { 1041 if (info->HasAbortedDueToDependentMap()) {
1004 optimizing_compiler->info()->set_bailout_reason( 1042 info->set_bailout_reason("bailed out due to dependent map");
1005 "failed/bailed out last time"); 1043 status = optimizing_compiler->AbortOptimization();
1044 } else if (status != OptimizingCompiler::SUCCEEDED) {
1045 info->set_bailout_reason("failed/bailed out last time");
1006 status = optimizing_compiler->AbortOptimization(); 1046 status = optimizing_compiler->AbortOptimization();
1007 } else { 1047 } else {
1008 status = optimizing_compiler->GenerateAndInstallCode(); 1048 status = optimizing_compiler->GenerateAndInstallCode();
1009 ASSERT(status == OptimizingCompiler::SUCCEEDED || 1049 ASSERT(status == OptimizingCompiler::SUCCEEDED ||
1010 status == OptimizingCompiler::BAILED_OUT); 1050 status == OptimizingCompiler::BAILED_OUT);
1011 } 1051 }
1012 1052
1013 InstallCodeCommon(*info); 1053 InstallCodeCommon(*info);
1014 if (status == OptimizingCompiler::SUCCEEDED) { 1054 if (status == OptimizingCompiler::SUCCEEDED) {
1015 Handle<Code> code = info->code(); 1055 Handle<Code> code = info->code();
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
1161 } 1201 }
1162 } 1202 }
1163 1203
1164 GDBJIT(AddCode(Handle<String>(shared->DebugName()), 1204 GDBJIT(AddCode(Handle<String>(shared->DebugName()),
1165 Handle<Script>(info->script()), 1205 Handle<Script>(info->script()),
1166 Handle<Code>(info->code()), 1206 Handle<Code>(info->code()),
1167 info)); 1207 info));
1168 } 1208 }
1169 1209
1170 } } // namespace v8::internal 1210 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/compiler.h ('k') | src/hydrogen.h » ('j') | src/objects.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698