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

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

Issue 1104453006: [turbofan] Introduce explicit JSCreateLiteral[Array|Object]. (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/linkage.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/compiler/access-builder.h" 6 #include "src/compiler/access-builder.h"
7 #include "src/compiler/js-graph.h" 7 #include "src/compiler/js-graph.h"
8 #include "src/compiler/js-typed-lowering.h" 8 #include "src/compiler/js-typed-lowering.h"
9 #include "src/compiler/linkage.h" 9 #include "src/compiler/linkage.h"
10 #include "src/compiler/node-matchers.h" 10 #include "src/compiler/node-matchers.h"
(...skipping 933 matching lines...) Expand 10 before | Expand all | Expand 10 after
944 node->ReplaceInput(0, jsgraph()->HeapConstant(shared)); 944 node->ReplaceInput(0, jsgraph()->HeapConstant(shared));
945 node->InsertInput(graph()->zone(), 0, stub_code); 945 node->InsertInput(graph()->zone(), 0, stub_code);
946 node->set_op(new_op); 946 node->set_op(new_op);
947 return Changed(node); 947 return Changed(node);
948 } 948 }
949 949
950 return NoChange(); 950 return NoChange();
951 } 951 }
952 952
953 953
954 Reduction JSTypedLowering::ReduceJSCreateLiteralArray(Node* node) {
955 DCHECK_EQ(IrOpcode::kJSCreateLiteralArray, node->opcode());
956 HeapObjectMatcher<FixedArray> mconst(NodeProperties::GetValueInput(node, 2));
957 int length = mconst.Value().handle()->length();
958 int flags = OpParameter<int>(node->op());
959
960 // Use the FastCloneShallowArrayStub only for shallow boilerplates up to the
961 // initial length limit for arrays with "fast" elements kind.
962 if ((flags & ArrayLiteral::kShallowElements) != 0 &&
963 length < JSObject::kInitialMaxFastElementArray) {
964 Isolate* isolate = jsgraph()->isolate();
965 Callable callable = CodeFactory::FastCloneShallowArray(isolate);
966 CallDescriptor* desc = Linkage::GetStubCallDescriptor(
967 isolate, graph()->zone(), callable.descriptor(), 0,
968 (OperatorProperties::GetFrameStateInputCount(node->op()) != 0)
969 ? CallDescriptor::kNeedsFrameState
970 : CallDescriptor::kNoFlags);
971 const Operator* new_op = common()->Call(desc);
972 Node* stub_code = jsgraph()->HeapConstant(callable.code());
973 node->InsertInput(graph()->zone(), 0, stub_code);
974 node->set_op(new_op);
975 return Changed(node);
976 }
977
978 return NoChange();
979 }
980
981
982 Reduction JSTypedLowering::ReduceJSCreateLiteralObject(Node* node) {
983 DCHECK_EQ(IrOpcode::kJSCreateLiteralObject, node->opcode());
984 HeapObjectMatcher<FixedArray> mconst(NodeProperties::GetValueInput(node, 2));
985 // Constants are pairs, see ObjectLiteral::properties_count().
986 int length = mconst.Value().handle()->length() / 2;
987 int flags = OpParameter<int>(node->op());
988
989 // Use the FastCloneShallowObjectStub only for shallow boilerplates without
990 // elements up to the number of properties that the stubs can handle.
991 if ((flags & ObjectLiteral::kShallowProperties) != 0 &&
992 length <= FastCloneShallowObjectStub::kMaximumClonedProperties) {
993 Isolate* isolate = jsgraph()->isolate();
994 Callable callable = CodeFactory::FastCloneShallowObject(isolate, length);
995 CallDescriptor* desc = Linkage::GetStubCallDescriptor(
996 isolate, graph()->zone(), callable.descriptor(), 0,
997 (OperatorProperties::GetFrameStateInputCount(node->op()) != 0)
998 ? CallDescriptor::kNeedsFrameState
999 : CallDescriptor::kNoFlags);
1000 const Operator* new_op = common()->Call(desc);
1001 Node* stub_code = jsgraph()->HeapConstant(callable.code());
1002 node->InsertInput(graph()->zone(), 3, jsgraph()->Constant(flags));
1003 node->InsertInput(graph()->zone(), 0, stub_code);
1004 node->set_op(new_op);
1005 return Changed(node);
1006 }
1007
1008 return NoChange();
1009 }
1010
1011
954 Reduction JSTypedLowering::Reduce(Node* node) { 1012 Reduction JSTypedLowering::Reduce(Node* node) {
955 // Check if the output type is a singleton. In that case we already know the 1013 // Check if the output type is a singleton. In that case we already know the
956 // result value and can simply replace the node if it's eliminable. 1014 // result value and can simply replace the node if it's eliminable.
957 if (!NodeProperties::IsConstant(node) && NodeProperties::IsTyped(node) && 1015 if (!NodeProperties::IsConstant(node) && NodeProperties::IsTyped(node) &&
958 node->op()->HasProperty(Operator::kEliminatable)) { 1016 node->op()->HasProperty(Operator::kEliminatable)) {
959 Type* upper = NodeProperties::GetBounds(node).upper; 1017 Type* upper = NodeProperties::GetBounds(node).upper;
960 if (upper->IsConstant()) { 1018 if (upper->IsConstant()) {
961 Node* replacement = jsgraph()->Constant(upper->AsConstant()->Value()); 1019 Node* replacement = jsgraph()->Constant(upper->AsConstant()->Value());
962 NodeProperties::ReplaceWithValue(node, replacement); 1020 NodeProperties::ReplaceWithValue(node, replacement);
963 return Changed(replacement); 1021 return Changed(replacement);
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
1032 case IrOpcode::kJSLoadProperty: 1090 case IrOpcode::kJSLoadProperty:
1033 return ReduceJSLoadProperty(node); 1091 return ReduceJSLoadProperty(node);
1034 case IrOpcode::kJSStoreProperty: 1092 case IrOpcode::kJSStoreProperty:
1035 return ReduceJSStoreProperty(node); 1093 return ReduceJSStoreProperty(node);
1036 case IrOpcode::kJSLoadContext: 1094 case IrOpcode::kJSLoadContext:
1037 return ReduceJSLoadContext(node); 1095 return ReduceJSLoadContext(node);
1038 case IrOpcode::kJSStoreContext: 1096 case IrOpcode::kJSStoreContext:
1039 return ReduceJSStoreContext(node); 1097 return ReduceJSStoreContext(node);
1040 case IrOpcode::kJSCreateClosure: 1098 case IrOpcode::kJSCreateClosure:
1041 return ReduceJSCreateClosure(node); 1099 return ReduceJSCreateClosure(node);
1100 case IrOpcode::kJSCreateLiteralArray:
1101 return ReduceJSCreateLiteralArray(node);
1102 case IrOpcode::kJSCreateLiteralObject:
1103 return ReduceJSCreateLiteralObject(node);
1042 default: 1104 default:
1043 break; 1105 break;
1044 } 1106 }
1045 return NoChange(); 1107 return NoChange();
1046 } 1108 }
1047 1109
1048 1110
1049 Node* JSTypedLowering::ConvertPrimitiveToNumber(Node* input) { 1111 Node* JSTypedLowering::ConvertPrimitiveToNumber(Node* input) {
1050 DCHECK(NodeProperties::GetBounds(input).upper->Is(Type::PlainPrimitive())); 1112 DCHECK(NodeProperties::GetBounds(input).upper->Is(Type::PlainPrimitive()));
1051 // Avoid inserting too many eager ToNumber() operations. 1113 // Avoid inserting too many eager ToNumber() operations.
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
1106 } 1168 }
1107 1169
1108 1170
1109 MachineOperatorBuilder* JSTypedLowering::machine() const { 1171 MachineOperatorBuilder* JSTypedLowering::machine() const {
1110 return jsgraph()->machine(); 1172 return jsgraph()->machine();
1111 } 1173 }
1112 1174
1113 } // namespace compiler 1175 } // namespace compiler
1114 } // namespace internal 1176 } // namespace internal
1115 } // namespace v8 1177 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/js-typed-lowering.h ('k') | src/compiler/linkage.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698