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 411 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
422 } | 422 } |
423 | 423 |
424 | 424 |
425 void FullCodeGenerator::VisitDeclarations( | 425 void FullCodeGenerator::VisitDeclarations( |
426 ZoneList<Declaration*>* declarations) { | 426 ZoneList<Declaration*>* declarations) { |
427 int length = declarations->length(); | 427 int length = declarations->length(); |
428 int globals = 0; | 428 int globals = 0; |
429 for (int i = 0; i < length; i++) { | 429 for (int i = 0; i < length; i++) { |
430 Declaration* decl = declarations->at(i); | 430 Declaration* decl = declarations->at(i); |
431 Variable* var = decl->proxy()->var(); | 431 Variable* var = decl->proxy()->var(); |
432 Slot* slot = var->slot(); | 432 Slot* slot = var->AsSlot(); |
433 | 433 |
434 // If it was not possible to allocate the variable at compile | 434 // If it was not possible to allocate the variable at compile |
435 // time, we need to "declare" it at runtime to make sure it | 435 // time, we need to "declare" it at runtime to make sure it |
436 // actually exists in the local context. | 436 // actually exists in the local context. |
437 if ((slot != NULL && slot->type() == Slot::LOOKUP) || !var->is_global()) { | 437 if ((slot != NULL && slot->type() == Slot::LOOKUP) || !var->is_global()) { |
438 VisitDeclaration(decl); | 438 VisitDeclaration(decl); |
439 } else { | 439 } else { |
440 // Count global variables and functions for later processing | 440 // Count global variables and functions for later processing |
441 globals++; | 441 globals++; |
442 } | 442 } |
443 } | 443 } |
444 | 444 |
445 // Compute array of global variable and function declarations. | 445 // Compute array of global variable and function declarations. |
446 // Do nothing in case of no declared global functions or variables. | 446 // Do nothing in case of no declared global functions or variables. |
447 if (globals > 0) { | 447 if (globals > 0) { |
448 Handle<FixedArray> array = Factory::NewFixedArray(2 * globals, TENURED); | 448 Handle<FixedArray> array = Factory::NewFixedArray(2 * globals, TENURED); |
449 for (int j = 0, i = 0; i < length; i++) { | 449 for (int j = 0, i = 0; i < length; i++) { |
450 Declaration* decl = declarations->at(i); | 450 Declaration* decl = declarations->at(i); |
451 Variable* var = decl->proxy()->var(); | 451 Variable* var = decl->proxy()->var(); |
452 Slot* slot = var->slot(); | 452 Slot* slot = var->AsSlot(); |
453 | 453 |
454 if ((slot == NULL || slot->type() != Slot::LOOKUP) && var->is_global()) { | 454 if ((slot == NULL || slot->type() != Slot::LOOKUP) && var->is_global()) { |
455 array->set(j++, *(var->name())); | 455 array->set(j++, *(var->name())); |
456 if (decl->fun() == NULL) { | 456 if (decl->fun() == NULL) { |
457 if (var->mode() == Variable::CONST) { | 457 if (var->mode() == Variable::CONST) { |
458 // In case this is const property use the hole. | 458 // In case this is const property use the hole. |
459 array->set_the_hole(j++); | 459 array->set_the_hole(j++); |
460 } else { | 460 } else { |
461 array->set_undefined(j++); | 461 array->set_undefined(j++); |
462 } | 462 } |
(...skipping 548 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1011 | 1011 |
1012 Label try_handler_setup, catch_entry, done; | 1012 Label try_handler_setup, catch_entry, done; |
1013 __ Call(&try_handler_setup); | 1013 __ Call(&try_handler_setup); |
1014 // Try handler code, exception in result register. | 1014 // Try handler code, exception in result register. |
1015 | 1015 |
1016 // Store exception in local .catch variable before executing catch block. | 1016 // Store exception in local .catch variable before executing catch block. |
1017 { | 1017 { |
1018 // The catch variable is *always* a variable proxy for a local variable. | 1018 // The catch variable is *always* a variable proxy for a local variable. |
1019 Variable* catch_var = stmt->catch_var()->AsVariableProxy()->AsVariable(); | 1019 Variable* catch_var = stmt->catch_var()->AsVariableProxy()->AsVariable(); |
1020 ASSERT_NOT_NULL(catch_var); | 1020 ASSERT_NOT_NULL(catch_var); |
1021 Slot* variable_slot = catch_var->slot(); | 1021 Slot* variable_slot = catch_var->AsSlot(); |
1022 ASSERT_NOT_NULL(variable_slot); | 1022 ASSERT_NOT_NULL(variable_slot); |
1023 ASSERT_EQ(Slot::LOCAL, variable_slot->type()); | 1023 ASSERT_EQ(Slot::LOCAL, variable_slot->type()); |
1024 StoreToFrameField(SlotOffset(variable_slot), result_register()); | 1024 StoreToFrameField(SlotOffset(variable_slot), result_register()); |
1025 } | 1025 } |
1026 | 1026 |
1027 Visit(stmt->catch_block()); | 1027 Visit(stmt->catch_block()); |
1028 __ jmp(&done); | 1028 __ jmp(&done); |
1029 | 1029 |
1030 // Try block code. Sets up the exception handler chain. | 1030 // Try block code. Sets up the exception handler chain. |
1031 __ bind(&try_handler_setup); | 1031 __ bind(&try_handler_setup); |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1215 ASSERT(args->length() == 1); | 1215 ASSERT(args->length() == 1); |
1216 VisitForStackValue(args->at(0)); | 1216 VisitForStackValue(args->at(0)); |
1217 __ CallRuntime(Runtime::kRegExpCloneResult, 1); | 1217 __ CallRuntime(Runtime::kRegExpCloneResult, 1); |
1218 context()->Plug(result_register()); | 1218 context()->Plug(result_register()); |
1219 } | 1219 } |
1220 | 1220 |
1221 #undef __ | 1221 #undef __ |
1222 | 1222 |
1223 | 1223 |
1224 } } // namespace v8::internal | 1224 } } // namespace v8::internal |
OLD | NEW |