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

Side by Side Diff: src/crankshaft/hydrogen.h

Issue 1782743003: [crankshaft] Support inlining of function calls in tail position (in ES6 sense). (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@tco-crank-4
Patch Set: Other ports Created 4 years, 9 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
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_CRANKSHAFT_HYDROGEN_H_ 5 #ifndef V8_CRANKSHAFT_HYDROGEN_H_
6 #define V8_CRANKSHAFT_HYDROGEN_H_ 6 #define V8_CRANKSHAFT_HYDROGEN_H_
7 7
8 #include "src/accessors.h" 8 #include "src/accessors.h"
9 #include "src/allocation.h" 9 #include "src/allocation.h"
10 #include "src/ast/ast.h" 10 #include "src/ast/ast.h"
(...skipping 483 matching lines...) Expand 10 before | Expand all | Expand 10 after
494 Zone* HBasicBlock::zone() const { return graph_->zone(); } 494 Zone* HBasicBlock::zone() const { return graph_->zone(); }
495 495
496 496
497 // Type of stack frame an environment might refer to. 497 // Type of stack frame an environment might refer to.
498 enum FrameType { 498 enum FrameType {
499 JS_FUNCTION, 499 JS_FUNCTION,
500 JS_CONSTRUCT, 500 JS_CONSTRUCT,
501 JS_GETTER, 501 JS_GETTER,
502 JS_SETTER, 502 JS_SETTER,
503 ARGUMENTS_ADAPTOR, 503 ARGUMENTS_ADAPTOR,
504 TAIL_CALLER_FUNCTION,
504 STUB 505 STUB
505 }; 506 };
506 507
507
508 class HEnvironment final : public ZoneObject { 508 class HEnvironment final : public ZoneObject {
509 public: 509 public:
510 HEnvironment(HEnvironment* outer, 510 HEnvironment(HEnvironment* outer,
511 Scope* scope, 511 Scope* scope,
512 Handle<JSFunction> closure, 512 Handle<JSFunction> closure,
513 Zone* zone); 513 Zone* zone);
514 514
515 HEnvironment(Zone* zone, int parameter_count); 515 HEnvironment(Zone* zone, int parameter_count);
516 516
517 HEnvironment* arguments_environment() { 517 HEnvironment* arguments_environment() {
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
606 606
607 void Print() const; 607 void Print() const;
608 608
609 HEnvironment* Copy() const; 609 HEnvironment* Copy() const;
610 HEnvironment* CopyWithoutHistory() const; 610 HEnvironment* CopyWithoutHistory() const;
611 HEnvironment* CopyAsLoopHeader(HBasicBlock* block) const; 611 HEnvironment* CopyAsLoopHeader(HBasicBlock* block) const;
612 612
613 // Create an "inlined version" of this environment, where the original 613 // Create an "inlined version" of this environment, where the original
614 // environment is the outer environment but the top expression stack 614 // environment is the outer environment but the top expression stack
615 // elements are moved to an inner environment as parameters. 615 // elements are moved to an inner environment as parameters.
616 HEnvironment* CopyForInlining(Handle<JSFunction> target, 616 HEnvironment* CopyForInlining(Handle<JSFunction> target, int arguments,
617 int arguments, 617 FunctionLiteral* function, HConstant* undefined,
618 FunctionLiteral* function, 618 InliningKind inlining_kind,
619 HConstant* undefined, 619 TailCallMode syntactic_tail_call_mode) const;
620 InliningKind inlining_kind) const;
621 620
622 HEnvironment* DiscardInlined(bool drop_extra) { 621 HEnvironment* DiscardInlined(bool drop_extra) {
623 HEnvironment* outer = outer_; 622 HEnvironment* outer = outer_;
624 while (outer->frame_type() != JS_FUNCTION) outer = outer->outer_; 623 while (outer->frame_type() != JS_FUNCTION &&
624 outer->frame_type() != TAIL_CALLER_FUNCTION) {
625 outer = outer->outer_;
626 }
625 if (drop_extra) outer->Drop(1); 627 if (drop_extra) outer->Drop(1);
626 return outer; 628 return outer;
627 } 629 }
628 630
629 void AddIncomingEdge(HBasicBlock* block, HEnvironment* other); 631 void AddIncomingEdge(HBasicBlock* block, HEnvironment* other);
630 632
631 void ClearHistory() { 633 void ClearHistory() {
632 pop_count_ = 0; 634 pop_count_ = 0;
633 push_count_ = 0; 635 push_count_ = 0;
634 assigned_variables_.Clear(); 636 assigned_variables_.Clear();
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
673 int arguments, 675 int arguments,
674 Zone* zone); 676 Zone* zone);
675 677
676 // Create an artificial stub environment (e.g. for argument adaptor or 678 // Create an artificial stub environment (e.g. for argument adaptor or
677 // constructor stub). 679 // constructor stub).
678 HEnvironment* CreateStubEnvironment(HEnvironment* outer, 680 HEnvironment* CreateStubEnvironment(HEnvironment* outer,
679 Handle<JSFunction> target, 681 Handle<JSFunction> target,
680 FrameType frame_type, 682 FrameType frame_type,
681 int arguments) const; 683 int arguments) const;
682 684
685 void MarkAsTailCaller();
Michael Starzinger 2016/03/21 14:06:50 nit: Let's add a short comment explaining the sema
Igor Sheludko 2016/03/22 14:08:37 Done. It looks like we can't drop outer environmen
686
683 // True if index is included in the expression stack part of the environment. 687 // True if index is included in the expression stack part of the environment.
684 bool HasExpressionAt(int index) const; 688 bool HasExpressionAt(int index) const;
685 689
686 void Initialize(int parameter_count, int local_count, int stack_height); 690 void Initialize(int parameter_count, int local_count, int stack_height);
687 void Initialize(const HEnvironment* other); 691 void Initialize(const HEnvironment* other);
688 692
689 Handle<JSFunction> closure_; 693 Handle<JSFunction> closure_;
690 // Value array [parameters] [specials] [locals] [temporaries]. 694 // Value array [parameters] [specials] [locals] [temporaries].
691 ZoneList<HValue*> values_; 695 ZoneList<HValue*> values_;
692 GrowableBitVector assigned_variables_; 696 GrowableBitVector assigned_variables_;
(...skipping 578 matching lines...) Expand 10 before | Expand all | Expand 10 after
1271 P5 p5, P6 p6, P7 p7, P8 p8) { 1275 P5 p5, P6 p6, P7 p7, P8 p8) {
1272 return AddInstruction(NewUncasted<I>(p1, p2, p3, p4, p5, p6, p7, p8)); 1276 return AddInstruction(NewUncasted<I>(p1, p2, p3, p4, p5, p6, p7, p8));
1273 } 1277 }
1274 1278
1275 template<class I, class P1, class P2, class P3, class P4, 1279 template<class I, class P1, class P2, class P3, class P4,
1276 class P5, class P6, class P7, class P8> 1280 class P5, class P6, class P7, class P8>
1277 I* Add(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6, P7 p7, P8 p8) { 1281 I* Add(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6, P7 p7, P8 p8) {
1278 return AddInstructionTyped(New<I>(p1, p2, p3, p4, p5, p6, p7, p8)); 1282 return AddInstructionTyped(New<I>(p1, p2, p3, p4, p5, p6, p7, p8));
1279 } 1283 }
1280 1284
1285 template <class I, class P1, class P2, class P3, class P4, class P5, class P6,
1286 class P7, class P8, class P9>
1287 I* New(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6, P7 p7, P8 p8, P9 p9) {
1288 return I::New(isolate(), zone(), context(), p1, p2, p3, p4, p5, p6, p7, p8,
1289 p9);
1290 }
1291
1292 template <class I, class P1, class P2, class P3, class P4, class P5, class P6,
1293 class P7, class P8, class P9>
1294 HInstruction* AddUncasted(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6, P7 p7,
1295 P8 p8, P9 p9) {
1296 return AddInstruction(NewUncasted<I>(p1, p2, p3, p4, p5, p6, p7, p8, p8));
1297 }
1298
1299 template <class I, class P1, class P2, class P3, class P4, class P5, class P6,
1300 class P7, class P8, class P9>
1301 I* Add(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6, P7 p7, P8 p8, P9 p9) {
1302 return AddInstructionTyped(New<I>(p1, p2, p3, p4, p5, p6, p7, p8, p9));
1303 }
1304
1281 void AddSimulate(BailoutId id, RemovableSimulate removable = FIXED_SIMULATE); 1305 void AddSimulate(BailoutId id, RemovableSimulate removable = FIXED_SIMULATE);
1282 1306
1283 // When initializing arrays, we'll unfold the loop if the number of elements 1307 // When initializing arrays, we'll unfold the loop if the number of elements
1284 // is known at compile time and is <= kElementLoopUnrollThreshold. 1308 // is known at compile time and is <= kElementLoopUnrollThreshold.
1285 static const int kElementLoopUnrollThreshold = 8; 1309 static const int kElementLoopUnrollThreshold = 8;
1286 1310
1287 protected: 1311 protected:
1288 virtual bool BuildGraph() = 0; 1312 virtual bool BuildGraph() = 0;
1289 1313
1290 HBasicBlock* CreateBasicBlock(HEnvironment* env); 1314 HBasicBlock* CreateBasicBlock(HEnvironment* env);
(...skipping 1767 matching lines...) Expand 10 before | Expand all | Expand 10 after
3058 } 3082 }
3059 3083
3060 private: 3084 private:
3061 HOptimizedGraphBuilder* builder_; 3085 HOptimizedGraphBuilder* builder_;
3062 }; 3086 };
3063 3087
3064 } // namespace internal 3088 } // namespace internal
3065 } // namespace v8 3089 } // namespace v8
3066 3090
3067 #endif // V8_CRANKSHAFT_HYDROGEN_H_ 3091 #endif // V8_CRANKSHAFT_HYDROGEN_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698