| Index: src/scopes.cc
|
| diff --git a/src/scopes.cc b/src/scopes.cc
|
| index 4680a1cf6a8518e0467ae45e4571d70af3ec311e..fa95bde2b2ff0f6062427003850bf94d2af5db8b 100644
|
| --- a/src/scopes.cc
|
| +++ b/src/scopes.cc
|
| @@ -67,10 +67,9 @@ Variable* VariableMap::Lookup(const AstRawString* name) {
|
| // ----------------------------------------------------------------------------
|
| // Implementation of Scope
|
|
|
| -Scope::Scope(Isolate* isolate, Zone* zone, Scope* outer_scope,
|
| - ScopeType scope_type, AstValueFactory* ast_value_factory)
|
| - : isolate_(isolate),
|
| - inner_scopes_(4, zone),
|
| +Scope::Scope(Zone* zone, Scope* outer_scope, ScopeType scope_type,
|
| + AstValueFactory* ast_value_factory)
|
| + : inner_scopes_(4, zone),
|
| variables_(zone),
|
| internals_(4, zone),
|
| temps_(4, zone),
|
| @@ -89,11 +88,9 @@ Scope::Scope(Isolate* isolate, Zone* zone, Scope* outer_scope,
|
| }
|
|
|
|
|
| -Scope::Scope(Isolate* isolate, Zone* zone, Scope* inner_scope,
|
| - ScopeType scope_type, Handle<ScopeInfo> scope_info,
|
| - AstValueFactory* value_factory)
|
| - : isolate_(isolate),
|
| - inner_scopes_(4, zone),
|
| +Scope::Scope(Zone* zone, Scope* inner_scope, ScopeType scope_type,
|
| + Handle<ScopeInfo> scope_info, AstValueFactory* value_factory)
|
| + : inner_scopes_(4, zone),
|
| variables_(zone),
|
| internals_(4, zone),
|
| temps_(4, zone),
|
| @@ -115,11 +112,10 @@ Scope::Scope(Isolate* isolate, Zone* zone, Scope* inner_scope,
|
| }
|
|
|
|
|
| -Scope::Scope(Isolate* isolate, Zone* zone, Scope* inner_scope,
|
| +Scope::Scope(Zone* zone, Scope* inner_scope,
|
| const AstRawString* catch_variable_name,
|
| AstValueFactory* value_factory)
|
| - : isolate_(isolate),
|
| - inner_scopes_(1, zone),
|
| + : inner_scopes_(1, zone),
|
| variables_(zone),
|
| internals_(0, zone),
|
| temps_(0, zone),
|
| @@ -201,8 +197,8 @@ Scope* Scope::DeserializeScopeChain(Isolate* isolate, Zone* zone,
|
| while (!context->IsNativeContext()) {
|
| if (context->IsWithContext()) {
|
| Scope* with_scope = new (zone)
|
| - Scope(isolate, zone, current_scope, WITH_SCOPE,
|
| - Handle<ScopeInfo>::null(), script_scope->ast_value_factory_);
|
| + Scope(zone, current_scope, WITH_SCOPE, Handle<ScopeInfo>::null(),
|
| + script_scope->ast_value_factory_);
|
| current_scope = with_scope;
|
| // All the inner scopes are inside a with.
|
| contains_with = true;
|
| @@ -211,31 +207,31 @@ Scope* Scope::DeserializeScopeChain(Isolate* isolate, Zone* zone,
|
| }
|
| } else if (context->IsScriptContext()) {
|
| ScopeInfo* scope_info = ScopeInfo::cast(context->extension());
|
| - current_scope = new (zone) Scope(
|
| - isolate, zone, current_scope, SCRIPT_SCOPE,
|
| - Handle<ScopeInfo>(scope_info), script_scope->ast_value_factory_);
|
| + 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());
|
| - current_scope = new (zone) Scope(
|
| - isolate, zone, current_scope, MODULE_SCOPE,
|
| - Handle<ScopeInfo>(scope_info), script_scope->ast_value_factory_);
|
| + current_scope = new (zone) Scope(zone, current_scope, MODULE_SCOPE,
|
| + Handle<ScopeInfo>(scope_info),
|
| + script_scope->ast_value_factory_);
|
| } else if (context->IsFunctionContext()) {
|
| ScopeInfo* scope_info = context->closure()->shared()->scope_info();
|
| - current_scope = new (zone) Scope(
|
| - isolate, zone, current_scope, FUNCTION_SCOPE,
|
| - Handle<ScopeInfo>(scope_info), script_scope->ast_value_factory_);
|
| + current_scope = new (zone) Scope(zone, current_scope, FUNCTION_SCOPE,
|
| + Handle<ScopeInfo>(scope_info),
|
| + script_scope->ast_value_factory_);
|
| 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());
|
| - current_scope = new (zone) Scope(
|
| - isolate, zone, current_scope, BLOCK_SCOPE,
|
| - Handle<ScopeInfo>(scope_info), script_scope->ast_value_factory_);
|
| + 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());
|
| current_scope = new (zone) Scope(
|
| - isolate, zone, current_scope,
|
| + zone, current_scope,
|
| script_scope->ast_value_factory_->GetString(Handle<String>(name)),
|
| script_scope->ast_value_factory_);
|
| }
|
| @@ -662,7 +658,7 @@ bool Scope::AllocateVariables(CompilationInfo* info, AstNodeFactory* factory) {
|
| if (!ResolveVariablesRecursively(info, factory)) return false;
|
|
|
| // 4) Allocate variables.
|
| - AllocateVariablesRecursively();
|
| + AllocateVariablesRecursively(info->isolate());
|
|
|
| return true;
|
| }
|
| @@ -751,18 +747,17 @@ Scope* Scope::DeclarationScope() {
|
| }
|
|
|
|
|
| -Handle<ScopeInfo> Scope::GetScopeInfo() {
|
| +Handle<ScopeInfo> Scope::GetScopeInfo(Isolate* isolate) {
|
| if (scope_info_.is_null()) {
|
| - scope_info_ = ScopeInfo::Create(isolate(), zone(), this);
|
| + scope_info_ = ScopeInfo::Create(isolate, zone(), this);
|
| }
|
| return scope_info_;
|
| }
|
|
|
|
|
| -void Scope::GetNestedScopeChain(
|
| - List<Handle<ScopeInfo> >* chain,
|
| - int position) {
|
| - if (!is_eval_scope()) chain->Add(Handle<ScopeInfo>(GetScopeInfo()));
|
| +void Scope::GetNestedScopeChain(Isolate* isolate,
|
| + List<Handle<ScopeInfo> >* chain, int position) {
|
| + if (!is_eval_scope()) chain->Add(Handle<ScopeInfo>(GetScopeInfo(isolate)));
|
|
|
| for (int i = 0; i < inner_scopes_.length(); i++) {
|
| Scope* scope = inner_scopes_[i];
|
| @@ -770,7 +765,7 @@ void Scope::GetNestedScopeChain(
|
| int end_pos = scope->end_position();
|
| DCHECK(beg_pos >= 0 && end_pos >= 0);
|
| if (beg_pos <= position && position < end_pos) {
|
| - scope->GetNestedScopeChain(chain, position);
|
| + scope->GetNestedScopeChain(isolate, chain, position);
|
| return;
|
| }
|
| }
|
| @@ -1245,10 +1240,10 @@ bool Scope::MustAllocateInContext(Variable* var) {
|
| }
|
|
|
|
|
| -bool Scope::HasArgumentsParameter() {
|
| +bool Scope::HasArgumentsParameter(Isolate* isolate) {
|
| for (int i = 0; i < params_.length(); i++) {
|
| if (params_[i]->name().is_identical_to(
|
| - isolate_->factory()->arguments_string())) {
|
| + isolate->factory()->arguments_string())) {
|
| return true;
|
| }
|
| }
|
| @@ -1266,14 +1261,14 @@ void Scope::AllocateHeapSlot(Variable* var) {
|
| }
|
|
|
|
|
| -void Scope::AllocateParameterLocals() {
|
| +void Scope::AllocateParameterLocals(Isolate* isolate) {
|
| DCHECK(is_function_scope());
|
| Variable* arguments = LookupLocal(ast_value_factory_->arguments_string());
|
| DCHECK(arguments != NULL); // functions have 'arguments' declared implicitly
|
|
|
| bool uses_sloppy_arguments = false;
|
|
|
| - if (MustAllocate(arguments) && !HasArgumentsParameter()) {
|
| + if (MustAllocate(arguments) && !HasArgumentsParameter(isolate)) {
|
| // 'arguments' is used. Unless there is also a parameter called
|
| // 'arguments', we must be conservative and allocate all parameters to
|
| // the context assuming they will be captured by the arguments object.
|
| @@ -1328,9 +1323,9 @@ void Scope::AllocateParameterLocals() {
|
| }
|
|
|
|
|
| -void Scope::AllocateNonParameterLocal(Variable* var) {
|
| +void Scope::AllocateNonParameterLocal(Isolate* isolate, Variable* var) {
|
| DCHECK(var->scope() == this);
|
| - DCHECK(!var->IsVariable(isolate_->factory()->dot_result_string()) ||
|
| + DCHECK(!var->IsVariable(isolate->factory()->dot_result_string()) ||
|
| !var->IsStackLocal());
|
| if (var->IsUnallocated() && MustAllocate(var)) {
|
| if (MustAllocateInContext(var)) {
|
| @@ -1342,14 +1337,14 @@ void Scope::AllocateNonParameterLocal(Variable* var) {
|
| }
|
|
|
|
|
| -void Scope::AllocateNonParameterLocals() {
|
| +void Scope::AllocateNonParameterLocals(Isolate* isolate) {
|
| // All variables that have no rewrite yet are non-parameter locals.
|
| for (int i = 0; i < temps_.length(); i++) {
|
| - AllocateNonParameterLocal(temps_[i]);
|
| + AllocateNonParameterLocal(isolate, temps_[i]);
|
| }
|
|
|
| for (int i = 0; i < internals_.length(); i++) {
|
| - AllocateNonParameterLocal(internals_[i]);
|
| + AllocateNonParameterLocal(isolate, internals_[i]);
|
| }
|
|
|
| ZoneList<VarAndOrder> vars(variables_.occupancy(), zone());
|
| @@ -1362,7 +1357,7 @@ void Scope::AllocateNonParameterLocals() {
|
| vars.Sort(VarAndOrder::Compare);
|
| int var_count = vars.length();
|
| for (int i = 0; i < var_count; i++) {
|
| - AllocateNonParameterLocal(vars[i].var());
|
| + AllocateNonParameterLocal(isolate, vars[i].var());
|
| }
|
|
|
| // For now, function_ must be allocated at the very end. If it gets
|
| @@ -1370,19 +1365,19 @@ void Scope::AllocateNonParameterLocals() {
|
| // because of the current ScopeInfo implementation (see
|
| // ScopeInfo::ScopeInfo(FunctionScope* scope) constructor).
|
| if (function_ != NULL) {
|
| - AllocateNonParameterLocal(function_->proxy()->var());
|
| + AllocateNonParameterLocal(isolate, function_->proxy()->var());
|
| }
|
|
|
| if (rest_parameter_) {
|
| - AllocateNonParameterLocal(rest_parameter_);
|
| + AllocateNonParameterLocal(isolate, rest_parameter_);
|
| }
|
| }
|
|
|
|
|
| -void Scope::AllocateVariablesRecursively() {
|
| +void Scope::AllocateVariablesRecursively(Isolate* isolate) {
|
| // Allocate variables for inner scopes.
|
| for (int i = 0; i < inner_scopes_.length(); i++) {
|
| - inner_scopes_[i]->AllocateVariablesRecursively();
|
| + inner_scopes_[i]->AllocateVariablesRecursively(isolate);
|
| }
|
|
|
| // If scope is already resolved, we still need to allocate
|
| @@ -1394,8 +1389,8 @@ void Scope::AllocateVariablesRecursively() {
|
|
|
| // Allocate variables for this scope.
|
| // Parameters must be allocated first, if any.
|
| - if (is_function_scope()) AllocateParameterLocals();
|
| - AllocateNonParameterLocals();
|
| + if (is_function_scope()) AllocateParameterLocals(isolate);
|
| + AllocateNonParameterLocals(isolate);
|
|
|
| // Force allocation of a context for this scope if necessary. For a 'with'
|
| // scope and for a function scope that makes an 'eval' call we need a context,
|
|
|