OLD | NEW |
---|---|
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 3023 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3034 class ScopeInfo : public FixedArray { | 3034 class ScopeInfo : public FixedArray { |
3035 public: | 3035 public: |
3036 static inline ScopeInfo* cast(Object* object); | 3036 static inline ScopeInfo* cast(Object* object); |
3037 | 3037 |
3038 // Return the type of this scope. | 3038 // Return the type of this scope. |
3039 ScopeType Type(); | 3039 ScopeType Type(); |
3040 | 3040 |
3041 // Does this scope call eval? | 3041 // Does this scope call eval? |
3042 bool CallsEval(); | 3042 bool CallsEval(); |
3043 | 3043 |
3044 // Is this scope a strict mode scope? | 3044 // Return the language mode of this scope. |
3045 bool IsStrictMode(); | 3045 LanguageMode language_mode(); |
3046 | 3046 |
3047 // Does this scope make a non-strict eval call? | 3047 // Does this scope make a non-strict eval call? |
3048 bool CallsNonStrictEval() { | 3048 bool CallsNonStrictEval() { |
3049 return CallsEval() && !IsStrictMode(); | 3049 return CallsEval() && (language_mode() == CLASSIC_MODE); |
3050 } | 3050 } |
3051 | 3051 |
3052 // Return the total number of locals allocated on the stack and in the | 3052 // Return the total number of locals allocated on the stack and in the |
3053 // context. This includes the parameters that are allocated in the context. | 3053 // context. This includes the parameters that are allocated in the context. |
3054 int LocalCount(); | 3054 int LocalCount(); |
3055 | 3055 |
3056 // Return the number of stack slots for code. This number consists of two | 3056 // Return the number of stack slots for code. This number consists of two |
3057 // parts: | 3057 // parts: |
3058 // 1. One stack slot per stack allocated local. | 3058 // 1. One stack slot per stack allocated local. |
3059 // 2. One stack slot for the function name if it is stack allocated. | 3059 // 2. One stack slot for the function name if it is stack allocated. |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3207 enum FunctionVariableInfo { | 3207 enum FunctionVariableInfo { |
3208 NONE, // No function name present. | 3208 NONE, // No function name present. |
3209 STACK, // Function | 3209 STACK, // Function |
3210 CONTEXT, | 3210 CONTEXT, |
3211 UNUSED | 3211 UNUSED |
3212 }; | 3212 }; |
3213 | 3213 |
3214 // Properties of scopes. | 3214 // Properties of scopes. |
3215 class TypeField: public BitField<ScopeType, 0, 3> {}; | 3215 class TypeField: public BitField<ScopeType, 0, 3> {}; |
3216 class CallsEvalField: public BitField<bool, 3, 1> {}; | 3216 class CallsEvalField: public BitField<bool, 3, 1> {}; |
3217 class StrictModeField: public BitField<bool, 4, 1> {}; | 3217 class LanguageModeField: public BitField<LanguageMode, 4, 2> {}; |
3218 class FunctionVariableField: public BitField<FunctionVariableInfo, 5, 2> {}; | 3218 class FunctionVariableField: public BitField<FunctionVariableInfo, 6, 2> {}; |
3219 class FunctionVariableMode: public BitField<VariableMode, 7, 3> {}; | 3219 class FunctionVariableMode: public BitField<VariableMode, 8, 3> {}; |
3220 | 3220 |
3221 // BitFields representing the encoded information for context locals in the | 3221 // BitFields representing the encoded information for context locals in the |
3222 // ContextLocalInfoEntries part. | 3222 // ContextLocalInfoEntries part. |
3223 class ContextLocalMode: public BitField<VariableMode, 0, 3> {}; | 3223 class ContextLocalMode: public BitField<VariableMode, 0, 3> {}; |
3224 class ContextLocalInitFlag: public BitField<InitializationFlag, 3, 1> {}; | 3224 class ContextLocalInitFlag: public BitField<InitializationFlag, 3, 1> {}; |
3225 }; | 3225 }; |
3226 | 3226 |
3227 | 3227 |
3228 // The cache for maps used by normalized (dictionary mode) objects. | 3228 // The cache for maps used by normalized (dictionary mode) objects. |
3229 // Such maps do not have property descriptors, so a typical program | 3229 // Such maps do not have property descriptors, so a typical program |
(...skipping 1733 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4963 // from the stack or compilation cache. | 4963 // from the stack or compilation cache. |
4964 inline int code_age(); | 4964 inline int code_age(); |
4965 inline void set_code_age(int age); | 4965 inline void set_code_age(int age); |
4966 | 4966 |
4967 // Indicates whether optimizations have been disabled for this | 4967 // Indicates whether optimizations have been disabled for this |
4968 // shared function info. If a function is repeatedly optimized or if | 4968 // shared function info. If a function is repeatedly optimized or if |
4969 // we cannot optimize the function we disable optimization to avoid | 4969 // we cannot optimize the function we disable optimization to avoid |
4970 // spending time attempting to optimize it again. | 4970 // spending time attempting to optimize it again. |
4971 DECL_BOOLEAN_ACCESSORS(optimization_disabled) | 4971 DECL_BOOLEAN_ACCESSORS(optimization_disabled) |
4972 | 4972 |
4973 // Indicates whether the function is a strict mode function. | 4973 // Indicates whether the function is a classic mode function. |
Rico
2011/11/15 08:25:07
I would add "(i.e., classic in the sense that we h
Steven
2011/11/15 13:33:30
Done.
| |
4974 inline bool strict_mode(); | 4974 inline bool is_classic_mode(); |
4975 | 4975 |
4976 // Indicates the mode of the function. | 4976 // Indicates whether the function is an extended mode function. |
4977 inline StrictModeFlag strict_mode_flag(); | 4977 inline bool is_extended_mode(); |
Rico
2011/11/15 08:25:07
Also, please add a comment here (or below for lang
Steven
2011/11/15 13:33:30
Done.
| |
4978 inline void set_strict_mode_flag(StrictModeFlag strict_mode_flag); | 4978 |
4979 // Indicates the language mode of the function. | |
4980 inline LanguageMode language_mode(); | |
4981 inline void set_language_mode(LanguageMode language_mode); | |
4979 | 4982 |
4980 // False if the function definitely does not allocate an arguments object. | 4983 // False if the function definitely does not allocate an arguments object. |
4981 DECL_BOOLEAN_ACCESSORS(uses_arguments) | 4984 DECL_BOOLEAN_ACCESSORS(uses_arguments) |
4982 | 4985 |
4983 // True if the function has any duplicated parameter names. | 4986 // True if the function has any duplicated parameter names. |
4984 DECL_BOOLEAN_ACCESSORS(has_duplicate_parameters) | 4987 DECL_BOOLEAN_ACCESSORS(has_duplicate_parameters) |
4985 | 4988 |
4986 // Indicates whether the function is a native function. | 4989 // Indicates whether the function is a native function. |
4987 // These needs special treatment in .call and .apply since | 4990 // These needs special treatment in .call and .apply since |
4988 // null passed as the receiver should not be translated to the | 4991 // null passed as the receiver should not be translated to the |
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5191 static const int kCodeAgeSize = 3; | 5194 static const int kCodeAgeSize = 3; |
5192 static const int kCodeAgeMask = (1 << kCodeAgeSize) - 1; | 5195 static const int kCodeAgeMask = (1 << kCodeAgeSize) - 1; |
5193 | 5196 |
5194 enum CompilerHints { | 5197 enum CompilerHints { |
5195 kHasOnlySimpleThisPropertyAssignments, | 5198 kHasOnlySimpleThisPropertyAssignments, |
5196 kAllowLazyCompilation, | 5199 kAllowLazyCompilation, |
5197 kLiveObjectsMayExist, | 5200 kLiveObjectsMayExist, |
5198 kCodeAgeShift, | 5201 kCodeAgeShift, |
5199 kOptimizationDisabled = kCodeAgeShift + kCodeAgeSize, | 5202 kOptimizationDisabled = kCodeAgeShift + kCodeAgeSize, |
5200 kStrictModeFunction, | 5203 kStrictModeFunction, |
5204 kExtendedModeFunction, | |
5201 kUsesArguments, | 5205 kUsesArguments, |
5202 kHasDuplicateParameters, | 5206 kHasDuplicateParameters, |
5203 kNative, | 5207 kNative, |
5204 kBoundFunction, | 5208 kBoundFunction, |
5205 kIsAnonymous, | 5209 kIsAnonymous, |
5206 kNameShouldPrintAsAnonymous, | 5210 kNameShouldPrintAsAnonymous, |
5207 kCompilerHintsCount // Pseudo entry | 5211 kCompilerHintsCount // Pseudo entry |
5208 }; | 5212 }; |
5209 | 5213 |
5210 private: | 5214 private: |
(...skipping 10 matching lines...) Expand all Loading... | |
5221 STATIC_ASSERT(SharedFunctionInfo::kCompilerHintsCount <= | 5225 STATIC_ASSERT(SharedFunctionInfo::kCompilerHintsCount <= |
5222 SharedFunctionInfo::kCompilerHintsSize * kBitsPerByte); | 5226 SharedFunctionInfo::kCompilerHintsSize * kBitsPerByte); |
5223 | 5227 |
5224 public: | 5228 public: |
5225 // Constants for optimizing codegen for strict mode function and | 5229 // Constants for optimizing codegen for strict mode function and |
5226 // native tests. | 5230 // native tests. |
5227 // Allows to use byte-width instructions. | 5231 // Allows to use byte-width instructions. |
5228 static const int kStrictModeBitWithinByte = | 5232 static const int kStrictModeBitWithinByte = |
5229 (kStrictModeFunction + kCompilerHintsSmiTagSize) % kBitsPerByte; | 5233 (kStrictModeFunction + kCompilerHintsSmiTagSize) % kBitsPerByte; |
5230 | 5234 |
5235 static const int kExtendedModeBitWithinByte = | |
5236 (kExtendedModeFunction + kCompilerHintsSmiTagSize) % kBitsPerByte; | |
5237 | |
5231 static const int kNativeBitWithinByte = | 5238 static const int kNativeBitWithinByte = |
5232 (kNative + kCompilerHintsSmiTagSize) % kBitsPerByte; | 5239 (kNative + kCompilerHintsSmiTagSize) % kBitsPerByte; |
5233 | 5240 |
5234 #if __BYTE_ORDER == __LITTLE_ENDIAN | 5241 #if __BYTE_ORDER == __LITTLE_ENDIAN |
5235 static const int kStrictModeByteOffset = kCompilerHintsOffset + | 5242 static const int kStrictModeByteOffset = kCompilerHintsOffset + |
5236 (kStrictModeFunction + kCompilerHintsSmiTagSize) / kBitsPerByte; | 5243 (kStrictModeFunction + kCompilerHintsSmiTagSize) / kBitsPerByte; |
5244 static const int kExtendedModeByteOffset = kCompilerHintsOffset + | |
5245 (kExtendedModeFunction + kCompilerHintsSmiTagSize) / kBitsPerByte; | |
5237 static const int kNativeByteOffset = kCompilerHintsOffset + | 5246 static const int kNativeByteOffset = kCompilerHintsOffset + |
5238 (kNative + kCompilerHintsSmiTagSize) / kBitsPerByte; | 5247 (kNative + kCompilerHintsSmiTagSize) / kBitsPerByte; |
5239 #elif __BYTE_ORDER == __BIG_ENDIAN | 5248 #elif __BYTE_ORDER == __BIG_ENDIAN |
5240 static const int kStrictModeByteOffset = kCompilerHintsOffset + | 5249 static const int kStrictModeByteOffset = kCompilerHintsOffset + |
5241 (kCompilerHintsSize - 1) - | 5250 (kCompilerHintsSize - 1) - |
5242 ((kStrictModeFunction + kCompilerHintsSmiTagSize) / kBitsPerByte); | 5251 ((kStrictModeFunction + kCompilerHintsSmiTagSize) / kBitsPerByte); |
5252 static const int kExtendedModeByteOffset = kCompilerHintsOffset + | |
5253 (kCompilerHintsSize - 1) - | |
5254 ((kExtendedModeFunction + kCompilerHintsSmiTagSize) / kBitsPerByte); | |
5243 static const int kNativeByteOffset = kCompilerHintsOffset + | 5255 static const int kNativeByteOffset = kCompilerHintsOffset + |
5244 (kCompilerHintsSize - 1) - | 5256 (kCompilerHintsSize - 1) - |
5245 ((kNative + kCompilerHintsSmiTagSize) / kBitsPerByte); | 5257 ((kNative + kCompilerHintsSmiTagSize) / kBitsPerByte); |
5246 #else | 5258 #else |
5247 #error Unknown byte ordering | 5259 #error Unknown byte ordering |
5248 #endif | 5260 #endif |
5249 | 5261 |
5250 private: | 5262 private: |
5251 DISALLOW_IMPLICIT_CONSTRUCTORS(SharedFunctionInfo); | 5263 DISALLOW_IMPLICIT_CONSTRUCTORS(SharedFunctionInfo); |
5252 }; | 5264 }; |
(...skipping 596 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5849 }; | 5861 }; |
5850 | 5862 |
5851 | 5863 |
5852 class CompilationCacheTable: public HashTable<CompilationCacheShape, | 5864 class CompilationCacheTable: public HashTable<CompilationCacheShape, |
5853 HashTableKey*> { | 5865 HashTableKey*> { |
5854 public: | 5866 public: |
5855 // Find cached value for a string key, otherwise return null. | 5867 // Find cached value for a string key, otherwise return null. |
5856 Object* Lookup(String* src); | 5868 Object* Lookup(String* src); |
5857 Object* LookupEval(String* src, | 5869 Object* LookupEval(String* src, |
5858 Context* context, | 5870 Context* context, |
5859 StrictModeFlag strict_mode, | 5871 LanguageMode language_mode, |
5860 int scope_position); | 5872 int scope_position); |
5861 Object* LookupRegExp(String* source, JSRegExp::Flags flags); | 5873 Object* LookupRegExp(String* source, JSRegExp::Flags flags); |
5862 MaybeObject* Put(String* src, Object* value); | 5874 MaybeObject* Put(String* src, Object* value); |
5863 MaybeObject* PutEval(String* src, | 5875 MaybeObject* PutEval(String* src, |
5864 Context* context, | 5876 Context* context, |
5865 SharedFunctionInfo* value, | 5877 SharedFunctionInfo* value, |
5866 int scope_position); | 5878 int scope_position); |
5867 MaybeObject* PutRegExp(String* src, JSRegExp::Flags flags, FixedArray* value); | 5879 MaybeObject* PutRegExp(String* src, JSRegExp::Flags flags, FixedArray* value); |
5868 | 5880 |
5869 // Remove given value from cache. | 5881 // Remove given value from cache. |
(...skipping 2005 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
7875 } else { | 7887 } else { |
7876 value &= ~(1 << bit_position); | 7888 value &= ~(1 << bit_position); |
7877 } | 7889 } |
7878 return value; | 7890 return value; |
7879 } | 7891 } |
7880 }; | 7892 }; |
7881 | 7893 |
7882 } } // namespace v8::internal | 7894 } } // namespace v8::internal |
7883 | 7895 |
7884 #endif // V8_OBJECTS_H_ | 7896 #endif // V8_OBJECTS_H_ |
OLD | NEW |