OLD | NEW |
---|---|
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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/ast.h" | 5 #include "src/ast.h" |
6 #include "src/ast-numbering.h" | 6 #include "src/ast-numbering.h" |
7 #include "src/compiler/access-builder.h" | 7 #include "src/compiler/access-builder.h" |
8 #include "src/compiler/ast-graph-builder.h" | 8 #include "src/compiler/ast-graph-builder.h" |
9 #include "src/compiler/common-operator.h" | 9 #include "src/compiler/common-operator.h" |
10 #include "src/compiler/generic-node-inl.h" | 10 #include "src/compiler/generic-node-inl.h" |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
52 JSInliner* inliner_; | 52 JSInliner* inliner_; |
53 }; | 53 }; |
54 | 54 |
55 | 55 |
56 void JSInliner::Inline() { | 56 void JSInliner::Inline() { |
57 InlinerVisitor visitor(this); | 57 InlinerVisitor visitor(this); |
58 jsgraph_->graph()->VisitNodeInputsFromEnd(&visitor); | 58 jsgraph_->graph()->VisitNodeInputsFromEnd(&visitor); |
59 } | 59 } |
60 | 60 |
61 | 61 |
62 // TODO(sigurds) Find a home for this function and reuse it everywhere (esp. in | |
63 // test cases, where similar code is currently duplicated). | |
64 static void Parse(Handle<JSFunction> function, CompilationInfoWithZone* info) { | |
65 CHECK(Parser::Parse(info)); | |
66 CHECK(Rewriter::Rewrite(info)); | |
67 CHECK(Scope::Analyze(info)); | |
68 CHECK(AstNumbering::Renumber(info->function(), info->zone())); | |
69 CHECK(Compiler::EnsureDeoptimizationSupport(info)); | |
70 } | |
71 | |
72 | |
73 // A facade on a JSFunction's graph to facilitate inlining. It assumes the | 62 // A facade on a JSFunction's graph to facilitate inlining. It assumes the |
74 // that the function graph has only one return statement, and provides | 63 // that the function graph has only one return statement, and provides |
75 // {UnifyReturn} to convert a function graph to that end. | 64 // {UnifyReturn} to convert a function graph to that end. |
76 class Inlinee { | 65 class Inlinee { |
77 public: | 66 public: |
78 Inlinee(Node* start, Node* end) : start_(start), end_(end) {} | 67 Inlinee(Node* start, Node* end) : start_(start), end_(end) {} |
79 | 68 |
80 // Returns the last regular control node, that is | 69 // Returns the last regular control node, that is |
81 // the last control node before the end node. | 70 // the last control node before the end node. |
82 Node* end_block() { return NodeProperties::GetControlInput(unique_return()); } | 71 Node* end_block() { return NodeProperties::GetControlInput(unique_return()); } |
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
378 if (FLAG_trace_turbo_inlining) { | 367 if (FLAG_trace_turbo_inlining) { |
379 SmartArrayPointer<char> name = | 368 SmartArrayPointer<char> name = |
380 function->shared()->DebugName()->ToCString(); | 369 function->shared()->DebugName()->ToCString(); |
381 PrintF("Not Inlining %s into %s because inlinee is native\n", name.get(), | 370 PrintF("Not Inlining %s into %s because inlinee is native\n", name.get(), |
382 info_->shared_info()->DebugName()->ToCString().get()); | 371 info_->shared_info()->DebugName()->ToCString().get()); |
383 } | 372 } |
384 return; | 373 return; |
385 } | 374 } |
386 | 375 |
387 CompilationInfoWithZone info(function); | 376 CompilationInfoWithZone info(function); |
388 Parse(function, &info); | 377 // TODO(wingo): ParseAndAnalyze can fail due to stack overflow. |
wingo
2014/10/28 08:31:02
Here I added this TODO. Should we just return if
| |
378 CHECK(Compiler::ParseAndAnalyze(&info)); | |
379 CHECK(Compiler::EnsureDeoptimizationSupport(&info)); | |
389 | 380 |
390 if (info.scope()->arguments() != NULL && info.strict_mode() != STRICT) { | 381 if (info.scope()->arguments() != NULL && info.strict_mode() != STRICT) { |
391 // For now do not inline functions that use their arguments array. | 382 // For now do not inline functions that use their arguments array. |
392 SmartArrayPointer<char> name = function->shared()->DebugName()->ToCString(); | 383 SmartArrayPointer<char> name = function->shared()->DebugName()->ToCString(); |
393 if (FLAG_trace_turbo_inlining) { | 384 if (FLAG_trace_turbo_inlining) { |
394 PrintF( | 385 PrintF( |
395 "Not Inlining %s into %s because inlinee uses arguments " | 386 "Not Inlining %s into %s because inlinee uses arguments " |
396 "array\n", | 387 "array\n", |
397 name.get(), info_->shared_info()->DebugName()->ToCString().get()); | 388 name.get(), info_->shared_info()->DebugName()->ToCString().get()); |
398 } | 389 } |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
498 info_->shared_info()->DebugName()->ToCString().get()); | 489 info_->shared_info()->DebugName()->ToCString().get()); |
499 } | 490 } |
500 NodeProperties::ReplaceWithValue(call_node, r.first, r.second); | 491 NodeProperties::ReplaceWithValue(call_node, r.first, r.second); |
501 call_node->RemoveAllInputs(); | 492 call_node->RemoveAllInputs(); |
502 DCHECK_EQ(0, call_node->UseCount()); | 493 DCHECK_EQ(0, call_node->UseCount()); |
503 } | 494 } |
504 } | 495 } |
505 } | 496 } |
506 } | 497 } |
507 } // namespace v8::internal::compiler | 498 } // namespace v8::internal::compiler |
OLD | NEW |