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 2595 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2606 return call; | 2606 return call; |
2607 } | 2607 } |
2608 | 2608 |
2609 | 2609 |
2610 void HGraphBuilder::SetUpScope(Scope* scope) { | 2610 void HGraphBuilder::SetUpScope(Scope* scope) { |
2611 HConstant* undefined_constant = new(zone()) HConstant( | 2611 HConstant* undefined_constant = new(zone()) HConstant( |
2612 isolate()->factory()->undefined_value(), Representation::Tagged()); | 2612 isolate()->factory()->undefined_value(), Representation::Tagged()); |
2613 AddInstruction(undefined_constant); | 2613 AddInstruction(undefined_constant); |
2614 graph_->set_undefined_constant(undefined_constant); | 2614 graph_->set_undefined_constant(undefined_constant); |
2615 | 2615 |
| 2616 HArgumentsObject* object = new(zone()) HArgumentsObject; |
| 2617 AddInstruction(object); |
| 2618 graph()->SetArgumentsObject(object); |
| 2619 |
2616 // Set the initial values of parameters including "this". "This" has | 2620 // Set the initial values of parameters including "this". "This" has |
2617 // parameter index 0. | 2621 // parameter index 0. |
2618 ASSERT_EQ(scope->num_parameters() + 1, environment()->parameter_count()); | 2622 ASSERT_EQ(scope->num_parameters() + 1, environment()->parameter_count()); |
2619 | 2623 |
2620 for (int i = 0; i < environment()->parameter_count(); ++i) { | 2624 for (int i = 0; i < environment()->parameter_count(); ++i) { |
2621 HInstruction* parameter = AddInstruction(new(zone()) HParameter(i)); | 2625 HInstruction* parameter = AddInstruction(new(zone()) HParameter(i)); |
2622 environment()->Bind(i, parameter); | 2626 environment()->Bind(i, parameter); |
2623 } | 2627 } |
2624 | 2628 |
2625 // First special is HContext. | 2629 // First special is HContext. |
2626 HInstruction* context = AddInstruction(new(zone()) HContext); | 2630 HInstruction* context = AddInstruction(new(zone()) HContext); |
2627 environment()->BindContext(context); | 2631 environment()->BindContext(context); |
2628 | 2632 |
2629 // Initialize specials and locals to undefined. | 2633 // Initialize specials and locals to undefined. |
2630 for (int i = environment()->parameter_count() + 1; | 2634 for (int i = environment()->parameter_count() + 1; |
2631 i < environment()->length(); | 2635 i < environment()->length(); |
2632 ++i) { | 2636 ++i) { |
2633 environment()->Bind(i, undefined_constant); | 2637 environment()->Bind(i, undefined_constant); |
2634 } | 2638 } |
2635 | 2639 |
2636 // Handle the arguments and arguments shadow variables specially (they do | 2640 // Handle the arguments and arguments shadow variables specially (they do |
2637 // not have declarations). | 2641 // not have declarations). |
2638 if (scope->arguments() != NULL) { | 2642 if (scope->arguments() != NULL) { |
2639 if (!scope->arguments()->IsStackAllocated()) { | 2643 if (!scope->arguments()->IsStackAllocated()) { |
2640 return Bailout("context-allocated arguments"); | 2644 return Bailout("context-allocated arguments"); |
2641 } | 2645 } |
2642 | 2646 |
2643 if (!graph()->HasArgumentsObject()) { | |
2644 HArgumentsObject* object = new(zone()) HArgumentsObject; | |
2645 AddInstruction(object); | |
2646 graph()->SetArgumentsObject(object); | |
2647 } | |
2648 environment()->Bind(scope->arguments(), | 2647 environment()->Bind(scope->arguments(), |
2649 graph()->GetArgumentsObject()); | 2648 graph()->GetArgumentsObject()); |
2650 } | 2649 } |
2651 } | 2650 } |
2652 | 2651 |
2653 | 2652 |
2654 void HGraphBuilder::VisitStatements(ZoneList<Statement*>* statements) { | 2653 void HGraphBuilder::VisitStatements(ZoneList<Statement*>* statements) { |
2655 for (int i = 0; i < statements->length(); i++) { | 2654 for (int i = 0; i < statements->length(); i++) { |
2656 CHECK_ALIVE(Visit(statements->at(i))); | 2655 CHECK_ALIVE(Visit(statements->at(i))); |
2657 } | 2656 } |
(...skipping 2660 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5318 AddSimulate(return_id); | 5317 AddSimulate(return_id); |
5319 current_block()->UpdateEnvironment(inner_env); | 5318 current_block()->UpdateEnvironment(inner_env); |
5320 AddInstruction(new(zone()) HEnterInlined(target, | 5319 AddInstruction(new(zone()) HEnterInlined(target, |
5321 arguments->length(), | 5320 arguments->length(), |
5322 function, | 5321 function, |
5323 call_kind, | 5322 call_kind, |
5324 function_state()->is_construct())); | 5323 function_state()->is_construct())); |
5325 // If the function uses arguments object create and bind one. | 5324 // If the function uses arguments object create and bind one. |
5326 if (function->scope()->arguments() != NULL) { | 5325 if (function->scope()->arguments() != NULL) { |
5327 ASSERT(function->scope()->arguments()->IsStackAllocated()); | 5326 ASSERT(function->scope()->arguments()->IsStackAllocated()); |
5328 if (!graph()->HasArgumentsObject()) { | |
5329 HArgumentsObject* object = new(zone()) HArgumentsObject; | |
5330 AddInstruction(object); | |
5331 graph()->SetArgumentsObject(object); | |
5332 } | |
5333 environment()->Bind(function->scope()->arguments(), | 5327 environment()->Bind(function->scope()->arguments(), |
5334 graph()->GetArgumentsObject()); | 5328 graph()->GetArgumentsObject()); |
5335 } | 5329 } |
5336 VisitDeclarations(target_info.scope()->declarations()); | 5330 VisitDeclarations(target_info.scope()->declarations()); |
5337 VisitStatements(function->body()); | 5331 VisitStatements(function->body()); |
5338 if (HasStackOverflow()) { | 5332 if (HasStackOverflow()) { |
5339 // Bail out if the inline function did, as we cannot residualize a call | 5333 // Bail out if the inline function did, as we cannot residualize a call |
5340 // instead. | 5334 // instead. |
5341 TraceInline(target, caller, "inline graph construction failed"); | 5335 TraceInline(target, caller, "inline graph construction failed"); |
5342 target_shared->DisableOptimization(); | 5336 target_shared->DisableOptimization(); |
(...skipping 2763 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8106 } | 8100 } |
8107 } | 8101 } |
8108 | 8102 |
8109 #ifdef DEBUG | 8103 #ifdef DEBUG |
8110 if (graph_ != NULL) graph_->Verify(false); // No full verify. | 8104 if (graph_ != NULL) graph_->Verify(false); // No full verify. |
8111 if (allocator_ != NULL) allocator_->Verify(); | 8105 if (allocator_ != NULL) allocator_->Verify(); |
8112 #endif | 8106 #endif |
8113 } | 8107 } |
8114 | 8108 |
8115 } } // namespace v8::internal | 8109 } } // namespace v8::internal |
OLD | NEW |