OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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/code-factory.h" | 5 #include "src/code-factory.h" |
6 #include "src/code-stubs.h" | 6 #include "src/code-stubs.h" |
7 #include "src/compiler/common-operator.h" | 7 #include "src/compiler/common-operator.h" |
8 #include "src/compiler/js-generic-lowering.h" | 8 #include "src/compiler/js-generic-lowering.h" |
9 #include "src/compiler/machine-operator.h" | 9 #include "src/compiler/machine-operator.h" |
10 #include "src/compiler/node-aux-data-inl.h" | 10 #include "src/compiler/node-aux-data-inl.h" |
(...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
390 // Lower to a direct call to a constant JSFunction if legal. | 390 // Lower to a direct call to a constant JSFunction if legal. |
391 const CallFunctionParameters& p = CallFunctionParametersOf(node->op()); | 391 const CallFunctionParameters& p = CallFunctionParametersOf(node->op()); |
392 int arg_count = static_cast<int>(p.arity() - 2); | 392 int arg_count = static_cast<int>(p.arity() - 2); |
393 | 393 |
394 // Check the function is a constant and is really a JSFunction. | 394 // Check the function is a constant and is really a JSFunction. |
395 HeapObjectMatcher<Object> function_const(node->InputAt(0)); | 395 HeapObjectMatcher<Object> function_const(node->InputAt(0)); |
396 if (!function_const.HasValue()) return false; // not a constant. | 396 if (!function_const.HasValue()) return false; // not a constant. |
397 Handle<Object> func = function_const.Value().handle(); | 397 Handle<Object> func = function_const.Value().handle(); |
398 if (!func->IsJSFunction()) return false; // not a function. | 398 if (!func->IsJSFunction()) return false; // not a function. |
399 Handle<JSFunction> function = Handle<JSFunction>::cast(func); | 399 Handle<JSFunction> function = Handle<JSFunction>::cast(func); |
400 if (arg_count != function->shared()->internal_formal_parameter_count()) { | 400 if (arg_count != function->shared()->formal_parameter_count()) return false; |
401 return false; | |
402 } | |
403 | 401 |
404 // Check the receiver doesn't need to be wrapped. | 402 // Check the receiver doesn't need to be wrapped. |
405 Node* receiver = node->InputAt(1); | 403 Node* receiver = node->InputAt(1); |
406 if (!NodeProperties::IsTyped(receiver)) return false; | 404 if (!NodeProperties::IsTyped(receiver)) return false; |
407 Type* ok_receiver = Type::Union(Type::Undefined(), Type::Receiver(), zone()); | 405 Type* ok_receiver = Type::Union(Type::Undefined(), Type::Receiver(), zone()); |
408 if (!NodeProperties::GetBounds(receiver).upper->Is(ok_receiver)) return false; | 406 if (!NodeProperties::GetBounds(receiver).upper->Is(ok_receiver)) return false; |
409 | 407 |
410 int index = NodeProperties::FirstContextIndex(node); | 408 int index = NodeProperties::FirstContextIndex(node); |
411 | 409 |
412 // TODO(titzer): total hack to share function context constants. | 410 // TODO(titzer): total hack to share function context constants. |
(...skipping 30 matching lines...) Expand all Loading... |
443 | 441 |
444 | 442 |
445 void JSGenericLowering::LowerJSCallRuntime(Node* node) { | 443 void JSGenericLowering::LowerJSCallRuntime(Node* node) { |
446 const CallRuntimeParameters& p = CallRuntimeParametersOf(node->op()); | 444 const CallRuntimeParameters& p = CallRuntimeParametersOf(node->op()); |
447 ReplaceWithRuntimeCall(node, p.id(), static_cast<int>(p.arity())); | 445 ReplaceWithRuntimeCall(node, p.id(), static_cast<int>(p.arity())); |
448 } | 446 } |
449 | 447 |
450 } // namespace compiler | 448 } // namespace compiler |
451 } // namespace internal | 449 } // namespace internal |
452 } // namespace v8 | 450 } // namespace v8 |
OLD | NEW |