Chromium Code Reviews| 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 7542 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 7553 if (args->length() != 2) return false; | 7553 if (args->length() != 2) return false; |
| 7554 | 7554 |
| 7555 VariableProxy* arg_two = args->at(1)->AsVariableProxy(); | 7555 VariableProxy* arg_two = args->at(1)->AsVariableProxy(); |
| 7556 if (arg_two == NULL || !arg_two->var()->IsStackAllocated()) return false; | 7556 if (arg_two == NULL || !arg_two->var()->IsStackAllocated()) return false; |
| 7557 HValue* arg_two_value = LookupAndMakeLive(arg_two->var()); | 7557 HValue* arg_two_value = LookupAndMakeLive(arg_two->var()); |
| 7558 if (!arg_two_value->CheckFlag(HValue::kIsArguments)) return false; | 7558 if (!arg_two_value->CheckFlag(HValue::kIsArguments)) return false; |
| 7559 | 7559 |
| 7560 // Found pattern f.apply(receiver, arguments). | 7560 // Found pattern f.apply(receiver, arguments). |
| 7561 CHECK_ALIVE_OR_RETURN(VisitForValue(prop->obj()), true); | 7561 CHECK_ALIVE_OR_RETURN(VisitForValue(prop->obj()), true); |
| 7562 HValue* function = Top(); | 7562 HValue* function = Top(); |
| 7563 // The function get here may be an undefined constant if lookup fails. | |
| 7564 if (function->IsConstant() && | |
| 7565 !HConstant::cast(function)->handle(isolate())->IsJSFunction()) { | |
| 7566 Drop(1); | |
| 7567 return false; | |
|
Michael Starzinger
2013/11/28 16:01:25
I don't think it is safe to bail out at this point
| |
| 7568 } | |
| 7569 | |
| 7563 AddCheckConstantFunction(expr->holder(), function, function_map); | 7570 AddCheckConstantFunction(expr->holder(), function, function_map); |
| 7564 Drop(1); | 7571 Drop(1); |
| 7565 | 7572 |
| 7566 CHECK_ALIVE_OR_RETURN(VisitForValue(args->at(0)), true); | 7573 CHECK_ALIVE_OR_RETURN(VisitForValue(args->at(0)), true); |
| 7567 HValue* receiver = Pop(); | 7574 HValue* receiver = Pop(); |
| 7568 | 7575 |
| 7569 if (function_state()->outer() == NULL) { | 7576 if (function_state()->outer() == NULL) { |
| 7570 HInstruction* elements = Add<HArgumentsElements>(false); | 7577 HInstruction* elements = Add<HArgumentsElements>(false); |
| 7571 HInstruction* length = Add<HArgumentsLength>(elements); | 7578 HInstruction* length = Add<HArgumentsLength>(elements); |
| 7572 HValue* wrapped_receiver = BuildWrapReceiver(receiver, function); | 7579 HValue* wrapped_receiver = BuildWrapReceiver(receiver, function); |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 7583 function_state()->entry()->arguments_object()->arguments_count()); | 7590 function_state()->entry()->arguments_object()->arguments_count()); |
| 7584 HArgumentsObject* args = function_state()->entry()->arguments_object(); | 7591 HArgumentsObject* args = function_state()->entry()->arguments_object(); |
| 7585 const ZoneList<HValue*>* arguments_values = args->arguments_values(); | 7592 const ZoneList<HValue*>* arguments_values = args->arguments_values(); |
| 7586 int arguments_count = arguments_values->length(); | 7593 int arguments_count = arguments_values->length(); |
| 7587 Push(BuildWrapReceiver(receiver, function)); | 7594 Push(BuildWrapReceiver(receiver, function)); |
| 7588 for (int i = 1; i < arguments_count; i++) { | 7595 for (int i = 1; i < arguments_count; i++) { |
| 7589 Push(arguments_values->at(i)); | 7596 Push(arguments_values->at(i)); |
| 7590 } | 7597 } |
| 7591 | 7598 |
| 7592 Handle<JSFunction> known_function; | 7599 Handle<JSFunction> known_function; |
| 7593 if (function->IsConstant()) { | 7600 if (function->IsConstant()) { |
|
Michael Starzinger
2013/11/28 16:01:25
... here, because that is the only place where the
| |
| 7594 HConstant* constant_function = HConstant::cast(function); | 7601 HConstant* constant_function = HConstant::cast(function); |
| 7595 known_function = Handle<JSFunction>::cast( | 7602 known_function = Handle<JSFunction>::cast( |
| 7596 constant_function->handle(isolate())); | 7603 constant_function->handle(isolate())); |
| 7597 int args_count = arguments_count - 1; // Excluding receiver. | 7604 int args_count = arguments_count - 1; // Excluding receiver. |
| 7598 if (TryInlineApply(known_function, expr, args_count)) return true; | 7605 if (TryInlineApply(known_function, expr, args_count)) return true; |
| 7599 } | 7606 } |
| 7600 | 7607 |
| 7601 Drop(arguments_count - 1); | 7608 Drop(arguments_count - 1); |
| 7602 Push(Add<HPushArgument>(Pop())); | 7609 Push(Add<HPushArgument>(Pop())); |
| 7603 for (int i = 1; i < arguments_count; i++) { | 7610 for (int i = 1; i < arguments_count; i++) { |
| (...skipping 3210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 10814 if (ShouldProduceTraceOutput()) { | 10821 if (ShouldProduceTraceOutput()) { |
| 10815 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); | 10822 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); |
| 10816 } | 10823 } |
| 10817 | 10824 |
| 10818 #ifdef DEBUG | 10825 #ifdef DEBUG |
| 10819 graph_->Verify(false); // No full verify. | 10826 graph_->Verify(false); // No full verify. |
| 10820 #endif | 10827 #endif |
| 10821 } | 10828 } |
| 10822 | 10829 |
| 10823 } } // namespace v8::internal | 10830 } } // namespace v8::internal |
| OLD | NEW |