| 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 "src/hydrogen.h" | 5 #include "src/hydrogen.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "src/v8.h" | 9 #include "src/v8.h" |
| 10 #include "src/allocation-site-scopes.h" | 10 #include "src/allocation-site-scopes.h" |
| (...skipping 8545 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8556 if (arg_two == NULL || !arg_two->var()->IsStackAllocated()) return false; | 8556 if (arg_two == NULL || !arg_two->var()->IsStackAllocated()) return false; |
| 8557 HValue* arg_two_value = LookupAndMakeLive(arg_two->var()); | 8557 HValue* arg_two_value = LookupAndMakeLive(arg_two->var()); |
| 8558 if (!arg_two_value->CheckFlag(HValue::kIsArguments)) return false; | 8558 if (!arg_two_value->CheckFlag(HValue::kIsArguments)) return false; |
| 8559 | 8559 |
| 8560 // Found pattern f.apply(receiver, arguments). | 8560 // Found pattern f.apply(receiver, arguments). |
| 8561 CHECK_ALIVE_OR_RETURN(VisitForValue(args->at(0)), true); | 8561 CHECK_ALIVE_OR_RETURN(VisitForValue(args->at(0)), true); |
| 8562 HValue* receiver = Pop(); // receiver | 8562 HValue* receiver = Pop(); // receiver |
| 8563 HValue* function = Pop(); // f | 8563 HValue* function = Pop(); // f |
| 8564 Drop(1); // apply | 8564 Drop(1); // apply |
| 8565 | 8565 |
| 8566 HValue* checked_function = AddCheckMap(function, function_map); |
| 8567 |
| 8566 if (function_state()->outer() == NULL) { | 8568 if (function_state()->outer() == NULL) { |
| 8567 HInstruction* elements = Add<HArgumentsElements>(false); | 8569 HInstruction* elements = Add<HArgumentsElements>(false); |
| 8568 HInstruction* length = Add<HArgumentsLength>(elements); | 8570 HInstruction* length = Add<HArgumentsLength>(elements); |
| 8569 HValue* wrapped_receiver = BuildWrapReceiver(receiver, function); | 8571 HValue* wrapped_receiver = BuildWrapReceiver(receiver, checked_function); |
| 8570 HInstruction* result = New<HApplyArguments>(function, | 8572 HInstruction* result = New<HApplyArguments>(function, |
| 8571 wrapped_receiver, | 8573 wrapped_receiver, |
| 8572 length, | 8574 length, |
| 8573 elements); | 8575 elements); |
| 8574 ast_context()->ReturnInstruction(result, expr->id()); | 8576 ast_context()->ReturnInstruction(result, expr->id()); |
| 8575 return true; | 8577 return true; |
| 8576 } else { | 8578 } else { |
| 8577 // We are inside inlined function and we know exactly what is inside | 8579 // We are inside inlined function and we know exactly what is inside |
| 8578 // arguments object. But we need to be able to materialize at deopt. | 8580 // arguments object. But we need to be able to materialize at deopt. |
| 8579 ASSERT_EQ(environment()->arguments_environment()->parameter_count(), | 8581 ASSERT_EQ(environment()->arguments_environment()->parameter_count(), |
| 8580 function_state()->entry()->arguments_object()->arguments_count()); | 8582 function_state()->entry()->arguments_object()->arguments_count()); |
| 8581 HArgumentsObject* args = function_state()->entry()->arguments_object(); | 8583 HArgumentsObject* args = function_state()->entry()->arguments_object(); |
| 8582 const ZoneList<HValue*>* arguments_values = args->arguments_values(); | 8584 const ZoneList<HValue*>* arguments_values = args->arguments_values(); |
| 8583 int arguments_count = arguments_values->length(); | 8585 int arguments_count = arguments_values->length(); |
| 8584 Push(function); | 8586 Push(function); |
| 8585 Push(BuildWrapReceiver(receiver, function)); | 8587 Push(BuildWrapReceiver(receiver, checked_function)); |
| 8586 for (int i = 1; i < arguments_count; i++) { | 8588 for (int i = 1; i < arguments_count; i++) { |
| 8587 Push(arguments_values->at(i)); | 8589 Push(arguments_values->at(i)); |
| 8588 } | 8590 } |
| 8589 | 8591 |
| 8590 Handle<JSFunction> known_function; | 8592 Handle<JSFunction> known_function; |
| 8591 if (function->IsConstant() && | 8593 if (function->IsConstant() && |
| 8592 HConstant::cast(function)->handle(isolate())->IsJSFunction()) { | 8594 HConstant::cast(function)->handle(isolate())->IsJSFunction()) { |
| 8593 known_function = Handle<JSFunction>::cast( | 8595 known_function = Handle<JSFunction>::cast( |
| 8594 HConstant::cast(function)->handle(isolate())); | 8596 HConstant::cast(function)->handle(isolate())); |
| 8595 int args_count = arguments_count - 1; // Excluding receiver. | 8597 int args_count = arguments_count - 1; // Excluding receiver. |
| (...skipping 3748 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12344 if (ShouldProduceTraceOutput()) { | 12346 if (ShouldProduceTraceOutput()) { |
| 12345 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); | 12347 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); |
| 12346 } | 12348 } |
| 12347 | 12349 |
| 12348 #ifdef DEBUG | 12350 #ifdef DEBUG |
| 12349 graph_->Verify(false); // No full verify. | 12351 graph_->Verify(false); // No full verify. |
| 12350 #endif | 12352 #endif |
| 12351 } | 12353 } |
| 12352 | 12354 |
| 12353 } } // namespace v8::internal | 12355 } } // namespace v8::internal |
| OLD | NEW |