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