| 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 7736 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7747 return TryInline(CALL_AS_METHOD, | 7747 return TryInline(CALL_AS_METHOD, |
| 7748 setter, | 7748 setter, |
| 7749 1, | 7749 1, |
| 7750 implicit_return_value, | 7750 implicit_return_value, |
| 7751 assignment->id(), | 7751 assignment->id(), |
| 7752 assignment->AssignmentId(), | 7752 assignment->AssignmentId(), |
| 7753 SETTER_CALL_RETURN); | 7753 SETTER_CALL_RETURN); |
| 7754 } | 7754 } |
| 7755 | 7755 |
| 7756 | 7756 |
| 7757 bool HOptimizedGraphBuilder::TryInlineApply(Handle<JSFunction> function, |
| 7758 Call* expr, |
| 7759 int arguments_count) { |
| 7760 return TryInline(CALL_AS_METHOD, |
| 7761 function, |
| 7762 arguments_count, |
| 7763 NULL, |
| 7764 expr->id(), |
| 7765 expr->ReturnId(), |
| 7766 NORMAL_RETURN); |
| 7767 } |
| 7768 |
| 7769 |
| 7757 bool HOptimizedGraphBuilder::TryInlineBuiltinFunctionCall(Call* expr, | 7770 bool HOptimizedGraphBuilder::TryInlineBuiltinFunctionCall(Call* expr, |
| 7758 bool drop_extra) { | 7771 bool drop_extra) { |
| 7759 if (!expr->target()->shared()->HasBuiltinFunctionId()) return false; | 7772 if (!expr->target()->shared()->HasBuiltinFunctionId()) return false; |
| 7760 BuiltinFunctionId id = expr->target()->shared()->builtin_function_id(); | 7773 BuiltinFunctionId id = expr->target()->shared()->builtin_function_id(); |
| 7761 switch (id) { | 7774 switch (id) { |
| 7762 case kMathExp: | 7775 case kMathExp: |
| 7763 if (!FLAG_fast_math) break; | 7776 if (!FLAG_fast_math) break; |
| 7764 // Fall through if FLAG_fast_math. | 7777 // Fall through if FLAG_fast_math. |
| 7765 case kMathRound: | 7778 case kMathRound: |
| 7766 case kMathAbs: | 7779 case kMathAbs: |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7974 elements); | 7987 elements); |
| 7975 result->set_position(expr->position()); | 7988 result->set_position(expr->position()); |
| 7976 ast_context()->ReturnInstruction(result, expr->id()); | 7989 ast_context()->ReturnInstruction(result, expr->id()); |
| 7977 return true; | 7990 return true; |
| 7978 } else { | 7991 } else { |
| 7979 // We are inside inlined function and we know exactly what is inside | 7992 // We are inside inlined function and we know exactly what is inside |
| 7980 // arguments object. But we need to be able to materialize at deopt. | 7993 // arguments object. But we need to be able to materialize at deopt. |
| 7981 // TODO(mstarzinger): For now we just ensure arguments are pushed | 7994 // TODO(mstarzinger): For now we just ensure arguments are pushed |
| 7982 // right after HEnterInlined, but we could be smarter about this. | 7995 // right after HEnterInlined, but we could be smarter about this. |
| 7983 EnsureArgumentsArePushedForAccess(); | 7996 EnsureArgumentsArePushedForAccess(); |
| 7984 HValue* context = environment()->LookupContext(); | 7997 HEnvironment* arguments_env = environment()->arguments_environment(); |
| 7998 int parameter_count = arguments_env->parameter_count(); |
| 7999 PushAndAdd(new(zone()) HWrapReceiver(receiver, function)); |
| 8000 for (int i = 1; i < arguments_env->parameter_count(); i++) { |
| 8001 Push(arguments_env->Lookup(i)); |
| 8002 } |
| 7985 | 8003 |
| 7986 HValue* wrapped_receiver = | 8004 Handle<JSFunction> known_function; |
| 7987 AddInstruction(new(zone()) HWrapReceiver(receiver, function)); | 8005 if (function->IsConstant()) { |
| 7988 PushAndAdd(new(zone()) HPushArgument(wrapped_receiver)); | 8006 HConstant* constant_function = HConstant::cast(function); |
| 8007 known_function = Handle<JSFunction>::cast(constant_function->handle()); |
| 8008 int arguments_count = parameter_count - 1; // Excluding receiver. |
| 8009 if (TryInlineApply(known_function, expr, arguments_count)) return true; |
| 8010 } |
| 7989 | 8011 |
| 7990 HEnvironment* arguments_env = environment()->arguments_environment(); | 8012 Drop(parameter_count - 1); |
| 7991 | 8013 PushAndAdd(new(zone()) HPushArgument(Pop())); |
| 7992 int parameter_count = arguments_env->parameter_count(); | |
| 7993 for (int i = 1; i < arguments_env->parameter_count(); i++) { | 8014 for (int i = 1; i < arguments_env->parameter_count(); i++) { |
| 7994 PushAndAdd(new(zone()) HPushArgument(arguments_env->Lookup(i))); | 8015 PushAndAdd(new(zone()) HPushArgument(arguments_env->Lookup(i))); |
| 7995 } | 8016 } |
| 7996 | 8017 |
| 8018 HValue* context = environment()->LookupContext(); |
| 7997 HInvokeFunction* call = new(zone()) HInvokeFunction( | 8019 HInvokeFunction* call = new(zone()) HInvokeFunction( |
| 7998 context, | 8020 context, |
| 7999 function, | 8021 function, |
| 8022 known_function, |
| 8000 parameter_count); | 8023 parameter_count); |
| 8001 Drop(parameter_count); | 8024 Drop(parameter_count); |
| 8002 call->set_position(expr->position()); | 8025 call->set_position(expr->position()); |
| 8003 ast_context()->ReturnInstruction(call, expr->id()); | 8026 ast_context()->ReturnInstruction(call, expr->id()); |
| 8004 return true; | 8027 return true; |
| 8005 } | 8028 } |
| 8006 } | 8029 } |
| 8007 | 8030 |
| 8008 | 8031 |
| 8009 // Checks if all maps in |types| are from the same family, i.e., are elements | 8032 // Checks if all maps in |types| are from the same family, i.e., are elements |
| (...skipping 2621 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10631 } | 10654 } |
| 10632 } | 10655 } |
| 10633 | 10656 |
| 10634 #ifdef DEBUG | 10657 #ifdef DEBUG |
| 10635 if (graph_ != NULL) graph_->Verify(false); // No full verify. | 10658 if (graph_ != NULL) graph_->Verify(false); // No full verify. |
| 10636 if (allocator_ != NULL) allocator_->Verify(); | 10659 if (allocator_ != NULL) allocator_->Verify(); |
| 10637 #endif | 10660 #endif |
| 10638 } | 10661 } |
| 10639 | 10662 |
| 10640 } } // namespace v8::internal | 10663 } } // namespace v8::internal |
| OLD | NEW |