OLD | NEW |
---|---|
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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 6343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6354 int nodes_added = InliningAstSize(target); | 6354 int nodes_added = InliningAstSize(target); |
6355 if (nodes_added == kNotInlinable) return false; | 6355 if (nodes_added == kNotInlinable) return false; |
6356 | 6356 |
6357 Handle<JSFunction> caller = current_info()->closure(); | 6357 Handle<JSFunction> caller = current_info()->closure(); |
6358 | 6358 |
6359 if (nodes_added > Min(FLAG_max_inlined_nodes, kUnlimitedMaxInlinedNodes)) { | 6359 if (nodes_added > Min(FLAG_max_inlined_nodes, kUnlimitedMaxInlinedNodes)) { |
6360 TraceInline(target, caller, "target AST is too large [early]"); | 6360 TraceInline(target, caller, "target AST is too large [early]"); |
6361 return false; | 6361 return false; |
6362 } | 6362 } |
6363 | 6363 |
6364 #if !V8_TARGET_ARCH_IA32 && !V8_TARGET_ARCH_ARM && !V8_TARGET_ARCH_MIPS | |
6365 // Target must be able to use caller's context. | |
6366 CompilationInfo* outer_info = current_info(); | |
6367 if (target->context() != outer_info->closure()->context() || | |
6368 outer_info->scope()->contains_with() || | |
6369 outer_info->scope()->num_heap_slots() > 0) { | |
6370 TraceInline(target, caller, "target requires context change"); | |
6371 return false; | |
6372 } | |
6373 #endif | |
6374 | |
6375 | |
6376 // Don't inline deeper than the maximum number of inlining levels. | 6364 // Don't inline deeper than the maximum number of inlining levels. |
6377 HEnvironment* env = environment(); | 6365 HEnvironment* env = environment(); |
6378 int current_level = 1; | 6366 int current_level = 1; |
6379 while (env->outer() != NULL) { | 6367 while (env->outer() != NULL) { |
6380 if (current_level == FLAG_max_inlining_levels) { | 6368 if (current_level == FLAG_max_inlining_levels) { |
6381 TraceInline(target, caller, "inline depth limit reached"); | 6369 TraceInline(target, caller, "inline depth limit reached"); |
6382 return false; | 6370 return false; |
6383 } | 6371 } |
6384 if (env->outer()->frame_type() == JS_FUNCTION) { | 6372 if (env->outer()->frame_type() == JS_FUNCTION) { |
6385 current_level++; | 6373 current_level++; |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6503 HConstant* undefined = graph()->GetConstantUndefined(); | 6491 HConstant* undefined = graph()->GetConstantUndefined(); |
6504 bool undefined_receiver = HEnvironment::UseUndefinedReceiver( | 6492 bool undefined_receiver = HEnvironment::UseUndefinedReceiver( |
6505 target, function, call_kind, inlining_kind); | 6493 target, function, call_kind, inlining_kind); |
6506 HEnvironment* inner_env = | 6494 HEnvironment* inner_env = |
6507 environment()->CopyForInlining(target, | 6495 environment()->CopyForInlining(target, |
6508 arguments_count, | 6496 arguments_count, |
6509 function, | 6497 function, |
6510 undefined, | 6498 undefined, |
6511 function_state()->inlining_kind(), | 6499 function_state()->inlining_kind(), |
6512 undefined_receiver); | 6500 undefined_receiver); |
6513 #if V8_TARGET_ARCH_IA32 || V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_MIPS | 6501 |
mvstanton
2013/10/31 08:39:24
TODO achieved :)
| |
6514 // IA32, ARM and MIPS only, overwrite the caller's context in the | |
6515 // deoptimization environment with the correct one. | |
6516 // | |
6517 // TODO(kmillikin): implement the same inlining on other platforms so we | |
6518 // can remove the unsightly ifdefs in this function. | |
6519 HConstant* context = Add<HConstant>(Handle<Context>(target->context())); | 6502 HConstant* context = Add<HConstant>(Handle<Context>(target->context())); |
6520 inner_env->BindContext(context); | 6503 inner_env->BindContext(context); |
6521 #endif | |
6522 | 6504 |
6523 Add<HSimulate>(return_id); | 6505 Add<HSimulate>(return_id); |
6524 current_block()->UpdateEnvironment(inner_env); | 6506 current_block()->UpdateEnvironment(inner_env); |
6525 HArgumentsObject* arguments_object = NULL; | 6507 HArgumentsObject* arguments_object = NULL; |
6526 | 6508 |
6527 // If the function uses arguments object create and bind one, also copy | 6509 // If the function uses arguments object create and bind one, also copy |
6528 // current arguments values to use them for materialization. | 6510 // current arguments values to use them for materialization. |
6529 if (function->scope()->arguments() != NULL) { | 6511 if (function->scope()->arguments() != NULL) { |
6530 ASSERT(function->scope()->arguments()->IsStackAllocated()); | 6512 ASSERT(function->scope()->arguments()->IsStackAllocated()); |
6531 HEnvironment* arguments_env = inner_env->arguments_environment(); | 6513 HEnvironment* arguments_env = inner_env->arguments_environment(); |
(...skipping 3292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
9824 if (ShouldProduceTraceOutput()) { | 9806 if (ShouldProduceTraceOutput()) { |
9825 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); | 9807 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); |
9826 } | 9808 } |
9827 | 9809 |
9828 #ifdef DEBUG | 9810 #ifdef DEBUG |
9829 graph_->Verify(false); // No full verify. | 9811 graph_->Verify(false); // No full verify. |
9830 #endif | 9812 #endif |
9831 } | 9813 } |
9832 | 9814 |
9833 } } // namespace v8::internal | 9815 } } // namespace v8::internal |
OLD | NEW |