| 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 #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 Loading... |
| 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 Loading... |
| 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 Loading... |
| 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 // Marks current environment as tail caller by setting frame type to |
| 686 // TAIL_CALLER_FUNCTION. |
| 687 void MarkAsTailCaller(); |
| 688 |
| 683 // True if index is included in the expression stack part of the environment. | 689 // True if index is included in the expression stack part of the environment. |
| 684 bool HasExpressionAt(int index) const; | 690 bool HasExpressionAt(int index) const; |
| 685 | 691 |
| 686 void Initialize(int parameter_count, int local_count, int stack_height); | 692 void Initialize(int parameter_count, int local_count, int stack_height); |
| 687 void Initialize(const HEnvironment* other); | 693 void Initialize(const HEnvironment* other); |
| 688 | 694 |
| 689 Handle<JSFunction> closure_; | 695 Handle<JSFunction> closure_; |
| 690 // Value array [parameters] [specials] [locals] [temporaries]. | 696 // Value array [parameters] [specials] [locals] [temporaries]. |
| 691 ZoneList<HValue*> values_; | 697 ZoneList<HValue*> values_; |
| 692 GrowableBitVector assigned_variables_; | 698 GrowableBitVector assigned_variables_; |
| (...skipping 578 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1271 P5 p5, P6 p6, P7 p7, P8 p8) { | 1277 P5 p5, P6 p6, P7 p7, P8 p8) { |
| 1272 return AddInstruction(NewUncasted<I>(p1, p2, p3, p4, p5, p6, p7, p8)); | 1278 return AddInstruction(NewUncasted<I>(p1, p2, p3, p4, p5, p6, p7, p8)); |
| 1273 } | 1279 } |
| 1274 | 1280 |
| 1275 template<class I, class P1, class P2, class P3, class P4, | 1281 template<class I, class P1, class P2, class P3, class P4, |
| 1276 class P5, class P6, class P7, class P8> | 1282 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) { | 1283 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)); | 1284 return AddInstructionTyped(New<I>(p1, p2, p3, p4, p5, p6, p7, p8)); |
| 1279 } | 1285 } |
| 1280 | 1286 |
| 1287 template <class I, class P1, class P2, class P3, class P4, class P5, class P6, |
| 1288 class P7, class P8, class P9> |
| 1289 I* New(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6, P7 p7, P8 p8, P9 p9) { |
| 1290 return I::New(isolate(), zone(), context(), p1, p2, p3, p4, p5, p6, p7, p8, |
| 1291 p9); |
| 1292 } |
| 1293 |
| 1294 template <class I, class P1, class P2, class P3, class P4, class P5, class P6, |
| 1295 class P7, class P8, class P9> |
| 1296 HInstruction* AddUncasted(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6, P7 p7, |
| 1297 P8 p8, P9 p9) { |
| 1298 return AddInstruction(NewUncasted<I>(p1, p2, p3, p4, p5, p6, p7, p8, p8)); |
| 1299 } |
| 1300 |
| 1301 template <class I, class P1, class P2, class P3, class P4, class P5, class P6, |
| 1302 class P7, class P8, class P9> |
| 1303 I* Add(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6, P7 p7, P8 p8, P9 p9) { |
| 1304 return AddInstructionTyped(New<I>(p1, p2, p3, p4, p5, p6, p7, p8, p9)); |
| 1305 } |
| 1306 |
| 1281 void AddSimulate(BailoutId id, RemovableSimulate removable = FIXED_SIMULATE); | 1307 void AddSimulate(BailoutId id, RemovableSimulate removable = FIXED_SIMULATE); |
| 1282 | 1308 |
| 1283 // When initializing arrays, we'll unfold the loop if the number of elements | 1309 // When initializing arrays, we'll unfold the loop if the number of elements |
| 1284 // is known at compile time and is <= kElementLoopUnrollThreshold. | 1310 // is known at compile time and is <= kElementLoopUnrollThreshold. |
| 1285 static const int kElementLoopUnrollThreshold = 8; | 1311 static const int kElementLoopUnrollThreshold = 8; |
| 1286 | 1312 |
| 1287 protected: | 1313 protected: |
| 1288 virtual bool BuildGraph() = 0; | 1314 virtual bool BuildGraph() = 0; |
| 1289 | 1315 |
| 1290 HBasicBlock* CreateBasicBlock(HEnvironment* env); | 1316 HBasicBlock* CreateBasicBlock(HEnvironment* env); |
| (...skipping 1767 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3058 } | 3084 } |
| 3059 | 3085 |
| 3060 private: | 3086 private: |
| 3061 HOptimizedGraphBuilder* builder_; | 3087 HOptimizedGraphBuilder* builder_; |
| 3062 }; | 3088 }; |
| 3063 | 3089 |
| 3064 } // namespace internal | 3090 } // namespace internal |
| 3065 } // namespace v8 | 3091 } // namespace v8 |
| 3066 | 3092 |
| 3067 #endif // V8_CRANKSHAFT_HYDROGEN_H_ | 3093 #endif // V8_CRANKSHAFT_HYDROGEN_H_ |
| OLD | NEW |