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