| 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_CODE_STUBS_H_ | 5 #ifndef V8_CODE_STUBS_H_ |
| 6 #define V8_CODE_STUBS_H_ | 6 #define V8_CODE_STUBS_H_ |
| 7 | 7 |
| 8 #include "src/allocation.h" | 8 #include "src/allocation.h" |
| 9 #include "src/assembler.h" | 9 #include "src/assembler.h" |
| 10 #include "src/codegen.h" | 10 #include "src/codegen.h" |
| 11 #include "src/globals.h" | 11 #include "src/globals.h" |
| 12 #include "src/macro-assembler.h" | 12 #include "src/macro-assembler.h" |
| 13 #include "src/ostreams.h" |
| 13 | 14 |
| 14 namespace v8 { | 15 namespace v8 { |
| 15 namespace internal { | 16 namespace internal { |
| 16 | 17 |
| 17 // List of code stubs used on all platforms. | 18 // List of code stubs used on all platforms. |
| 18 #define CODE_STUB_LIST_ALL_PLATFORMS(V) \ | 19 #define CODE_STUB_LIST_ALL_PLATFORMS(V) \ |
| 19 V(CallFunction) \ | 20 V(CallFunction) \ |
| 20 V(CallConstruct) \ | 21 V(CallConstruct) \ |
| 21 V(BinaryOpIC) \ | 22 V(BinaryOpIC) \ |
| 22 V(BinaryOpICWithAllocationSite) \ | 23 V(BinaryOpICWithAllocationSite) \ |
| (...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 341 PlatformInterfaceDescriptor* platform_specific_descriptor_; | 342 PlatformInterfaceDescriptor* platform_specific_descriptor_; |
| 342 | 343 |
| 343 DISALLOW_COPY_AND_ASSIGN(InterfaceDescriptor); | 344 DISALLOW_COPY_AND_ASSIGN(InterfaceDescriptor); |
| 344 }; | 345 }; |
| 345 | 346 |
| 346 | 347 |
| 347 class CodeStubInterfaceDescriptor: public InterfaceDescriptor { | 348 class CodeStubInterfaceDescriptor: public InterfaceDescriptor { |
| 348 public: | 349 public: |
| 349 CodeStubInterfaceDescriptor(); | 350 CodeStubInterfaceDescriptor(); |
| 350 | 351 |
| 351 void Initialize(int register_parameter_count, Register* registers, | 352 void Initialize(CodeStub::Major major, int register_parameter_count, |
| 353 Register* registers, Address deoptimization_handler = NULL, |
| 354 Representation* register_param_representations = NULL, |
| 355 int hint_stack_parameter_count = -1, |
| 356 StubFunctionMode function_mode = NOT_JS_FUNCTION_STUB_MODE); |
| 357 void Initialize(CodeStub::Major major, int register_parameter_count, |
| 358 Register* registers, Register stack_parameter_count, |
| 352 Address deoptimization_handler = NULL, | 359 Address deoptimization_handler = NULL, |
| 353 Representation* register_param_representations = NULL, | 360 Representation* register_param_representations = NULL, |
| 354 int hint_stack_parameter_count = -1, | 361 int hint_stack_parameter_count = -1, |
| 355 StubFunctionMode function_mode = NOT_JS_FUNCTION_STUB_MODE); | |
| 356 void Initialize(int register_parameter_count, Register* registers, | |
| 357 Register stack_parameter_count, | |
| 358 Address deoptimization_handler = NULL, | |
| 359 Representation* register_param_representations = NULL, | |
| 360 int hint_stack_parameter_count = -1, | |
| 361 StubFunctionMode function_mode = NOT_JS_FUNCTION_STUB_MODE, | 362 StubFunctionMode function_mode = NOT_JS_FUNCTION_STUB_MODE, |
| 362 HandlerArgumentsMode handler_mode = DONT_PASS_ARGUMENTS); | 363 HandlerArgumentsMode handler_mode = DONT_PASS_ARGUMENTS); |
| 363 | 364 |
| 364 void SetMissHandler(ExternalReference handler) { | 365 void SetMissHandler(ExternalReference handler) { |
| 365 miss_handler_ = handler; | 366 miss_handler_ = handler; |
| 366 has_miss_handler_ = true; | 367 has_miss_handler_ = true; |
| 367 // Our miss handler infrastructure doesn't currently support | 368 // Our miss handler infrastructure doesn't currently support |
| 368 // variable stack parameter counts. | 369 // variable stack parameter counts. |
| 369 ASSERT(!stack_parameter_count_.is_valid()); | 370 ASSERT(!stack_parameter_count_.is_valid()); |
| 370 } | 371 } |
| (...skipping 16 matching lines...) Expand all Loading... |
| 387 if (handler_arguments_mode_ == PASS_ARGUMENTS) { | 388 if (handler_arguments_mode_ == PASS_ARGUMENTS) { |
| 388 params += 1; | 389 params += 1; |
| 389 } | 390 } |
| 390 return params; | 391 return params; |
| 391 } | 392 } |
| 392 | 393 |
| 393 int hint_stack_parameter_count() const { return hint_stack_parameter_count_; } | 394 int hint_stack_parameter_count() const { return hint_stack_parameter_count_; } |
| 394 Register stack_parameter_count() const { return stack_parameter_count_; } | 395 Register stack_parameter_count() const { return stack_parameter_count_; } |
| 395 StubFunctionMode function_mode() const { return function_mode_; } | 396 StubFunctionMode function_mode() const { return function_mode_; } |
| 396 Address deoptimization_handler() const { return deoptimization_handler_; } | 397 Address deoptimization_handler() const { return deoptimization_handler_; } |
| 398 CodeStub::Major MajorKey() const { return major_; } |
| 397 | 399 |
| 398 private: | 400 private: |
| 399 Register stack_parameter_count_; | 401 Register stack_parameter_count_; |
| 400 // If hint_stack_parameter_count_ > 0, the code stub can optimize the | 402 // If hint_stack_parameter_count_ > 0, the code stub can optimize the |
| 401 // return sequence. Default value is -1, which means it is ignored. | 403 // return sequence. Default value is -1, which means it is ignored. |
| 402 int hint_stack_parameter_count_; | 404 int hint_stack_parameter_count_; |
| 403 StubFunctionMode function_mode_; | 405 StubFunctionMode function_mode_; |
| 404 | 406 |
| 405 Address deoptimization_handler_; | 407 Address deoptimization_handler_; |
| 406 HandlerArgumentsMode handler_arguments_mode_; | 408 HandlerArgumentsMode handler_arguments_mode_; |
| 407 | 409 |
| 408 ExternalReference miss_handler_; | 410 ExternalReference miss_handler_; |
| 409 bool has_miss_handler_; | 411 bool has_miss_handler_; |
| 412 CodeStub::Major major_; |
| 410 }; | 413 }; |
| 411 | 414 |
| 412 | 415 |
| 413 class CallInterfaceDescriptor: public InterfaceDescriptor { | 416 class CallInterfaceDescriptor: public InterfaceDescriptor { |
| 414 public: | 417 public: |
| 415 CallInterfaceDescriptor() { } | 418 CallInterfaceDescriptor() { } |
| 416 | 419 |
| 417 // A copy of the passed in registers and param_representations is made | 420 // A copy of the passed in registers and param_representations is made |
| 418 // and owned by the CallInterfaceDescriptor. | 421 // and owned by the CallInterfaceDescriptor. |
| 419 | 422 |
| (...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 736 }; | 739 }; |
| 737 | 740 |
| 738 InstanceofStub(Isolate* isolate, Flags flags) | 741 InstanceofStub(Isolate* isolate, Flags flags) |
| 739 : PlatformCodeStub(isolate), flags_(flags) { } | 742 : PlatformCodeStub(isolate), flags_(flags) { } |
| 740 | 743 |
| 741 static Register left(); | 744 static Register left(); |
| 742 static Register right(); | 745 static Register right(); |
| 743 | 746 |
| 744 void Generate(MacroAssembler* masm); | 747 void Generate(MacroAssembler* masm); |
| 745 | 748 |
| 749 virtual void InitializeInterfaceDescriptor( |
| 750 Isolate* isolate, CodeStubInterfaceDescriptor* descriptor); |
| 751 |
| 746 private: | 752 private: |
| 747 Major MajorKey() const { return Instanceof; } | 753 Major MajorKey() const { return Instanceof; } |
| 748 int MinorKey() const { return static_cast<int>(flags_); } | 754 int MinorKey() const { return static_cast<int>(flags_); } |
| 749 | 755 |
| 750 bool HasArgsInRegisters() const { | 756 bool HasArgsInRegisters() const { |
| 751 return (flags_ & kArgsInRegisters) != 0; | 757 return (flags_ & kArgsInRegisters) != 0; |
| 752 } | 758 } |
| 753 | 759 |
| 754 bool HasCallSiteInlineCheck() const { | 760 bool HasCallSiteInlineCheck() const { |
| 755 return (flags_ & kCallSiteInlineCheck) != 0; | 761 return (flags_ & kCallSiteInlineCheck) != 0; |
| (...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1125 virtual void Generate(MacroAssembler* masm) V8_OVERRIDE; | 1131 virtual void Generate(MacroAssembler* masm) V8_OVERRIDE; |
| 1126 virtual Major MajorKey() const V8_OVERRIDE { return CallApiGetter; } | 1132 virtual Major MajorKey() const V8_OVERRIDE { return CallApiGetter; } |
| 1127 virtual int MinorKey() const V8_OVERRIDE { return 0; } | 1133 virtual int MinorKey() const V8_OVERRIDE { return 0; } |
| 1128 | 1134 |
| 1129 DISALLOW_COPY_AND_ASSIGN(CallApiGetterStub); | 1135 DISALLOW_COPY_AND_ASSIGN(CallApiGetterStub); |
| 1130 }; | 1136 }; |
| 1131 | 1137 |
| 1132 | 1138 |
| 1133 class BinaryOpICStub : public HydrogenCodeStub { | 1139 class BinaryOpICStub : public HydrogenCodeStub { |
| 1134 public: | 1140 public: |
| 1135 BinaryOpICStub(Isolate* isolate, Token::Value op, OverwriteMode mode) | 1141 BinaryOpICStub(Isolate* isolate, Token::Value op, |
| 1142 OverwriteMode mode = NO_OVERWRITE) |
| 1136 : HydrogenCodeStub(isolate, UNINITIALIZED), state_(isolate, op, mode) {} | 1143 : HydrogenCodeStub(isolate, UNINITIALIZED), state_(isolate, op, mode) {} |
| 1137 | 1144 |
| 1138 BinaryOpICStub(Isolate* isolate, const BinaryOpIC::State& state) | 1145 explicit BinaryOpICStub(Isolate* isolate, const BinaryOpIC::State& state) |
| 1139 : HydrogenCodeStub(isolate), state_(state) {} | 1146 : HydrogenCodeStub(isolate), state_(state) {} |
| 1140 | 1147 |
| 1141 static void GenerateAheadOfTime(Isolate* isolate); | 1148 static void GenerateAheadOfTime(Isolate* isolate); |
| 1142 | 1149 |
| 1143 virtual void InitializeInterfaceDescriptor( | 1150 virtual void InitializeInterfaceDescriptor( |
| 1144 CodeStubInterfaceDescriptor* descriptor) V8_OVERRIDE; | 1151 CodeStubInterfaceDescriptor* descriptor) V8_OVERRIDE; |
| 1145 | 1152 |
| 1146 static void InstallDescriptors(Isolate* isolate); | 1153 static void InstallDescriptors(Isolate* isolate); |
| 1147 | 1154 |
| 1148 virtual Code::Kind GetCodeKind() const V8_OVERRIDE { | 1155 virtual Code::Kind GetCodeKind() const V8_OVERRIDE { |
| (...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1611 public: | 1618 public: |
| 1612 CallFunctionStub(Isolate* isolate, int argc, CallFunctionFlags flags) | 1619 CallFunctionStub(Isolate* isolate, int argc, CallFunctionFlags flags) |
| 1613 : PlatformCodeStub(isolate), argc_(argc), flags_(flags) { } | 1620 : PlatformCodeStub(isolate), argc_(argc), flags_(flags) { } |
| 1614 | 1621 |
| 1615 void Generate(MacroAssembler* masm); | 1622 void Generate(MacroAssembler* masm); |
| 1616 | 1623 |
| 1617 static int ExtractArgcFromMinorKey(int minor_key) { | 1624 static int ExtractArgcFromMinorKey(int minor_key) { |
| 1618 return ArgcBits::decode(minor_key); | 1625 return ArgcBits::decode(minor_key); |
| 1619 } | 1626 } |
| 1620 | 1627 |
| 1628 virtual void InitializeInterfaceDescriptor( |
| 1629 Isolate* isolate, CodeStubInterfaceDescriptor* descriptor); |
| 1630 |
| 1621 private: | 1631 private: |
| 1622 int argc_; | 1632 int argc_; |
| 1623 CallFunctionFlags flags_; | 1633 CallFunctionFlags flags_; |
| 1624 | 1634 |
| 1625 virtual void PrintName(OStream& os) const V8_OVERRIDE; // NOLINT | 1635 virtual void PrintName(OStream& os) const V8_OVERRIDE; // NOLINT |
| 1626 | 1636 |
| 1627 // Minor key encoding in 32 bits with Bitfield <Type, shift, size>. | 1637 // Minor key encoding in 32 bits with Bitfield <Type, shift, size>. |
| 1628 class FlagBits: public BitField<CallFunctionFlags, 0, 2> {}; | 1638 class FlagBits: public BitField<CallFunctionFlags, 0, 2> {}; |
| 1629 class ArgcBits: public BitField<unsigned, 2, 32 - 2> {}; | 1639 class ArgcBits: public BitField<unsigned, 2, 32 - 2> {}; |
| 1630 | 1640 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 1648 public: | 1658 public: |
| 1649 CallConstructStub(Isolate* isolate, CallConstructorFlags flags) | 1659 CallConstructStub(Isolate* isolate, CallConstructorFlags flags) |
| 1650 : PlatformCodeStub(isolate), flags_(flags) {} | 1660 : PlatformCodeStub(isolate), flags_(flags) {} |
| 1651 | 1661 |
| 1652 void Generate(MacroAssembler* masm); | 1662 void Generate(MacroAssembler* masm); |
| 1653 | 1663 |
| 1654 virtual void FinishCode(Handle<Code> code) { | 1664 virtual void FinishCode(Handle<Code> code) { |
| 1655 code->set_has_function_cache(RecordCallTarget()); | 1665 code->set_has_function_cache(RecordCallTarget()); |
| 1656 } | 1666 } |
| 1657 | 1667 |
| 1668 virtual void InitializeInterfaceDescriptor( |
| 1669 Isolate* isolate, CodeStubInterfaceDescriptor* descriptor); |
| 1670 |
| 1658 private: | 1671 private: |
| 1659 CallConstructorFlags flags_; | 1672 CallConstructorFlags flags_; |
| 1660 | 1673 |
| 1661 virtual void PrintName(OStream& os) const V8_OVERRIDE; // NOLINT | 1674 virtual void PrintName(OStream& os) const V8_OVERRIDE; // NOLINT |
| 1662 | 1675 |
| 1663 Major MajorKey() const { return CallConstruct; } | 1676 Major MajorKey() const { return CallConstruct; } |
| 1664 int MinorKey() const { return flags_; } | 1677 int MinorKey() const { return flags_; } |
| 1665 | 1678 |
| 1666 bool RecordCallTarget() const { | 1679 bool RecordCallTarget() const { |
| 1667 return (flags_ & RECORD_CONSTRUCTOR_TARGET) != 0; | 1680 return (flags_ & RECORD_CONSTRUCTOR_TARGET) != 0; |
| (...skipping 855 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2523 | 2536 |
| 2524 | 2537 |
| 2525 class CallDescriptors { | 2538 class CallDescriptors { |
| 2526 public: | 2539 public: |
| 2527 static void InitializeForIsolate(Isolate* isolate); | 2540 static void InitializeForIsolate(Isolate* isolate); |
| 2528 }; | 2541 }; |
| 2529 | 2542 |
| 2530 } } // namespace v8::internal | 2543 } } // namespace v8::internal |
| 2531 | 2544 |
| 2532 #endif // V8_CODE_STUBS_H_ | 2545 #endif // V8_CODE_STUBS_H_ |
| OLD | NEW |