diff options
| author | Ben Murdoch <benm@google.com> | 2012-03-05 11:04:45 +0000 |
|---|---|---|
| committer | Ben Murdoch <benm@google.com> | 2012-04-11 15:39:56 +0100 |
| commit | 592a9fc1d8ea420377a2e7efd0600e20b058be2b (patch) | |
| tree | 23fe22995f4f9056a96266d169d49426a5e745d7 /src/scopeinfo.h | |
| parent | e25ed7434cc3a061dd965ad25b923bca153aed94 (diff) | |
| download | android_external_v8-592a9fc1d8ea420377a2e7efd0600e20b058be2b.tar.gz android_external_v8-592a9fc1d8ea420377a2e7efd0600e20b058be2b.tar.bz2 android_external_v8-592a9fc1d8ea420377a2e7efd0600e20b058be2b.zip | |
Merge V8 at 3.7.12.28
Bug: 5688872
Change-Id: Iddb40cae44d51a2b449f2858951e0472771f5981
Diffstat (limited to 'src/scopeinfo.h')
| -rw-r--r-- | src/scopeinfo.h | 160 |
1 files changed, 23 insertions, 137 deletions
diff --git a/src/scopeinfo.h b/src/scopeinfo.h index 40c5c8a6..93734f5a 100644 --- a/src/scopeinfo.h +++ b/src/scopeinfo.h @@ -35,135 +35,6 @@ namespace v8 { namespace internal { -// Scope information represents information about a functions's -// scopes (currently only one, because we don't do any inlining) -// and the allocation of the scope's variables. Scope information -// is stored in a compressed form in FixedArray objects and is used -// at runtime (stack dumps, deoptimization, etc.). -// -// Historical note: In other VMs built by this team, ScopeInfo was -// usually called DebugInfo since the information was used (among -// other things) for on-demand debugging (Self, Smalltalk). However, -// DebugInfo seems misleading, since this information is primarily used -// in debugging-unrelated contexts. - -// Forward defined as -// template <class Allocator = FreeStoreAllocationPolicy> class ScopeInfo; -template<class Allocator> -class ScopeInfo BASE_EMBEDDED { - public: - // Create a ScopeInfo instance from a scope. - explicit ScopeInfo(Scope* scope); - - // Create a ScopeInfo instance from SerializedScopeInfo. - explicit ScopeInfo(SerializedScopeInfo* data); - - // Creates a SerializedScopeInfo holding the serialized scope info. - Handle<SerializedScopeInfo> Serialize(); - - // -------------------------------------------------------------------------- - // Lookup - - Handle<String> function_name() const { return function_name_; } - - Handle<String> parameter_name(int i) const { return parameters_[i]; } - int number_of_parameters() const { return parameters_.length(); } - - Handle<String> stack_slot_name(int i) const { return stack_slots_[i]; } - int number_of_stack_slots() const { return stack_slots_.length(); } - - Handle<String> context_slot_name(int i) const { - return context_slots_[i - Context::MIN_CONTEXT_SLOTS]; - } - int number_of_context_slots() const { - int l = context_slots_.length(); - return l == 0 ? 0 : l + Context::MIN_CONTEXT_SLOTS; - } - - Handle<String> LocalName(int i) const; - int NumberOfLocals() const; - - // -------------------------------------------------------------------------- - // Debugging support - -#ifdef DEBUG - void Print(); -#endif - - private: - Handle<String> function_name_; - bool calls_eval_; - bool is_strict_mode_; - List<Handle<String>, Allocator > parameters_; - List<Handle<String>, Allocator > stack_slots_; - List<Handle<String>, Allocator > context_slots_; - List<Variable::Mode, Allocator > context_modes_; -}; - - -// This object provides quick access to scope info details for runtime -// routines w/o the need to explicitly create a ScopeInfo object. -class SerializedScopeInfo : public FixedArray { - public : - - static SerializedScopeInfo* cast(Object* object) { - ASSERT(object->IsSerializedScopeInfo()); - return reinterpret_cast<SerializedScopeInfo*>(object); - } - - // Does this scope call eval? - bool CallsEval(); - - // Is this scope a strict mode scope? - bool IsStrictMode(); - - // Return the number of stack slots for code. - int NumberOfStackSlots(); - - // Return the number of context slots for code. - int NumberOfContextSlots(); - - // Return if this has context slots besides MIN_CONTEXT_SLOTS; - bool HasHeapAllocatedLocals(); - - // Lookup support for serialized scope info. Returns the - // the stack slot index for a given slot name if the slot is - // present; otherwise returns a value < 0. The name must be a symbol - // (canonicalized). - int StackSlotIndex(String* name); - - // Lookup support for serialized scope info. Returns the - // context slot index for a given slot name if the slot is present; otherwise - // returns a value < 0. The name must be a symbol (canonicalized). - // If the slot is present and mode != NULL, sets *mode to the corresponding - // mode for that variable. - int ContextSlotIndex(String* name, Variable::Mode* mode); - - // Lookup support for serialized scope info. Returns the - // parameter index for a given parameter name if the parameter is present; - // otherwise returns a value < 0. The name must be a symbol (canonicalized). - int ParameterIndex(String* name); - - // Lookup support for serialized scope info. Returns the - // function context slot index if the function name is present (named - // function expressions, only), otherwise returns a value < 0. The name - // must be a symbol (canonicalized). - int FunctionContextSlotIndex(String* name); - - static Handle<SerializedScopeInfo> Create(Scope* scope); - - // Serializes empty scope info. - static SerializedScopeInfo* Empty(); - - private: - inline Object** ContextEntriesAddr(); - - inline Object** ParameterEntriesAddr(); - - inline Object** StackSlotEntriesAddr(); -}; - - // Cache for mapping (data, property name) into context slot index. // The cache contains both positive and negative results. // Slot index equals -1 means the property is absent. @@ -174,12 +45,14 @@ class ContextSlotCache { // If absent, kNotFound is returned. int Lookup(Object* data, String* name, - Variable::Mode* mode); + VariableMode* mode, + InitializationFlag* init_flag); // Update an element in the cache. void Update(Object* data, String* name, - Variable::Mode mode, + VariableMode mode, + InitializationFlag init_flag, int slot_index); // Clear the cache. @@ -201,7 +74,8 @@ class ContextSlotCache { #ifdef DEBUG void ValidateEntry(Object* data, String* name, - Variable::Mode mode, + VariableMode mode, + InitializationFlag init_flag, int slot_index); #endif @@ -212,11 +86,17 @@ class ContextSlotCache { }; struct Value { - Value(Variable::Mode mode, int index) { + Value(VariableMode mode, + InitializationFlag init_flag, + int index) { ASSERT(ModeField::is_valid(mode)); + ASSERT(InitField::is_valid(init_flag)); ASSERT(IndexField::is_valid(index)); - value_ = ModeField::encode(mode) | IndexField::encode(index); + value_ = ModeField::encode(mode) | + IndexField::encode(index) | + InitField::encode(init_flag); ASSERT(mode == this->mode()); + ASSERT(init_flag == this->initialization_flag()); ASSERT(index == this->index()); } @@ -224,14 +104,20 @@ class ContextSlotCache { uint32_t raw() { return value_; } - Variable::Mode mode() { return ModeField::decode(value_); } + VariableMode mode() { return ModeField::decode(value_); } + + InitializationFlag initialization_flag() { + return InitField::decode(value_); + } int index() { return IndexField::decode(value_); } // Bit fields in value_ (type, shift, size). Must be public so the // constants can be embedded in generated code. - class ModeField: public BitField<Variable::Mode, 0, 3> {}; - class IndexField: public BitField<int, 3, 32-3> {}; + class ModeField: public BitField<VariableMode, 0, 3> {}; + class InitField: public BitField<InitializationFlag, 3, 1> {}; + class IndexField: public BitField<int, 4, 32-4> {}; + private: uint32_t value_; }; |
