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

Side by Side Diff: src/compiler.h

Issue 596783002: Refactor bailout reasons and disable optimization in more cases. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 2 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
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 #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/zone.h" 11 #include "src/zone.h"
11 12
12 namespace v8 { 13 namespace v8 {
13 namespace internal { 14 namespace internal {
14 15
15 class AstValueFactory; 16 class AstValueFactory;
16 class HydrogenCodeStub; 17 class HydrogenCodeStub;
17 18
18 // ParseRestriction is used to restrict the set of valid statements in a 19 // ParseRestriction is used to restrict the set of valid statements in a
19 // unit of compilation. Restriction violations cause a syntax error. 20 // unit of compilation. Restriction violations cause a syntax error.
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 kSavesCallerDoubles = 1 << 8, 76 kSavesCallerDoubles = 1 << 8,
76 kRequiresFrame = 1 << 9, 77 kRequiresFrame = 1 << 9,
77 kMustNotHaveEagerFrame = 1 << 10, 78 kMustNotHaveEagerFrame = 1 << 10,
78 kDeoptimizationSupport = 1 << 11, 79 kDeoptimizationSupport = 1 << 11,
79 kDebug = 1 << 12, 80 kDebug = 1 << 12,
80 kCompilingForDebugging = 1 << 13, 81 kCompilingForDebugging = 1 << 13,
81 kParseRestriction = 1 << 14, 82 kParseRestriction = 1 << 14,
82 kSerializing = 1 << 15, 83 kSerializing = 1 << 15,
83 kContextSpecializing = 1 << 16, 84 kContextSpecializing = 1 << 16,
84 kInliningEnabled = 1 << 17, 85 kInliningEnabled = 1 << 17,
85 kTypingEnabled = 1 << 18 86 kTypingEnabled = 1 << 18,
87 kDisableFutureOptimization = 1 << 19,
88 kAbortedDueToDependency = 1 << 20
86 }; 89 };
87 90
88 CompilationInfo(Handle<JSFunction> closure, Zone* zone); 91 CompilationInfo(Handle<JSFunction> closure, Zone* zone);
89 CompilationInfo(Isolate* isolate, Zone* zone); 92 CompilationInfo(Isolate* isolate, Zone* zone);
90 virtual ~CompilationInfo(); 93 virtual ~CompilationInfo();
91 94
92 Isolate* isolate() const { 95 Isolate* isolate() const {
93 return isolate_; 96 return isolate_;
94 } 97 }
95 Zone* zone() { return zone_; } 98 Zone* zone() { return zone_; }
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
312 void RollbackDependencies(); 315 void RollbackDependencies();
313 316
314 void SaveHandles() { 317 void SaveHandles() {
315 SaveHandle(&closure_); 318 SaveHandle(&closure_);
316 SaveHandle(&shared_info_); 319 SaveHandle(&shared_info_);
317 SaveHandle(&context_); 320 SaveHandle(&context_);
318 SaveHandle(&script_); 321 SaveHandle(&script_);
319 SaveHandle(&unoptimized_code_); 322 SaveHandle(&unoptimized_code_);
320 } 323 }
321 324
325 void AbortOptimization(BailoutReason reason) {
326 DCHECK_EQ(OPTIMIZE, mode_);
327 if (bailout_reason_ != kNoReason) bailout_reason_ = reason;
328 SetFlag(kDisableFutureOptimization);
329 }
330
331 void RetryOptimization(BailoutReason reason) {
332 DCHECK_EQ(OPTIMIZE, mode_);
333 if (bailout_reason_ != kNoReason) bailout_reason_ = reason;
334 }
335
322 BailoutReason bailout_reason() const { return bailout_reason_; } 336 BailoutReason bailout_reason() const { return bailout_reason_; }
323 void set_bailout_reason(BailoutReason reason) { bailout_reason_ = reason; }
324 337
325 int prologue_offset() const { 338 int prologue_offset() const {
326 DCHECK_NE(Code::kPrologueOffsetNotSet, prologue_offset_); 339 DCHECK_NE(Code::kPrologueOffsetNotSet, prologue_offset_);
327 return prologue_offset_; 340 return prologue_offset_;
328 } 341 }
329 342
330 void set_prologue_offset(int prologue_offset) { 343 void set_prologue_offset(int prologue_offset) {
331 DCHECK_EQ(Code::kPrologueOffsetNotSet, prologue_offset_); 344 DCHECK_EQ(Code::kPrologueOffsetNotSet, prologue_offset_);
332 prologue_offset_ = prologue_offset; 345 prologue_offset_ = prologue_offset;
333 } 346 }
(...skipping 14 matching lines...) Expand all
348 Handle<Foreign> object_wrapper() { 361 Handle<Foreign> object_wrapper() {
349 if (object_wrapper_.is_null()) { 362 if (object_wrapper_.is_null()) {
350 object_wrapper_ = 363 object_wrapper_ =
351 isolate()->factory()->NewForeign(reinterpret_cast<Address>(this)); 364 isolate()->factory()->NewForeign(reinterpret_cast<Address>(this));
352 } 365 }
353 return object_wrapper_; 366 return object_wrapper_;
354 } 367 }
355 368
356 void AbortDueToDependencyChange() { 369 void AbortDueToDependencyChange() {
357 DCHECK(!OptimizingCompilerThread::IsOptimizerThread(isolate())); 370 DCHECK(!OptimizingCompilerThread::IsOptimizerThread(isolate()));
358 abort_due_to_dependency_ = true; 371 SetFlag(kAbortedDueToDependency);
359 } 372 }
360 373
361 bool HasAbortedDueToDependencyChange() { 374 bool HasAbortedDueToDependencyChange() const {
362 DCHECK(!OptimizingCompilerThread::IsOptimizerThread(isolate())); 375 DCHECK(!OptimizingCompilerThread::IsOptimizerThread(isolate()));
363 return abort_due_to_dependency_; 376 return GetFlag(kAbortedDueToDependency);
364 } 377 }
365 378
366 bool HasSameOsrEntry(Handle<JSFunction> function, BailoutId osr_ast_id) { 379 bool HasSameOsrEntry(Handle<JSFunction> function, BailoutId osr_ast_id) {
367 return osr_ast_id_ == osr_ast_id && function.is_identical_to(closure_); 380 return osr_ast_id_ == osr_ast_id && function.is_identical_to(closure_);
368 } 381 }
369 382
370 int optimization_id() const { return optimization_id_; } 383 int optimization_id() const { return optimization_id_; }
371 384
372 AstValueFactory* ast_value_factory() const { return ast_value_factory_; } 385 AstValueFactory* ast_value_factory() const { return ast_value_factory_; }
373 void SetAstValueFactory(AstValueFactory* ast_value_factory, 386 void SetAstValueFactory(AstValueFactory* ast_value_factory,
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
455 Handle<TypeFeedbackVector> feedback_vector_; 468 Handle<TypeFeedbackVector> feedback_vector_;
456 469
457 // Compilation mode flag and whether deoptimization is allowed. 470 // Compilation mode flag and whether deoptimization is allowed.
458 Mode mode_; 471 Mode mode_;
459 BailoutId osr_ast_id_; 472 BailoutId osr_ast_id_;
460 // The unoptimized code we patched for OSR may not be the shared code 473 // The unoptimized code we patched for OSR may not be the shared code
461 // afterwards, since we may need to compile it again to include deoptimization 474 // afterwards, since we may need to compile it again to include deoptimization
462 // data. Keep track which code we patched. 475 // data. Keep track which code we patched.
463 Handle<Code> unoptimized_code_; 476 Handle<Code> unoptimized_code_;
464 477
465 // Flag whether compilation needs to be aborted due to dependency change.
466 bool abort_due_to_dependency_;
467
468 // The zone from which the compilation pipeline working on this 478 // The zone from which the compilation pipeline working on this
469 // CompilationInfo allocates. 479 // CompilationInfo allocates.
470 Zone* zone_; 480 Zone* zone_;
471 481
472 DeferredHandles* deferred_handles_; 482 DeferredHandles* deferred_handles_;
473 483
474 ZoneList<Handle<HeapObject> >* dependencies_[DependentCode::kGroupCount]; 484 ZoneList<Handle<HeapObject> >* dependencies_[DependentCode::kGroupCount];
475 485
476 template<typename T> 486 template<typename T>
477 void SaveHandle(Handle<T> *object) { 487 void SaveHandle(Handle<T> *object) {
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
581 }; 591 };
582 592
583 MUST_USE_RESULT Status CreateGraph(); 593 MUST_USE_RESULT Status CreateGraph();
584 MUST_USE_RESULT Status OptimizeGraph(); 594 MUST_USE_RESULT Status OptimizeGraph();
585 MUST_USE_RESULT Status GenerateCode(); 595 MUST_USE_RESULT Status GenerateCode();
586 596
587 Status last_status() const { return last_status_; } 597 Status last_status() const { return last_status_; }
588 CompilationInfo* info() const { return info_; } 598 CompilationInfo* info() const { return info_; }
589 Isolate* isolate() const { return info()->isolate(); } 599 Isolate* isolate() const { return info()->isolate(); }
590 600
591 MUST_USE_RESULT Status AbortOptimization( 601 Status RetryOptimization(BailoutReason reason) {
592 BailoutReason reason = kNoReason) { 602 info_->RetryOptimization(reason);
593 if (reason != kNoReason) info_->set_bailout_reason(reason);
594 return SetLastStatus(BAILED_OUT); 603 return SetLastStatus(BAILED_OUT);
595 } 604 }
596 605
597 MUST_USE_RESULT Status AbortAndDisableOptimization( 606 Status AbortOptimization(BailoutReason reason) {
598 BailoutReason reason = kNoReason) { 607 info_->AbortOptimization(reason);
599 if (reason != kNoReason) info_->set_bailout_reason(reason);
600 // Reference to shared function info does not change between phases.
601 AllowDeferredHandleDereference allow_handle_dereference;
602 info_->shared_info()->DisableOptimization(info_->bailout_reason());
603 return SetLastStatus(BAILED_OUT); 608 return SetLastStatus(BAILED_OUT);
604 } 609 }
605 610
606 void WaitForInstall() { 611 void WaitForInstall() {
607 DCHECK(info_->is_osr()); 612 DCHECK(info_->is_osr());
608 awaiting_install_ = true; 613 awaiting_install_ = true;
609 } 614 }
610 615
611 bool IsWaitingForInstall() { return awaiting_install_; } 616 bool IsWaitingForInstall() { return awaiting_install_; }
612 617
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
737 Zone zone_; 742 Zone zone_;
738 unsigned info_zone_start_allocation_size_; 743 unsigned info_zone_start_allocation_size_;
739 base::ElapsedTimer timer_; 744 base::ElapsedTimer timer_;
740 745
741 DISALLOW_COPY_AND_ASSIGN(CompilationPhase); 746 DISALLOW_COPY_AND_ASSIGN(CompilationPhase);
742 }; 747 };
743 748
744 } } // namespace v8::internal 749 } } // namespace v8::internal
745 750
746 #endif // V8_COMPILER_H_ 751 #endif // V8_COMPILER_H_
OLDNEW
« no previous file with comments | « src/code-stubs-hydrogen.cc ('k') | src/compiler.cc » ('j') | src/lithium.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698