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

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

Issue 1517593003: [turbofan] Optimize JSCallConstruct in typed lowering to direct calls. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix arm typo. Created 5 years 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
« no previous file with comments | « src/compiler/js-typed-lowering.h ('k') | src/ia32/interface-descriptors-ia32.cc » ('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/compilation-dependencies.h" 6 #include "src/compilation-dependencies.h"
7 #include "src/compiler/access-builder.h" 7 #include "src/compiler/access-builder.h"
8 #include "src/compiler/js-graph.h" 8 #include "src/compiler/js-graph.h"
9 #include "src/compiler/js-typed-lowering.h" 9 #include "src/compiler/js-typed-lowering.h"
10 #include "src/compiler/linkage.h" 10 #include "src/compiler/linkage.h"
(...skipping 1922 matching lines...) Expand 10 before | Expand all | Expand 10 after
1933 } 1933 }
1934 RelaxControls(node); 1934 RelaxControls(node);
1935 a.FinishAndChange(node); 1935 a.FinishAndChange(node);
1936 return Changed(node); 1936 return Changed(node);
1937 } 1937 }
1938 1938
1939 return NoChange(); 1939 return NoChange();
1940 } 1940 }
1941 1941
1942 1942
1943 Reduction JSTypedLowering::ReduceJSCallConstruct(Node* node) {
1944 DCHECK_EQ(IrOpcode::kJSCallConstruct, node->opcode());
1945 CallConstructParameters const& p = CallConstructParametersOf(node->op());
1946 DCHECK_LE(2u, p.arity());
1947 int const arity = static_cast<int>(p.arity() - 2);
1948 Node* target = NodeProperties::GetValueInput(node, 0);
1949 Type* target_type = NodeProperties::GetType(target);
1950 Node* new_target = NodeProperties::GetValueInput(node, arity + 1);
1951
1952 // Check if {target} is a known JSFunction.
1953 if (target_type->IsConstant() &&
1954 target_type->AsConstant()->Value()->IsJSFunction()) {
1955 Handle<JSFunction> function =
1956 Handle<JSFunction>::cast(target_type->AsConstant()->Value());
1957 Handle<SharedFunctionInfo> shared(function->shared(), isolate());
1958
1959 // Remove the eager bailout frame state.
1960 NodeProperties::RemoveFrameStateInput(node, 1);
1961
1962 // Patch {node} to an indirect call via the {function}s construct stub.
1963 Callable callable(handle(shared->construct_stub(), isolate()),
1964 ConstructStubDescriptor(isolate()));
1965 node->RemoveInput(arity + 1);
1966 node->InsertInput(graph()->zone(), 0,
1967 jsgraph()->HeapConstant(callable.code()));
1968 node->InsertInput(graph()->zone(), 2, new_target);
1969 node->InsertInput(graph()->zone(), 3, jsgraph()->Int32Constant(arity));
1970 node->InsertInput(graph()->zone(), 4, jsgraph()->UndefinedConstant());
1971 node->InsertInput(graph()->zone(), 5, jsgraph()->UndefinedConstant());
1972 NodeProperties::ChangeOp(
1973 node, common()->Call(Linkage::GetStubCallDescriptor(
1974 isolate(), graph()->zone(), callable.descriptor(), 1 + arity,
1975 CallDescriptor::kNeedsFrameState)));
1976 return Changed(node);
1977 }
1978
1979 // Check if {target} is a JSFunction.
1980 if (target_type->Is(Type::Function())) {
1981 // Remove the eager bailout frame state.
1982 NodeProperties::RemoveFrameStateInput(node, 1);
1983
1984 // Patch {node} to an indirect call via the ConstructFunction builtin.
1985 Callable callable = CodeFactory::ConstructFunction(isolate());
1986 node->RemoveInput(arity + 1);
1987 node->InsertInput(graph()->zone(), 0,
1988 jsgraph()->HeapConstant(callable.code()));
1989 node->InsertInput(graph()->zone(), 2, new_target);
1990 node->InsertInput(graph()->zone(), 3, jsgraph()->Int32Constant(arity));
1991 node->InsertInput(graph()->zone(), 4, jsgraph()->UndefinedConstant());
1992 NodeProperties::ChangeOp(
1993 node, common()->Call(Linkage::GetStubCallDescriptor(
1994 isolate(), graph()->zone(), callable.descriptor(), 1 + arity,
1995 CallDescriptor::kNeedsFrameState)));
1996 return Changed(node);
1997 }
1998
1999 return NoChange();
2000 }
2001
2002
1943 Reduction JSTypedLowering::ReduceJSCallFunction(Node* node) { 2003 Reduction JSTypedLowering::ReduceJSCallFunction(Node* node) {
1944 DCHECK_EQ(IrOpcode::kJSCallFunction, node->opcode()); 2004 DCHECK_EQ(IrOpcode::kJSCallFunction, node->opcode());
1945 CallFunctionParameters const& p = CallFunctionParametersOf(node->op()); 2005 CallFunctionParameters const& p = CallFunctionParametersOf(node->op());
1946 int const arity = static_cast<int>(p.arity() - 2); 2006 int const arity = static_cast<int>(p.arity() - 2);
1947 ConvertReceiverMode convert_mode = p.convert_mode(); 2007 ConvertReceiverMode convert_mode = p.convert_mode();
1948 Node* target = NodeProperties::GetValueInput(node, 0); 2008 Node* target = NodeProperties::GetValueInput(node, 0);
1949 Type* target_type = NodeProperties::GetType(target); 2009 Type* target_type = NodeProperties::GetType(target);
1950 Node* receiver = NodeProperties::GetValueInput(node, 1); 2010 Node* receiver = NodeProperties::GetValueInput(node, 1);
1951 Type* receiver_type = NodeProperties::GetType(receiver); 2011 Type* receiver_type = NodeProperties::GetType(receiver);
1952 Node* frame_state = NodeProperties::GetFrameStateInput(node, 1); 2012 Node* frame_state = NodeProperties::GetFrameStateInput(node, 1);
(...skipping 509 matching lines...) Expand 10 before | Expand all | Expand 10 after
2462 case IrOpcode::kJSCreateLiteralObject: 2522 case IrOpcode::kJSCreateLiteralObject:
2463 return ReduceJSCreateLiteralObject(node); 2523 return ReduceJSCreateLiteralObject(node);
2464 case IrOpcode::kJSCreateFunctionContext: 2524 case IrOpcode::kJSCreateFunctionContext:
2465 return ReduceJSCreateFunctionContext(node); 2525 return ReduceJSCreateFunctionContext(node);
2466 case IrOpcode::kJSCreateWithContext: 2526 case IrOpcode::kJSCreateWithContext:
2467 return ReduceJSCreateWithContext(node); 2527 return ReduceJSCreateWithContext(node);
2468 case IrOpcode::kJSCreateCatchContext: 2528 case IrOpcode::kJSCreateCatchContext:
2469 return ReduceJSCreateCatchContext(node); 2529 return ReduceJSCreateCatchContext(node);
2470 case IrOpcode::kJSCreateBlockContext: 2530 case IrOpcode::kJSCreateBlockContext:
2471 return ReduceJSCreateBlockContext(node); 2531 return ReduceJSCreateBlockContext(node);
2532 case IrOpcode::kJSCallConstruct:
2533 return ReduceJSCallConstruct(node);
2472 case IrOpcode::kJSCallFunction: 2534 case IrOpcode::kJSCallFunction:
2473 return ReduceJSCallFunction(node); 2535 return ReduceJSCallFunction(node);
2474 case IrOpcode::kJSForInDone: 2536 case IrOpcode::kJSForInDone:
2475 return ReduceJSForInDone(node); 2537 return ReduceJSForInDone(node);
2476 case IrOpcode::kJSForInNext: 2538 case IrOpcode::kJSForInNext:
2477 return ReduceJSForInNext(node); 2539 return ReduceJSForInNext(node);
2478 case IrOpcode::kJSForInPrepare: 2540 case IrOpcode::kJSForInPrepare:
2479 return ReduceJSForInPrepare(node); 2541 return ReduceJSForInPrepare(node);
2480 case IrOpcode::kJSForInStep: 2542 case IrOpcode::kJSForInStep:
2481 return ReduceJSForInStep(node); 2543 return ReduceJSForInStep(node);
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
2627 } 2689 }
2628 2690
2629 2691
2630 CompilationDependencies* JSTypedLowering::dependencies() const { 2692 CompilationDependencies* JSTypedLowering::dependencies() const {
2631 return dependencies_; 2693 return dependencies_;
2632 } 2694 }
2633 2695
2634 } // namespace compiler 2696 } // namespace compiler
2635 } // namespace internal 2697 } // namespace internal
2636 } // namespace v8 2698 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/js-typed-lowering.h ('k') | src/ia32/interface-descriptors-ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698