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

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

Issue 1760253003: [crankshaft] Support ES6 tail call elimination. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@tco-crank-2
Patch Set: Addressing comments 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
« no previous file with comments | « src/crankshaft/hydrogen.cc ('k') | src/crankshaft/ia32/lithium-codegen-ia32.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_INSTRUCTIONS_H_ 5 #ifndef V8_CRANKSHAFT_HYDROGEN_INSTRUCTIONS_H_
6 #define V8_CRANKSHAFT_HYDROGEN_INSTRUCTIONS_H_ 6 #define V8_CRANKSHAFT_HYDROGEN_INSTRUCTIONS_H_
7 7
8 #include <cstring> 8 #include <cstring>
9 #include <iosfwd> 9 #include <iosfwd>
10 10
(...skipping 2289 matching lines...) Expand 10 before | Expand all | Expand 10 after
2300 2300
2301 CallInterfaceDescriptor descriptor_; 2301 CallInterfaceDescriptor descriptor_;
2302 ZoneList<HValue*> values_; 2302 ZoneList<HValue*> values_;
2303 int argument_count_; 2303 int argument_count_;
2304 CallMode call_mode_; 2304 CallMode call_mode_;
2305 }; 2305 };
2306 2306
2307 2307
2308 class HInvokeFunction final : public HBinaryCall { 2308 class HInvokeFunction final : public HBinaryCall {
2309 public: 2309 public:
2310 DECLARE_INSTRUCTION_WITH_CONTEXT_FACTORY_P2(HInvokeFunction, HValue*, int); 2310 DECLARE_INSTRUCTION_WITH_CONTEXT_FACTORY_P4(HInvokeFunction, HValue*,
2311 2311 Handle<JSFunction>, int,
2312 HInvokeFunction(HValue* context, 2312 TailCallMode);
2313 HValue* function,
2314 Handle<JSFunction> known_function,
2315 int argument_count)
2316 : HBinaryCall(context, function, argument_count),
2317 known_function_(known_function) {
2318 formal_parameter_count_ =
2319 known_function.is_null()
2320 ? 0
2321 : known_function->shared()->internal_formal_parameter_count();
2322 has_stack_check_ = !known_function.is_null() &&
2323 (known_function->code()->kind() == Code::FUNCTION ||
2324 known_function->code()->kind() == Code::OPTIMIZED_FUNCTION);
2325 }
2326
2327 static HInvokeFunction* New(Isolate* isolate, Zone* zone, HValue* context,
2328 HValue* function,
2329 Handle<JSFunction> known_function,
2330 int argument_count) {
2331 return new(zone) HInvokeFunction(context, function,
2332 known_function, argument_count);
2333 }
2334 2313
2335 HValue* context() { return first(); } 2314 HValue* context() { return first(); }
2336 HValue* function() { return second(); } 2315 HValue* function() { return second(); }
2337 Handle<JSFunction> known_function() { return known_function_; } 2316 Handle<JSFunction> known_function() { return known_function_; }
2338 int formal_parameter_count() const { return formal_parameter_count_; } 2317 int formal_parameter_count() const { return formal_parameter_count_; }
2339 2318
2340 bool HasStackCheck() final { return has_stack_check_; } 2319 bool HasStackCheck() final { return HasStackCheckField::decode(bit_field_); }
2320 TailCallMode tail_call_mode() const {
2321 return TailCallModeField::decode(bit_field_);
2322 }
2341 2323
2342 DECLARE_CONCRETE_INSTRUCTION(InvokeFunction) 2324 DECLARE_CONCRETE_INSTRUCTION(InvokeFunction)
2343 2325
2344 private: 2326 private:
2345 HInvokeFunction(HValue* context, HValue* function, int argument_count) 2327 void set_has_stack_check(bool has_stack_check) {
2328 bit_field_ = HasStackCheckField::update(bit_field_, has_stack_check);
2329 }
2330
2331 HInvokeFunction(HValue* context, HValue* function,
2332 Handle<JSFunction> known_function, int argument_count,
2333 TailCallMode tail_call_mode)
2346 : HBinaryCall(context, function, argument_count), 2334 : HBinaryCall(context, function, argument_count),
2347 has_stack_check_(false) { 2335 known_function_(known_function),
2336 bit_field_(TailCallModeField::encode(tail_call_mode)) {
2337 formal_parameter_count_ =
2338 known_function.is_null()
2339 ? 0
2340 : known_function->shared()->internal_formal_parameter_count();
2341 set_has_stack_check(
2342 !known_function.is_null() &&
2343 (known_function->code()->kind() == Code::FUNCTION ||
2344 known_function->code()->kind() == Code::OPTIMIZED_FUNCTION));
2348 } 2345 }
2349 2346
2350 Handle<JSFunction> known_function_; 2347 Handle<JSFunction> known_function_;
2351 int formal_parameter_count_; 2348 int formal_parameter_count_;
2352 bool has_stack_check_; 2349
2350 class HasStackCheckField : public BitField<bool, 0, 1> {};
2351 class TailCallModeField
2352 : public BitField<TailCallMode, HasStackCheckField::kNext, 1> {};
2353 uint32_t bit_field_;
2353 }; 2354 };
2354 2355
2355 2356
2356 class HCallNewArray final : public HBinaryCall { 2357 class HCallNewArray final : public HBinaryCall {
2357 public: 2358 public:
2358 DECLARE_INSTRUCTION_WITH_CONTEXT_FACTORY_P4(HCallNewArray, HValue*, int, 2359 DECLARE_INSTRUCTION_WITH_CONTEXT_FACTORY_P4(HCallNewArray, HValue*, int,
2359 ElementsKind, 2360 ElementsKind,
2360 Handle<AllocationSite>); 2361 Handle<AllocationSite>);
2361 2362
2362 HValue* context() { return first(); } 2363 HValue* context() { return first(); }
(...skipping 1415 matching lines...) Expand 10 before | Expand all | Expand 10 after
3778 SetOperandAt(1, function); 3779 SetOperandAt(1, function);
3779 SetFlag(kUseGVN); 3780 SetFlag(kUseGVN);
3780 } 3781 }
3781 3782
3782 bool known_function_; 3783 bool known_function_;
3783 }; 3784 };
3784 3785
3785 3786
3786 class HApplyArguments final : public HTemplateInstruction<4> { 3787 class HApplyArguments final : public HTemplateInstruction<4> {
3787 public: 3788 public:
3788 DECLARE_INSTRUCTION_FACTORY_P4(HApplyArguments, HValue*, HValue*, HValue*, 3789 DECLARE_INSTRUCTION_FACTORY_P5(HApplyArguments, HValue*, HValue*, HValue*,
3789 HValue*); 3790 HValue*, TailCallMode);
3790 3791
3791 Representation RequiredInputRepresentation(int index) override { 3792 Representation RequiredInputRepresentation(int index) override {
3792 // The length is untagged, all other inputs are tagged. 3793 // The length is untagged, all other inputs are tagged.
3793 return (index == 2) 3794 return (index == 2)
3794 ? Representation::Integer32() 3795 ? Representation::Integer32()
3795 : Representation::Tagged(); 3796 : Representation::Tagged();
3796 } 3797 }
3797 3798
3798 HValue* function() { return OperandAt(0); } 3799 HValue* function() { return OperandAt(0); }
3799 HValue* receiver() { return OperandAt(1); } 3800 HValue* receiver() { return OperandAt(1); }
3800 HValue* length() { return OperandAt(2); } 3801 HValue* length() { return OperandAt(2); }
3801 HValue* elements() { return OperandAt(3); } 3802 HValue* elements() { return OperandAt(3); }
3802 3803
3804 TailCallMode tail_call_mode() const {
3805 return TailCallModeField::decode(bit_field_);
3806 }
3807
3803 DECLARE_CONCRETE_INSTRUCTION(ApplyArguments) 3808 DECLARE_CONCRETE_INSTRUCTION(ApplyArguments)
3804 3809
3805 private: 3810 private:
3806 HApplyArguments(HValue* function, 3811 HApplyArguments(HValue* function, HValue* receiver, HValue* length,
3807 HValue* receiver, 3812 HValue* elements, TailCallMode tail_call_mode)
3808 HValue* length, 3813 : bit_field_(TailCallModeField::encode(tail_call_mode)) {
3809 HValue* elements) {
3810 set_representation(Representation::Tagged()); 3814 set_representation(Representation::Tagged());
3811 SetOperandAt(0, function); 3815 SetOperandAt(0, function);
3812 SetOperandAt(1, receiver); 3816 SetOperandAt(1, receiver);
3813 SetOperandAt(2, length); 3817 SetOperandAt(2, length);
3814 SetOperandAt(3, elements); 3818 SetOperandAt(3, elements);
3815 SetAllSideEffects(); 3819 SetAllSideEffects();
3816 } 3820 }
3821
3822 class TailCallModeField : public BitField<TailCallMode, 0, 1> {};
3823 uint32_t bit_field_;
3817 }; 3824 };
3818 3825
3819 3826
3820 class HArgumentsElements final : public HTemplateInstruction<0> { 3827 class HArgumentsElements final : public HTemplateInstruction<0> {
3821 public: 3828 public:
3822 DECLARE_INSTRUCTION_FACTORY_P1(HArgumentsElements, bool); 3829 DECLARE_INSTRUCTION_FACTORY_P1(HArgumentsElements, bool);
3823 3830
3824 DECLARE_CONCRETE_INSTRUCTION(ArgumentsElements) 3831 DECLARE_CONCRETE_INSTRUCTION(ArgumentsElements)
3825 3832
3826 Representation RequiredInputRepresentation(int index) override { 3833 Representation RequiredInputRepresentation(int index) override {
(...skipping 3761 matching lines...) Expand 10 before | Expand all | Expand 10 after
7588 7595
7589 7596
7590 7597
7591 #undef DECLARE_INSTRUCTION 7598 #undef DECLARE_INSTRUCTION
7592 #undef DECLARE_CONCRETE_INSTRUCTION 7599 #undef DECLARE_CONCRETE_INSTRUCTION
7593 7600
7594 } // namespace internal 7601 } // namespace internal
7595 } // namespace v8 7602 } // namespace v8
7596 7603
7597 #endif // V8_CRANKSHAFT_HYDROGEN_INSTRUCTIONS_H_ 7604 #endif // V8_CRANKSHAFT_HYDROGEN_INSTRUCTIONS_H_
OLDNEW
« no previous file with comments | « src/crankshaft/hydrogen.cc ('k') | src/crankshaft/ia32/lithium-codegen-ia32.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698