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_OBJECTS_H_ | 5 #ifndef V8_OBJECTS_H_ |
6 #define V8_OBJECTS_H_ | 6 #define V8_OBJECTS_H_ |
7 | 7 |
8 #include <iosfwd> | 8 #include <iosfwd> |
9 | 9 |
10 #include "src/allocation.h" | 10 #include "src/allocation.h" |
(...skipping 6910 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6921 static const int kCountersOffset = | 6921 static const int kCountersOffset = |
6922 kOptCountAndBailoutReasonOffset + kPointerSize; | 6922 kOptCountAndBailoutReasonOffset + kPointerSize; |
6923 static const int kAstNodeCountOffset = | 6923 static const int kAstNodeCountOffset = |
6924 kCountersOffset + kPointerSize; | 6924 kCountersOffset + kPointerSize; |
6925 static const int kProfilerTicksOffset = | 6925 static const int kProfilerTicksOffset = |
6926 kAstNodeCountOffset + kPointerSize; | 6926 kAstNodeCountOffset + kPointerSize; |
6927 | 6927 |
6928 // Total size. | 6928 // Total size. |
6929 static const int kSize = kProfilerTicksOffset + kPointerSize; | 6929 static const int kSize = kProfilerTicksOffset + kPointerSize; |
6930 #else | 6930 #else |
6931 // The only reason to use smi fields instead of int fields is to allow | 6931 // The only reason to use smi fields instead of int fields |
6932 // iteration without maps decoding during garbage collections. | 6932 // is to allow iteration without maps decoding during |
6933 // To avoid wasting space on 64-bit architectures we use the following trick: | 6933 // garbage collections. |
6934 // we group integer fields into pairs | 6934 // To avoid wasting space on 64-bit architectures we use |
6935 // The least significant integer in each pair is shifted left by 1. By doing | 6935 // the following trick: we group integer fields into pairs |
6936 // this we guarantee that LSB of each kPointerSize aligned word is not set and | 6936 // The least significant integer in each pair is shifted left by 1. |
6937 // thus this word cannot be treated as pointer to HeapObject during old space | 6937 // By doing this we guarantee that LSB of each kPointerSize aligned |
6938 // traversal. | 6938 // word is not set and thus this word cannot be treated as pointer |
| 6939 // to HeapObject during old space traversal. |
6939 #if V8_TARGET_LITTLE_ENDIAN | 6940 #if V8_TARGET_LITTLE_ENDIAN |
6940 static const int kLengthOffset = kLastPointerFieldOffset + kPointerSize; | 6941 static const int kLengthOffset = kLastPointerFieldOffset + kPointerSize; |
6941 static const int kFormalParameterCountOffset = | 6942 static const int kFormalParameterCountOffset = |
6942 kLengthOffset + kIntSize; | 6943 kLengthOffset + kIntSize; |
6943 | 6944 |
6944 static const int kExpectedNofPropertiesOffset = | 6945 static const int kExpectedNofPropertiesOffset = |
6945 kFormalParameterCountOffset + kIntSize; | 6946 kFormalParameterCountOffset + kIntSize; |
6946 static const int kNumLiteralsOffset = | 6947 static const int kNumLiteralsOffset = |
6947 kExpectedNofPropertiesOffset + kIntSize; | 6948 kExpectedNofPropertiesOffset + kIntSize; |
6948 | 6949 |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7010 // Bit positions in start_position_and_type. | 7011 // Bit positions in start_position_and_type. |
7011 // The source code start position is in the 30 most significant bits of | 7012 // The source code start position is in the 30 most significant bits of |
7012 // the start_position_and_type field. | 7013 // the start_position_and_type field. |
7013 static const int kIsExpressionBit = 0; | 7014 static const int kIsExpressionBit = 0; |
7014 static const int kIsTopLevelBit = 1; | 7015 static const int kIsTopLevelBit = 1; |
7015 static const int kStartPositionShift = 2; | 7016 static const int kStartPositionShift = 2; |
7016 static const int kStartPositionMask = ~((1 << kStartPositionShift) - 1); | 7017 static const int kStartPositionMask = ~((1 << kStartPositionShift) - 1); |
7017 | 7018 |
7018 // Bit positions in compiler_hints. | 7019 // Bit positions in compiler_hints. |
7019 enum CompilerHints { | 7020 enum CompilerHints { |
7020 // byte 0 | |
7021 kAllowLazyCompilation, | 7021 kAllowLazyCompilation, |
7022 kAllowLazyCompilationWithoutContext, | 7022 kAllowLazyCompilationWithoutContext, |
7023 kOptimizationDisabled, | 7023 kOptimizationDisabled, |
7024 kNative, | 7024 kNative, |
7025 kStrictModeFunction, | 7025 kStrictModeFunction, |
7026 kStrongModeFunction, | 7026 kStrongModeFunction, |
7027 kUsesArguments, | 7027 kUsesArguments, |
7028 kNeedsHomeObject, | 7028 kNeedsHomeObject, |
7029 // byte 1 | |
7030 kHasDuplicateParameters, | 7029 kHasDuplicateParameters, |
7031 kForceInline, | 7030 kForceInline, |
7032 kBoundFunction, | 7031 kBoundFunction, |
7033 kIsAnonymous, | 7032 kIsAnonymous, |
7034 kNameShouldPrintAsAnonymous, | 7033 kNameShouldPrintAsAnonymous, |
7035 kIsFunction, | 7034 kIsFunction, |
7036 kDontCrankshaft, | 7035 kDontCrankshaft, |
7037 kDontFlush, | 7036 kDontFlush, |
7038 // byte 2 | 7037 kIsArrow, |
7039 kFunctionKind, | |
7040 kIsArrow = kFunctionKind, | |
7041 kIsGenerator, | 7038 kIsGenerator, |
7042 kIsConciseMethod, | 7039 kIsConciseMethod, |
7043 kIsAccessorFunction, | 7040 kIsAccessorFunction, |
7044 kIsDefaultConstructor, | 7041 kIsDefaultConstructor, |
7045 kIsSubclassConstructor, | 7042 kIsSubclassConstructor, |
7046 kIsBaseConstructor, | 7043 kIsBaseConstructor, |
7047 kIsInObjectLiteral, | 7044 kInClassLiteral, |
7048 // byte 3 | |
7049 kIsAsmFunction, | 7045 kIsAsmFunction, |
7050 kDeserialized, | 7046 kDeserialized, |
7051 kNeverCompiled, | 7047 kNeverCompiled, |
7052 kCompilerHintsCount, // Pseudo entry | 7048 kCompilerHintsCount // Pseudo entry |
7053 }; | 7049 }; |
7054 // Add hints for other modes when they're added. | 7050 // Add hints for other modes when they're added. |
7055 STATIC_ASSERT(LANGUAGE_END == 3); | 7051 STATIC_ASSERT(LANGUAGE_END == 3); |
7056 // kFunctionKind has to be byte-aligned | |
7057 STATIC_ASSERT((kFunctionKind % kBitsPerByte) == 0); | |
7058 // Make sure that FunctionKind and byte 2 are in sync: | |
7059 #define ASSERT_FUNCTION_KIND_ORDER(functionKind, compilerFunctionKind) \ | |
7060 STATIC_ASSERT(FunctionKind::functionKind == \ | |
7061 1 << (compilerFunctionKind - kFunctionKind)) | |
7062 ASSERT_FUNCTION_KIND_ORDER(kArrowFunction, kIsArrow); | |
7063 ASSERT_FUNCTION_KIND_ORDER(kGeneratorFunction, kIsGenerator); | |
7064 ASSERT_FUNCTION_KIND_ORDER(kConciseMethod, kIsConciseMethod); | |
7065 ASSERT_FUNCTION_KIND_ORDER(kAccessorFunction, kIsAccessorFunction); | |
7066 ASSERT_FUNCTION_KIND_ORDER(kDefaultConstructor, kIsDefaultConstructor); | |
7067 ASSERT_FUNCTION_KIND_ORDER(kSubclassConstructor, kIsSubclassConstructor); | |
7068 ASSERT_FUNCTION_KIND_ORDER(kBaseConstructor, kIsBaseConstructor); | |
7069 ASSERT_FUNCTION_KIND_ORDER(kInObjectLiteral, kIsInObjectLiteral); | |
7070 #undef ASSERT_FUNCTION_KIND_ORDER | |
7071 | 7052 |
7072 class FunctionKindBits : public BitField<FunctionKind, kIsArrow, 8> {}; | 7053 class FunctionKindBits : public BitField<FunctionKind, kIsArrow, 8> {}; |
7073 | 7054 |
7074 class DeoptCountBits : public BitField<int, 0, 4> {}; | 7055 class DeoptCountBits : public BitField<int, 0, 4> {}; |
7075 class OptReenableTriesBits : public BitField<int, 4, 18> {}; | 7056 class OptReenableTriesBits : public BitField<int, 4, 18> {}; |
7076 class ICAgeBits : public BitField<int, 22, 8> {}; | 7057 class ICAgeBits : public BitField<int, 22, 8> {}; |
7077 | 7058 |
7078 class OptCountBits : public BitField<int, 0, 22> {}; | 7059 class OptCountBits : public BitField<int, 0, 22> {}; |
7079 class DisabledOptimizationReasonBits : public BitField<int, 22, 8> {}; | 7060 class DisabledOptimizationReasonBits : public BitField<int, 22, 8> {}; |
7080 | 7061 |
(...skipping 19 matching lines...) Expand all Loading... |
7100 (kStrictModeFunction + kCompilerHintsSmiTagSize) % kBitsPerByte; | 7081 (kStrictModeFunction + kCompilerHintsSmiTagSize) % kBitsPerByte; |
7101 static const int kStrongModeBitWithinByte = | 7082 static const int kStrongModeBitWithinByte = |
7102 (kStrongModeFunction + kCompilerHintsSmiTagSize) % kBitsPerByte; | 7083 (kStrongModeFunction + kCompilerHintsSmiTagSize) % kBitsPerByte; |
7103 | 7084 |
7104 static const int kNativeBitWithinByte = | 7085 static const int kNativeBitWithinByte = |
7105 (kNative + kCompilerHintsSmiTagSize) % kBitsPerByte; | 7086 (kNative + kCompilerHintsSmiTagSize) % kBitsPerByte; |
7106 | 7087 |
7107 static const int kBoundBitWithinByte = | 7088 static const int kBoundBitWithinByte = |
7108 (kBoundFunction + kCompilerHintsSmiTagSize) % kBitsPerByte; | 7089 (kBoundFunction + kCompilerHintsSmiTagSize) % kBitsPerByte; |
7109 | 7090 |
7110 static const int kClassConstructorBitsWithinByte = | |
7111 FunctionKind::kClassConstructor << kCompilerHintsSmiTagSize; | |
7112 STATIC_ASSERT(kClassConstructorBitsWithinByte < (1 << kBitsPerByte)); | |
7113 | |
7114 #if defined(V8_TARGET_LITTLE_ENDIAN) | 7091 #if defined(V8_TARGET_LITTLE_ENDIAN) |
7115 #define BYTE_OFFSET(compiler_hint) \ | 7092 static const int kStrictModeByteOffset = kCompilerHintsOffset + |
7116 kCompilerHintsOffset + \ | 7093 (kStrictModeFunction + kCompilerHintsSmiTagSize) / kBitsPerByte; |
7117 (compiler_hint + kCompilerHintsSmiTagSize) / kBitsPerByte | 7094 static const int kStrongModeByteOffset = |
| 7095 kCompilerHintsOffset + |
| 7096 (kStrongModeFunction + kCompilerHintsSmiTagSize) / kBitsPerByte; |
| 7097 static const int kNativeByteOffset = kCompilerHintsOffset + |
| 7098 (kNative + kCompilerHintsSmiTagSize) / kBitsPerByte; |
| 7099 static const int kBoundByteOffset = |
| 7100 kCompilerHintsOffset + |
| 7101 (kBoundFunction + kCompilerHintsSmiTagSize) / kBitsPerByte; |
7118 #elif defined(V8_TARGET_BIG_ENDIAN) | 7102 #elif defined(V8_TARGET_BIG_ENDIAN) |
7119 #define BYTE_OFFSET(compiler_hint) \ | 7103 static const int kStrictModeByteOffset = kCompilerHintsOffset + |
7120 kCompilerHintsOffset + +(kCompilerHintsSize - 1) - \ | 7104 (kCompilerHintsSize - 1) - |
7121 ((kStrictModeFunction + kCompilerHintsSmiTagSize) / kBitsPerByte) | 7105 ((kStrictModeFunction + kCompilerHintsSmiTagSize) / kBitsPerByte); |
| 7106 static const int kStrongModeByteOffset = |
| 7107 kCompilerHintsOffset + (kCompilerHintsSize - 1) - |
| 7108 ((kStrongModeFunction + kCompilerHintsSmiTagSize) / kBitsPerByte); |
| 7109 static const int kNativeByteOffset = kCompilerHintsOffset + |
| 7110 (kCompilerHintsSize - 1) - |
| 7111 ((kNative + kCompilerHintsSmiTagSize) / kBitsPerByte); |
| 7112 static const int kBoundByteOffset = |
| 7113 kCompilerHintsOffset + (kCompilerHintsSize - 1) - |
| 7114 ((kBoundFunction + kCompilerHintsSmiTagSize) / kBitsPerByte); |
7122 #else | 7115 #else |
7123 #error Unknown byte ordering | 7116 #error Unknown byte ordering |
7124 #endif | 7117 #endif |
7125 static const int kStrictModeByteOffset = BYTE_OFFSET(kStrictModeFunction); | |
7126 static const int kStrongModeByteOffset = BYTE_OFFSET(kStrongModeFunction); | |
7127 static const int kNativeByteOffset = BYTE_OFFSET(kNative); | |
7128 static const int kBoundByteOffset = BYTE_OFFSET(kBoundFunction); | |
7129 static const int kFunctionKindByteOffset = BYTE_OFFSET(kFunctionKind); | |
7130 #undef BYTE_OFFSET | |
7131 | 7118 |
7132 private: | 7119 private: |
7133 // Returns entry from optimized code map for specified context and OSR entry. | 7120 // Returns entry from optimized code map for specified context and OSR entry. |
7134 // The result is either kNotFound, kSharedCodeIndex for context-independent | 7121 // The result is either kNotFound, kSharedCodeIndex for context-independent |
7135 // entry or a start index of the context-dependent entry. | 7122 // entry or a start index of the context-dependent entry. |
7136 int SearchOptimizedCodeMapEntry(Context* native_context, | 7123 int SearchOptimizedCodeMapEntry(Context* native_context, |
7137 BailoutId osr_ast_id); | 7124 BailoutId osr_ast_id); |
7138 | 7125 |
7139 DISALLOW_IMPLICIT_CONSTRUCTORS(SharedFunctionInfo); | 7126 DISALLOW_IMPLICIT_CONSTRUCTORS(SharedFunctionInfo); |
7140 }; | 7127 }; |
(...skipping 3710 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10851 // (elements + properties) in the current level. | 10838 // (elements + properties) in the current level. |
10852 int levelLength_ = 0; | 10839 int levelLength_ = 0; |
10853 | 10840 |
10854 DISALLOW_COPY_AND_ASSIGN(KeyAccumulator); | 10841 DISALLOW_COPY_AND_ASSIGN(KeyAccumulator); |
10855 }; | 10842 }; |
10856 | 10843 |
10857 } // NOLINT, false-positive due to second-order macros. | 10844 } // NOLINT, false-positive due to second-order macros. |
10858 } // NOLINT, false-positive due to second-order macros. | 10845 } // NOLINT, false-positive due to second-order macros. |
10859 | 10846 |
10860 #endif // V8_OBJECTS_H_ | 10847 #endif // V8_OBJECTS_H_ |
OLD | NEW |