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/compiler/access-builder.h" | 5 #include "src/compiler/access-builder.h" |
6 #include "src/compiler/ast-graph-builder.h" | 6 #include "src/compiler/ast-graph-builder.h" |
7 #include "src/compiler/common-operator.h" | 7 #include "src/compiler/common-operator.h" |
8 #include "src/compiler/generic-node-inl.h" | 8 #include "src/compiler/generic-node-inl.h" |
9 #include "src/compiler/graph-inl.h" | 9 #include "src/compiler/graph-inl.h" |
10 #include "src/compiler/graph-visualizer.h" | 10 #include "src/compiler/graph-visualizer.h" |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 jsgraph_->graph()->VisitNodeInputsFromEnd(&visitor); | 50 jsgraph_->graph()->VisitNodeInputsFromEnd(&visitor); |
51 } | 51 } |
52 | 52 |
53 | 53 |
54 // TODO(sigurds) Find a home for this function and reuse it everywhere (esp. in | 54 // TODO(sigurds) Find a home for this function and reuse it everywhere (esp. in |
55 // test cases, where similar code is currently duplicated). | 55 // test cases, where similar code is currently duplicated). |
56 static void Parse(Handle<JSFunction> function, CompilationInfoWithZone* info) { | 56 static void Parse(Handle<JSFunction> function, CompilationInfoWithZone* info) { |
57 CHECK(Parser::Parse(info)); | 57 CHECK(Parser::Parse(info)); |
58 CHECK(Rewriter::Rewrite(info)); | 58 CHECK(Rewriter::Rewrite(info)); |
59 CHECK(Scope::Analyze(info)); | 59 CHECK(Scope::Analyze(info)); |
60 CHECK_NE(NULL, info->scope()); | 60 CHECK(Compiler::EnsureDeoptimizationSupport(info)); |
61 Handle<ScopeInfo> scope_info = ScopeInfo::Create(info->scope(), info->zone()); | |
62 info->shared_info()->set_scope_info(*scope_info); | |
63 } | 61 } |
64 | 62 |
65 | 63 |
66 // A facade on a JSFunction's graph to facilitate inlining. It assumes the | 64 // A facade on a JSFunction's graph to facilitate inlining. It assumes the |
67 // that the function graph has only one return statement, and provides | 65 // that the function graph has only one return statement, and provides |
68 // {UnifyReturn} to convert a function graph to that end. | 66 // {UnifyReturn} to convert a function graph to that end. |
69 class Inlinee { | 67 class Inlinee { |
70 public: | 68 public: |
71 Inlinee(Node* start, Node* end) : start_(start), end_(end) {} | 69 Inlinee(Node* start, Node* end) : start_(start), end_(end) {} |
72 | 70 |
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
386 function->shared()->DebugName()->ToCString(); | 384 function->shared()->DebugName()->ToCString(); |
387 PrintF("Not Inlining %s into %s because inlinee is native\n", name.get(), | 385 PrintF("Not Inlining %s into %s because inlinee is native\n", name.get(), |
388 info_->shared_info()->DebugName()->ToCString().get()); | 386 info_->shared_info()->DebugName()->ToCString().get()); |
389 } | 387 } |
390 return; | 388 return; |
391 } | 389 } |
392 | 390 |
393 CompilationInfoWithZone info(function); | 391 CompilationInfoWithZone info(function); |
394 Parse(function, &info); | 392 Parse(function, &info); |
395 | 393 |
396 if (!function->shared()->has_deoptimization_support()) { | |
397 // TODO(turbofan) In the future, unoptimized code with deopt support could | |
398 // be generated lazily once deopt is triggered. | |
399 info.EnableDeoptimizationSupport(); | |
400 if (!FullCodeGenerator::MakeCode(&info)) { | |
401 DCHECK(false); | |
402 return; | |
403 } | |
404 function->shared()->EnableDeoptimizationSupport(*info.code()); | |
405 function->shared()->set_feedback_vector(*info.feedback_vector()); | |
406 } | |
407 | |
408 if (info.scope()->arguments() != NULL) { | 394 if (info.scope()->arguments() != NULL) { |
409 // For now do not inline functions that use their arguments array. | 395 // For now do not inline functions that use their arguments array. |
410 SmartArrayPointer<char> name = function->shared()->DebugName()->ToCString(); | 396 SmartArrayPointer<char> name = function->shared()->DebugName()->ToCString(); |
411 if (FLAG_trace_turbo_inlining) { | 397 if (FLAG_trace_turbo_inlining) { |
412 PrintF( | 398 PrintF( |
413 "Not Inlining %s into %s because inlinee uses arguments " | 399 "Not Inlining %s into %s because inlinee uses arguments " |
414 "array\n", | 400 "array\n", |
415 name.get(), info_->shared_info()->DebugName()->ToCString().get()); | 401 name.get(), info_->shared_info()->DebugName()->ToCString().get()); |
416 } | 402 } |
417 return; | 403 return; |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
451 AddClosureToFrameState(node, function); | 437 AddClosureToFrameState(node, function); |
452 NodeProperties::ReplaceFrameStateInput(node, outer_frame_state); | 438 NodeProperties::ReplaceFrameStateInput(node, outer_frame_state); |
453 } | 439 } |
454 } | 440 } |
455 | 441 |
456 inlinee.InlineAtCall(jsgraph_, call_node); | 442 inlinee.InlineAtCall(jsgraph_, call_node); |
457 } | 443 } |
458 } | 444 } |
459 } | 445 } |
460 } // namespace v8::internal::compiler | 446 } // namespace v8::internal::compiler |
OLD | NEW |