| Index: src/scopes.cc
|
| diff --git a/src/scopes.cc b/src/scopes.cc
|
| index b2958db60fbc20d5d7689bfcb4aca8adf50ca2c6..a321a4edaecfe9e07a0a54c71fe80adb2dd1b4d0 100644
|
| --- a/src/scopes.cc
|
| +++ b/src/scopes.cc
|
| @@ -31,7 +31,6 @@
|
|
|
| #include "bootstrapper.h"
|
| #include "compiler.h"
|
| -#include "prettyprinter.h"
|
| #include "scopeinfo.h"
|
|
|
| #include "allocation-inl.h"
|
| @@ -314,7 +313,7 @@ void Scope::Initialize(bool inside_with) {
|
| Variable::VAR,
|
| false,
|
| Variable::THIS);
|
| - var->set_rewrite(NewSlot(var, Slot::PARAMETER, -1));
|
| + var->AllocateTo(Variable::PARAMETER, -1);
|
| receiver_ = var;
|
| }
|
|
|
| @@ -360,7 +359,7 @@ Variable* Scope::LocalLookup(Handle<String> name) {
|
|
|
| Variable* var =
|
| variables_.Declare(this, name, mode, true, Variable::NORMAL);
|
| - var->set_rewrite(NewSlot(var, Slot::CONTEXT, index));
|
| + var->AllocateTo(Variable::CONTEXT, index);
|
| return var;
|
| }
|
|
|
| @@ -381,7 +380,7 @@ Variable* Scope::DeclareFunctionVar(Handle<String> name) {
|
| Variable* function_var =
|
| new Variable(this, name, Variable::CONST, true, Variable::NORMAL);
|
| function_ = new(isolate_->zone()) VariableProxy(isolate_, function_var);
|
| - return function_->var();
|
| + return function_var;
|
| }
|
|
|
|
|
| @@ -409,7 +408,8 @@ Variable* Scope::DeclareLocal(Handle<String> name, Variable::Mode mode) {
|
|
|
| Variable* Scope::DeclareGlobal(Handle<String> name) {
|
| ASSERT(is_global_scope());
|
| - return variables_.Declare(this, name, Variable::DYNAMIC_GLOBAL, true,
|
| + return variables_.Declare(this, name, Variable::DYNAMIC_GLOBAL,
|
| + true,
|
| Variable::NORMAL);
|
| }
|
|
|
| @@ -442,8 +442,11 @@ void Scope::RemoveUnresolved(VariableProxy* var) {
|
|
|
| Variable* Scope::NewTemporary(Handle<String> name) {
|
| ASSERT(!already_resolved());
|
| - Variable* var =
|
| - new Variable(this, name, Variable::TEMPORARY, true, Variable::NORMAL);
|
| + Variable* var = new Variable(this,
|
| + name,
|
| + Variable::TEMPORARY,
|
| + true,
|
| + Variable::NORMAL);
|
| temps_.Add(var);
|
| return var;
|
| }
|
| @@ -636,17 +639,35 @@ static void PrintName(Handle<String> name) {
|
| }
|
|
|
|
|
| -static void PrintVar(PrettyPrinter* printer, int indent, Variable* var) {
|
| - if (var->is_used() || var->rewrite() != NULL) {
|
| +static void PrintLocation(Variable* var) {
|
| + switch (var->location()) {
|
| + case Variable::UNALLOCATED:
|
| + break;
|
| + case Variable::PARAMETER:
|
| + PrintF("parameter[%d]", var->index());
|
| + break;
|
| + case Variable::LOCAL:
|
| + PrintF("local[%d]", var->index());
|
| + break;
|
| + case Variable::CONTEXT:
|
| + PrintF("context[%d]", var->index());
|
| + break;
|
| + case Variable::LOOKUP:
|
| + PrintF("lookup");
|
| + break;
|
| + }
|
| +}
|
| +
|
| +
|
| +static void PrintVar(int indent, Variable* var) {
|
| + if (var->is_used() || !var->IsUnallocated()) {
|
| Indent(indent, Variable::Mode2String(var->mode()));
|
| PrintF(" ");
|
| PrintName(var->name());
|
| PrintF("; // ");
|
| - if (var->rewrite() != NULL) {
|
| - PrintF("%s, ", printer->Print(var->rewrite()));
|
| - if (var->is_accessed_from_inner_function_scope()) PrintF(", ");
|
| - }
|
| + PrintLocation(var);
|
| if (var->is_accessed_from_inner_function_scope()) {
|
| + if (!var->IsUnallocated()) PrintF(", ");
|
| PrintF("inner scope access");
|
| }
|
| PrintF("\n");
|
| @@ -654,10 +675,10 @@ static void PrintVar(PrettyPrinter* printer, int indent, Variable* var) {
|
| }
|
|
|
|
|
| -static void PrintMap(PrettyPrinter* printer, int indent, VariableMap* map) {
|
| +static void PrintMap(int indent, VariableMap* map) {
|
| for (VariableMap::Entry* p = map->Start(); p != NULL; p = map->Next(p)) {
|
| Variable* var = reinterpret_cast<Variable*>(p->value);
|
| - PrintVar(printer, indent, var);
|
| + PrintVar(indent, var);
|
| }
|
| }
|
|
|
| @@ -714,25 +735,24 @@ void Scope::Print(int n) {
|
| PrintF("%d heap slots\n", num_heap_slots_); }
|
|
|
| // Print locals.
|
| - PrettyPrinter printer;
|
| Indent(n1, "// function var\n");
|
| if (function_ != NULL) {
|
| - PrintVar(&printer, n1, function_->var());
|
| + PrintVar(n1, function_->var());
|
| }
|
|
|
| Indent(n1, "// temporary vars\n");
|
| for (int i = 0; i < temps_.length(); i++) {
|
| - PrintVar(&printer, n1, temps_[i]);
|
| + PrintVar(n1, temps_[i]);
|
| }
|
|
|
| Indent(n1, "// local vars\n");
|
| - PrintMap(&printer, n1, &variables_);
|
| + PrintMap(n1, &variables_);
|
|
|
| Indent(n1, "// dynamic vars\n");
|
| if (dynamics_ != NULL) {
|
| - PrintMap(&printer, n1, dynamics_->GetMap(Variable::DYNAMIC));
|
| - PrintMap(&printer, n1, dynamics_->GetMap(Variable::DYNAMIC_LOCAL));
|
| - PrintMap(&printer, n1, dynamics_->GetMap(Variable::DYNAMIC_GLOBAL));
|
| + PrintMap(n1, dynamics_->GetMap(Variable::DYNAMIC));
|
| + PrintMap(n1, dynamics_->GetMap(Variable::DYNAMIC_LOCAL));
|
| + PrintMap(n1, dynamics_->GetMap(Variable::DYNAMIC_GLOBAL));
|
| }
|
|
|
| // Print inner scopes (disable by providing negative n).
|
| @@ -756,7 +776,7 @@ Variable* Scope::NonLocal(Handle<String> name, Variable::Mode mode) {
|
| // Declare a new non-local.
|
| var = map->Declare(NULL, name, mode, true, Variable::NORMAL);
|
| // Allocate it by giving it a dynamic lookup.
|
| - var->set_rewrite(NewSlot(var, Slot::LOOKUP, -1));
|
| + var->AllocateTo(Variable::LOOKUP, -1);
|
| }
|
| return var;
|
| }
|
| @@ -1016,12 +1036,12 @@ bool Scope::HasArgumentsParameter() {
|
|
|
|
|
| void Scope::AllocateStackSlot(Variable* var) {
|
| - var->set_rewrite(NewSlot(var, Slot::LOCAL, num_stack_slots_++));
|
| + var->AllocateTo(Variable::LOCAL, num_stack_slots_++);
|
| }
|
|
|
|
|
| void Scope::AllocateHeapSlot(Variable* var) {
|
| - var->set_rewrite(NewSlot(var, Slot::CONTEXT, num_heap_slots_++));
|
| + var->AllocateTo(Variable::CONTEXT, num_heap_slots_++);
|
| }
|
|
|
|
|
| @@ -1067,14 +1087,14 @@ void Scope::AllocateParameterLocals() {
|
|
|
| if (MustAllocate(var)) {
|
| if (MustAllocateInContext(var)) {
|
| - ASSERT(var->rewrite() == NULL || var->IsContextSlot());
|
| - if (var->rewrite() == NULL) {
|
| + ASSERT(var->IsUnallocated() || var->IsContextSlot());
|
| + if (var->IsUnallocated()) {
|
| AllocateHeapSlot(var);
|
| }
|
| } else {
|
| - ASSERT(var->rewrite() == NULL || var->IsParameter());
|
| - if (var->rewrite() == NULL) {
|
| - var->set_rewrite(NewSlot(var, Slot::PARAMETER, i));
|
| + ASSERT(var->IsUnallocated() || var->IsParameter());
|
| + if (var->IsUnallocated()) {
|
| + var->AllocateTo(Variable::PARAMETER, i);
|
| }
|
| }
|
| }
|
| @@ -1084,11 +1104,9 @@ void Scope::AllocateParameterLocals() {
|
|
|
| void Scope::AllocateNonParameterLocal(Variable* var) {
|
| ASSERT(var->scope() == this);
|
| - ASSERT(var->rewrite() == NULL ||
|
| - !var->IsVariable(isolate_->factory()->result_symbol()) ||
|
| - var->AsSlot() == NULL ||
|
| - var->AsSlot()->type() != Slot::LOCAL);
|
| - if (var->rewrite() == NULL && MustAllocate(var)) {
|
| + ASSERT(!var->IsVariable(isolate_->factory()->result_symbol()) ||
|
| + !var->IsStackLocal());
|
| + if (var->IsUnallocated() && MustAllocate(var)) {
|
| if (MustAllocateInContext(var)) {
|
| AllocateHeapSlot(var);
|
| } else {
|
|
|