| 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/compiler.h" | 5 #include "src/compiler.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "src/ast/ast-numbering.h" | 9 #include "src/ast/ast-numbering.h" |
| 10 #include "src/ast/prettyprinter.h" | 10 #include "src/ast/prettyprinter.h" |
| (...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 483 info()->scope(), info()->osr_ast_id(), info()->literal()) | 483 info()->scope(), info()->osr_ast_id(), info()->literal()) |
| 484 .Run(); | 484 .Run(); |
| 485 | 485 |
| 486 // Optimization could have been disabled by the parser. Note that this check | 486 // Optimization could have been disabled by the parser. Note that this check |
| 487 // is only needed because the Hydrogen graph builder is missing some bailouts. | 487 // is only needed because the Hydrogen graph builder is missing some bailouts. |
| 488 if (info()->shared_info()->optimization_disabled()) { | 488 if (info()->shared_info()->optimization_disabled()) { |
| 489 return AbortOptimization( | 489 return AbortOptimization( |
| 490 info()->shared_info()->disable_optimization_reason()); | 490 info()->shared_info()->disable_optimization_reason()); |
| 491 } | 491 } |
| 492 | 492 |
| 493 graph_builder_ = (info()->is_tracking_positions() || FLAG_trace_ic) | 493 HOptimizedGraphBuilder* graph_builder = |
| 494 ? new (info()->zone()) | 494 (info()->is_tracking_positions() || FLAG_trace_ic) |
| 495 HOptimizedGraphBuilderWithPositions(info()) | 495 ? new (info()->zone()) HOptimizedGraphBuilderWithPositions(info()) |
| 496 : new (info()->zone()) HOptimizedGraphBuilder(info()); | 496 : new (info()->zone()) HOptimizedGraphBuilder(info()); |
| 497 | 497 |
| 498 Timer t(this, &time_taken_to_create_graph_); | 498 Timer t(this, &time_taken_to_create_graph_); |
| 499 graph_ = graph_builder_->CreateGraph(); | 499 graph_ = graph_builder->CreateGraph(); |
| 500 | 500 |
| 501 if (isolate()->has_pending_exception()) { | 501 if (isolate()->has_pending_exception()) { |
| 502 return SetLastStatus(FAILED); | 502 return SetLastStatus(FAILED); |
| 503 } | 503 } |
| 504 | 504 |
| 505 if (graph_ == NULL) return SetLastStatus(BAILED_OUT); | 505 if (graph_ == NULL) return SetLastStatus(BAILED_OUT); |
| 506 | 506 |
| 507 if (info()->dependencies()->HasAborted()) { | 507 if (info()->dependencies()->HasAborted()) { |
| 508 // Dependency has changed during graph creation. Let's try again later. | 508 // Dependency has changed during graph creation. Let's try again later. |
| 509 return RetryOptimization(kBailedOutDueToDependencyChange); | 509 return RetryOptimization(kBailedOutDueToDependencyChange); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 526 } | 526 } |
| 527 | 527 |
| 528 Timer t(this, &time_taken_to_optimize_); | 528 Timer t(this, &time_taken_to_optimize_); |
| 529 DCHECK(graph_ != NULL); | 529 DCHECK(graph_ != NULL); |
| 530 BailoutReason bailout_reason = kNoReason; | 530 BailoutReason bailout_reason = kNoReason; |
| 531 | 531 |
| 532 if (graph_->Optimize(&bailout_reason)) { | 532 if (graph_->Optimize(&bailout_reason)) { |
| 533 chunk_ = LChunk::NewChunk(graph_); | 533 chunk_ = LChunk::NewChunk(graph_); |
| 534 if (chunk_ != NULL) return SetLastStatus(SUCCEEDED); | 534 if (chunk_ != NULL) return SetLastStatus(SUCCEEDED); |
| 535 } else if (bailout_reason != kNoReason) { | 535 } else if (bailout_reason != kNoReason) { |
| 536 graph_builder_->Bailout(bailout_reason); | 536 info_->AbortOptimization(bailout_reason); |
| 537 } | 537 } |
| 538 | 538 |
| 539 return SetLastStatus(BAILED_OUT); | 539 return SetLastStatus(BAILED_OUT); |
| 540 } | 540 } |
| 541 | 541 |
| 542 | 542 |
| 543 namespace { | 543 namespace { |
| 544 | 544 |
| 545 void AddWeakObjectToCodeDependency(Isolate* isolate, Handle<HeapObject> object, | 545 void AddWeakObjectToCodeDependency(Isolate* isolate, Handle<HeapObject> object, |
| 546 Handle<Code> code) { | 546 Handle<Code> code) { |
| (...skipping 1341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1888 } | 1888 } |
| 1889 | 1889 |
| 1890 #if DEBUG | 1890 #if DEBUG |
| 1891 void CompilationInfo::PrintAstForTesting() { | 1891 void CompilationInfo::PrintAstForTesting() { |
| 1892 PrintF("--- Source from AST ---\n%s\n", | 1892 PrintF("--- Source from AST ---\n%s\n", |
| 1893 PrettyPrinter(isolate()).PrintProgram(literal())); | 1893 PrettyPrinter(isolate()).PrintProgram(literal())); |
| 1894 } | 1894 } |
| 1895 #endif | 1895 #endif |
| 1896 } // namespace internal | 1896 } // namespace internal |
| 1897 } // namespace v8 | 1897 } // namespace v8 |
| OLD | NEW |