Roll V8 back to 3.6
Roll back to V8 3.6 to fix x86 build, we don't have ucontext.h.
This reverts commits:
5d4cdbf7a67d3662fa0bee4efdb7edd8daec9b0b
c7cc028aaeedbbfa11c11d0b7b243b3d9e837ed9
592a9fc1d8ea420377a2e7efd0600e20b058be2b
Bug: 5688872
Change-Id: Ic961bb5e65b778e98bbfb71cce71d99fa949e995
diff --git a/src/scopeinfo.h b/src/scopeinfo.h
index 93734f5..40c5c8a 100644
--- a/src/scopeinfo.h
+++ b/src/scopeinfo.h
@@ -35,6 +35,135 @@
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.
@@ -45,14 +174,12 @@
// If absent, kNotFound is returned.
int Lookup(Object* data,
String* name,
- VariableMode* mode,
- InitializationFlag* init_flag);
+ Variable::Mode* mode);
// Update an element in the cache.
void Update(Object* data,
String* name,
- VariableMode mode,
- InitializationFlag init_flag,
+ Variable::Mode mode,
int slot_index);
// Clear the cache.
@@ -74,8 +201,7 @@
#ifdef DEBUG
void ValidateEntry(Object* data,
String* name,
- VariableMode mode,
- InitializationFlag init_flag,
+ Variable::Mode mode,
int slot_index);
#endif
@@ -86,17 +212,11 @@
};
struct Value {
- Value(VariableMode mode,
- InitializationFlag init_flag,
- int index) {
+ Value(Variable::Mode mode, 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) |
- InitField::encode(init_flag);
+ value_ = ModeField::encode(mode) | IndexField::encode(index);
ASSERT(mode == this->mode());
- ASSERT(init_flag == this->initialization_flag());
ASSERT(index == this->index());
}
@@ -104,20 +224,14 @@
uint32_t raw() { return value_; }
- VariableMode mode() { return ModeField::decode(value_); }
-
- InitializationFlag initialization_flag() {
- return InitField::decode(value_);
- }
+ Variable::Mode mode() { return ModeField::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<VariableMode, 0, 3> {};
- class InitField: public BitField<InitializationFlag, 3, 1> {};
- class IndexField: public BitField<int, 4, 32-4> {};
-
+ class ModeField: public BitField<Variable::Mode, 0, 3> {};
+ class IndexField: public BitField<int, 3, 32-3> {};
private:
uint32_t value_;
};