OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 606 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
617 Scope* scope = module->body()->scope(); | 617 Scope* scope = module->body()->scope(); |
618 Interface* interface = scope->interface(); | 618 Interface* interface = scope->interface(); |
619 ASSERT(interface->IsModule() && interface->IsFrozen()); | 619 ASSERT(interface->IsModule() && interface->IsFrozen()); |
620 | 620 |
621 interface->Allocate(scope->module_var()->index()); | 621 interface->Allocate(scope->module_var()->index()); |
622 | 622 |
623 // Set up module context. | 623 // Set up module context. |
624 ASSERT(scope->interface()->Index() >= 0); | 624 ASSERT(scope->interface()->Index() >= 0); |
625 __ Push(Smi::FromInt(scope->interface()->Index())); | 625 __ Push(Smi::FromInt(scope->interface()->Index())); |
626 __ Push(scope->GetScopeInfo()); | 626 __ Push(scope->GetScopeInfo()); |
627 __ CallRuntime(Runtime::kPushModuleContext, 2); | 627 __ CallRuntime(Runtime::kHiddenPushModuleContext, 2); |
628 StoreToFrameField(StandardFrameConstants::kContextOffset, | 628 StoreToFrameField(StandardFrameConstants::kContextOffset, |
629 context_register()); | 629 context_register()); |
630 | 630 |
631 AllocateModules(scope->declarations()); | 631 AllocateModules(scope->declarations()); |
632 | 632 |
633 // Pop module context. | 633 // Pop module context. |
634 LoadContextField(context_register(), Context::PREVIOUS_INDEX); | 634 LoadContextField(context_register(), Context::PREVIOUS_INDEX); |
635 // Update local stack frame context field. | 635 // Update local stack frame context field. |
636 StoreToFrameField(StandardFrameConstants::kContextOffset, | 636 StoreToFrameField(StandardFrameConstants::kContextOffset, |
637 context_register()); | 637 context_register()); |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
757 SetStatementPosition(block); | 757 SetStatementPosition(block); |
758 | 758 |
759 ASSERT(!modules_.is_null()); | 759 ASSERT(!modules_.is_null()); |
760 ASSERT(module_index_ < modules_->length()); | 760 ASSERT(module_index_ < modules_->length()); |
761 int index = module_index_++; | 761 int index = module_index_++; |
762 | 762 |
763 // Set up module context. | 763 // Set up module context. |
764 ASSERT(interface->Index() >= 0); | 764 ASSERT(interface->Index() >= 0); |
765 __ Push(Smi::FromInt(interface->Index())); | 765 __ Push(Smi::FromInt(interface->Index())); |
766 __ Push(Smi::FromInt(0)); | 766 __ Push(Smi::FromInt(0)); |
767 __ CallRuntime(Runtime::kPushModuleContext, 2); | 767 __ CallRuntime(Runtime::kHiddenPushModuleContext, 2); |
768 StoreToFrameField(StandardFrameConstants::kContextOffset, context_register()); | 768 StoreToFrameField(StandardFrameConstants::kContextOffset, context_register()); |
769 | 769 |
770 { | 770 { |
771 Comment cmnt(masm_, "[ Declarations"); | 771 Comment cmnt(masm_, "[ Declarations"); |
772 VisitDeclarations(scope_->declarations()); | 772 VisitDeclarations(scope_->declarations()); |
773 } | 773 } |
774 | 774 |
775 // Populate the module description. | 775 // Populate the module description. |
776 Handle<ModuleInfo> description = | 776 Handle<ModuleInfo> description = |
777 ModuleInfo::Create(isolate(), interface, scope_); | 777 ModuleInfo::Create(isolate(), interface, scope_); |
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1084 SetStatementPosition(stmt); | 1084 SetStatementPosition(stmt); |
1085 | 1085 |
1086 Scope* saved_scope = scope(); | 1086 Scope* saved_scope = scope(); |
1087 // Push a block context when entering a block with block scoped variables. | 1087 // Push a block context when entering a block with block scoped variables. |
1088 if (stmt->scope() != NULL) { | 1088 if (stmt->scope() != NULL) { |
1089 scope_ = stmt->scope(); | 1089 scope_ = stmt->scope(); |
1090 ASSERT(!scope_->is_module_scope()); | 1090 ASSERT(!scope_->is_module_scope()); |
1091 { Comment cmnt(masm_, "[ Extend block context"); | 1091 { Comment cmnt(masm_, "[ Extend block context"); |
1092 __ Push(scope_->GetScopeInfo()); | 1092 __ Push(scope_->GetScopeInfo()); |
1093 PushFunctionArgumentForContextAllocation(); | 1093 PushFunctionArgumentForContextAllocation(); |
1094 __ CallRuntime(Runtime::kPushBlockContext, 2); | 1094 __ CallRuntime(Runtime::kHiddenPushBlockContext, 2); |
1095 | 1095 |
1096 // Replace the context stored in the frame. | 1096 // Replace the context stored in the frame. |
1097 StoreToFrameField(StandardFrameConstants::kContextOffset, | 1097 StoreToFrameField(StandardFrameConstants::kContextOffset, |
1098 context_register()); | 1098 context_register()); |
1099 } | 1099 } |
1100 { Comment cmnt(masm_, "[ Declarations"); | 1100 { Comment cmnt(masm_, "[ Declarations"); |
1101 VisitDeclarations(scope_->declarations()); | 1101 VisitDeclarations(scope_->declarations()); |
1102 } | 1102 } |
1103 } | 1103 } |
1104 | 1104 |
(...skipping 11 matching lines...) Expand all Loading... |
1116 context_register()); | 1116 context_register()); |
1117 } | 1117 } |
1118 } | 1118 } |
1119 | 1119 |
1120 | 1120 |
1121 void FullCodeGenerator::VisitModuleStatement(ModuleStatement* stmt) { | 1121 void FullCodeGenerator::VisitModuleStatement(ModuleStatement* stmt) { |
1122 Comment cmnt(masm_, "[ Module context"); | 1122 Comment cmnt(masm_, "[ Module context"); |
1123 | 1123 |
1124 __ Push(Smi::FromInt(stmt->proxy()->interface()->Index())); | 1124 __ Push(Smi::FromInt(stmt->proxy()->interface()->Index())); |
1125 __ Push(Smi::FromInt(0)); | 1125 __ Push(Smi::FromInt(0)); |
1126 __ CallRuntime(Runtime::kPushModuleContext, 2); | 1126 __ CallRuntime(Runtime::kHiddenPushModuleContext, 2); |
1127 StoreToFrameField( | 1127 StoreToFrameField( |
1128 StandardFrameConstants::kContextOffset, context_register()); | 1128 StandardFrameConstants::kContextOffset, context_register()); |
1129 | 1129 |
1130 Scope* saved_scope = scope_; | 1130 Scope* saved_scope = scope_; |
1131 scope_ = stmt->body()->scope(); | 1131 scope_ = stmt->body()->scope(); |
1132 VisitStatements(stmt->body()->statements()); | 1132 VisitStatements(stmt->body()->statements()); |
1133 scope_ = saved_scope; | 1133 scope_ = saved_scope; |
1134 LoadContextField(context_register(), Context::PREVIOUS_INDEX); | 1134 LoadContextField(context_register(), Context::PREVIOUS_INDEX); |
1135 // Update local stack frame context field. | 1135 // Update local stack frame context field. |
1136 StoreToFrameField(StandardFrameConstants::kContextOffset, | 1136 StoreToFrameField(StandardFrameConstants::kContextOffset, |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1255 EmitReturnSequence(); | 1255 EmitReturnSequence(); |
1256 } | 1256 } |
1257 | 1257 |
1258 | 1258 |
1259 void FullCodeGenerator::VisitWithStatement(WithStatement* stmt) { | 1259 void FullCodeGenerator::VisitWithStatement(WithStatement* stmt) { |
1260 Comment cmnt(masm_, "[ WithStatement"); | 1260 Comment cmnt(masm_, "[ WithStatement"); |
1261 SetStatementPosition(stmt); | 1261 SetStatementPosition(stmt); |
1262 | 1262 |
1263 VisitForStackValue(stmt->expression()); | 1263 VisitForStackValue(stmt->expression()); |
1264 PushFunctionArgumentForContextAllocation(); | 1264 PushFunctionArgumentForContextAllocation(); |
1265 __ CallRuntime(Runtime::kPushWithContext, 2); | 1265 __ CallRuntime(Runtime::kHiddenPushWithContext, 2); |
1266 StoreToFrameField(StandardFrameConstants::kContextOffset, context_register()); | 1266 StoreToFrameField(StandardFrameConstants::kContextOffset, context_register()); |
1267 | 1267 |
1268 Scope* saved_scope = scope(); | 1268 Scope* saved_scope = scope(); |
1269 scope_ = stmt->scope(); | 1269 scope_ = stmt->scope(); |
1270 { WithOrCatch body(this); | 1270 { WithOrCatch body(this); |
1271 Visit(stmt->statement()); | 1271 Visit(stmt->statement()); |
1272 } | 1272 } |
1273 scope_ = saved_scope; | 1273 scope_ = saved_scope; |
1274 | 1274 |
1275 // Pop context. | 1275 // Pop context. |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1408 Label try_entry, handler_entry, exit; | 1408 Label try_entry, handler_entry, exit; |
1409 __ jmp(&try_entry); | 1409 __ jmp(&try_entry); |
1410 __ bind(&handler_entry); | 1410 __ bind(&handler_entry); |
1411 handler_table()->set(stmt->index(), Smi::FromInt(handler_entry.pos())); | 1411 handler_table()->set(stmt->index(), Smi::FromInt(handler_entry.pos())); |
1412 // Exception handler code, the exception is in the result register. | 1412 // Exception handler code, the exception is in the result register. |
1413 // Extend the context before executing the catch block. | 1413 // Extend the context before executing the catch block. |
1414 { Comment cmnt(masm_, "[ Extend catch context"); | 1414 { Comment cmnt(masm_, "[ Extend catch context"); |
1415 __ Push(stmt->variable()->name()); | 1415 __ Push(stmt->variable()->name()); |
1416 __ Push(result_register()); | 1416 __ Push(result_register()); |
1417 PushFunctionArgumentForContextAllocation(); | 1417 PushFunctionArgumentForContextAllocation(); |
1418 __ CallRuntime(Runtime::kPushCatchContext, 3); | 1418 __ CallRuntime(Runtime::kHiddenPushCatchContext, 3); |
1419 StoreToFrameField(StandardFrameConstants::kContextOffset, | 1419 StoreToFrameField(StandardFrameConstants::kContextOffset, |
1420 context_register()); | 1420 context_register()); |
1421 } | 1421 } |
1422 | 1422 |
1423 Scope* saved_scope = scope(); | 1423 Scope* saved_scope = scope(); |
1424 scope_ = stmt->scope(); | 1424 scope_ = stmt->scope(); |
1425 ASSERT(scope_->declarations()->is_empty()); | 1425 ASSERT(scope_->declarations()->is_empty()); |
1426 { WithOrCatch catch_body(this); | 1426 { WithOrCatch catch_body(this); |
1427 Visit(stmt->catch_block()); | 1427 Visit(stmt->catch_block()); |
1428 } | 1428 } |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1472 // Jump to try-handler setup and try-block code. | 1472 // Jump to try-handler setup and try-block code. |
1473 __ jmp(&try_entry); | 1473 __ jmp(&try_entry); |
1474 __ bind(&handler_entry); | 1474 __ bind(&handler_entry); |
1475 handler_table()->set(stmt->index(), Smi::FromInt(handler_entry.pos())); | 1475 handler_table()->set(stmt->index(), Smi::FromInt(handler_entry.pos())); |
1476 // Exception handler code. This code is only executed when an exception | 1476 // Exception handler code. This code is only executed when an exception |
1477 // is thrown. The exception is in the result register, and must be | 1477 // is thrown. The exception is in the result register, and must be |
1478 // preserved by the finally block. Call the finally block and then | 1478 // preserved by the finally block. Call the finally block and then |
1479 // rethrow the exception if it returns. | 1479 // rethrow the exception if it returns. |
1480 __ Call(&finally_entry); | 1480 __ Call(&finally_entry); |
1481 __ Push(result_register()); | 1481 __ Push(result_register()); |
1482 __ CallRuntime(Runtime::kReThrow, 1); | 1482 __ CallRuntime(Runtime::kHiddenReThrow, 1); |
1483 | 1483 |
1484 // Finally block implementation. | 1484 // Finally block implementation. |
1485 __ bind(&finally_entry); | 1485 __ bind(&finally_entry); |
1486 EnterFinallyBlock(); | 1486 EnterFinallyBlock(); |
1487 { Finally finally_body(this); | 1487 { Finally finally_body(this); |
1488 Visit(stmt->finally_block()); | 1488 Visit(stmt->finally_block()); |
1489 } | 1489 } |
1490 ExitFinallyBlock(); // Return to the calling code. | 1490 ExitFinallyBlock(); // Return to the calling code. |
1491 | 1491 |
1492 // Set up try handler. | 1492 // Set up try handler. |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1598 int parameters = fun->shared()->formal_parameter_count(); | 1598 int parameters = fun->shared()->formal_parameter_count(); |
1599 shared->set_formal_parameter_count(parameters); | 1599 shared->set_formal_parameter_count(parameters); |
1600 | 1600 |
1601 EmitNewClosure(shared, false); | 1601 EmitNewClosure(shared, false); |
1602 } | 1602 } |
1603 | 1603 |
1604 | 1604 |
1605 void FullCodeGenerator::VisitThrow(Throw* expr) { | 1605 void FullCodeGenerator::VisitThrow(Throw* expr) { |
1606 Comment cmnt(masm_, "[ Throw"); | 1606 Comment cmnt(masm_, "[ Throw"); |
1607 VisitForStackValue(expr->exception()); | 1607 VisitForStackValue(expr->exception()); |
1608 __ CallRuntime(Runtime::kThrow, 1); | 1608 __ CallRuntime(Runtime::kHiddenThrow, 1); |
1609 // Never returns here. | 1609 // Never returns here. |
1610 } | 1610 } |
1611 | 1611 |
1612 | 1612 |
1613 FullCodeGenerator::NestedStatement* FullCodeGenerator::TryCatch::Exit( | 1613 FullCodeGenerator::NestedStatement* FullCodeGenerator::TryCatch::Exit( |
1614 int* stack_depth, | 1614 int* stack_depth, |
1615 int* context_length) { | 1615 int* context_length) { |
1616 // The macros used here must preserve the result register. | 1616 // The macros used here must preserve the result register. |
1617 __ Drop(*stack_depth); | 1617 __ Drop(*stack_depth); |
1618 __ PopTryHandler(); | 1618 __ PopTryHandler(); |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1730 } | 1730 } |
1731 return true; | 1731 return true; |
1732 } | 1732 } |
1733 #endif // DEBUG | 1733 #endif // DEBUG |
1734 | 1734 |
1735 | 1735 |
1736 #undef __ | 1736 #undef __ |
1737 | 1737 |
1738 | 1738 |
1739 } } // namespace v8::internal | 1739 } } // namespace v8::internal |
OLD | NEW |