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 #ifndef V8_COMPILER_H_ | 5 #ifndef V8_COMPILER_H_ |
6 #define V8_COMPILER_H_ | 6 #define V8_COMPILER_H_ |
7 | 7 |
8 #include "src/allocation.h" | 8 #include "src/allocation.h" |
9 #include "src/ast.h" | 9 #include "src/ast.h" |
10 #include "src/bailout-reason.h" | 10 #include "src/bailout-reason.h" |
| 11 #include "src/compilation-dependencies.h" |
11 #include "src/zone.h" | 12 #include "src/zone.h" |
12 | 13 |
13 namespace v8 { | 14 namespace v8 { |
14 namespace internal { | 15 namespace internal { |
15 | 16 |
16 class AstValueFactory; | 17 class AstValueFactory; |
17 class HydrogenCodeStub; | 18 class HydrogenCodeStub; |
18 class ParseInfo; | 19 class ParseInfo; |
19 class ScriptData; | 20 class ScriptData; |
20 | 21 |
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
292 } | 293 } |
293 | 294 |
294 // Determines whether or not to insert a self-optimization header. | 295 // Determines whether or not to insert a self-optimization header. |
295 bool ShouldSelfOptimize(); | 296 bool ShouldSelfOptimize(); |
296 | 297 |
297 void set_deferred_handles(DeferredHandles* deferred_handles) { | 298 void set_deferred_handles(DeferredHandles* deferred_handles) { |
298 DCHECK(deferred_handles_ == NULL); | 299 DCHECK(deferred_handles_ == NULL); |
299 deferred_handles_ = deferred_handles; | 300 deferred_handles_ = deferred_handles; |
300 } | 301 } |
301 | 302 |
302 ZoneList<Handle<HeapObject> >* dependencies( | |
303 DependentCode::DependencyGroup group) { | |
304 if (dependencies_[group] == NULL) { | |
305 dependencies_[group] = new(zone_) ZoneList<Handle<HeapObject> >(2, zone_); | |
306 } | |
307 return dependencies_[group]; | |
308 } | |
309 | |
310 void CommitDependencies(Handle<Code> code); | |
311 | |
312 void RollbackDependencies(); | |
313 | |
314 void ReopenHandlesInNewHandleScope() { | 303 void ReopenHandlesInNewHandleScope() { |
315 unoptimized_code_ = Handle<Code>(*unoptimized_code_); | 304 unoptimized_code_ = Handle<Code>(*unoptimized_code_); |
316 } | 305 } |
317 | 306 |
318 void AbortOptimization(BailoutReason reason) { | 307 void AbortOptimization(BailoutReason reason) { |
319 DCHECK(reason != kNoReason); | 308 DCHECK(reason != kNoReason); |
320 if (bailout_reason_ == kNoReason) bailout_reason_ = reason; | 309 if (bailout_reason_ == kNoReason) bailout_reason_ = reason; |
321 SetFlag(kDisableFutureOptimization); | 310 SetFlag(kDisableFutureOptimization); |
322 } | 311 } |
323 | 312 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
356 return inlined_function_infos_.at(inlining_id).start_position; | 345 return inlined_function_infos_.at(inlining_id).start_position; |
357 } | 346 } |
358 const std::vector<InlinedFunctionInfo>& inlined_function_infos() { | 347 const std::vector<InlinedFunctionInfo>& inlined_function_infos() { |
359 return inlined_function_infos_; | 348 return inlined_function_infos_; |
360 } | 349 } |
361 | 350 |
362 void LogDeoptCallPosition(int pc_offset, int inlining_id); | 351 void LogDeoptCallPosition(int pc_offset, int inlining_id); |
363 int TraceInlinedFunction(Handle<SharedFunctionInfo> shared, | 352 int TraceInlinedFunction(Handle<SharedFunctionInfo> shared, |
364 SourcePosition position, int pareint_id); | 353 SourcePosition position, int pareint_id); |
365 | 354 |
366 Handle<Foreign> object_wrapper() { | 355 CompilationDependencies* dependencies() { return &dependencies_; } |
367 if (object_wrapper_.is_null()) { | |
368 object_wrapper_ = | |
369 isolate()->factory()->NewForeign(reinterpret_cast<Address>(this)); | |
370 } | |
371 return object_wrapper_; | |
372 } | |
373 | |
374 void AbortDueToDependencyChange() { | |
375 aborted_due_to_dependency_change_ = true; | |
376 } | |
377 | |
378 bool HasAbortedDueToDependencyChange() const { | |
379 return aborted_due_to_dependency_change_; | |
380 } | |
381 | 356 |
382 bool HasSameOsrEntry(Handle<JSFunction> function, BailoutId osr_ast_id) { | 357 bool HasSameOsrEntry(Handle<JSFunction> function, BailoutId osr_ast_id) { |
383 return osr_ast_id_ == osr_ast_id && function.is_identical_to(closure()); | 358 return osr_ast_id_ == osr_ast_id && function.is_identical_to(closure()); |
384 } | 359 } |
385 | 360 |
386 int optimization_id() const { return optimization_id_; } | 361 int optimization_id() const { return optimization_id_; } |
387 | 362 |
388 int osr_expr_stack_height() { return osr_expr_stack_height_; } | 363 int osr_expr_stack_height() { return osr_expr_stack_height_; } |
389 void set_osr_expr_stack_height(int height) { | 364 void set_osr_expr_stack_height(int height) { |
390 DCHECK(height >= 0); | 365 DCHECK(height >= 0); |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
453 // afterwards, since we may need to compile it again to include deoptimization | 428 // afterwards, since we may need to compile it again to include deoptimization |
454 // data. Keep track which code we patched. | 429 // data. Keep track which code we patched. |
455 Handle<Code> unoptimized_code_; | 430 Handle<Code> unoptimized_code_; |
456 | 431 |
457 // The zone from which the compilation pipeline working on this | 432 // The zone from which the compilation pipeline working on this |
458 // CompilationInfo allocates. | 433 // CompilationInfo allocates. |
459 Zone* zone_; | 434 Zone* zone_; |
460 | 435 |
461 DeferredHandles* deferred_handles_; | 436 DeferredHandles* deferred_handles_; |
462 | 437 |
463 ZoneList<Handle<HeapObject> >* dependencies_[DependentCode::kGroupCount]; | 438 // Dependencies for this compilation, e.g. stable maps. |
| 439 CompilationDependencies dependencies_; |
464 | 440 |
465 BailoutReason bailout_reason_; | 441 BailoutReason bailout_reason_; |
466 | 442 |
467 int prologue_offset_; | 443 int prologue_offset_; |
468 | 444 |
469 List<OffsetRange>* no_frame_ranges_; | 445 List<OffsetRange>* no_frame_ranges_; |
470 std::vector<InlinedFunctionInfo> inlined_function_infos_; | 446 std::vector<InlinedFunctionInfo> inlined_function_infos_; |
471 bool track_positions_; | 447 bool track_positions_; |
472 | 448 |
473 // A copy of shared_info()->opt_count() to avoid handle deref | 449 // A copy of shared_info()->opt_count() to avoid handle deref |
474 // during graph optimization. | 450 // during graph optimization. |
475 int opt_count_; | 451 int opt_count_; |
476 | 452 |
477 // Number of parameters used for compilation of stubs that require arguments. | 453 // Number of parameters used for compilation of stubs that require arguments. |
478 int parameter_count_; | 454 int parameter_count_; |
479 | 455 |
480 Handle<Foreign> object_wrapper_; | |
481 | |
482 int optimization_id_; | 456 int optimization_id_; |
483 | 457 |
484 // This flag is used by the main thread to track whether this compilation | |
485 // should be abandoned due to dependency change. | |
486 bool aborted_due_to_dependency_change_; | |
487 | |
488 int osr_expr_stack_height_; | 458 int osr_expr_stack_height_; |
489 | 459 |
490 DISALLOW_COPY_AND_ASSIGN(CompilationInfo); | 460 DISALLOW_COPY_AND_ASSIGN(CompilationInfo); |
491 }; | 461 }; |
492 | 462 |
493 | 463 |
494 // A wrapper around a CompilationInfo that detaches the Handles from | 464 // A wrapper around a CompilationInfo that detaches the Handles from |
495 // the underlying DeferredHandleScope and stores them in info_ on | 465 // the underlying DeferredHandleScope and stores them in info_ on |
496 // destruction. | 466 // destruction. |
497 class CompilationHandleScope BASE_EMBEDDED { | 467 class CompilationHandleScope BASE_EMBEDDED { |
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
690 Zone zone_; | 660 Zone zone_; |
691 size_t info_zone_start_allocation_size_; | 661 size_t info_zone_start_allocation_size_; |
692 base::ElapsedTimer timer_; | 662 base::ElapsedTimer timer_; |
693 | 663 |
694 DISALLOW_COPY_AND_ASSIGN(CompilationPhase); | 664 DISALLOW_COPY_AND_ASSIGN(CompilationPhase); |
695 }; | 665 }; |
696 | 666 |
697 } } // namespace v8::internal | 667 } } // namespace v8::internal |
698 | 668 |
699 #endif // V8_COMPILER_H_ | 669 #endif // V8_COMPILER_H_ |
OLD | NEW |