OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "hydrogen.h" | 5 #include "hydrogen.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "v8.h" | 9 #include "v8.h" |
10 #include "allocation-site-scopes.h" | 10 #include "allocation-site-scopes.h" |
(...skipping 7993 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8004 if (arg_two == NULL || !arg_two->var()->IsStackAllocated()) return false; | 8004 if (arg_two == NULL || !arg_two->var()->IsStackAllocated()) return false; |
8005 HValue* arg_two_value = LookupAndMakeLive(arg_two->var()); | 8005 HValue* arg_two_value = LookupAndMakeLive(arg_two->var()); |
8006 if (!arg_two_value->CheckFlag(HValue::kIsArguments)) return false; | 8006 if (!arg_two_value->CheckFlag(HValue::kIsArguments)) return false; |
8007 | 8007 |
8008 // Found pattern f.apply(receiver, arguments). | 8008 // Found pattern f.apply(receiver, arguments). |
8009 CHECK_ALIVE_OR_RETURN(VisitForValue(args->at(0)), true); | 8009 CHECK_ALIVE_OR_RETURN(VisitForValue(args->at(0)), true); |
8010 HValue* receiver = Pop(); // receiver | 8010 HValue* receiver = Pop(); // receiver |
8011 HValue* function = Pop(); // f | 8011 HValue* function = Pop(); // f |
8012 Drop(1); // apply | 8012 Drop(1); // apply |
8013 | 8013 |
| 8014 HValue* checked_function = AddCheckMap(function, function_map); |
| 8015 |
8014 if (function_state()->outer() == NULL) { | 8016 if (function_state()->outer() == NULL) { |
8015 HInstruction* elements = Add<HArgumentsElements>(false); | 8017 HInstruction* elements = Add<HArgumentsElements>(false); |
8016 HInstruction* length = Add<HArgumentsLength>(elements); | 8018 HInstruction* length = Add<HArgumentsLength>(elements); |
8017 HValue* wrapped_receiver = BuildWrapReceiver(receiver, function); | 8019 HValue* wrapped_receiver = BuildWrapReceiver(receiver, checked_function); |
8018 HInstruction* result = New<HApplyArguments>(function, | 8020 HInstruction* result = New<HApplyArguments>(function, |
8019 wrapped_receiver, | 8021 wrapped_receiver, |
8020 length, | 8022 length, |
8021 elements); | 8023 elements); |
8022 ast_context()->ReturnInstruction(result, expr->id()); | 8024 ast_context()->ReturnInstruction(result, expr->id()); |
8023 return true; | 8025 return true; |
8024 } else { | 8026 } else { |
8025 // We are inside inlined function and we know exactly what is inside | 8027 // We are inside inlined function and we know exactly what is inside |
8026 // arguments object. But we need to be able to materialize at deopt. | 8028 // arguments object. But we need to be able to materialize at deopt. |
8027 ASSERT_EQ(environment()->arguments_environment()->parameter_count(), | 8029 ASSERT_EQ(environment()->arguments_environment()->parameter_count(), |
8028 function_state()->entry()->arguments_object()->arguments_count()); | 8030 function_state()->entry()->arguments_object()->arguments_count()); |
8029 HArgumentsObject* args = function_state()->entry()->arguments_object(); | 8031 HArgumentsObject* args = function_state()->entry()->arguments_object(); |
8030 const ZoneList<HValue*>* arguments_values = args->arguments_values(); | 8032 const ZoneList<HValue*>* arguments_values = args->arguments_values(); |
8031 int arguments_count = arguments_values->length(); | 8033 int arguments_count = arguments_values->length(); |
8032 Push(function); | 8034 Push(function); |
8033 Push(BuildWrapReceiver(receiver, function)); | 8035 Push(BuildWrapReceiver(receiver, checked_function)); |
8034 for (int i = 1; i < arguments_count; i++) { | 8036 for (int i = 1; i < arguments_count; i++) { |
8035 Push(arguments_values->at(i)); | 8037 Push(arguments_values->at(i)); |
8036 } | 8038 } |
8037 | 8039 |
8038 Handle<JSFunction> known_function; | 8040 Handle<JSFunction> known_function; |
8039 if (function->IsConstant() && | 8041 if (function->IsConstant() && |
8040 HConstant::cast(function)->handle(isolate())->IsJSFunction()) { | 8042 HConstant::cast(function)->handle(isolate())->IsJSFunction()) { |
8041 known_function = Handle<JSFunction>::cast( | 8043 known_function = Handle<JSFunction>::cast( |
8042 HConstant::cast(function)->handle(isolate())); | 8044 HConstant::cast(function)->handle(isolate())); |
8043 int args_count = arguments_count - 1; // Excluding receiver. | 8045 int args_count = arguments_count - 1; // Excluding receiver. |
(...skipping 3596 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11640 if (ShouldProduceTraceOutput()) { | 11642 if (ShouldProduceTraceOutput()) { |
11641 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); | 11643 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); |
11642 } | 11644 } |
11643 | 11645 |
11644 #ifdef DEBUG | 11646 #ifdef DEBUG |
11645 graph_->Verify(false); // No full verify. | 11647 graph_->Verify(false); // No full verify. |
11646 #endif | 11648 #endif |
11647 } | 11649 } |
11648 | 11650 |
11649 } } // namespace v8::internal | 11651 } } // namespace v8::internal |
OLD | NEW |