OLD | NEW |
---|---|
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 4475 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4486 TraceInline(target, caller, "target text too big"); | 4486 TraceInline(target, caller, "target text too big"); |
4487 return false; | 4487 return false; |
4488 } | 4488 } |
4489 | 4489 |
4490 // Target must be inlineable. | 4490 // Target must be inlineable. |
4491 if (!target->IsInlineable()) { | 4491 if (!target->IsInlineable()) { |
4492 TraceInline(target, caller, "target not inlineable"); | 4492 TraceInline(target, caller, "target not inlineable"); |
4493 return false; | 4493 return false; |
4494 } | 4494 } |
4495 | 4495 |
4496 // No context change required. | |
4497 CompilationInfo* outer_info = info(); | 4496 CompilationInfo* outer_info = info(); |
4497 #if !defined(V8_TARGET_ARCH_IA32) | |
4498 // Target must be able to use caller's context. | |
4498 if (target->context() != outer_info->closure()->context() || | 4499 if (target->context() != outer_info->closure()->context() || |
4499 outer_info->scope()->contains_with() || | 4500 outer_info->scope()->contains_with() || |
4500 outer_info->scope()->num_heap_slots() > 0) { | 4501 outer_info->scope()->num_heap_slots() > 0) { |
4501 TraceInline(target, caller, "target requires context change"); | 4502 TraceInline(target, caller, "target requires context change"); |
4502 return false; | 4503 return false; |
4503 } | 4504 } |
4505 #endif | |
4506 | |
fschneider
2011/09/23 13:15:31
Extra newline.
| |
4504 | 4507 |
4505 // Don't inline deeper than kMaxInliningLevels calls. | 4508 // Don't inline deeper than kMaxInliningLevels calls. |
4506 HEnvironment* env = environment(); | 4509 HEnvironment* env = environment(); |
4507 int current_level = 1; | 4510 int current_level = 1; |
4508 while (env->outer() != NULL) { | 4511 while (env->outer() != NULL) { |
4509 if (FLAG_limit_inlining && current_level == Compiler::kMaxInliningLevels) { | 4512 if (FLAG_limit_inlining && current_level == Compiler::kMaxInliningLevels) { |
4510 TraceInline(target, caller, "inline depth limit reached"); | 4513 TraceInline(target, caller, "inline depth limit reached"); |
4511 return false; | 4514 return false; |
4512 } | 4515 } |
4513 current_level++; | 4516 current_level++; |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4614 Handle<Code>(target_shared->code()), | 4617 Handle<Code>(target_shared->code()), |
4615 Handle<Context>(target->context()->global_context())); | 4618 Handle<Context>(target->context()->global_context())); |
4616 FunctionState target_state(this, &target_info, &target_oracle); | 4619 FunctionState target_state(this, &target_info, &target_oracle); |
4617 | 4620 |
4618 HConstant* undefined = graph()->GetConstantUndefined(); | 4621 HConstant* undefined = graph()->GetConstantUndefined(); |
4619 HEnvironment* inner_env = | 4622 HEnvironment* inner_env = |
4620 environment()->CopyForInlining(target, | 4623 environment()->CopyForInlining(target, |
4621 function, | 4624 function, |
4622 undefined, | 4625 undefined, |
4623 call_kind); | 4626 call_kind); |
4627 HConstant* context = new HConstant(Handle<Context>(target->context()), | |
4628 Representation::Tagged()); | |
4629 AddInstruction(context); | |
4630 inner_env->BindContext(context); | |
4624 HBasicBlock* body_entry = CreateBasicBlock(inner_env); | 4631 HBasicBlock* body_entry = CreateBasicBlock(inner_env); |
4625 current_block()->Goto(body_entry); | 4632 current_block()->Goto(body_entry); |
4626 body_entry->SetJoinId(expr->ReturnId()); | 4633 body_entry->SetJoinId(expr->ReturnId()); |
4627 set_current_block(body_entry); | 4634 set_current_block(body_entry); |
4628 AddInstruction(new(zone()) HEnterInlined(target, | 4635 AddInstruction(new(zone()) HEnterInlined(target, |
4629 function, | 4636 function, |
4630 call_kind)); | 4637 call_kind)); |
4631 VisitDeclarations(target_info.scope()->declarations()); | 4638 VisitDeclarations(target_info.scope()->declarations()); |
4632 VisitStatements(function->body()); | 4639 VisitStatements(function->body()); |
4633 if (HasStackOverflow()) { | 4640 if (HasStackOverflow()) { |
(...skipping 2201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6835 } | 6842 } |
6836 } | 6843 } |
6837 | 6844 |
6838 #ifdef DEBUG | 6845 #ifdef DEBUG |
6839 if (graph_ != NULL) graph_->Verify(false); // No full verify. | 6846 if (graph_ != NULL) graph_->Verify(false); // No full verify. |
6840 if (allocator_ != NULL) allocator_->Verify(); | 6847 if (allocator_ != NULL) allocator_->Verify(); |
6841 #endif | 6848 #endif |
6842 } | 6849 } |
6843 | 6850 |
6844 } } // namespace v8::internal | 6851 } } // namespace v8::internal |
OLD | NEW |