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

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

Issue 1105513002: [turbofan] Use FastNewClosureStub if possible. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebased. Created 5 years, 7 months 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/compiler/opcodes.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/compiler/access-builder.h" 6 #include "src/compiler/access-builder.h"
6 #include "src/compiler/js-graph.h" 7 #include "src/compiler/js-graph.h"
7 #include "src/compiler/js-typed-lowering.h" 8 #include "src/compiler/js-typed-lowering.h"
9 #include "src/compiler/linkage.h"
8 #include "src/compiler/node-matchers.h" 10 #include "src/compiler/node-matchers.h"
9 #include "src/compiler/node-properties.h" 11 #include "src/compiler/node-properties.h"
10 #include "src/compiler/operator-properties.h" 12 #include "src/compiler/operator-properties.h"
11 #include "src/types.h" 13 #include "src/types.h"
12 14
13 namespace v8 { 15 namespace v8 {
14 namespace internal { 16 namespace internal {
15 namespace compiler { 17 namespace compiler {
16 18
17 // TODO(turbofan): js-typed-lowering improvements possible 19 // TODO(turbofan): js-typed-lowering improvements possible
(...skipping 898 matching lines...) Expand 10 before | Expand all | Expand 10 after
916 NodeProperties::GetValueInput(node, 0), effect, control)); 918 NodeProperties::GetValueInput(node, 0), effect, control));
917 } 919 }
918 node->set_op( 920 node->set_op(
919 simplified()->StoreField(AccessBuilder::ForContextSlot(access.index()))); 921 simplified()->StoreField(AccessBuilder::ForContextSlot(access.index())));
920 node->RemoveInput(2); 922 node->RemoveInput(2);
921 DCHECK_EQ(4, node->InputCount()); 923 DCHECK_EQ(4, node->InputCount());
922 return Changed(node); 924 return Changed(node);
923 } 925 }
924 926
925 927
928 Reduction JSTypedLowering::ReduceJSCreateClosure(Node* node) {
929 DCHECK_EQ(IrOpcode::kJSCreateClosure, node->opcode());
930 CreateClosureParameters const& p = CreateClosureParametersOf(node->op());
931 Handle<SharedFunctionInfo> shared = p.shared_info();
932
933 // Use the FastNewClosureStub that allocates in new space only for nested
934 // functions that don't need literals cloning.
935 if (p.pretenure() == NOT_TENURED && shared->num_literals() == 0) {
936 Isolate* isolate = jsgraph()->isolate();
937 Callable callable = CodeFactory::FastNewClosure(
938 isolate, shared->language_mode(), shared->kind());
939 CallDescriptor* desc = Linkage::GetStubCallDescriptor(
940 isolate, graph()->zone(), callable.descriptor(), 0,
941 CallDescriptor::kNoFlags);
942 const Operator* new_op = common()->Call(desc);
943 Node* stub_code = jsgraph()->HeapConstant(callable.code());
944 node->ReplaceInput(0, jsgraph()->HeapConstant(shared));
945 node->InsertInput(graph()->zone(), 0, stub_code);
946 node->set_op(new_op);
947 return Changed(node);
948 }
949
950 return NoChange();
951 }
952
953
926 Reduction JSTypedLowering::Reduce(Node* node) { 954 Reduction JSTypedLowering::Reduce(Node* node) {
927 // Check if the output type is a singleton. In that case we already know the 955 // Check if the output type is a singleton. In that case we already know the
928 // result value and can simply replace the node if it's eliminable. 956 // result value and can simply replace the node if it's eliminable.
929 if (!NodeProperties::IsConstant(node) && NodeProperties::IsTyped(node) && 957 if (!NodeProperties::IsConstant(node) && NodeProperties::IsTyped(node) &&
930 node->op()->HasProperty(Operator::kEliminatable)) { 958 node->op()->HasProperty(Operator::kEliminatable)) {
931 Type* upper = NodeProperties::GetBounds(node).upper; 959 Type* upper = NodeProperties::GetBounds(node).upper;
932 if (upper->IsConstant()) { 960 if (upper->IsConstant()) {
933 Node* replacement = jsgraph()->Constant(upper->AsConstant()->Value()); 961 Node* replacement = jsgraph()->Constant(upper->AsConstant()->Value());
934 NodeProperties::ReplaceWithValue(node, replacement); 962 NodeProperties::ReplaceWithValue(node, replacement);
935 return Changed(replacement); 963 return Changed(replacement);
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
1002 case IrOpcode::kJSLoadNamed: 1030 case IrOpcode::kJSLoadNamed:
1003 return ReduceJSLoadNamed(node); 1031 return ReduceJSLoadNamed(node);
1004 case IrOpcode::kJSLoadProperty: 1032 case IrOpcode::kJSLoadProperty:
1005 return ReduceJSLoadProperty(node); 1033 return ReduceJSLoadProperty(node);
1006 case IrOpcode::kJSStoreProperty: 1034 case IrOpcode::kJSStoreProperty:
1007 return ReduceJSStoreProperty(node); 1035 return ReduceJSStoreProperty(node);
1008 case IrOpcode::kJSLoadContext: 1036 case IrOpcode::kJSLoadContext:
1009 return ReduceJSLoadContext(node); 1037 return ReduceJSLoadContext(node);
1010 case IrOpcode::kJSStoreContext: 1038 case IrOpcode::kJSStoreContext:
1011 return ReduceJSStoreContext(node); 1039 return ReduceJSStoreContext(node);
1040 case IrOpcode::kJSCreateClosure:
1041 return ReduceJSCreateClosure(node);
1012 default: 1042 default:
1013 break; 1043 break;
1014 } 1044 }
1015 return NoChange(); 1045 return NoChange();
1016 } 1046 }
1017 1047
1018 1048
1019 Node* JSTypedLowering::ConvertPrimitiveToNumber(Node* input) { 1049 Node* JSTypedLowering::ConvertPrimitiveToNumber(Node* input) {
1020 DCHECK(NodeProperties::GetBounds(input).upper->Is(Type::PlainPrimitive())); 1050 DCHECK(NodeProperties::GetBounds(input).upper->Is(Type::PlainPrimitive()));
1021 // Avoid inserting too many eager ToNumber() operations. 1051 // Avoid inserting too many eager ToNumber() operations.
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
1076 } 1106 }
1077 1107
1078 1108
1079 MachineOperatorBuilder* JSTypedLowering::machine() const { 1109 MachineOperatorBuilder* JSTypedLowering::machine() const {
1080 return jsgraph()->machine(); 1110 return jsgraph()->machine();
1081 } 1111 }
1082 1112
1083 } // namespace compiler 1113 } // namespace compiler
1084 } // namespace internal 1114 } // namespace internal
1085 } // namespace v8 1115 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/js-typed-lowering.h ('k') | src/compiler/opcodes.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698