OLD | NEW |
---|---|
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/bootstrapper.h" | 10 #include "src/bootstrapper.h" |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
140 extension_ = NULL; | 140 extension_ = NULL; |
141 cached_data_ = NULL; | 141 cached_data_ = NULL; |
142 compile_options_ = ScriptCompiler::kNoCompileOptions; | 142 compile_options_ = ScriptCompiler::kNoCompileOptions; |
143 zone_ = zone; | 143 zone_ = zone; |
144 deferred_handles_ = NULL; | 144 deferred_handles_ = NULL; |
145 code_stub_ = NULL; | 145 code_stub_ = NULL; |
146 prologue_offset_ = Code::kPrologueOffsetNotSet; | 146 prologue_offset_ = Code::kPrologueOffsetNotSet; |
147 opt_count_ = shared_info().is_null() ? 0 : shared_info()->opt_count(); | 147 opt_count_ = shared_info().is_null() ? 0 : shared_info()->opt_count(); |
148 no_frame_ranges_ = isolate->cpu_profiler()->is_profiling() | 148 no_frame_ranges_ = isolate->cpu_profiler()->is_profiling() |
149 ? new List<OffsetRange>(2) : NULL; | 149 ? new List<OffsetRange>(2) : NULL; |
150 if (FLAG_hydrogen_track_positions) { | |
151 inlined_function_infos_ = new List<InlinedFunctionInfo>(5); | |
152 inlining_id_to_function_id_ = new List<int>(5); | |
153 } else { | |
154 inlined_function_infos_ = NULL; | |
155 inlining_id_to_function_id_ = NULL; | |
156 } | |
157 | |
150 for (int i = 0; i < DependentCode::kGroupCount; i++) { | 158 for (int i = 0; i < DependentCode::kGroupCount; i++) { |
151 dependencies_[i] = NULL; | 159 dependencies_[i] = NULL; |
152 } | 160 } |
153 if (mode == STUB) { | 161 if (mode == STUB) { |
154 mode_ = STUB; | 162 mode_ = STUB; |
155 return; | 163 return; |
156 } | 164 } |
157 mode_ = mode; | 165 mode_ = mode; |
158 if (!script_.is_null() && script_->type()->value() == Script::TYPE_NATIVE) { | 166 if (!script_.is_null() && script_->type()->value() == Script::TYPE_NATIVE) { |
159 MarkAsNative(); | 167 MarkAsNative(); |
(...skipping 26 matching lines...) Expand all Loading... | |
186 } | 194 } |
187 } | 195 } |
188 | 196 |
189 | 197 |
190 CompilationInfo::~CompilationInfo() { | 198 CompilationInfo::~CompilationInfo() { |
191 if (GetFlag(kDisableFutureOptimization)) { | 199 if (GetFlag(kDisableFutureOptimization)) { |
192 shared_info()->DisableOptimization(bailout_reason()); | 200 shared_info()->DisableOptimization(bailout_reason()); |
193 } | 201 } |
194 delete deferred_handles_; | 202 delete deferred_handles_; |
195 delete no_frame_ranges_; | 203 delete no_frame_ranges_; |
204 if (inlined_function_infos_) delete inlined_function_infos_; | |
Vyacheslav Egorov (Google)
2015/02/16 13:38:50
delete NULL works just fine - so no need for if.
loislo
2015/02/16 14:48:32
Done.
| |
205 if (inlining_id_to_function_id_) delete inlining_id_to_function_id_; | |
196 if (ast_value_factory_owned_) delete ast_value_factory_; | 206 if (ast_value_factory_owned_) delete ast_value_factory_; |
197 #ifdef DEBUG | 207 #ifdef DEBUG |
198 // Check that no dependent maps have been added or added dependent maps have | 208 // Check that no dependent maps have been added or added dependent maps have |
199 // been rolled back or committed. | 209 // been rolled back or committed. |
200 for (int i = 0; i < DependentCode::kGroupCount; i++) { | 210 for (int i = 0; i < DependentCode::kGroupCount; i++) { |
201 DCHECK(!dependencies_[i]); | 211 DCHECK(!dependencies_[i]); |
202 } | 212 } |
203 #endif // DEBUG | 213 #endif // DEBUG |
204 } | 214 } |
205 | 215 |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
306 function()->feedback_vector_spec()); | 316 function()->feedback_vector_spec()); |
307 } | 317 } |
308 } | 318 } |
309 | 319 |
310 | 320 |
311 bool CompilationInfo::is_simple_parameter_list() { | 321 bool CompilationInfo::is_simple_parameter_list() { |
312 return scope_->is_simple_parameter_list(); | 322 return scope_->is_simple_parameter_list(); |
313 } | 323 } |
314 | 324 |
315 | 325 |
326 int CompilationInfo::GetInlinedFunctionId(Handle<SharedFunctionInfo> shared) { | |
327 DCHECK(inlined_function_infos_); | |
328 DCHECK(inlining_id_to_function_id_); | |
329 int id = 0; | |
330 for (; id < inlined_function_infos_->length(); id++) { | |
331 if (inlined_function_infos_->at(id).shared().is_identical_to(shared)) { | |
332 break; | |
333 } | |
334 } | |
335 if (id == inlined_function_infos_->length()) { | |
336 inlined_function_infos_->Add(InlinedFunctionInfo(shared)); | |
337 | |
338 if (!shared->script()->IsUndefined()) { | |
Vyacheslav Egorov (Google)
2015/02/16 13:38:50
Given that you want to reuse this function for pro
loislo
2015/02/16 14:48:32
Yep. I supposed to do that in the next patch.
| |
339 Handle<Script> script(Script::cast(shared->script())); | |
340 if (!script->source()->IsUndefined()) { | |
341 CodeTracer::Scope tracing_scopex(isolate()->GetCodeTracer()); | |
Vyacheslav Egorov (Google)
2015/02/16 13:38:50
can it be called just tracing_scope here?
loislo
2015/02/16 14:48:32
Done.
| |
342 OFStream os(tracing_scopex.file()); | |
343 os << "--- FUNCTION SOURCE (" << shared->DebugName()->ToCString().get() | |
344 << ") id{" << optimization_id() << "," << id << "} ---\n"; | |
345 { | |
346 DisallowHeapAllocation no_allocation; | |
347 int start = shared->start_position(); | |
348 int len = shared->end_position() - start + 1; | |
349 String::SubStringRange source(String::cast(script->source()), start, | |
350 len); | |
351 for (const auto& c : source) { | |
352 os << AsReversiblyEscapedUC16(c); | |
353 } | |
354 } | |
355 | |
356 os << "\n--- END ---\n"; | |
357 } | |
358 } | |
359 } | |
360 return id; | |
361 } | |
362 | |
363 | |
316 class HOptimizedGraphBuilderWithPositions: public HOptimizedGraphBuilder { | 364 class HOptimizedGraphBuilderWithPositions: public HOptimizedGraphBuilder { |
317 public: | 365 public: |
318 explicit HOptimizedGraphBuilderWithPositions(CompilationInfo* info) | 366 explicit HOptimizedGraphBuilderWithPositions(CompilationInfo* info) |
319 : HOptimizedGraphBuilder(info) { | 367 : HOptimizedGraphBuilder(info) { |
320 } | 368 } |
321 | 369 |
322 #define DEF_VISIT(type) \ | 370 #define DEF_VISIT(type) \ |
323 void Visit##type(type* node) OVERRIDE { \ | 371 void Visit##type(type* node) OVERRIDE { \ |
324 if (node->position() != RelocInfo::kNoPosition) { \ | 372 if (node->position() != RelocInfo::kNoPosition) { \ |
325 SetSourcePosition(node->position()); \ | 373 SetSourcePosition(node->position()); \ |
(...skipping 1195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1521 } | 1569 } |
1522 | 1570 |
1523 | 1571 |
1524 #if DEBUG | 1572 #if DEBUG |
1525 void CompilationInfo::PrintAstForTesting() { | 1573 void CompilationInfo::PrintAstForTesting() { |
1526 PrintF("--- Source from AST ---\n%s\n", | 1574 PrintF("--- Source from AST ---\n%s\n", |
1527 PrettyPrinter(isolate(), zone()).PrintProgram(function())); | 1575 PrettyPrinter(isolate(), zone()).PrintProgram(function())); |
1528 } | 1576 } |
1529 #endif | 1577 #endif |
1530 } } // namespace v8::internal | 1578 } } // namespace v8::internal |
OLD | NEW |