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

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 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/ic.cc ('k') | src/objects.cc » ('j') | src/objects.cc » ('J')
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 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 strict mode function. 5042 // Indicates whether the function is a classic mode function.
5043 inline bool strict_mode(); 5043 inline bool is_classic_mode();
5044 5044
5045 // Indicates the mode of the function. 5045 // Indicates whether the function is an extended mode function.
5046 inline StrictModeFlag strict_mode_flag(); 5046 inline bool is_extended_mode();
5047 inline void set_strict_mode_flag(StrictModeFlag strict_mode_flag); 5047
5048 // Indicates the language mode of the function.
5049 inline LanguageMode language_mode();
5050 inline void set_language_mode(LanguageMode language_mode);
5048 5051
5049 // False if the function definitely does not allocate an arguments object. 5052 // False if the function definitely does not allocate an arguments object.
5050 DECL_BOOLEAN_ACCESSORS(uses_arguments) 5053 DECL_BOOLEAN_ACCESSORS(uses_arguments)
5051 5054
5052 // True if the function has any duplicated parameter names. 5055 // True if the function has any duplicated parameter names.
5053 DECL_BOOLEAN_ACCESSORS(has_duplicate_parameters) 5056 DECL_BOOLEAN_ACCESSORS(has_duplicate_parameters)
5054 5057
5055 // Indicates whether the function is a native function. 5058 // Indicates whether the function is a native function.
5056 // These needs special treatment in .call and .apply since 5059 // These needs special treatment in .call and .apply since
5057 // null passed as the receiver should not be translated to the 5060 // 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; 5263 static const int kCodeAgeSize = 3;
5261 static const int kCodeAgeMask = (1 << kCodeAgeSize) - 1; 5264 static const int kCodeAgeMask = (1 << kCodeAgeSize) - 1;
5262 5265
5263 enum CompilerHints { 5266 enum CompilerHints {
5264 kHasOnlySimpleThisPropertyAssignments, 5267 kHasOnlySimpleThisPropertyAssignments,
5265 kAllowLazyCompilation, 5268 kAllowLazyCompilation,
5266 kLiveObjectsMayExist, 5269 kLiveObjectsMayExist,
5267 kCodeAgeShift, 5270 kCodeAgeShift,
5268 kOptimizationDisabled = kCodeAgeShift + kCodeAgeSize, 5271 kOptimizationDisabled = kCodeAgeShift + kCodeAgeSize,
5269 kStrictModeFunction, 5272 kStrictModeFunction,
5273 kExtendedModeFunction,
5270 kUsesArguments, 5274 kUsesArguments,
5271 kHasDuplicateParameters, 5275 kHasDuplicateParameters,
5272 kNative, 5276 kNative,
5273 kBoundFunction, 5277 kBoundFunction,
5274 kIsAnonymous, 5278 kIsAnonymous,
5275 kNameShouldPrintAsAnonymous, 5279 kNameShouldPrintAsAnonymous,
5276 kCompilerHintsCount // Pseudo entry 5280 kCompilerHintsCount // Pseudo entry
5277 }; 5281 };
5278 5282
5279 private: 5283 private:
(...skipping 10 matching lines...) Expand all
5290 STATIC_ASSERT(SharedFunctionInfo::kCompilerHintsCount <= 5294 STATIC_ASSERT(SharedFunctionInfo::kCompilerHintsCount <=
5291 SharedFunctionInfo::kCompilerHintsSize * kBitsPerByte); 5295 SharedFunctionInfo::kCompilerHintsSize * kBitsPerByte);
5292 5296
5293 public: 5297 public:
5294 // Constants for optimizing codegen for strict mode function and 5298 // Constants for optimizing codegen for strict mode function and
5295 // native tests. 5299 // native tests.
5296 // Allows to use byte-width instructions. 5300 // Allows to use byte-width instructions.
5297 static const int kStrictModeBitWithinByte = 5301 static const int kStrictModeBitWithinByte =
5298 (kStrictModeFunction + kCompilerHintsSmiTagSize) % kBitsPerByte; 5302 (kStrictModeFunction + kCompilerHintsSmiTagSize) % kBitsPerByte;
5299 5303
5304 static const int kExtendedModeBitWithinByte =
5305 (kExtendedModeFunction + kCompilerHintsSmiTagSize) % kBitsPerByte;
5306
5300 static const int kNativeBitWithinByte = 5307 static const int kNativeBitWithinByte =
5301 (kNative + kCompilerHintsSmiTagSize) % kBitsPerByte; 5308 (kNative + kCompilerHintsSmiTagSize) % kBitsPerByte;
5302 5309
5303 #if __BYTE_ORDER == __LITTLE_ENDIAN 5310 #if __BYTE_ORDER == __LITTLE_ENDIAN
5304 static const int kStrictModeByteOffset = kCompilerHintsOffset + 5311 static const int kStrictModeByteOffset = kCompilerHintsOffset +
5305 (kStrictModeFunction + kCompilerHintsSmiTagSize) / kBitsPerByte; 5312 (kStrictModeFunction + kCompilerHintsSmiTagSize) / kBitsPerByte;
5313 static const int kExtendedModeByteOffset = kCompilerHintsOffset +
5314 (kExtendedModeFunction + kCompilerHintsSmiTagSize) / kBitsPerByte;
5306 static const int kNativeByteOffset = kCompilerHintsOffset + 5315 static const int kNativeByteOffset = kCompilerHintsOffset +
5307 (kNative + kCompilerHintsSmiTagSize) / kBitsPerByte; 5316 (kNative + kCompilerHintsSmiTagSize) / kBitsPerByte;
5308 #elif __BYTE_ORDER == __BIG_ENDIAN 5317 #elif __BYTE_ORDER == __BIG_ENDIAN
5309 static const int kStrictModeByteOffset = kCompilerHintsOffset + 5318 static const int kStrictModeByteOffset = kCompilerHintsOffset +
5310 (kCompilerHintsSize - 1) - 5319 (kCompilerHintsSize - 1) -
5311 ((kStrictModeFunction + kCompilerHintsSmiTagSize) / kBitsPerByte); 5320 ((kStrictModeFunction + kCompilerHintsSmiTagSize) / kBitsPerByte);
5321 static const int kExtendedModeByteOffset = kCompilerHintsOffset +
5322 (kCompilerHintsSize - 1) -
5323 ((kExtendedModeFunction + kCompilerHintsSmiTagSize) / kBitsPerByte);
5312 static const int kNativeByteOffset = kCompilerHintsOffset + 5324 static const int kNativeByteOffset = kCompilerHintsOffset +
5313 (kCompilerHintsSize - 1) - 5325 (kCompilerHintsSize - 1) -
5314 ((kNative + kCompilerHintsSmiTagSize) / kBitsPerByte); 5326 ((kNative + kCompilerHintsSmiTagSize) / kBitsPerByte);
5315 #else 5327 #else
5316 #error Unknown byte ordering 5328 #error Unknown byte ordering
5317 #endif 5329 #endif
5318 5330
5319 private: 5331 private:
5320 DISALLOW_IMPLICIT_CONSTRUCTORS(SharedFunctionInfo); 5332 DISALLOW_IMPLICIT_CONSTRUCTORS(SharedFunctionInfo);
5321 }; 5333 };
(...skipping 594 matching lines...) Expand 10 before | Expand all | Expand 10 after
5916 static const int kPrefixSize = 0; 5928 static const int kPrefixSize = 0;
5917 static const int kEntrySize = 2; 5929 static const int kEntrySize = 2;
5918 }; 5930 };
5919 5931
5920 5932
5921 class CompilationCacheTable: public HashTable<CompilationCacheShape, 5933 class CompilationCacheTable: public HashTable<CompilationCacheShape,
5922 HashTableKey*> { 5934 HashTableKey*> {
5923 public: 5935 public:
5924 // Find cached value for a string key, otherwise return null. 5936 // Find cached value for a string key, otherwise return null.
5925 Object* Lookup(String* src); 5937 Object* Lookup(String* src);
5926 Object* LookupEval(String* src, Context* context, StrictModeFlag strict_mode); 5938 Object* LookupEval(String* src, Context* context, LanguageMode language_mode);
5927 Object* LookupRegExp(String* source, JSRegExp::Flags flags); 5939 Object* LookupRegExp(String* source, JSRegExp::Flags flags);
5928 MaybeObject* Put(String* src, Object* value); 5940 MaybeObject* Put(String* src, Object* value);
5929 MaybeObject* PutEval(String* src, 5941 MaybeObject* PutEval(String* src,
5930 Context* context, 5942 Context* context,
5931 SharedFunctionInfo* value); 5943 SharedFunctionInfo* value);
5932 MaybeObject* PutRegExp(String* src, JSRegExp::Flags flags, FixedArray* value); 5944 MaybeObject* PutRegExp(String* src, JSRegExp::Flags flags, FixedArray* value);
5933 5945
5934 // Remove given value from cache. 5946 // Remove given value from cache.
5935 void Remove(Object* value); 5947 void Remove(Object* value);
5936 5948
(...skipping 2001 matching lines...) Expand 10 before | Expand all | Expand 10 after
7938 } else { 7950 } else {
7939 value &= ~(1 << bit_position); 7951 value &= ~(1 << bit_position);
7940 } 7952 }
7941 return value; 7953 return value;
7942 } 7954 }
7943 }; 7955 };
7944 7956
7945 } } // namespace v8::internal 7957 } } // namespace v8::internal
7946 7958
7947 #endif // V8_OBJECTS_H_ 7959 #endif // V8_OBJECTS_H_
OLDNEW
« no previous file with comments | « src/ic.cc ('k') | src/objects.cc » ('j') | src/objects.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698