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 3991 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4002 if_false->MarkAsInlineReturnTarget(); | 4002 if_false->MarkAsInlineReturnTarget(); |
4003 // AstContext constructor pushes on the context stack. | 4003 // AstContext constructor pushes on the context stack. |
4004 test_context = new TestContext(this, if_true, if_false); | 4004 test_context = new TestContext(this, if_true, if_false); |
4005 function_return_ = NULL; | 4005 function_return_ = NULL; |
4006 } else { | 4006 } else { |
4007 // Inlined body is treated as if it occurs in the original call context. | 4007 // Inlined body is treated as if it occurs in the original call context. |
4008 function_return_ = graph()->CreateBasicBlock(); | 4008 function_return_ = graph()->CreateBasicBlock(); |
4009 function_return_->MarkAsInlineReturnTarget(); | 4009 function_return_->MarkAsInlineReturnTarget(); |
4010 } | 4010 } |
4011 call_context_ = ast_context(); | 4011 call_context_ = ast_context(); |
4012 TypeFeedbackOracle new_oracle(Handle<Code>(shared->code())); | 4012 TypeFeedbackOracle new_oracle( |
| 4013 Handle<Code>(shared->code()), |
| 4014 Handle<Context>(target->context()->global_context())); |
4013 oracle_ = &new_oracle; | 4015 oracle_ = &new_oracle; |
4014 graph()->info()->SetOsrAstId(AstNode::kNoNumber); | 4016 graph()->info()->SetOsrAstId(AstNode::kNoNumber); |
4015 | 4017 |
4016 HSubgraph* body = CreateInlinedSubgraph(env, target, function); | 4018 HSubgraph* body = CreateInlinedSubgraph(env, target, function); |
4017 body->exit_block()->AddInstruction(new HEnterInlined(target, function)); | 4019 body->exit_block()->AddInstruction(new HEnterInlined(target, function)); |
4018 AddToSubgraph(body, function->body()); | 4020 AddToSubgraph(body, function->body()); |
4019 if (HasStackOverflow()) { | 4021 if (HasStackOverflow()) { |
4020 // Bail out if the inline function did, as we cannot residualize a call | 4022 // Bail out if the inline function did, as we cannot residualize a call |
4021 // instead. | 4023 // instead. |
4022 delete test_context; | 4024 delete test_context; |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4204 if (!name->IsEqualTo(CStrVector("apply"))) return false; | 4206 if (!name->IsEqualTo(CStrVector("apply"))) return false; |
4205 | 4207 |
4206 ZoneList<Expression*>* args = expr->arguments(); | 4208 ZoneList<Expression*>* args = expr->arguments(); |
4207 if (args->length() != 2) return false; | 4209 if (args->length() != 2) return false; |
4208 | 4210 |
4209 VariableProxy* arg_two = args->at(1)->AsVariableProxy(); | 4211 VariableProxy* arg_two = args->at(1)->AsVariableProxy(); |
4210 if (arg_two == NULL || !arg_two->var()->IsStackAllocated()) return false; | 4212 if (arg_two == NULL || !arg_two->var()->IsStackAllocated()) return false; |
4211 HValue* arg_two_value = environment()->Lookup(arg_two->var()); | 4213 HValue* arg_two_value = environment()->Lookup(arg_two->var()); |
4212 if (!arg_two_value->CheckFlag(HValue::kIsArguments)) return false; | 4214 if (!arg_two_value->CheckFlag(HValue::kIsArguments)) return false; |
4213 | 4215 |
4214 if (!expr->IsMonomorphic()) return false; | 4216 if (!expr->IsMonomorphic() || |
| 4217 expr->check_type() != RECEIVER_MAP_CHECK) return false; |
4215 | 4218 |
4216 // Found pattern f.apply(receiver, arguments). | 4219 // Found pattern f.apply(receiver, arguments). |
4217 VisitForValue(prop->obj()); | 4220 VisitForValue(prop->obj()); |
4218 if (HasStackOverflow()) return false; | 4221 if (HasStackOverflow()) return false; |
4219 HValue* function = Pop(); | 4222 HValue* function = Pop(); |
4220 VisitForValue(args->at(0)); | 4223 VisitForValue(args->at(0)); |
4221 if (HasStackOverflow()) return false; | 4224 if (HasStackOverflow()) return false; |
4222 HValue* receiver = Pop(); | 4225 HValue* receiver = Pop(); |
4223 HInstruction* elements = AddInstruction(new HArgumentsElements); | 4226 HInstruction* elements = AddInstruction(new HArgumentsElements); |
4224 HInstruction* length = AddInstruction(new HArgumentsLength(elements)); | 4227 HInstruction* length = AddInstruction(new HArgumentsLength(elements)); |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4273 HValue* receiver = VisitArgument(prop->obj()); | 4276 HValue* receiver = VisitArgument(prop->obj()); |
4274 CHECK_BAILOUT; | 4277 CHECK_BAILOUT; |
4275 VisitArgumentList(expr->arguments()); | 4278 VisitArgumentList(expr->arguments()); |
4276 CHECK_BAILOUT; | 4279 CHECK_BAILOUT; |
4277 | 4280 |
4278 Handle<String> name = prop->key()->AsLiteral()->AsPropertyName(); | 4281 Handle<String> name = prop->key()->AsLiteral()->AsPropertyName(); |
4279 | 4282 |
4280 expr->RecordTypeFeedback(oracle()); | 4283 expr->RecordTypeFeedback(oracle()); |
4281 ZoneMapList* types = expr->GetReceiverTypes(); | 4284 ZoneMapList* types = expr->GetReceiverTypes(); |
4282 | 4285 |
4283 if (expr->IsMonomorphic()) { | 4286 if (expr->IsMonomorphic() && expr->check_type() == RECEIVER_MAP_CHECK) { |
4284 AddCheckConstantFunction(expr, receiver, types->first(), true); | 4287 AddCheckConstantFunction(expr, receiver, types->first(), true); |
4285 | 4288 |
4286 if (TryMathFunctionInline(expr)) { | 4289 if (TryMathFunctionInline(expr)) { |
4287 return; | 4290 return; |
4288 } else if (TryInline(expr)) { | 4291 } else if (TryInline(expr)) { |
4289 if (subgraph()->HasExit()) { | 4292 if (subgraph()->HasExit()) { |
4290 HValue* return_value = Pop(); | 4293 HValue* return_value = Pop(); |
4291 // If we inlined a function in a test context then we need to emit | 4294 // If we inlined a function in a test context then we need to emit |
4292 // a simulate here to shadow the ones at the end of the | 4295 // a simulate here to shadow the ones at the end of the |
4293 // predecessor blocks. Those environments contain the return | 4296 // predecessor blocks. Those environments contain the return |
4294 // value on top and do not correspond to any actual state of the | 4297 // value on top and do not correspond to any actual state of the |
4295 // unoptimized code. | 4298 // unoptimized code. |
4296 if (ast_context()->IsEffect()) AddSimulate(expr->id()); | 4299 if (ast_context()->IsEffect()) AddSimulate(expr->id()); |
4297 ast_context()->ReturnValue(return_value); | 4300 ast_context()->ReturnValue(return_value); |
4298 } | 4301 } |
4299 return; | 4302 return; |
4300 } else { | 4303 } else { |
4301 // Check for bailout, as the TryInline call in the if condition above | 4304 // Check for bailout, as the TryInline call in the if condition above |
4302 // might return false due to bailout during hydrogen processing. | 4305 // might return false due to bailout during hydrogen processing. |
4303 CHECK_BAILOUT; | 4306 CHECK_BAILOUT; |
4304 call = new HCallConstantFunction(expr->target(), argument_count); | 4307 call = new HCallConstantFunction(expr->target(), argument_count); |
4305 } | 4308 } |
4306 | 4309 |
4307 } else if (types != NULL && types->length() > 1) { | 4310 } else if (types != NULL && types->length() > 1) { |
| 4311 ASSERT(expr->check_type() == RECEIVER_MAP_CHECK); |
4308 HandlePolymorphicCallNamed(expr, receiver, types, name); | 4312 HandlePolymorphicCallNamed(expr, receiver, types, name); |
4309 return; | 4313 return; |
4310 | 4314 |
4311 } else { | 4315 } else { |
4312 call = new HCallNamed(name, argument_count); | 4316 call = new HCallNamed(name, argument_count); |
4313 } | 4317 } |
4314 | 4318 |
4315 } else { | 4319 } else { |
4316 Variable* var = expr->expression()->AsVariableProxy()->AsVariable(); | 4320 Variable* var = expr->expression()->AsVariableProxy()->AsVariable(); |
4317 bool global_call = (var != NULL) && var->is_global() && !var->is_this(); | 4321 bool global_call = (var != NULL) && var->is_global() && !var->is_this(); |
(...skipping 1468 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5786 } | 5790 } |
5787 } | 5791 } |
5788 | 5792 |
5789 #ifdef DEBUG | 5793 #ifdef DEBUG |
5790 if (graph_ != NULL) graph_->Verify(); | 5794 if (graph_ != NULL) graph_->Verify(); |
5791 if (allocator_ != NULL) allocator_->Verify(); | 5795 if (allocator_ != NULL) allocator_->Verify(); |
5792 #endif | 5796 #endif |
5793 } | 5797 } |
5794 | 5798 |
5795 } } // namespace v8::internal | 5799 } } // namespace v8::internal |
OLD | NEW |