Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(173)

Side by Side Diff: src/compiler/js-generic-lowering.cc

Issue 693103004: Revert "Skip the CallFunctionStub when the callee function can be statically determined." (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/compiler/js-generic-lowering.h ('k') | src/compiler/linkage.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/graph-inl.h" 8 #include "src/compiler/graph-inl.h"
9 #include "src/compiler/js-generic-lowering.h" 9 #include "src/compiler/js-generic-lowering.h"
10 #include "src/compiler/machine-operator.h" 10 #include "src/compiler/machine-operator.h"
11 #include "src/compiler/node-aux-data-inl.h" 11 #include "src/compiler/node-aux-data-inl.h"
12 #include "src/compiler/node-matchers.h"
13 #include "src/compiler/node-properties-inl.h" 12 #include "src/compiler/node-properties-inl.h"
14 #include "src/unique.h" 13 #include "src/unique.h"
15 14
16 namespace v8 { 15 namespace v8 {
17 namespace internal { 16 namespace internal {
18 namespace compiler { 17 namespace compiler {
19 18
20 JSGenericLowering::JSGenericLowering(CompilationInfo* info, JSGraph* jsgraph) 19 JSGenericLowering::JSGenericLowering(CompilationInfo* info, JSGraph* jsgraph)
21 : info_(info), 20 : info_(info),
22 jsgraph_(jsgraph), 21 jsgraph_(jsgraph),
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after
399 Node* stub_code = CodeConstant(stub.GetCode()); 398 Node* stub_code = CodeConstant(stub.GetCode());
400 Node* construct = NodeProperties::GetValueInput(node, 0); 399 Node* construct = NodeProperties::GetValueInput(node, 0);
401 PatchInsertInput(node, 0, stub_code); 400 PatchInsertInput(node, 0, stub_code);
402 PatchInsertInput(node, 1, Int32Constant(arity - 1)); 401 PatchInsertInput(node, 1, Int32Constant(arity - 1));
403 PatchInsertInput(node, 2, construct); 402 PatchInsertInput(node, 2, construct);
404 PatchInsertInput(node, 3, jsgraph()->UndefinedConstant()); 403 PatchInsertInput(node, 3, jsgraph()->UndefinedConstant());
405 PatchOperator(node, common()->Call(desc)); 404 PatchOperator(node, common()->Call(desc));
406 } 405 }
407 406
408 407
409 bool JSGenericLowering::TryLowerDirectJSCall(Node* node) {
410 // Lower to a direct call to a constant JSFunction if the arity matches.
411 const CallFunctionParameters& p = CallFunctionParametersOf(node->op());
412 int arg_count = static_cast<int>(p.arity() - 2);
413 HeapObjectMatcher<JSFunction> func(node->InputAt(0));
414 if (!func.HasValue()) return false;
415
416 Handle<JSFunction> function = func.Value().handle();
417 if (arg_count != function->shared()->formal_parameter_count()) return false;
418
419 int index = NodeProperties::FirstContextIndex(node);
420
421 // TODO(titzer): total hack to share function context constants.
422 // Remove this when the JSGraph canonicalizes heap constants.
423 Node* context = node->InputAt(index);
424 HeapObjectMatcher<Context> context_const(context);
425 if (!context_const.HasValue() ||
426 *(context_const.Value().handle()) != function->context()) {
427 context = jsgraph()->HeapConstant(Handle<Context>(function->context()));
428 }
429 node->ReplaceInput(index, context);
430 CallDescriptor* desc = linkage()->GetJSCallDescriptor(
431 1 + arg_count, jsgraph()->zone(), FlagsForNode(node));
432 PatchOperator(node, common()->Call(desc));
433 return true;
434 }
435
436
437 void JSGenericLowering::LowerJSCallFunction(Node* node) { 408 void JSGenericLowering::LowerJSCallFunction(Node* node) {
438 if (!TryLowerDirectJSCall(node)) { 409 const CallFunctionParameters& p = CallFunctionParametersOf(node->op());
439 // Call to computed function; use CallFunctionStub; 410 CallFunctionStub stub(isolate(), static_cast<int>(p.arity() - 2), p.flags());
440 const CallFunctionParameters& p = CallFunctionParametersOf(node->op()); 411 CallInterfaceDescriptor d = stub.GetCallInterfaceDescriptor();
441 int arg_count = static_cast<int>(p.arity() - 2); 412 CallDescriptor* desc = linkage()->GetStubCallDescriptor(
442 CallFunctionStub stub(isolate(), arg_count, p.flags()); 413 d, static_cast<int>(p.arity() - 1), FlagsForNode(node));
443 CallInterfaceDescriptor d = stub.GetCallInterfaceDescriptor(); 414 Node* stub_code = CodeConstant(stub.GetCode());
444 CallDescriptor* desc = linkage()->GetStubCallDescriptor( 415 PatchInsertInput(node, 0, stub_code);
445 d, static_cast<int>(p.arity() - 1), FlagsForNode(node)); 416 PatchOperator(node, common()->Call(desc));
446 Node* stub_code = CodeConstant(stub.GetCode());
447 PatchInsertInput(node, 0, stub_code);
448 PatchOperator(node, common()->Call(desc));
449 }
450 } 417 }
451 418
452 419
453 void JSGenericLowering::LowerJSCallRuntime(Node* node) { 420 void JSGenericLowering::LowerJSCallRuntime(Node* node) {
454 const CallRuntimeParameters& p = CallRuntimeParametersOf(node->op()); 421 const CallRuntimeParameters& p = CallRuntimeParametersOf(node->op());
455 ReplaceWithRuntimeCall(node, p.id(), static_cast<int>(p.arity())); 422 ReplaceWithRuntimeCall(node, p.id(), static_cast<int>(p.arity()));
456 } 423 }
457 424
458 } // namespace compiler 425 } // namespace compiler
459 } // namespace internal 426 } // namespace internal
460 } // namespace v8 427 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/js-generic-lowering.h ('k') | src/compiler/linkage.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698