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

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: Rebased version. 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
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 3096 matching lines...) Expand 10 before | Expand all | Expand 10 after
3107 class ScopeInfo : public FixedArray { 3107 class ScopeInfo : public FixedArray {
3108 public: 3108 public:
3109 static inline ScopeInfo* cast(Object* object); 3109 static inline ScopeInfo* cast(Object* object);
3110 3110
3111 // Return the type of this scope. 3111 // Return the type of this scope.
3112 ScopeType Type(); 3112 ScopeType Type();
3113 3113
3114 // Does this scope call eval? 3114 // Does this scope call eval?
3115 bool CallsEval(); 3115 bool CallsEval();
3116 3116
3117 // Is this scope a strict mode scope? 3117 // Return the language mode of this scope.
3118 bool IsStrictMode(); 3118 LanguageMode language_mode();
3119 3119
3120 // Does this scope make a non-strict eval call? 3120 // Does this scope make a non-strict eval call?
3121 bool CallsNonStrictEval() { 3121 bool CallsNonStrictEval() {
3122 return CallsEval() && !IsStrictMode(); 3122 return CallsEval() && (language_mode() == CLASSIC_MODE);
3123 } 3123 }
3124 3124
3125 // Return the total number of locals allocated on the stack and in the 3125 // Return the total number of locals allocated on the stack and in the
3126 // context. This includes the parameters that are allocated in the context. 3126 // context. This includes the parameters that are allocated in the context.
3127 int LocalCount(); 3127 int LocalCount();
3128 3128
3129 // Return the number of stack slots for code. This number consists of two 3129 // Return the number of stack slots for code. This number consists of two
3130 // parts: 3130 // parts:
3131 // 1. One stack slot per stack allocated local. 3131 // 1. One stack slot per stack allocated local.
3132 // 2. One stack slot for the function name if it is stack allocated. 3132 // 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
3280 enum FunctionVariableInfo { 3280 enum FunctionVariableInfo {
3281 NONE, // No function name present. 3281 NONE, // No function name present.
3282 STACK, // Function 3282 STACK, // Function
3283 CONTEXT, 3283 CONTEXT,
3284 UNUSED 3284 UNUSED
3285 }; 3285 };
3286 3286
3287 // Properties of scopes. 3287 // Properties of scopes.
3288 class TypeField: public BitField<ScopeType, 0, 3> {}; 3288 class TypeField: public BitField<ScopeType, 0, 3> {};
3289 class CallsEvalField: public BitField<bool, 3, 1> {}; 3289 class CallsEvalField: public BitField<bool, 3, 1> {};
3290 class StrictModeField: public BitField<bool, 4, 1> {}; 3290 class LanguageModeField: public BitField<LanguageMode, 4, 2> {};
3291 class FunctionVariableField: public BitField<FunctionVariableInfo, 5, 2> {}; 3291 class FunctionVariableField: public BitField<FunctionVariableInfo, 6, 2> {};
3292 class FunctionVariableMode: public BitField<VariableMode, 7, 3> {}; 3292 class FunctionVariableMode: public BitField<VariableMode, 8, 3> {};
3293 3293
3294 // BitFields representing the encoded information for context locals in the 3294 // BitFields representing the encoded information for context locals in the
3295 // ContextLocalInfoEntries part. 3295 // ContextLocalInfoEntries part.
3296 class ContextLocalMode: public BitField<VariableMode, 0, 3> {}; 3296 class ContextLocalMode: public BitField<VariableMode, 0, 3> {};
3297 class ContextLocalInitFlag: public BitField<InitializationFlag, 3, 1> {}; 3297 class ContextLocalInitFlag: public BitField<InitializationFlag, 3, 1> {};
3298 }; 3298 };
3299 3299
3300 3300
3301 // The cache for maps used by normalized (dictionary mode) objects. 3301 // The cache for maps used by normalized (dictionary mode) objects.
3302 // Such maps do not have property descriptors, so a typical program 3302 // Such maps do not have property descriptors, so a typical program
(...skipping 1729 matching lines...) Expand 10 before | Expand all | Expand 10 after
5032 // from the stack or compilation cache. 5032 // from the stack or compilation cache.
5033 inline int code_age(); 5033 inline int code_age();
5034 inline void set_code_age(int age); 5034 inline void set_code_age(int age);
5035 5035
5036 // Indicates whether optimizations have been disabled for this 5036 // Indicates whether optimizations have been disabled for this
5037 // shared function info. If a function is repeatedly optimized or if 5037 // shared function info. If a function is repeatedly optimized or if
5038 // we cannot optimize the function we disable optimization to avoid 5038 // we cannot optimize the function we disable optimization to avoid
5039 // spending time attempting to optimize it again. 5039 // spending time attempting to optimize it again.
5040 DECL_BOOLEAN_ACCESSORS(optimization_disabled) 5040 DECL_BOOLEAN_ACCESSORS(optimization_disabled)
5041 5041
5042 // Indicates whether the function is a classic mode function.
5043 inline bool is_classic_mode();
5044
5045 // Indicates whether the function is an extended mode function.
5046 inline bool is_extended_mode();
5047
5042 // Indicates whether the function is a strict mode function. 5048 // Indicates whether the function is a strict mode function.
5043 inline bool strict_mode(); 5049 inline bool is_strict_or_extended_mode();
5044 5050
5045 // Indicates the mode of the function. 5051 // Indicates the language mode of the function.
5046 inline StrictModeFlag strict_mode_flag(); 5052 inline LanguageMode language_mode();
5047 inline void set_strict_mode_flag(StrictModeFlag strict_mode_flag); 5053 inline void set_language_mode(LanguageMode language_mode);
5048 5054
5049 // False if the function definitely does not allocate an arguments object. 5055 // False if the function definitely does not allocate an arguments object.
5050 DECL_BOOLEAN_ACCESSORS(uses_arguments) 5056 DECL_BOOLEAN_ACCESSORS(uses_arguments)
5051 5057
5052 // True if the function has any duplicated parameter names. 5058 // True if the function has any duplicated parameter names.
5053 DECL_BOOLEAN_ACCESSORS(has_duplicate_parameters) 5059 DECL_BOOLEAN_ACCESSORS(has_duplicate_parameters)
5054 5060
5055 // Indicates whether the function is a native function. 5061 // Indicates whether the function is a native function.
5056 // These needs special treatment in .call and .apply since 5062 // These needs special treatment in .call and .apply since
5057 // null passed as the receiver should not be translated to the 5063 // null passed as the receiver should not be translated to the
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
5260 static const int kCodeAgeSize = 3; 5266 static const int kCodeAgeSize = 3;
5261 static const int kCodeAgeMask = (1 << kCodeAgeSize) - 1; 5267 static const int kCodeAgeMask = (1 << kCodeAgeSize) - 1;
5262 5268
5263 enum CompilerHints { 5269 enum CompilerHints {
5264 kHasOnlySimpleThisPropertyAssignments, 5270 kHasOnlySimpleThisPropertyAssignments,
5265 kAllowLazyCompilation, 5271 kAllowLazyCompilation,
5266 kLiveObjectsMayExist, 5272 kLiveObjectsMayExist,
5267 kCodeAgeShift, 5273 kCodeAgeShift,
5268 kOptimizationDisabled = kCodeAgeShift + kCodeAgeSize, 5274 kOptimizationDisabled = kCodeAgeShift + kCodeAgeSize,
5269 kStrictModeFunction, 5275 kStrictModeFunction,
5276 kExtendedModeFunction,
5270 kUsesArguments, 5277 kUsesArguments,
5271 kHasDuplicateParameters, 5278 kHasDuplicateParameters,
5272 kNative, 5279 kNative,
5273 kBoundFunction, 5280 kBoundFunction,
5274 kIsAnonymous, 5281 kIsAnonymous,
5275 kNameShouldPrintAsAnonymous, 5282 kNameShouldPrintAsAnonymous,
5276 kCompilerHintsCount // Pseudo entry 5283 kCompilerHintsCount // Pseudo entry
5277 }; 5284 };
5278 5285
5279 private: 5286 private:
(...skipping 10 matching lines...) Expand all
5290 STATIC_ASSERT(SharedFunctionInfo::kCompilerHintsCount <= 5297 STATIC_ASSERT(SharedFunctionInfo::kCompilerHintsCount <=
5291 SharedFunctionInfo::kCompilerHintsSize * kBitsPerByte); 5298 SharedFunctionInfo::kCompilerHintsSize * kBitsPerByte);
5292 5299
5293 public: 5300 public:
5294 // Constants for optimizing codegen for strict mode function and 5301 // Constants for optimizing codegen for strict mode function and
5295 // native tests. 5302 // native tests.
5296 // Allows to use byte-width instructions. 5303 // Allows to use byte-width instructions.
5297 static const int kStrictModeBitWithinByte = 5304 static const int kStrictModeBitWithinByte =
5298 (kStrictModeFunction + kCompilerHintsSmiTagSize) % kBitsPerByte; 5305 (kStrictModeFunction + kCompilerHintsSmiTagSize) % kBitsPerByte;
5299 5306
5307 static const int kExtendedModeBitWithinByte =
5308 (kExtendedModeFunction + kCompilerHintsSmiTagSize) % kBitsPerByte;
5309
5300 static const int kNativeBitWithinByte = 5310 static const int kNativeBitWithinByte =
5301 (kNative + kCompilerHintsSmiTagSize) % kBitsPerByte; 5311 (kNative + kCompilerHintsSmiTagSize) % kBitsPerByte;
5302 5312
5303 #if __BYTE_ORDER == __LITTLE_ENDIAN 5313 #if __BYTE_ORDER == __LITTLE_ENDIAN
5304 static const int kStrictModeByteOffset = kCompilerHintsOffset + 5314 static const int kStrictModeByteOffset = kCompilerHintsOffset +
5305 (kStrictModeFunction + kCompilerHintsSmiTagSize) / kBitsPerByte; 5315 (kStrictModeFunction + kCompilerHintsSmiTagSize) / kBitsPerByte;
5316 static const int kExtendedModeByteOffset = kCompilerHintsOffset +
5317 (kExtendedModeFunction + kCompilerHintsSmiTagSize) / kBitsPerByte;
5306 static const int kNativeByteOffset = kCompilerHintsOffset + 5318 static const int kNativeByteOffset = kCompilerHintsOffset +
5307 (kNative + kCompilerHintsSmiTagSize) / kBitsPerByte; 5319 (kNative + kCompilerHintsSmiTagSize) / kBitsPerByte;
5308 #elif __BYTE_ORDER == __BIG_ENDIAN 5320 #elif __BYTE_ORDER == __BIG_ENDIAN
5309 static const int kStrictModeByteOffset = kCompilerHintsOffset + 5321 static const int kStrictModeByteOffset = kCompilerHintsOffset +
5310 (kCompilerHintsSize - 1) - 5322 (kCompilerHintsSize - 1) -
5311 ((kStrictModeFunction + kCompilerHintsSmiTagSize) / kBitsPerByte); 5323 ((kStrictModeFunction + kCompilerHintsSmiTagSize) / kBitsPerByte);
5324 static const int kExtendedModeByteOffset = kCompilerHintsOffset +
5325 (kCompilerHintsSize - 1) -
5326 ((kExtendedModeFunction + kCompilerHintsSmiTagSize) / kBitsPerByte);
5312 static const int kNativeByteOffset = kCompilerHintsOffset + 5327 static const int kNativeByteOffset = kCompilerHintsOffset +
5313 (kCompilerHintsSize - 1) - 5328 (kCompilerHintsSize - 1) -
5314 ((kNative + kCompilerHintsSmiTagSize) / kBitsPerByte); 5329 ((kNative + kCompilerHintsSmiTagSize) / kBitsPerByte);
5315 #else 5330 #else
5316 #error Unknown byte ordering 5331 #error Unknown byte ordering
5317 #endif 5332 #endif
5318 5333
5319 private: 5334 private:
5320 DISALLOW_IMPLICIT_CONSTRUCTORS(SharedFunctionInfo); 5335 DISALLOW_IMPLICIT_CONSTRUCTORS(SharedFunctionInfo);
5321 }; 5336 };
(...skipping 594 matching lines...) Expand 10 before | Expand all | Expand 10 after
5916 static const int kPrefixSize = 0; 5931 static const int kPrefixSize = 0;
5917 static const int kEntrySize = 2; 5932 static const int kEntrySize = 2;
5918 }; 5933 };
5919 5934
5920 5935
5921 class CompilationCacheTable: public HashTable<CompilationCacheShape, 5936 class CompilationCacheTable: public HashTable<CompilationCacheShape,
5922 HashTableKey*> { 5937 HashTableKey*> {
5923 public: 5938 public:
5924 // Find cached value for a string key, otherwise return null. 5939 // Find cached value for a string key, otherwise return null.
5925 Object* Lookup(String* src); 5940 Object* Lookup(String* src);
5926 Object* LookupEval(String* src, Context* context, StrictModeFlag strict_mode); 5941 Object* LookupEval(String* src, Context* context, LanguageMode language_mode);
5927 Object* LookupRegExp(String* source, JSRegExp::Flags flags); 5942 Object* LookupRegExp(String* source, JSRegExp::Flags flags);
5928 MaybeObject* Put(String* src, Object* value); 5943 MaybeObject* Put(String* src, Object* value);
5929 MaybeObject* PutEval(String* src, 5944 MaybeObject* PutEval(String* src,
5930 Context* context, 5945 Context* context,
5931 SharedFunctionInfo* value); 5946 SharedFunctionInfo* value);
5932 MaybeObject* PutRegExp(String* src, JSRegExp::Flags flags, FixedArray* value); 5947 MaybeObject* PutRegExp(String* src, JSRegExp::Flags flags, FixedArray* value);
5933 5948
5934 // Remove given value from cache. 5949 // Remove given value from cache.
5935 void Remove(Object* value); 5950 void Remove(Object* value);
5936 5951
(...skipping 2001 matching lines...) Expand 10 before | Expand all | Expand 10 after
7938 } else { 7953 } else {
7939 value &= ~(1 << bit_position); 7954 value &= ~(1 << bit_position);
7940 } 7955 }
7941 return value; 7956 return value;
7942 } 7957 }
7943 }; 7958 };
7944 7959
7945 } } // namespace v8::internal 7960 } } // namespace v8::internal
7946 7961
7947 #endif // V8_OBJECTS_H_ 7962 #endif // V8_OBJECTS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698