| 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 // The GC maintains a bit of information, the MarkingParity, which toggles |
| 188 // from odd to even and back every time marking is completed. Incremental |
| 189 // marking can visit an object twice during a marking phase, so algorithms that |
| 190 // that piggy-back on marking can use the parity to ensure that they only |
| 191 // perform an operation on an object once per marking phase: they record the |
| 192 // MarkingParity when they visit an object, and only re-visit the object when it |
| 193 // is marked again and the MarkingParity changes. |
| 194 enum MarkingParity { |
| 195 NO_MARKING_PARITY, |
| 196 ODD_MARKING_PARITY, |
| 197 EVEN_MARKING_PARITY |
| 198 }; |
| 187 | 199 |
| 188 // Instance size sentinel for objects of variable size. | 200 // Instance size sentinel for objects of variable size. |
| 189 const int kVariableSizeSentinel = 0; | 201 const int kVariableSizeSentinel = 0; |
| 190 | 202 |
| 191 const int kStubMajorKeyBits = 6; | 203 const int kStubMajorKeyBits = 6; |
| 192 const int kStubMinorKeyBits = kBitsPerInt - kSmiTagSize - kStubMajorKeyBits; | 204 const int kStubMinorKeyBits = kBitsPerInt - kSmiTagSize - kStubMajorKeyBits; |
| 193 | 205 |
| 194 // All Maps have a field instance_type containing a InstanceType. | 206 // All Maps have a field instance_type containing a InstanceType. |
| 195 // It describes the type of the instances. | 207 // It describes the type of the instances. |
| 196 // | 208 // |
| (...skipping 4297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4494 CodePrint(stdout); | 4506 CodePrint(stdout); |
| 4495 } | 4507 } |
| 4496 void CodePrint(FILE* out); | 4508 void CodePrint(FILE* out); |
| 4497 #endif | 4509 #endif |
| 4498 #ifdef DEBUG | 4510 #ifdef DEBUG |
| 4499 void CodeVerify(); | 4511 void CodeVerify(); |
| 4500 #endif | 4512 #endif |
| 4501 void ClearInlineCaches(); | 4513 void ClearInlineCaches(); |
| 4502 void ClearTypeFeedbackCells(Heap* heap); | 4514 void ClearTypeFeedbackCells(Heap* heap); |
| 4503 | 4515 |
| 4516 #define DECLARE_CODE_AGE_ENUM(X) k##X##CodeAge, |
| 4517 enum Age { |
| 4518 kNoAge = 0, |
| 4519 CODE_AGE_LIST(DECLARE_CODE_AGE_ENUM) |
| 4520 kAfterLastCodeAge, |
| 4521 kLastCodeAge = kAfterLastCodeAge - 1, |
| 4522 kCodeAgeCount = kAfterLastCodeAge - 1 |
| 4523 }; |
| 4524 #undef DECLARE_CODE_AGE_ENUM |
| 4525 |
| 4526 // Code aging |
| 4527 static void MakeCodeAgeSequenceYoung(byte* sequence); |
| 4528 void MakeYoung(); |
| 4529 void MakeOlder(MarkingParity); |
| 4530 static bool IsYoungSequence(byte* sequence); |
| 4531 bool IsOld(); |
| 4532 |
| 4504 // Max loop nesting marker used to postpose OSR. We don't take loop | 4533 // Max loop nesting marker used to postpose OSR. We don't take loop |
| 4505 // nesting that is deeper than 5 levels into account. | 4534 // nesting that is deeper than 5 levels into account. |
| 4506 static const int kMaxLoopNestingMarker = 6; | 4535 static const int kMaxLoopNestingMarker = 6; |
| 4507 | 4536 |
| 4508 // Layout description. | 4537 // Layout description. |
| 4509 static const int kInstructionSizeOffset = HeapObject::kHeaderSize; | 4538 static const int kInstructionSizeOffset = HeapObject::kHeaderSize; |
| 4510 static const int kRelocationInfoOffset = kInstructionSizeOffset + kIntSize; | 4539 static const int kRelocationInfoOffset = kInstructionSizeOffset + kIntSize; |
| 4511 static const int kHandlerTableOffset = kRelocationInfoOffset + kPointerSize; | 4540 static const int kHandlerTableOffset = kRelocationInfoOffset + kPointerSize; |
| 4512 static const int kDeoptimizationDataOffset = | 4541 static const int kDeoptimizationDataOffset = |
| 4513 kHandlerTableOffset + kPointerSize; | 4542 kHandlerTableOffset + kPointerSize; |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4622 | 4651 |
| 4623 // Signed field cannot be encoded using the BitField class. | 4652 // Signed field cannot be encoded using the BitField class. |
| 4624 static const int kArgumentsCountShift = 14; | 4653 static const int kArgumentsCountShift = 14; |
| 4625 static const int kArgumentsCountMask = ~((1 << kArgumentsCountShift) - 1); | 4654 static const int kArgumentsCountMask = ~((1 << kArgumentsCountShift) - 1); |
| 4626 | 4655 |
| 4627 // This constant should be encodable in an ARM instruction. | 4656 // This constant should be encodable in an ARM instruction. |
| 4628 static const int kFlagsNotUsedInLookup = | 4657 static const int kFlagsNotUsedInLookup = |
| 4629 TypeField::kMask | CacheHolderField::kMask; | 4658 TypeField::kMask | CacheHolderField::kMask; |
| 4630 | 4659 |
| 4631 private: | 4660 private: |
| 4661 friend class RelocIterator; |
| 4662 |
| 4663 // Code aging |
| 4664 byte* FindCodeAgeSequence(); |
| 4665 static void GetCodeAgeAndParity(Code* code, Age* age, |
| 4666 MarkingParity* parity); |
| 4667 static void GetCodeAgeAndParity(byte* sequence, Age* age, |
| 4668 MarkingParity* parity); |
| 4669 static Code* GetCodeAgeStub(Age age, MarkingParity parity); |
| 4670 |
| 4671 // Code aging -- platform-specific |
| 4672 byte* FindPlatformCodeAgeSequence(); |
| 4673 static void PatchPlatformCodeAge(byte* sequence, Age age, |
| 4674 MarkingParity parity); |
| 4675 |
| 4632 DISALLOW_IMPLICIT_CONSTRUCTORS(Code); | 4676 DISALLOW_IMPLICIT_CONSTRUCTORS(Code); |
| 4633 }; | 4677 }; |
| 4634 | 4678 |
| 4635 | 4679 |
| 4636 // All heap objects have a Map that describes their structure. | 4680 // All heap objects have a Map that describes their structure. |
| 4637 // A Map contains information about: | 4681 // A Map contains information about: |
| 4638 // - Size information about the object | 4682 // - Size information about the object |
| 4639 // - How to iterate over an object (for garbage collection) | 4683 // - How to iterate over an object (for garbage collection) |
| 4640 class Map: public HeapObject { | 4684 class Map: public HeapObject { |
| 4641 public: | 4685 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 | 5646 // 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. | 5647 // when doing GC if we expect that the function will no longer be used. |
| 5604 DECL_BOOLEAN_ACCESSORS(allows_lazy_compilation) | 5648 DECL_BOOLEAN_ACCESSORS(allows_lazy_compilation) |
| 5605 | 5649 |
| 5606 // Indicates if this function can be lazy compiled without a context. | 5650 // Indicates if this function can be lazy compiled without a context. |
| 5607 // This is used to determine if we can force compilation without reaching | 5651 // 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 | 5652 // the function through program execution but through other means (e.g. heap |
| 5609 // iteration by the debugger). | 5653 // iteration by the debugger). |
| 5610 DECL_BOOLEAN_ACCESSORS(allows_lazy_compilation_without_context) | 5654 DECL_BOOLEAN_ACCESSORS(allows_lazy_compilation_without_context) |
| 5611 | 5655 |
| 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 | 5656 // Indicates whether optimizations have been disabled for this |
| 5621 // shared function info. If a function is repeatedly optimized or if | 5657 // shared function info. If a function is repeatedly optimized or if |
| 5622 // we cannot optimize the function we disable optimization to avoid | 5658 // we cannot optimize the function we disable optimization to avoid |
| 5623 // spending time attempting to optimize it again. | 5659 // spending time attempting to optimize it again. |
| 5624 DECL_BOOLEAN_ACCESSORS(optimization_disabled) | 5660 DECL_BOOLEAN_ACCESSORS(optimization_disabled) |
| 5625 | 5661 |
| 5626 // Indicates the language mode of the function's code as defined by the | 5662 // Indicates the language mode of the function's code as defined by the |
| 5627 // current harmony drafts for the next ES language standard. Possible | 5663 // current harmony drafts for the next ES language standard. Possible |
| 5628 // values are: | 5664 // values are: |
| 5629 // 1. CLASSIC_MODE - Unrestricted syntax and semantics, same as in ES5. | 5665 // 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 | 5916 |
| 5881 // Bit positions in start_position_and_type. | 5917 // Bit positions in start_position_and_type. |
| 5882 // The source code start position is in the 30 most significant bits of | 5918 // The source code start position is in the 30 most significant bits of |
| 5883 // the start_position_and_type field. | 5919 // the start_position_and_type field. |
| 5884 static const int kIsExpressionBit = 0; | 5920 static const int kIsExpressionBit = 0; |
| 5885 static const int kIsTopLevelBit = 1; | 5921 static const int kIsTopLevelBit = 1; |
| 5886 static const int kStartPositionShift = 2; | 5922 static const int kStartPositionShift = 2; |
| 5887 static const int kStartPositionMask = ~((1 << kStartPositionShift) - 1); | 5923 static const int kStartPositionMask = ~((1 << kStartPositionShift) - 1); |
| 5888 | 5924 |
| 5889 // Bit positions in compiler_hints. | 5925 // Bit positions in compiler_hints. |
| 5890 static const int kCodeAgeSize = 3; | |
| 5891 static const int kCodeAgeMask = (1 << kCodeAgeSize) - 1; | |
| 5892 | |
| 5893 enum CompilerHints { | 5926 enum CompilerHints { |
| 5894 kHasOnlySimpleThisPropertyAssignments, | 5927 kHasOnlySimpleThisPropertyAssignments, |
| 5895 kAllowLazyCompilation, | 5928 kAllowLazyCompilation, |
| 5896 kAllowLazyCompilationWithoutContext, | 5929 kAllowLazyCompilationWithoutContext, |
| 5897 kLiveObjectsMayExist, | 5930 kLiveObjectsMayExist, |
| 5898 kCodeAgeShift, | 5931 kOptimizationDisabled, |
| 5899 kOptimizationDisabled = kCodeAgeShift + kCodeAgeSize, | |
| 5900 kStrictModeFunction, | 5932 kStrictModeFunction, |
| 5901 kExtendedModeFunction, | 5933 kExtendedModeFunction, |
| 5902 kUsesArguments, | 5934 kUsesArguments, |
| 5903 kHasDuplicateParameters, | 5935 kHasDuplicateParameters, |
| 5904 kNative, | 5936 kNative, |
| 5905 kBoundFunction, | 5937 kBoundFunction, |
| 5906 kIsAnonymous, | 5938 kIsAnonymous, |
| 5907 kNameShouldPrintAsAnonymous, | 5939 kNameShouldPrintAsAnonymous, |
| 5908 kIsFunction, | 5940 kIsFunction, |
| 5909 kDontOptimize, | 5941 kDontOptimize, |
| (...skipping 3001 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8911 | 8943 |
| 8912 // Visits the resource of an ASCII or two-byte string. | 8944 // Visits the resource of an ASCII or two-byte string. |
| 8913 virtual void VisitExternalAsciiString( | 8945 virtual void VisitExternalAsciiString( |
| 8914 v8::String::ExternalAsciiStringResource** resource) {} | 8946 v8::String::ExternalAsciiStringResource** resource) {} |
| 8915 virtual void VisitExternalTwoByteString( | 8947 virtual void VisitExternalTwoByteString( |
| 8916 v8::String::ExternalStringResource** resource) {} | 8948 v8::String::ExternalStringResource** resource) {} |
| 8917 | 8949 |
| 8918 // Visits a debug call target in the instruction stream. | 8950 // Visits a debug call target in the instruction stream. |
| 8919 virtual void VisitDebugTarget(RelocInfo* rinfo); | 8951 virtual void VisitDebugTarget(RelocInfo* rinfo); |
| 8920 | 8952 |
| 8953 // Visits the byte sequence in a function's prologue that contains information |
| 8954 // about the code's age. |
| 8955 virtual void VisitCodeAgeSequence(RelocInfo* rinfo); |
| 8956 |
| 8921 // Handy shorthand for visiting a single pointer. | 8957 // Handy shorthand for visiting a single pointer. |
| 8922 virtual void VisitPointer(Object** p) { VisitPointers(p, p + 1); } | 8958 virtual void VisitPointer(Object** p) { VisitPointers(p, p + 1); } |
| 8923 | 8959 |
| 8924 // Visit pointer embedded into a code object. | 8960 // Visit pointer embedded into a code object. |
| 8925 virtual void VisitEmbeddedPointer(RelocInfo* rinfo); | 8961 virtual void VisitEmbeddedPointer(RelocInfo* rinfo); |
| 8926 | 8962 |
| 8927 // Visits a contiguous arrays of external references (references to the C++ | 8963 // 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 | 8964 // heap) in the half-open range [start, end). Any or all of the values |
| 8929 // may be modified on return. | 8965 // may be modified on return. |
| 8930 virtual void VisitExternalReferences(Address* start, Address* end) {} | 8966 virtual void VisitExternalReferences(Address* start, Address* end) {} |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8976 } else { | 9012 } else { |
| 8977 value &= ~(1 << bit_position); | 9013 value &= ~(1 << bit_position); |
| 8978 } | 9014 } |
| 8979 return value; | 9015 return value; |
| 8980 } | 9016 } |
| 8981 }; | 9017 }; |
| 8982 | 9018 |
| 8983 } } // namespace v8::internal | 9019 } } // namespace v8::internal |
| 8984 | 9020 |
| 8985 #endif // V8_OBJECTS_H_ | 9021 #endif // V8_OBJECTS_H_ |
| OLD | NEW |