| OLD | NEW | 
|---|
| 1 // Copyright 2009 the V8 project authors. All rights reserved. | 1 // Copyright 2009 the V8 project authors. All rights reserved. | 
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without | 
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are | 
| 4 // met: | 4 // met: | 
| 5 // | 5 // | 
| 6 //     * Redistributions of source code must retain the above copyright | 6 //     * Redistributions of source code must retain the above copyright | 
| 7 //       notice, this list of conditions and the following disclaimer. | 7 //       notice, this list of conditions and the following disclaimer. | 
| 8 //     * Redistributions in binary form must reproduce the above | 8 //     * Redistributions in binary form must reproduce the above | 
| 9 //       copyright notice, this list of conditions and the following | 9 //       copyright notice, this list of conditions and the following | 
| 10 //       disclaimer in the documentation and/or other materials provided | 10 //       disclaimer in the documentation and/or other materials provided | 
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 81   int globals = 0; | 81   int globals = 0; | 
| 82   for (int i = 0; i < length; i++) { | 82   for (int i = 0; i < length; i++) { | 
| 83     Declaration* decl = declarations->at(i); | 83     Declaration* decl = declarations->at(i); | 
| 84     Variable* var = decl->proxy()->var(); | 84     Variable* var = decl->proxy()->var(); | 
| 85     Slot* slot = var->slot(); | 85     Slot* slot = var->slot(); | 
| 86 | 86 | 
| 87     // If it was not possible to allocate the variable at compile | 87     // If it was not possible to allocate the variable at compile | 
| 88     // time, we need to "declare" it at runtime to make sure it | 88     // time, we need to "declare" it at runtime to make sure it | 
| 89     // actually exists in the local context. | 89     // actually exists in the local context. | 
| 90     if ((slot != NULL && slot->type() == Slot::LOOKUP) || !var->is_global()) { | 90     if ((slot != NULL && slot->type() == Slot::LOOKUP) || !var->is_global()) { | 
| 91       UNREACHABLE(); | 91       VisitDeclaration(decl); | 
| 92     } else { | 92     } else { | 
| 93       // Count global variables and functions for later processing | 93       // Count global variables and functions for later processing | 
| 94       globals++; | 94       globals++; | 
| 95     } | 95     } | 
| 96   } | 96   } | 
| 97 | 97 | 
| 98   // Return in case of no declared global functions or variables. | 98   // Compute array of global variable and function declarations. | 
| 99   if (globals == 0) return; | 99   // Do nothing in case of no declared global functions or variables. | 
|  | 100   if (globals > 0) { | 
|  | 101     Handle<FixedArray> array = Factory::NewFixedArray(2 * globals, TENURED); | 
|  | 102     for (int j = 0, i = 0; i < length; i++) { | 
|  | 103       Declaration* decl = declarations->at(i); | 
|  | 104       Variable* var = decl->proxy()->var(); | 
|  | 105       Slot* slot = var->slot(); | 
| 100 | 106 | 
| 101   // Compute array of global variable and function declarations. | 107       if ((slot == NULL || slot->type() != Slot::LOOKUP) && var->is_global()) { | 
| 102   Handle<FixedArray> array = Factory::NewFixedArray(2 * globals, TENURED); | 108         array->set(j++, *(var->name())); | 
| 103   for (int j = 0, i = 0; i < length; i++) { | 109         if (decl->fun() == NULL) { | 
| 104     Declaration* decl = declarations->at(i); | 110           if (var->mode() == Variable::CONST) { | 
| 105     Variable* var = decl->proxy()->var(); | 111             // In case this is const property use the hole. | 
| 106     Slot* slot = var->slot(); | 112             array->set_the_hole(j++); | 
| 107 | 113           } else { | 
| 108     if ((slot == NULL || slot->type() != Slot::LOOKUP) && var->is_global()) { | 114             array->set_undefined(j++); | 
| 109       array->set(j++, *(var->name())); | 115           } | 
| 110       if (decl->fun() == NULL) { |  | 
| 111         if (var->mode() == Variable::CONST) { |  | 
| 112           // In case this is const property use the hole. |  | 
| 113           array->set_the_hole(j++); |  | 
| 114         } else { | 116         } else { | 
| 115           array->set_undefined(j++); | 117           Handle<JSFunction> function = | 
|  | 118               Compiler::BuildBoilerplate(decl->fun(), script_, this); | 
|  | 119           // Check for stack-overflow exception. | 
|  | 120           if (HasStackOverflow()) return; | 
|  | 121           array->set(j++, *function); | 
| 116         } | 122         } | 
| 117       } else { |  | 
| 118         Handle<JSFunction> function = |  | 
| 119             Compiler::BuildBoilerplate(decl->fun(), script_, this); |  | 
| 120         // Check for stack-overflow exception. |  | 
| 121         if (HasStackOverflow()) return; |  | 
| 122         array->set(j++, *function); |  | 
| 123       } | 123       } | 
| 124     } | 124     } | 
|  | 125     // Invoke the platform-dependent code generator to do the actual | 
|  | 126     // declaration the global variables and functions. | 
|  | 127     DeclareGlobals(array); | 
| 125   } | 128   } | 
| 126 |  | 
| 127   // Invoke the platform-dependent code generator to do the actual |  | 
| 128   // declaration the global variables and functions. |  | 
| 129   DeclareGlobals(array); |  | 
| 130 } | 129 } | 
| 131 | 130 | 
| 132 | 131 | 
| 133 void FastCodeGenerator::SetFunctionPosition(FunctionLiteral* fun) { | 132 void FastCodeGenerator::SetFunctionPosition(FunctionLiteral* fun) { | 
| 134   if (FLAG_debug_info) { | 133   if (FLAG_debug_info) { | 
| 135     CodeGenerator::RecordPositions(masm_, fun->start_position()); | 134     CodeGenerator::RecordPositions(masm_, fun->start_position()); | 
| 136   } | 135   } | 
| 137 } | 136 } | 
| 138 | 137 | 
| 139 | 138 | 
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 225   true_label_ = saved_true; | 224   true_label_ = saved_true; | 
| 226   false_label_ = saved_false; | 225   false_label_ = saved_false; | 
| 227 | 226 | 
| 228   __ bind(&eval_right); | 227   __ bind(&eval_right); | 
| 229   Visit(expr->right()); | 228   Visit(expr->right()); | 
| 230 | 229 | 
| 231   __ bind(&done); | 230   __ bind(&done); | 
| 232 } | 231 } | 
| 233 | 232 | 
| 234 | 233 | 
| 235 void FastCodeGenerator::VisitDeclaration(Declaration* decl) { |  | 
| 236   UNREACHABLE(); |  | 
| 237 } |  | 
| 238 |  | 
| 239 |  | 
| 240 void FastCodeGenerator::VisitBlock(Block* stmt) { | 234 void FastCodeGenerator::VisitBlock(Block* stmt) { | 
| 241   Comment cmnt(masm_, "[ Block"); | 235   Comment cmnt(masm_, "[ Block"); | 
| 242   SetStatementPosition(stmt); | 236   SetStatementPosition(stmt); | 
| 243   VisitStatements(stmt->statements()); | 237   VisitStatements(stmt->statements()); | 
| 244 } | 238 } | 
| 245 | 239 | 
| 246 | 240 | 
| 247 void FastCodeGenerator::VisitExpressionStatement(ExpressionStatement* stmt) { | 241 void FastCodeGenerator::VisitExpressionStatement(ExpressionStatement* stmt) { | 
| 248   Comment cmnt(masm_, "[ ExpressionStatement"); | 242   Comment cmnt(masm_, "[ ExpressionStatement"); | 
| 249   SetStatementPosition(stmt); | 243   SetStatementPosition(stmt); | 
| (...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 483 | 477 | 
| 484 void FastCodeGenerator::VisitThisFunction(ThisFunction* expr) { | 478 void FastCodeGenerator::VisitThisFunction(ThisFunction* expr) { | 
| 485   UNREACHABLE(); | 479   UNREACHABLE(); | 
| 486 } | 480 } | 
| 487 | 481 | 
| 488 | 482 | 
| 489 #undef __ | 483 #undef __ | 
| 490 | 484 | 
| 491 | 485 | 
| 492 } }  // namespace v8::internal | 486 } }  // namespace v8::internal | 
| OLD | NEW | 
|---|