MIPS: Refactor code generation for global declarations.

Port r11332 (0e6df8b6)

Original commit message:
Refactor code generation for global declarations.

BUG=
TEST=

Review URL: https://chromiumcodereview.appspot.com/10041029

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@11373 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
rossberg@chromium.org 2012-04-18 15:46:08 +00:00
parent 42b77f3156
commit 1aa16d8689

View File

@ -817,7 +817,10 @@ void FullCodeGenerator::VisitVariableDeclaration(
bool hole_init = mode == CONST || mode == CONST_HARMONY || mode == LET; bool hole_init = mode == CONST || mode == CONST_HARMONY || mode == LET;
switch (variable->location()) { switch (variable->location()) {
case Variable::UNALLOCATED: case Variable::UNALLOCATED:
++global_count_; globals_.Add(variable->name());
globals_.Add(variable->binding_needs_init()
? isolate()->factory()->the_hole_value()
: isolate()->factory()->undefined_value());
break; break;
case Variable::PARAMETER: case Variable::PARAMETER:
@ -873,9 +876,15 @@ void FullCodeGenerator::VisitFunctionDeclaration(
VariableProxy* proxy = declaration->proxy(); VariableProxy* proxy = declaration->proxy();
Variable* variable = proxy->var(); Variable* variable = proxy->var();
switch (variable->location()) { switch (variable->location()) {
case Variable::UNALLOCATED: case Variable::UNALLOCATED: {
++global_count_; globals_.Add(variable->name());
Handle<SharedFunctionInfo> function =
Compiler::BuildFunctionInfo(declaration->fun(), script());
// Check for stack-overflow exception.
if (function.is_null()) return SetStackOverflow();
globals_.Add(function);
break; break;
}
case Variable::PARAMETER: case Variable::PARAMETER:
case Variable::LOCAL: { case Variable::LOCAL: {
@ -923,7 +932,7 @@ void FullCodeGenerator::VisitModuleDeclaration(ModuleDeclaration* declaration) {
Variable* variable = proxy->var(); Variable* variable = proxy->var();
switch (variable->location()) { switch (variable->location()) {
case Variable::UNALLOCATED: case Variable::UNALLOCATED:
++global_count_; // TODO(rossberg): initialize module instance object
break; break;
case Variable::CONTEXT: { case Variable::CONTEXT: {
@ -946,7 +955,7 @@ void FullCodeGenerator::VisitImportDeclaration(ImportDeclaration* declaration) {
Variable* variable = proxy->var(); Variable* variable = proxy->var();
switch (variable->location()) { switch (variable->location()) {
case Variable::UNALLOCATED: case Variable::UNALLOCATED:
++global_count_; // TODO(rossberg)
break; break;
case Variable::CONTEXT: { case Variable::CONTEXT: {