From b8a73f06500059da8c049a04e8805a99165aac54 Mon Sep 17 00:00:00 2001 From: "sgjesse@chromium.org" Date: Wed, 19 Aug 2009 12:06:16 +0000 Subject: [PATCH] Fix uninitialized members. Make sure that the DummyScope top level scope used for pre-parsing have all members initialized. The type of this scope is set to global scope as it is a top level scope. Also ensure that the "naked" Scope constructor can only be used by sub-classes of Scope. The bug of missing initiaalization of members in the DummyScope was found by Valgrind. Review URL: http://codereview.chromium.org/173052 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@2719 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/scopes.cc | 23 ++++++++++++++++++++--- src/scopes.h | 7 ++++--- 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/src/scopes.cc b/src/scopes.cc index 78ed035..25873fa 100644 --- a/src/scopes.cc +++ b/src/scopes.cc @@ -108,14 +108,31 @@ Variable* VariableMap::Lookup(Handle name) { // Dummy constructor -Scope::Scope() - : inner_scopes_(0), +Scope::Scope(Type type) + : outer_scope_(NULL), + inner_scopes_(0), + type_(type), + scope_name_(Factory::empty_symbol()), variables_(false), temps_(0), params_(0), dynamics_(NULL), unresolved_(0), - decls_(0) { + decls_(0), + receiver_(NULL), + function_(NULL), + arguments_(NULL), + arguments_shadow_(NULL), + illegal_redecl_(NULL), + scope_inside_with_(false), + scope_contains_with_(false), + scope_calls_eval_(false), + outer_scope_calls_eval_(false), + inner_scope_calls_eval_(false), + outer_scope_is_eval_scope_(false), + force_eager_compilation_(false), + num_stack_slots_(0), + num_heap_slots_(0) { } diff --git a/src/scopes.h b/src/scopes.h index 5767d9f..ddbff8b 100644 --- a/src/scopes.h +++ b/src/scopes.h @@ -93,7 +93,6 @@ class Scope: public ZoneObject { GLOBAL_SCOPE // the top-level scope for a program or a top-level eval }; - Scope(); Scope(Scope* outer_scope, Type type); virtual ~Scope() { } @@ -130,7 +129,7 @@ class Scope: public ZoneObject { Variable* DeclareGlobal(Handle name); // Add a parameter to the parameter list. The parameter must have been - // declared via Declare. The same parameter may occur more then once in + // declared via Declare. The same parameter may occur more than once in // the parameter list; they must be added in source order, from left to // right. void AddParameter(Variable* var); @@ -286,6 +285,8 @@ class Scope: public ZoneObject { protected: friend class ParserFactory; + explicit Scope(Type type); + // Scope tree. Scope* outer_scope_; // the immediately enclosing outer scope, or NULL ZoneList inner_scopes_; // the immediately enclosed inner scopes @@ -375,7 +376,7 @@ class Scope: public ZoneObject { class DummyScope : public Scope { public: - DummyScope() { + DummyScope() : Scope(GLOBAL_SCOPE) { outer_scope_ = this; } -- 2.7.4