Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(111)

Side by Side Diff: src/objects.h

Issue 8417035: Introduce extended mode. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressed more comments. Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/mips/stub-cache-mips.cc ('k') | src/objects.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
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 the language mode of the function's code as defined by the
4974 inline bool strict_mode(); 4974 // current harmony drafts for the next ES language standard. Possible
4975 // values are:
4976 // 1. CLASSIC_MODE - Unrestricted syntax and semantics, same as in ES5.
4977 // 2. STRICT_MODE - Restricted syntax and semantics, same as in ES5.
4978 // 3. EXTENDED_MODE - Only available under the harmony flag, not part of ES5.
4979 inline LanguageMode language_mode();
4980 inline void set_language_mode(LanguageMode language_mode);
4975 4981
4976 // Indicates the mode of the function. 4982 // Indicates whether the language mode of this function is CLASSIC_MODE.
4977 inline StrictModeFlag strict_mode_flag(); 4983 inline bool is_classic_mode();
4978 inline void set_strict_mode_flag(StrictModeFlag strict_mode_flag); 4984
4985 // Indicates whether the language mode of this function is EXTENDED_MODE.
4986 inline bool is_extended_mode();
4979 4987
4980 // False if the function definitely does not allocate an arguments object. 4988 // False if the function definitely does not allocate an arguments object.
4981 DECL_BOOLEAN_ACCESSORS(uses_arguments) 4989 DECL_BOOLEAN_ACCESSORS(uses_arguments)
4982 4990
4983 // True if the function has any duplicated parameter names. 4991 // True if the function has any duplicated parameter names.
4984 DECL_BOOLEAN_ACCESSORS(has_duplicate_parameters) 4992 DECL_BOOLEAN_ACCESSORS(has_duplicate_parameters)
4985 4993
4986 // Indicates whether the function is a native function. 4994 // Indicates whether the function is a native function.
4987 // These needs special treatment in .call and .apply since 4995 // These needs special treatment in .call and .apply since
4988 // null passed as the receiver should not be translated to the 4996 // null passed as the receiver should not be translated to the
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
5191 static const int kCodeAgeSize = 3; 5199 static const int kCodeAgeSize = 3;
5192 static const int kCodeAgeMask = (1 << kCodeAgeSize) - 1; 5200 static const int kCodeAgeMask = (1 << kCodeAgeSize) - 1;
5193 5201
5194 enum CompilerHints { 5202 enum CompilerHints {
5195 kHasOnlySimpleThisPropertyAssignments, 5203 kHasOnlySimpleThisPropertyAssignments,
5196 kAllowLazyCompilation, 5204 kAllowLazyCompilation,
5197 kLiveObjectsMayExist, 5205 kLiveObjectsMayExist,
5198 kCodeAgeShift, 5206 kCodeAgeShift,
5199 kOptimizationDisabled = kCodeAgeShift + kCodeAgeSize, 5207 kOptimizationDisabled = kCodeAgeShift + kCodeAgeSize,
5200 kStrictModeFunction, 5208 kStrictModeFunction,
5209 kExtendedModeFunction,
5201 kUsesArguments, 5210 kUsesArguments,
5202 kHasDuplicateParameters, 5211 kHasDuplicateParameters,
5203 kNative, 5212 kNative,
5204 kBoundFunction, 5213 kBoundFunction,
5205 kIsAnonymous, 5214 kIsAnonymous,
5206 kNameShouldPrintAsAnonymous, 5215 kNameShouldPrintAsAnonymous,
5207 kCompilerHintsCount // Pseudo entry 5216 kCompilerHintsCount // Pseudo entry
5208 }; 5217 };
5209 5218
5210 private: 5219 private:
(...skipping 10 matching lines...) Expand all
5221 STATIC_ASSERT(SharedFunctionInfo::kCompilerHintsCount <= 5230 STATIC_ASSERT(SharedFunctionInfo::kCompilerHintsCount <=
5222 SharedFunctionInfo::kCompilerHintsSize * kBitsPerByte); 5231 SharedFunctionInfo::kCompilerHintsSize * kBitsPerByte);
5223 5232
5224 public: 5233 public:
5225 // Constants for optimizing codegen for strict mode function and 5234 // Constants for optimizing codegen for strict mode function and
5226 // native tests. 5235 // native tests.
5227 // Allows to use byte-width instructions. 5236 // Allows to use byte-width instructions.
5228 static const int kStrictModeBitWithinByte = 5237 static const int kStrictModeBitWithinByte =
5229 (kStrictModeFunction + kCompilerHintsSmiTagSize) % kBitsPerByte; 5238 (kStrictModeFunction + kCompilerHintsSmiTagSize) % kBitsPerByte;
5230 5239
5240 static const int kExtendedModeBitWithinByte =
5241 (kExtendedModeFunction + kCompilerHintsSmiTagSize) % kBitsPerByte;
5242
5231 static const int kNativeBitWithinByte = 5243 static const int kNativeBitWithinByte =
5232 (kNative + kCompilerHintsSmiTagSize) % kBitsPerByte; 5244 (kNative + kCompilerHintsSmiTagSize) % kBitsPerByte;
5233 5245
5234 #if __BYTE_ORDER == __LITTLE_ENDIAN 5246 #if __BYTE_ORDER == __LITTLE_ENDIAN
5235 static const int kStrictModeByteOffset = kCompilerHintsOffset + 5247 static const int kStrictModeByteOffset = kCompilerHintsOffset +
5236 (kStrictModeFunction + kCompilerHintsSmiTagSize) / kBitsPerByte; 5248 (kStrictModeFunction + kCompilerHintsSmiTagSize) / kBitsPerByte;
5249 static const int kExtendedModeByteOffset = kCompilerHintsOffset +
5250 (kExtendedModeFunction + kCompilerHintsSmiTagSize) / kBitsPerByte;
5237 static const int kNativeByteOffset = kCompilerHintsOffset + 5251 static const int kNativeByteOffset = kCompilerHintsOffset +
5238 (kNative + kCompilerHintsSmiTagSize) / kBitsPerByte; 5252 (kNative + kCompilerHintsSmiTagSize) / kBitsPerByte;
5239 #elif __BYTE_ORDER == __BIG_ENDIAN 5253 #elif __BYTE_ORDER == __BIG_ENDIAN
5240 static const int kStrictModeByteOffset = kCompilerHintsOffset + 5254 static const int kStrictModeByteOffset = kCompilerHintsOffset +
5241 (kCompilerHintsSize - 1) - 5255 (kCompilerHintsSize - 1) -
5242 ((kStrictModeFunction + kCompilerHintsSmiTagSize) / kBitsPerByte); 5256 ((kStrictModeFunction + kCompilerHintsSmiTagSize) / kBitsPerByte);
5257 static const int kExtendedModeByteOffset = kCompilerHintsOffset +
5258 (kCompilerHintsSize - 1) -
5259 ((kExtendedModeFunction + kCompilerHintsSmiTagSize) / kBitsPerByte);
5243 static const int kNativeByteOffset = kCompilerHintsOffset + 5260 static const int kNativeByteOffset = kCompilerHintsOffset +
5244 (kCompilerHintsSize - 1) - 5261 (kCompilerHintsSize - 1) -
5245 ((kNative + kCompilerHintsSmiTagSize) / kBitsPerByte); 5262 ((kNative + kCompilerHintsSmiTagSize) / kBitsPerByte);
5246 #else 5263 #else
5247 #error Unknown byte ordering 5264 #error Unknown byte ordering
5248 #endif 5265 #endif
5249 5266
5250 private: 5267 private:
5251 DISALLOW_IMPLICIT_CONSTRUCTORS(SharedFunctionInfo); 5268 DISALLOW_IMPLICIT_CONSTRUCTORS(SharedFunctionInfo);
5252 }; 5269 };
(...skipping 596 matching lines...) Expand 10 before | Expand all | Expand 10 after
5849 }; 5866 };
5850 5867
5851 5868
5852 class CompilationCacheTable: public HashTable<CompilationCacheShape, 5869 class CompilationCacheTable: public HashTable<CompilationCacheShape,
5853 HashTableKey*> { 5870 HashTableKey*> {
5854 public: 5871 public:
5855 // Find cached value for a string key, otherwise return null. 5872 // Find cached value for a string key, otherwise return null.
5856 Object* Lookup(String* src); 5873 Object* Lookup(String* src);
5857 Object* LookupEval(String* src, 5874 Object* LookupEval(String* src,
5858 Context* context, 5875 Context* context,
5859 StrictModeFlag strict_mode, 5876 LanguageMode language_mode,
5860 int scope_position); 5877 int scope_position);
5861 Object* LookupRegExp(String* source, JSRegExp::Flags flags); 5878 Object* LookupRegExp(String* source, JSRegExp::Flags flags);
5862 MaybeObject* Put(String* src, Object* value); 5879 MaybeObject* Put(String* src, Object* value);
5863 MaybeObject* PutEval(String* src, 5880 MaybeObject* PutEval(String* src,
5864 Context* context, 5881 Context* context,
5865 SharedFunctionInfo* value, 5882 SharedFunctionInfo* value,
5866 int scope_position); 5883 int scope_position);
5867 MaybeObject* PutRegExp(String* src, JSRegExp::Flags flags, FixedArray* value); 5884 MaybeObject* PutRegExp(String* src, JSRegExp::Flags flags, FixedArray* value);
5868 5885
5869 // Remove given value from cache. 5886 // Remove given value from cache.
(...skipping 2005 matching lines...) Expand 10 before | Expand all | Expand 10 after
7875 } else { 7892 } else {
7876 value &= ~(1 << bit_position); 7893 value &= ~(1 << bit_position);
7877 } 7894 }
7878 return value; 7895 return value;
7879 } 7896 }
7880 }; 7897 };
7881 7898
7882 } } // namespace v8::internal 7899 } } // namespace v8::internal
7883 7900
7884 #endif // V8_OBJECTS_H_ 7901 #endif // V8_OBJECTS_H_
OLDNEW
« no previous file with comments | « src/mips/stub-cache-mips.cc ('k') | src/objects.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698