| 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" |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 203 // Returns whether the code generated for this stub needs to be allocated as | 203 // Returns whether the code generated for this stub needs to be allocated as |
| 204 // a fixed (non-moveable) code object. | 204 // a fixed (non-moveable) code object. |
| 205 virtual bool NeedsImmovableCode() { return false; } | 205 virtual bool NeedsImmovableCode() { return false; } |
| 206 | 206 |
| 207 virtual void PrintName(OStream& os) const; // NOLINT | 207 virtual void PrintName(OStream& os) const; // NOLINT |
| 208 virtual void PrintBaseName(OStream& os) const; // NOLINT | 208 virtual void PrintBaseName(OStream& os) const; // NOLINT |
| 209 virtual void PrintState(OStream& os) const { ; } // NOLINT | 209 virtual void PrintState(OStream& os) const { ; } // NOLINT |
| 210 | 210 |
| 211 // Computes the key based on major and minor. | 211 // Computes the key based on major and minor. |
| 212 uint32_t GetKey() { | 212 uint32_t GetKey() { |
| 213 ASSERT(static_cast<int>(MajorKey()) < NUMBER_OF_IDS); | 213 DCHECK(static_cast<int>(MajorKey()) < NUMBER_OF_IDS); |
| 214 return MinorKeyBits::encode(MinorKey()) | MajorKeyBits::encode(MajorKey()); | 214 return MinorKeyBits::encode(MinorKey()) | MajorKeyBits::encode(MajorKey()); |
| 215 } | 215 } |
| 216 | 216 |
| 217 private: | 217 private: |
| 218 // Perform bookkeeping required after code generation when stub code is | 218 // Perform bookkeeping required after code generation when stub code is |
| 219 // initially generated. | 219 // initially generated. |
| 220 void RecordCodeGeneration(Handle<Code> code); | 220 void RecordCodeGeneration(Handle<Code> code); |
| 221 | 221 |
| 222 // Finish the code object after it has been generated. | 222 // Finish the code object after it has been generated. |
| 223 virtual void FinishCode(Handle<Code> code) { } | 223 virtual void FinishCode(Handle<Code> code) { } |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 281 | 281 |
| 282 int GetEnvironmentLength() const { return register_param_count_; } | 282 int GetEnvironmentLength() const { return register_param_count_; } |
| 283 | 283 |
| 284 int GetRegisterParameterCount() const { return register_param_count_; } | 284 int GetRegisterParameterCount() const { return register_param_count_; } |
| 285 | 285 |
| 286 Register GetParameterRegister(int index) const { | 286 Register GetParameterRegister(int index) const { |
| 287 return register_params_[index]; | 287 return register_params_[index]; |
| 288 } | 288 } |
| 289 | 289 |
| 290 Representation GetParameterRepresentation(int index) const { | 290 Representation GetParameterRepresentation(int index) const { |
| 291 ASSERT(index < register_param_count_); | 291 DCHECK(index < register_param_count_); |
| 292 if (register_param_representations_.get() == NULL) { | 292 if (register_param_representations_.get() == NULL) { |
| 293 return Representation::Tagged(); | 293 return Representation::Tagged(); |
| 294 } | 294 } |
| 295 | 295 |
| 296 return register_param_representations_[index]; | 296 return register_param_representations_[index]; |
| 297 } | 297 } |
| 298 | 298 |
| 299 // "Environment" versions of parameter functions. The first register | 299 // "Environment" versions of parameter functions. The first register |
| 300 // parameter (context) is not included. | 300 // parameter (context) is not included. |
| 301 int GetEnvironmentParameterCount() const { | 301 int GetEnvironmentParameterCount() const { |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 360 Representation* register_param_representations = NULL, | 360 Representation* register_param_representations = NULL, |
| 361 int hint_stack_parameter_count = -1, | 361 int hint_stack_parameter_count = -1, |
| 362 StubFunctionMode function_mode = NOT_JS_FUNCTION_STUB_MODE, | 362 StubFunctionMode function_mode = NOT_JS_FUNCTION_STUB_MODE, |
| 363 HandlerArgumentsMode handler_mode = DONT_PASS_ARGUMENTS); | 363 HandlerArgumentsMode handler_mode = DONT_PASS_ARGUMENTS); |
| 364 | 364 |
| 365 void SetMissHandler(ExternalReference handler) { | 365 void SetMissHandler(ExternalReference handler) { |
| 366 miss_handler_ = handler; | 366 miss_handler_ = handler; |
| 367 has_miss_handler_ = true; | 367 has_miss_handler_ = true; |
| 368 // Our miss handler infrastructure doesn't currently support | 368 // Our miss handler infrastructure doesn't currently support |
| 369 // variable stack parameter counts. | 369 // variable stack parameter counts. |
| 370 ASSERT(!stack_parameter_count_.is_valid()); | 370 DCHECK(!stack_parameter_count_.is_valid()); |
| 371 } | 371 } |
| 372 | 372 |
| 373 ExternalReference miss_handler() const { | 373 ExternalReference miss_handler() const { |
| 374 ASSERT(has_miss_handler_); | 374 DCHECK(has_miss_handler_); |
| 375 return miss_handler_; | 375 return miss_handler_; |
| 376 } | 376 } |
| 377 | 377 |
| 378 bool has_miss_handler() const { | 378 bool has_miss_handler() const { |
| 379 return has_miss_handler_; | 379 return has_miss_handler_; |
| 380 } | 380 } |
| 381 | 381 |
| 382 bool IsEnvironmentParameterCountRegister(int index) const { | 382 bool IsEnvironmentParameterCountRegister(int index) const { |
| 383 return GetEnvironmentParameterRegister(index).is(stack_parameter_count_); | 383 return GetEnvironmentParameterRegister(index).is(stack_parameter_count_); |
| 384 } | 384 } |
| (...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 621 bool is_generator_; | 621 bool is_generator_; |
| 622 }; | 622 }; |
| 623 | 623 |
| 624 | 624 |
| 625 class FastNewContextStub V8_FINAL : public HydrogenCodeStub { | 625 class FastNewContextStub V8_FINAL : public HydrogenCodeStub { |
| 626 public: | 626 public: |
| 627 static const int kMaximumSlots = 64; | 627 static const int kMaximumSlots = 64; |
| 628 | 628 |
| 629 FastNewContextStub(Isolate* isolate, int slots) | 629 FastNewContextStub(Isolate* isolate, int slots) |
| 630 : HydrogenCodeStub(isolate), slots_(slots) { | 630 : HydrogenCodeStub(isolate), slots_(slots) { |
| 631 ASSERT(slots_ > 0 && slots_ <= kMaximumSlots); | 631 DCHECK(slots_ > 0 && slots_ <= kMaximumSlots); |
| 632 } | 632 } |
| 633 | 633 |
| 634 virtual Handle<Code> GenerateCode() V8_OVERRIDE; | 634 virtual Handle<Code> GenerateCode() V8_OVERRIDE; |
| 635 | 635 |
| 636 virtual void InitializeInterfaceDescriptor( | 636 virtual void InitializeInterfaceDescriptor( |
| 637 CodeStubInterfaceDescriptor* descriptor) V8_OVERRIDE; | 637 CodeStubInterfaceDescriptor* descriptor) V8_OVERRIDE; |
| 638 | 638 |
| 639 static void InstallDescriptors(Isolate* isolate); | 639 static void InstallDescriptors(Isolate* isolate); |
| 640 | 640 |
| 641 int slots() const { return slots_; } | 641 int slots() const { return slots_; } |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 681 }; | 681 }; |
| 682 | 682 |
| 683 | 683 |
| 684 class FastCloneShallowObjectStub : public HydrogenCodeStub { | 684 class FastCloneShallowObjectStub : public HydrogenCodeStub { |
| 685 public: | 685 public: |
| 686 // Maximum number of properties in copied object. | 686 // Maximum number of properties in copied object. |
| 687 static const int kMaximumClonedProperties = 6; | 687 static const int kMaximumClonedProperties = 6; |
| 688 | 688 |
| 689 FastCloneShallowObjectStub(Isolate* isolate, int length) | 689 FastCloneShallowObjectStub(Isolate* isolate, int length) |
| 690 : HydrogenCodeStub(isolate), length_(length) { | 690 : HydrogenCodeStub(isolate), length_(length) { |
| 691 ASSERT_GE(length_, 0); | 691 DCHECK_GE(length_, 0); |
| 692 ASSERT_LE(length_, kMaximumClonedProperties); | 692 DCHECK_LE(length_, kMaximumClonedProperties); |
| 693 } | 693 } |
| 694 | 694 |
| 695 int length() const { return length_; } | 695 int length() const { return length_; } |
| 696 | 696 |
| 697 virtual Handle<Code> GenerateCode() V8_OVERRIDE; | 697 virtual Handle<Code> GenerateCode() V8_OVERRIDE; |
| 698 | 698 |
| 699 virtual void InitializeInterfaceDescriptor( | 699 virtual void InitializeInterfaceDescriptor( |
| 700 CodeStubInterfaceDescriptor* descriptor) V8_OVERRIDE; | 700 CodeStubInterfaceDescriptor* descriptor) V8_OVERRIDE; |
| 701 | 701 |
| 702 private: | 702 private: |
| (...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1098 class CallApiFunctionStub : public PlatformCodeStub { | 1098 class CallApiFunctionStub : public PlatformCodeStub { |
| 1099 public: | 1099 public: |
| 1100 CallApiFunctionStub(Isolate* isolate, | 1100 CallApiFunctionStub(Isolate* isolate, |
| 1101 bool is_store, | 1101 bool is_store, |
| 1102 bool call_data_undefined, | 1102 bool call_data_undefined, |
| 1103 int argc) : PlatformCodeStub(isolate) { | 1103 int argc) : PlatformCodeStub(isolate) { |
| 1104 bit_field_ = | 1104 bit_field_ = |
| 1105 IsStoreBits::encode(is_store) | | 1105 IsStoreBits::encode(is_store) | |
| 1106 CallDataUndefinedBits::encode(call_data_undefined) | | 1106 CallDataUndefinedBits::encode(call_data_undefined) | |
| 1107 ArgumentBits::encode(argc); | 1107 ArgumentBits::encode(argc); |
| 1108 ASSERT(!is_store || argc == 1); | 1108 DCHECK(!is_store || argc == 1); |
| 1109 } | 1109 } |
| 1110 | 1110 |
| 1111 private: | 1111 private: |
| 1112 virtual void Generate(MacroAssembler* masm) V8_OVERRIDE; | 1112 virtual void Generate(MacroAssembler* masm) V8_OVERRIDE; |
| 1113 virtual Major MajorKey() const V8_OVERRIDE { return CallApiFunction; } | 1113 virtual Major MajorKey() const V8_OVERRIDE { return CallApiFunction; } |
| 1114 virtual int MinorKey() const V8_OVERRIDE { return bit_field_; } | 1114 virtual int MinorKey() const V8_OVERRIDE { return bit_field_; } |
| 1115 | 1115 |
| 1116 class IsStoreBits: public BitField<bool, 0, 1> {}; | 1116 class IsStoreBits: public BitField<bool, 0, 1> {}; |
| 1117 class CallDataUndefinedBits: public BitField<bool, 1, 1> {}; | 1117 class CallDataUndefinedBits: public BitField<bool, 1, 1> {}; |
| 1118 class ArgumentBits: public BitField<int, 2, Code::kArgumentsBits> {}; | 1118 class ArgumentBits: public BitField<int, 2, Code::kArgumentsBits> {}; |
| (...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1328 ICCompareStub(Isolate* isolate, | 1328 ICCompareStub(Isolate* isolate, |
| 1329 Token::Value op, | 1329 Token::Value op, |
| 1330 CompareIC::State left, | 1330 CompareIC::State left, |
| 1331 CompareIC::State right, | 1331 CompareIC::State right, |
| 1332 CompareIC::State handler) | 1332 CompareIC::State handler) |
| 1333 : PlatformCodeStub(isolate), | 1333 : PlatformCodeStub(isolate), |
| 1334 op_(op), | 1334 op_(op), |
| 1335 left_(left), | 1335 left_(left), |
| 1336 right_(right), | 1336 right_(right), |
| 1337 state_(handler) { | 1337 state_(handler) { |
| 1338 ASSERT(Token::IsCompareOp(op)); | 1338 DCHECK(Token::IsCompareOp(op)); |
| 1339 } | 1339 } |
| 1340 | 1340 |
| 1341 virtual void Generate(MacroAssembler* masm); | 1341 virtual void Generate(MacroAssembler* masm); |
| 1342 | 1342 |
| 1343 void set_known_map(Handle<Map> map) { known_map_ = map; } | 1343 void set_known_map(Handle<Map> map) { known_map_ = map; } |
| 1344 | 1344 |
| 1345 static void DecodeKey(uint32_t stub_key, CompareIC::State* left_state, | 1345 static void DecodeKey(uint32_t stub_key, CompareIC::State* left_state, |
| 1346 CompareIC::State* right_state, | 1346 CompareIC::State* right_state, |
| 1347 CompareIC::State* handler_state, Token::Value* op); | 1347 CompareIC::State* handler_state, Token::Value* op); |
| 1348 | 1348 |
| (...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1611 | 1611 |
| 1612 private: | 1612 private: |
| 1613 DISALLOW_COPY_AND_ASSIGN(RegExpConstructResultStub); | 1613 DISALLOW_COPY_AND_ASSIGN(RegExpConstructResultStub); |
| 1614 }; | 1614 }; |
| 1615 | 1615 |
| 1616 | 1616 |
| 1617 class CallFunctionStub: public PlatformCodeStub { | 1617 class CallFunctionStub: public PlatformCodeStub { |
| 1618 public: | 1618 public: |
| 1619 CallFunctionStub(Isolate* isolate, int argc, CallFunctionFlags flags) | 1619 CallFunctionStub(Isolate* isolate, int argc, CallFunctionFlags flags) |
| 1620 : PlatformCodeStub(isolate), argc_(argc), flags_(flags) { | 1620 : PlatformCodeStub(isolate), argc_(argc), flags_(flags) { |
| 1621 ASSERT(argc <= Code::kMaxArguments); | 1621 DCHECK(argc <= Code::kMaxArguments); |
| 1622 } | 1622 } |
| 1623 | 1623 |
| 1624 void Generate(MacroAssembler* masm); | 1624 void Generate(MacroAssembler* masm); |
| 1625 | 1625 |
| 1626 static int ExtractArgcFromMinorKey(int minor_key) { | 1626 static int ExtractArgcFromMinorKey(int minor_key) { |
| 1627 return ArgcBits::decode(minor_key); | 1627 return ArgcBits::decode(minor_key); |
| 1628 } | 1628 } |
| 1629 | 1629 |
| 1630 virtual void InitializeInterfaceDescriptor( | 1630 virtual void InitializeInterfaceDescriptor( |
| 1631 CodeStubInterfaceDescriptor* descriptor); | 1631 CodeStubInterfaceDescriptor* descriptor); |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1716 Label* index_not_number, | 1716 Label* index_not_number, |
| 1717 Label* index_out_of_range, | 1717 Label* index_out_of_range, |
| 1718 StringIndexFlags index_flags) | 1718 StringIndexFlags index_flags) |
| 1719 : object_(object), | 1719 : object_(object), |
| 1720 index_(index), | 1720 index_(index), |
| 1721 result_(result), | 1721 result_(result), |
| 1722 receiver_not_string_(receiver_not_string), | 1722 receiver_not_string_(receiver_not_string), |
| 1723 index_not_number_(index_not_number), | 1723 index_not_number_(index_not_number), |
| 1724 index_out_of_range_(index_out_of_range), | 1724 index_out_of_range_(index_out_of_range), |
| 1725 index_flags_(index_flags) { | 1725 index_flags_(index_flags) { |
| 1726 ASSERT(!result_.is(object_)); | 1726 DCHECK(!result_.is(object_)); |
| 1727 ASSERT(!result_.is(index_)); | 1727 DCHECK(!result_.is(index_)); |
| 1728 } | 1728 } |
| 1729 | 1729 |
| 1730 // Generates the fast case code. On the fallthrough path |result| | 1730 // Generates the fast case code. On the fallthrough path |result| |
| 1731 // register contains the result. | 1731 // register contains the result. |
| 1732 void GenerateFast(MacroAssembler* masm); | 1732 void GenerateFast(MacroAssembler* masm); |
| 1733 | 1733 |
| 1734 // Generates the slow case code. Must not be naturally | 1734 // Generates the slow case code. Must not be naturally |
| 1735 // reachable. Expected to be put after a ret instruction (e.g., in | 1735 // reachable. Expected to be put after a ret instruction (e.g., in |
| 1736 // deferred code). Always jumps back to the fast case. | 1736 // deferred code). Always jumps back to the fast case. |
| 1737 void GenerateSlow(MacroAssembler* masm, | 1737 void GenerateSlow(MacroAssembler* masm, |
| (...skipping 26 matching lines...) Expand all Loading... |
| 1764 }; | 1764 }; |
| 1765 | 1765 |
| 1766 | 1766 |
| 1767 // Generates code for creating a one-char string from a char code. | 1767 // Generates code for creating a one-char string from a char code. |
| 1768 class StringCharFromCodeGenerator { | 1768 class StringCharFromCodeGenerator { |
| 1769 public: | 1769 public: |
| 1770 StringCharFromCodeGenerator(Register code, | 1770 StringCharFromCodeGenerator(Register code, |
| 1771 Register result) | 1771 Register result) |
| 1772 : code_(code), | 1772 : code_(code), |
| 1773 result_(result) { | 1773 result_(result) { |
| 1774 ASSERT(!code_.is(result_)); | 1774 DCHECK(!code_.is(result_)); |
| 1775 } | 1775 } |
| 1776 | 1776 |
| 1777 // Generates the fast case code. On the fallthrough path |result| | 1777 // Generates the fast case code. On the fallthrough path |result| |
| 1778 // register contains the result. | 1778 // register contains the result. |
| 1779 void GenerateFast(MacroAssembler* masm); | 1779 void GenerateFast(MacroAssembler* masm); |
| 1780 | 1780 |
| 1781 // Generates the slow case code. Must not be naturally | 1781 // Generates the slow case code. Must not be naturally |
| 1782 // reachable. Expected to be put after a ret instruction (e.g., in | 1782 // reachable. Expected to be put after a ret instruction (e.g., in |
| 1783 // deferred code). Always jumps back to the fast case. | 1783 // deferred code). Always jumps back to the fast case. |
| 1784 void GenerateSlow(MacroAssembler* masm, | 1784 void GenerateSlow(MacroAssembler* masm, |
| (...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2099 | 2099 |
| 2100 class ArrayConstructorStubBase : public HydrogenCodeStub { | 2100 class ArrayConstructorStubBase : public HydrogenCodeStub { |
| 2101 public: | 2101 public: |
| 2102 ArrayConstructorStubBase(Isolate* isolate, | 2102 ArrayConstructorStubBase(Isolate* isolate, |
| 2103 ElementsKind kind, | 2103 ElementsKind kind, |
| 2104 AllocationSiteOverrideMode override_mode) | 2104 AllocationSiteOverrideMode override_mode) |
| 2105 : HydrogenCodeStub(isolate) { | 2105 : HydrogenCodeStub(isolate) { |
| 2106 // It only makes sense to override local allocation site behavior | 2106 // It only makes sense to override local allocation site behavior |
| 2107 // if there is a difference between the global allocation site policy | 2107 // if there is a difference between the global allocation site policy |
| 2108 // for an ElementsKind and the desired usage of the stub. | 2108 // for an ElementsKind and the desired usage of the stub. |
| 2109 ASSERT(override_mode != DISABLE_ALLOCATION_SITES || | 2109 DCHECK(override_mode != DISABLE_ALLOCATION_SITES || |
| 2110 AllocationSite::GetMode(kind) == TRACK_ALLOCATION_SITE); | 2110 AllocationSite::GetMode(kind) == TRACK_ALLOCATION_SITE); |
| 2111 bit_field_ = ElementsKindBits::encode(kind) | | 2111 bit_field_ = ElementsKindBits::encode(kind) | |
| 2112 AllocationSiteOverrideModeBits::encode(override_mode); | 2112 AllocationSiteOverrideModeBits::encode(override_mode); |
| 2113 } | 2113 } |
| 2114 | 2114 |
| 2115 ElementsKind elements_kind() const { | 2115 ElementsKind elements_kind() const { |
| 2116 return ElementsKindBits::decode(bit_field_); | 2116 return ElementsKindBits::decode(bit_field_); |
| 2117 } | 2117 } |
| 2118 | 2118 |
| 2119 AllocationSiteOverrideMode override_mode() const { | 2119 AllocationSiteOverrideMode override_mode() const { |
| (...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2540 | 2540 |
| 2541 | 2541 |
| 2542 class CallDescriptors { | 2542 class CallDescriptors { |
| 2543 public: | 2543 public: |
| 2544 static void InitializeForIsolate(Isolate* isolate); | 2544 static void InitializeForIsolate(Isolate* isolate); |
| 2545 }; | 2545 }; |
| 2546 | 2546 |
| 2547 } } // namespace v8::internal | 2547 } } // namespace v8::internal |
| 2548 | 2548 |
| 2549 #endif // V8_CODE_STUBS_H_ | 2549 #endif // V8_CODE_STUBS_H_ |
| OLD | NEW |