OLD | NEW |
---|---|
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
177 OMIT_TRANSITION | 177 OMIT_TRANSITION |
178 }; | 178 }; |
179 | 179 |
180 // Indicates whether we are only interested in the descriptors of a particular | 180 // Indicates whether we are only interested in the descriptors of a particular |
181 // map, or in all descriptors in the descriptor array. | 181 // map, or in all descriptors in the descriptor array. |
182 enum DescriptorFlag { | 182 enum DescriptorFlag { |
183 ALL_DESCRIPTORS, | 183 ALL_DESCRIPTORS, |
184 OWN_DESCRIPTORS | 184 OWN_DESCRIPTORS |
185 }; | 185 }; |
186 | 186 |
187 enum MarkingParity { | |
Michael Starzinger
2012/09/21 09:43:19
Can we have a short comment on what the marking pa
danno
2012/10/25 10:07:23
Done.
| |
188 NO_MARKING_PARITY, | |
189 ODD_MARKING_PARITY, | |
190 EVEN_MARKING_PARITY | |
191 }; | |
187 | 192 |
188 // Instance size sentinel for objects of variable size. | 193 // Instance size sentinel for objects of variable size. |
189 const int kVariableSizeSentinel = 0; | 194 const int kVariableSizeSentinel = 0; |
190 | 195 |
191 const int kStubMajorKeyBits = 6; | 196 const int kStubMajorKeyBits = 6; |
192 const int kStubMinorKeyBits = kBitsPerInt - kSmiTagSize - kStubMajorKeyBits; | 197 const int kStubMinorKeyBits = kBitsPerInt - kSmiTagSize - kStubMajorKeyBits; |
193 | 198 |
194 // All Maps have a field instance_type containing a InstanceType. | 199 // All Maps have a field instance_type containing a InstanceType. |
195 // It describes the type of the instances. | 200 // It describes the type of the instances. |
196 // | 201 // |
(...skipping 4297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4494 CodePrint(stdout); | 4499 CodePrint(stdout); |
4495 } | 4500 } |
4496 void CodePrint(FILE* out); | 4501 void CodePrint(FILE* out); |
4497 #endif | 4502 #endif |
4498 #ifdef DEBUG | 4503 #ifdef DEBUG |
4499 void CodeVerify(); | 4504 void CodeVerify(); |
4500 #endif | 4505 #endif |
4501 void ClearInlineCaches(); | 4506 void ClearInlineCaches(); |
4502 void ClearTypeFeedbackCells(Heap* heap); | 4507 void ClearTypeFeedbackCells(Heap* heap); |
4503 | 4508 |
4509 #define DECLARE_CODE_AGE_ENUM(X) k##X##CodeAge, | |
4510 enum Age { | |
4511 kNoAge = 0, | |
4512 CODE_AGE_LIST(DECLARE_CODE_AGE_ENUM) | |
4513 kAfterLastCodeAge, | |
4514 kLastCodeAge = kAfterLastCodeAge - 1, | |
4515 kCodeAgeCount = kAfterLastCodeAge - 1 | |
4516 }; | |
4517 #undef DECLARE_CODE_AGE_ENUM | |
4518 | |
4519 // Code aging | |
4520 static void MakeCodeAgeSequenceYoung(byte* sequence); | |
4521 void MakeYoung(); | |
4522 void MakeOlder(); | |
4523 bool IsOld(); | |
4524 | |
4504 // Max loop nesting marker used to postpose OSR. We don't take loop | 4525 // Max loop nesting marker used to postpose OSR. We don't take loop |
4505 // nesting that is deeper than 5 levels into account. | 4526 // nesting that is deeper than 5 levels into account. |
4506 static const int kMaxLoopNestingMarker = 6; | 4527 static const int kMaxLoopNestingMarker = 6; |
4507 | 4528 |
4508 // Layout description. | 4529 // Layout description. |
4509 static const int kInstructionSizeOffset = HeapObject::kHeaderSize; | 4530 static const int kInstructionSizeOffset = HeapObject::kHeaderSize; |
4510 static const int kRelocationInfoOffset = kInstructionSizeOffset + kIntSize; | 4531 static const int kRelocationInfoOffset = kInstructionSizeOffset + kIntSize; |
4511 static const int kHandlerTableOffset = kRelocationInfoOffset + kPointerSize; | 4532 static const int kHandlerTableOffset = kRelocationInfoOffset + kPointerSize; |
4512 static const int kDeoptimizationDataOffset = | 4533 static const int kDeoptimizationDataOffset = |
4513 kHandlerTableOffset + kPointerSize; | 4534 kHandlerTableOffset + kPointerSize; |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4622 | 4643 |
4623 // Signed field cannot be encoded using the BitField class. | 4644 // Signed field cannot be encoded using the BitField class. |
4624 static const int kArgumentsCountShift = 14; | 4645 static const int kArgumentsCountShift = 14; |
4625 static const int kArgumentsCountMask = ~((1 << kArgumentsCountShift) - 1); | 4646 static const int kArgumentsCountMask = ~((1 << kArgumentsCountShift) - 1); |
4626 | 4647 |
4627 // This constant should be encodable in an ARM instruction. | 4648 // This constant should be encodable in an ARM instruction. |
4628 static const int kFlagsNotUsedInLookup = | 4649 static const int kFlagsNotUsedInLookup = |
4629 TypeField::kMask | CacheHolderField::kMask; | 4650 TypeField::kMask | CacheHolderField::kMask; |
4630 | 4651 |
4631 private: | 4652 private: |
4653 friend class RelocIterator; | |
4654 | |
4655 // Code aging | |
4656 byte* FindCodeAgeSequence(); | |
4657 static void GetCodeAgeAndParity(Code* code, Age* age, | |
4658 MarkingParity* parity); | |
4659 static void GetCodeAgeAndParity(byte* sequence, Age* age, | |
4660 MarkingParity* parity); | |
4661 static Code* GetCodeAgeStub(Age age, MarkingParity parity); | |
4662 | |
4663 // Code aging -- platform-specific | |
4664 byte* FindPlatformCodeAgeSequence(); | |
4665 static void PatchPlatformCodeAge(byte* sequence, Age age, | |
4666 MarkingParity parity); | |
4667 | |
4632 DISALLOW_IMPLICIT_CONSTRUCTORS(Code); | 4668 DISALLOW_IMPLICIT_CONSTRUCTORS(Code); |
4633 }; | 4669 }; |
4634 | 4670 |
4635 | 4671 |
4636 // All heap objects have a Map that describes their structure. | 4672 // All heap objects have a Map that describes their structure. |
4637 // A Map contains information about: | 4673 // A Map contains information about: |
4638 // - Size information about the object | 4674 // - Size information about the object |
4639 // - How to iterate over an object (for garbage collection) | 4675 // - How to iterate over an object (for garbage collection) |
4640 class Map: public HeapObject { | 4676 class Map: public HeapObject { |
4641 public: | 4677 public: |
(...skipping 960 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5602 // This is used to determine if we can safely flush code from a function | 5638 // This is used to determine if we can safely flush code from a function |
5603 // when doing GC if we expect that the function will no longer be used. | 5639 // when doing GC if we expect that the function will no longer be used. |
5604 DECL_BOOLEAN_ACCESSORS(allows_lazy_compilation) | 5640 DECL_BOOLEAN_ACCESSORS(allows_lazy_compilation) |
5605 | 5641 |
5606 // Indicates if this function can be lazy compiled without a context. | 5642 // Indicates if this function can be lazy compiled without a context. |
5607 // This is used to determine if we can force compilation without reaching | 5643 // This is used to determine if we can force compilation without reaching |
5608 // the function through program execution but through other means (e.g. heap | 5644 // the function through program execution but through other means (e.g. heap |
5609 // iteration by the debugger). | 5645 // iteration by the debugger). |
5610 DECL_BOOLEAN_ACCESSORS(allows_lazy_compilation_without_context) | 5646 DECL_BOOLEAN_ACCESSORS(allows_lazy_compilation_without_context) |
5611 | 5647 |
5612 // Indicates how many full GCs this function has survived with assigned | |
5613 // code object. Used to determine when it is relatively safe to flush | |
5614 // this code object and replace it with lazy compilation stub. | |
5615 // Age is reset when GC notices that the code object is referenced | |
5616 // from the stack or compilation cache. | |
5617 inline int code_age(); | |
5618 inline void set_code_age(int age); | |
5619 | |
5620 // Indicates whether optimizations have been disabled for this | 5648 // Indicates whether optimizations have been disabled for this |
5621 // shared function info. If a function is repeatedly optimized or if | 5649 // shared function info. If a function is repeatedly optimized or if |
5622 // we cannot optimize the function we disable optimization to avoid | 5650 // we cannot optimize the function we disable optimization to avoid |
5623 // spending time attempting to optimize it again. | 5651 // spending time attempting to optimize it again. |
5624 DECL_BOOLEAN_ACCESSORS(optimization_disabled) | 5652 DECL_BOOLEAN_ACCESSORS(optimization_disabled) |
5625 | 5653 |
5626 // Indicates the language mode of the function's code as defined by the | 5654 // Indicates the language mode of the function's code as defined by the |
5627 // current harmony drafts for the next ES language standard. Possible | 5655 // current harmony drafts for the next ES language standard. Possible |
5628 // values are: | 5656 // values are: |
5629 // 1. CLASSIC_MODE - Unrestricted syntax and semantics, same as in ES5. | 5657 // 1. CLASSIC_MODE - Unrestricted syntax and semantics, same as in ES5. |
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5880 | 5908 |
5881 // Bit positions in start_position_and_type. | 5909 // Bit positions in start_position_and_type. |
5882 // The source code start position is in the 30 most significant bits of | 5910 // The source code start position is in the 30 most significant bits of |
5883 // the start_position_and_type field. | 5911 // the start_position_and_type field. |
5884 static const int kIsExpressionBit = 0; | 5912 static const int kIsExpressionBit = 0; |
5885 static const int kIsTopLevelBit = 1; | 5913 static const int kIsTopLevelBit = 1; |
5886 static const int kStartPositionShift = 2; | 5914 static const int kStartPositionShift = 2; |
5887 static const int kStartPositionMask = ~((1 << kStartPositionShift) - 1); | 5915 static const int kStartPositionMask = ~((1 << kStartPositionShift) - 1); |
5888 | 5916 |
5889 // Bit positions in compiler_hints. | 5917 // Bit positions in compiler_hints. |
5890 static const int kCodeAgeSize = 3; | |
5891 static const int kCodeAgeMask = (1 << kCodeAgeSize) - 1; | |
5892 | |
5893 enum CompilerHints { | 5918 enum CompilerHints { |
5894 kHasOnlySimpleThisPropertyAssignments, | 5919 kHasOnlySimpleThisPropertyAssignments, |
5895 kAllowLazyCompilation, | 5920 kAllowLazyCompilation, |
5896 kAllowLazyCompilationWithoutContext, | 5921 kAllowLazyCompilationWithoutContext, |
5897 kLiveObjectsMayExist, | 5922 kLiveObjectsMayExist, |
5898 kCodeAgeShift, | 5923 kOptimizationDisabled, |
5899 kOptimizationDisabled = kCodeAgeShift + kCodeAgeSize, | |
5900 kStrictModeFunction, | 5924 kStrictModeFunction, |
5901 kExtendedModeFunction, | 5925 kExtendedModeFunction, |
5902 kUsesArguments, | 5926 kUsesArguments, |
5903 kHasDuplicateParameters, | 5927 kHasDuplicateParameters, |
5904 kNative, | 5928 kNative, |
5905 kBoundFunction, | 5929 kBoundFunction, |
5906 kIsAnonymous, | 5930 kIsAnonymous, |
5907 kNameShouldPrintAsAnonymous, | 5931 kNameShouldPrintAsAnonymous, |
5908 kIsFunction, | 5932 kIsFunction, |
5909 kDontOptimize, | 5933 kDontOptimize, |
(...skipping 3001 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
8911 | 8935 |
8912 // Visits the resource of an ASCII or two-byte string. | 8936 // Visits the resource of an ASCII or two-byte string. |
8913 virtual void VisitExternalAsciiString( | 8937 virtual void VisitExternalAsciiString( |
8914 v8::String::ExternalAsciiStringResource** resource) {} | 8938 v8::String::ExternalAsciiStringResource** resource) {} |
8915 virtual void VisitExternalTwoByteString( | 8939 virtual void VisitExternalTwoByteString( |
8916 v8::String::ExternalStringResource** resource) {} | 8940 v8::String::ExternalStringResource** resource) {} |
8917 | 8941 |
8918 // Visits a debug call target in the instruction stream. | 8942 // Visits a debug call target in the instruction stream. |
8919 virtual void VisitDebugTarget(RelocInfo* rinfo); | 8943 virtual void VisitDebugTarget(RelocInfo* rinfo); |
8920 | 8944 |
8945 virtual void VisitCodeAgeSequence(RelocInfo* rinfo); | |
Michael Starzinger
2012/09/21 09:43:19
Add a comment of some sort ...
// Visits a code a
danno
2012/10/25 10:07:23
Done.
| |
8946 | |
8921 // Handy shorthand for visiting a single pointer. | 8947 // Handy shorthand for visiting a single pointer. |
8922 virtual void VisitPointer(Object** p) { VisitPointers(p, p + 1); } | 8948 virtual void VisitPointer(Object** p) { VisitPointers(p, p + 1); } |
8923 | 8949 |
8924 // Visit pointer embedded into a code object. | 8950 // Visit pointer embedded into a code object. |
8925 virtual void VisitEmbeddedPointer(RelocInfo* rinfo); | 8951 virtual void VisitEmbeddedPointer(RelocInfo* rinfo); |
8926 | 8952 |
8927 // Visits a contiguous arrays of external references (references to the C++ | 8953 // Visits a contiguous arrays of external references (references to the C++ |
8928 // heap) in the half-open range [start, end). Any or all of the values | 8954 // heap) in the half-open range [start, end). Any or all of the values |
8929 // may be modified on return. | 8955 // may be modified on return. |
8930 virtual void VisitExternalReferences(Address* start, Address* end) {} | 8956 virtual void VisitExternalReferences(Address* start, Address* end) {} |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
8976 } else { | 9002 } else { |
8977 value &= ~(1 << bit_position); | 9003 value &= ~(1 << bit_position); |
8978 } | 9004 } |
8979 return value; | 9005 return value; |
8980 } | 9006 } |
8981 }; | 9007 }; |
8982 | 9008 |
8983 } } // namespace v8::internal | 9009 } } // namespace v8::internal |
8984 | 9010 |
8985 #endif // V8_OBJECTS_H_ | 9011 #endif // V8_OBJECTS_H_ |
OLD | NEW |