| Index: src/scopes.cc
|
| diff --git a/src/scopes.cc b/src/scopes.cc
|
| index 8f821461d16949ceb2151ac55ae4787a4c454ebd..9a6e3aae6da4d72b705970990826e3fd78308f90 100644
|
| --- a/src/scopes.cc
|
| +++ b/src/scopes.cc
|
| @@ -189,6 +189,7 @@ void Scope::SetDefaults(ScopeType scope_type, Scope* outer_scope,
|
| if (!scope_info.is_null()) {
|
| scope_calls_eval_ = scope_info->CallsEval();
|
| language_mode_ = scope_info->language_mode();
|
| + is_declaration_scope_ = scope_info->is_declaration_scope();
|
| function_kind_ = scope_info->function_kind();
|
| }
|
| }
|
| @@ -212,12 +213,12 @@ Scope* Scope::DeserializeScopeChain(Isolate* isolate, Zone* zone,
|
| s->scope_inside_with_ = true;
|
| }
|
| } else if (context->IsScriptContext()) {
|
| - ScopeInfo* scope_info = ScopeInfo::cast(context->extension());
|
| + ScopeInfo* scope_info = context->scope_info();
|
| current_scope = new (zone) Scope(zone, current_scope, SCRIPT_SCOPE,
|
| Handle<ScopeInfo>(scope_info),
|
| script_scope->ast_value_factory_);
|
| } else if (context->IsModuleContext()) {
|
| - ScopeInfo* scope_info = ScopeInfo::cast(context->module()->scope_info());
|
| + ScopeInfo* scope_info = context->module()->scope_info();
|
| current_scope = new (zone) Scope(zone, current_scope, MODULE_SCOPE,
|
| Handle<ScopeInfo>(scope_info),
|
| script_scope->ast_value_factory_);
|
| @@ -229,13 +230,13 @@ Scope* Scope::DeserializeScopeChain(Isolate* isolate, Zone* zone,
|
| if (scope_info->IsAsmFunction()) current_scope->asm_function_ = true;
|
| if (scope_info->IsAsmModule()) current_scope->asm_module_ = true;
|
| } else if (context->IsBlockContext()) {
|
| - ScopeInfo* scope_info = ScopeInfo::cast(context->extension());
|
| + ScopeInfo* scope_info = context->scope_info();
|
| current_scope = new (zone)
|
| Scope(zone, current_scope, BLOCK_SCOPE, Handle<ScopeInfo>(scope_info),
|
| script_scope->ast_value_factory_);
|
| } else {
|
| DCHECK(context->IsCatchContext());
|
| - String* name = String::cast(context->extension());
|
| + String* name = context->catch_name();
|
| current_scope = new (zone) Scope(
|
| zone, current_scope,
|
| script_scope->ast_value_factory_->GetString(Handle<String>(name)),
|
| @@ -344,7 +345,10 @@ Scope* Scope::FinalizeBlockScope() {
|
| DCHECK(temps_.is_empty());
|
| DCHECK(params_.is_empty());
|
|
|
| - if (num_var_or_const() > 0) return this;
|
| + if (num_var_or_const() > 0 ||
|
| + (is_declaration_scope() && calls_sloppy_eval())) {
|
| + return this;
|
| + }
|
|
|
| // Remove this scope from outer scope.
|
| for (int i = 0; i < outer_scope_->inner_scopes_.length(); i++) {
|
| @@ -811,14 +815,14 @@ void Scope::ReportMessage(int start_position, int end_position,
|
|
|
|
|
| #ifdef DEBUG
|
| -static const char* Header(ScopeType scope_type) {
|
| +static const char* Header(ScopeType scope_type, bool is_declaration_scope) {
|
| switch (scope_type) {
|
| case EVAL_SCOPE: return "eval";
|
| case FUNCTION_SCOPE: return "function";
|
| case MODULE_SCOPE: return "module";
|
| case SCRIPT_SCOPE: return "global";
|
| case CATCH_SCOPE: return "catch";
|
| - case BLOCK_SCOPE: return "block";
|
| + case BLOCK_SCOPE: return is_declaration_scope ? "varblock" : "block";
|
| case WITH_SCOPE: return "with";
|
| case ARROW_SCOPE: return "arrow";
|
| }
|
| @@ -902,7 +906,7 @@ void Scope::Print(int n) {
|
| int n1 = n0 + 2; // indentation
|
|
|
| // Print header.
|
| - Indent(n0, Header(scope_type_));
|
| + Indent(n0, Header(scope_type_, is_declaration_scope()));
|
| if (!scope_name_->IsEmpty()) {
|
| PrintF(" ");
|
| PrintName(scope_name_);
|
| @@ -1567,8 +1571,10 @@ void Scope::AllocateVariablesRecursively(Isolate* isolate) {
|
| // scope and for a function scope that makes an 'eval' call we need a context,
|
| // even if no local variables were statically allocated in the scope.
|
| // Likewise for modules.
|
| - bool must_have_context = is_with_scope() || is_module_scope() ||
|
| - (is_function_scope() && calls_sloppy_eval());
|
| + bool must_have_context =
|
| + is_with_scope() || is_module_scope() ||
|
| + (is_function_scope() && calls_sloppy_eval()) ||
|
| + (is_block_scope() && is_declaration_scope() && calls_sloppy_eval());
|
|
|
| // If we didn't allocate any locals in the local context, then we only
|
| // need the minimal number of slots if we must have a context.
|
|
|