| 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 4431 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4442 ASSERT(target_shared->has_deoptimization_support()); | 4442 ASSERT(target_shared->has_deoptimization_support()); |
| 4443 TypeFeedbackOracle target_oracle( | 4443 TypeFeedbackOracle target_oracle( |
| 4444 Handle<Code>(target_shared->code()), | 4444 Handle<Code>(target_shared->code()), |
| 4445 Handle<Context>(target->context()->global_context())); | 4445 Handle<Context>(target->context()->global_context())); |
| 4446 FunctionState target_state(this, &target_info, &target_oracle); | 4446 FunctionState target_state(this, &target_info, &target_oracle); |
| 4447 | 4447 |
| 4448 HConstant* undefined = graph()->GetConstantUndefined(); | 4448 HConstant* undefined = graph()->GetConstantUndefined(); |
| 4449 HEnvironment* inner_env = | 4449 HEnvironment* inner_env = |
| 4450 environment()->CopyForInlining(target, | 4450 environment()->CopyForInlining(target, |
| 4451 function, | 4451 function, |
| 4452 HEnvironment::HYDROGEN, | |
| 4453 undefined, | 4452 undefined, |
| 4454 call_kind); | 4453 call_kind); |
| 4455 HBasicBlock* body_entry = CreateBasicBlock(inner_env); | 4454 HBasicBlock* body_entry = CreateBasicBlock(inner_env); |
| 4456 current_block()->Goto(body_entry); | 4455 current_block()->Goto(body_entry); |
| 4457 body_entry->SetJoinId(expr->ReturnId()); | 4456 body_entry->SetJoinId(expr->ReturnId()); |
| 4458 set_current_block(body_entry); | 4457 set_current_block(body_entry); |
| 4459 AddInstruction(new(zone()) HEnterInlined(target, | 4458 AddInstruction(new(zone()) HEnterInlined(target, |
| 4460 function, | 4459 function, |
| 4461 call_kind)); | 4460 call_kind)); |
| 4462 VisitDeclarations(target_info.scope()->declarations()); | 4461 VisitDeclarations(target_info.scope()->declarations()); |
| (...skipping 1742 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6205 loop_header->AddPhi(phi); | 6204 loop_header->AddPhi(phi); |
| 6206 } | 6205 } |
| 6207 new_env->ClearHistory(); | 6206 new_env->ClearHistory(); |
| 6208 return new_env; | 6207 return new_env; |
| 6209 } | 6208 } |
| 6210 | 6209 |
| 6211 | 6210 |
| 6212 HEnvironment* HEnvironment::CopyForInlining( | 6211 HEnvironment* HEnvironment::CopyForInlining( |
| 6213 Handle<JSFunction> target, | 6212 Handle<JSFunction> target, |
| 6214 FunctionLiteral* function, | 6213 FunctionLiteral* function, |
| 6215 CompilationPhase compilation_phase, | |
| 6216 HConstant* undefined, | 6214 HConstant* undefined, |
| 6217 CallKind call_kind) const { | 6215 CallKind call_kind) const { |
| 6218 // Outer environment is a copy of this one without the arguments. | 6216 // Outer environment is a copy of this one without the arguments. |
| 6219 int arity = function->scope()->num_parameters(); | 6217 int arity = function->scope()->num_parameters(); |
| 6220 HEnvironment* outer = Copy(); | 6218 HEnvironment* outer = Copy(); |
| 6221 outer->Drop(arity + 1); // Including receiver. | 6219 outer->Drop(arity + 1); // Including receiver. |
| 6222 outer->ClearHistory(); | 6220 outer->ClearHistory(); |
| 6223 Zone* zone = closure()->GetIsolate()->zone(); | 6221 Zone* zone = closure()->GetIsolate()->zone(); |
| 6224 HEnvironment* inner = | 6222 HEnvironment* inner = |
| 6225 new(zone) HEnvironment(outer, function->scope(), target); | 6223 new(zone) HEnvironment(outer, function->scope(), target); |
| 6226 // Get the argument values from the original environment. | 6224 // Get the argument values from the original environment. |
| 6227 if (compilation_phase == HYDROGEN) { | 6225 for (int i = 0; i <= arity; ++i) { // Include receiver. |
| 6228 for (int i = 0; i <= arity; ++i) { // Include receiver. | 6226 HValue* push = ExpressionStackAt(arity - i); |
| 6229 HValue* push = ExpressionStackAt(arity - i); | 6227 inner->SetValueAt(i, push); |
| 6230 inner->SetValueAt(i, push); | |
| 6231 } | |
| 6232 } else { | |
| 6233 ASSERT(compilation_phase == LITHIUM); | |
| 6234 for (int i = 0; i <= arity; ++i) { // Include receiver. | |
| 6235 HValue* push = ExpressionStackAt(arity - i); | |
| 6236 inner->SetValueAt(i, push); | |
| 6237 } | |
| 6238 } | 6228 } |
| 6239 // If the function we are inlining is a strict mode function or a | 6229 // If the function we are inlining is a strict mode function or a |
| 6240 // builtin function, pass undefined as the receiver for function | 6230 // builtin function, pass undefined as the receiver for function |
| 6241 // calls (instead of the global receiver). | 6231 // calls (instead of the global receiver). |
| 6242 if ((target->shared()->native() || function->strict_mode()) && | 6232 if ((target->shared()->native() || function->strict_mode()) && |
| 6243 call_kind == CALL_AS_FUNCTION) { | 6233 call_kind == CALL_AS_FUNCTION) { |
| 6244 inner->SetValueAt(0, undefined); | 6234 inner->SetValueAt(0, undefined); |
| 6245 } | 6235 } |
| 6246 inner->SetValueAt(arity + 1, outer->LookupContext()); | 6236 inner->SetValueAt(arity + 1, outer->LookupContext()); |
| 6247 for (int i = arity + 2; i < inner->length(); ++i) { | 6237 for (int i = arity + 2; i < inner->length(); ++i) { |
| (...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6583 } | 6573 } |
| 6584 } | 6574 } |
| 6585 | 6575 |
| 6586 #ifdef DEBUG | 6576 #ifdef DEBUG |
| 6587 if (graph_ != NULL) graph_->Verify(); | 6577 if (graph_ != NULL) graph_->Verify(); |
| 6588 if (allocator_ != NULL) allocator_->Verify(); | 6578 if (allocator_ != NULL) allocator_->Verify(); |
| 6589 #endif | 6579 #endif |
| 6590 } | 6580 } |
| 6591 | 6581 |
| 6592 } } // namespace v8::internal | 6582 } } // namespace v8::internal |
| OLD | NEW |