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/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 891 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
909 NodeProperties::GetValueInput(node, 0), effect, control)); | 911 NodeProperties::GetValueInput(node, 0), effect, control)); |
910 } | 912 } |
911 node->set_op( | 913 node->set_op( |
912 simplified()->StoreField(AccessBuilder::ForContextSlot(access.index()))); | 914 simplified()->StoreField(AccessBuilder::ForContextSlot(access.index()))); |
913 node->RemoveInput(2); | 915 node->RemoveInput(2); |
914 DCHECK_EQ(4, node->InputCount()); | 916 DCHECK_EQ(4, node->InputCount()); |
915 return Changed(node); | 917 return Changed(node); |
916 } | 918 } |
917 | 919 |
918 | 920 |
| 921 Reduction JSTypedLowering::ReduceJSCreateClosure(Node* node) { |
| 922 DCHECK_EQ(IrOpcode::kJSCreateClosure, node->opcode()); |
| 923 CreateClosureParameters const& p = CreateClosureParametersOf(node->op()); |
| 924 Handle<SharedFunctionInfo> shared = p.shared_info(); |
| 925 |
| 926 // Use the FastNewClosureStub that allocates in new space only for nested |
| 927 // functions that don't need literals cloning. |
| 928 if (p.pretenure() == NOT_TENURED && shared->num_literals() == 0) { |
| 929 Isolate* isolate = jsgraph()->isolate(); |
| 930 Callable callable = CodeFactory::FastNewClosure( |
| 931 isolate, shared->language_mode(), shared->kind()); |
| 932 CallDescriptor* desc = Linkage::GetStubCallDescriptor( |
| 933 isolate, graph()->zone(), callable.descriptor(), 0, |
| 934 CallDescriptor::kNoFlags); |
| 935 const Operator* new_op = common()->Call(desc); |
| 936 Node* stub_code = jsgraph()->HeapConstant(callable.code()); |
| 937 node->ReplaceInput(0, jsgraph()->HeapConstant(shared)); |
| 938 node->InsertInput(graph()->zone(), 0, stub_code); |
| 939 node->set_op(new_op); |
| 940 return Changed(node); |
| 941 } |
| 942 |
| 943 return NoChange(); |
| 944 } |
| 945 |
| 946 |
919 Reduction JSTypedLowering::Reduce(Node* node) { | 947 Reduction JSTypedLowering::Reduce(Node* node) { |
920 // Check if the output type is a singleton. In that case we already know the | 948 // Check if the output type is a singleton. In that case we already know the |
921 // result value and can simply replace the node if it's eliminable. | 949 // result value and can simply replace the node if it's eliminable. |
922 if (!NodeProperties::IsConstant(node) && NodeProperties::IsTyped(node) && | 950 if (!NodeProperties::IsConstant(node) && NodeProperties::IsTyped(node) && |
923 node->op()->HasProperty(Operator::kEliminatable)) { | 951 node->op()->HasProperty(Operator::kEliminatable)) { |
924 Type* upper = NodeProperties::GetBounds(node).upper; | 952 Type* upper = NodeProperties::GetBounds(node).upper; |
925 if (upper->IsConstant()) { | 953 if (upper->IsConstant()) { |
926 Node* replacement = jsgraph()->Constant(upper->AsConstant()->Value()); | 954 Node* replacement = jsgraph()->Constant(upper->AsConstant()->Value()); |
927 NodeProperties::ReplaceWithValue(node, replacement); | 955 NodeProperties::ReplaceWithValue(node, replacement); |
928 return Changed(replacement); | 956 return Changed(replacement); |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
995 case IrOpcode::kJSLoadNamed: | 1023 case IrOpcode::kJSLoadNamed: |
996 return ReduceJSLoadNamed(node); | 1024 return ReduceJSLoadNamed(node); |
997 case IrOpcode::kJSLoadProperty: | 1025 case IrOpcode::kJSLoadProperty: |
998 return ReduceJSLoadProperty(node); | 1026 return ReduceJSLoadProperty(node); |
999 case IrOpcode::kJSStoreProperty: | 1027 case IrOpcode::kJSStoreProperty: |
1000 return ReduceJSStoreProperty(node); | 1028 return ReduceJSStoreProperty(node); |
1001 case IrOpcode::kJSLoadContext: | 1029 case IrOpcode::kJSLoadContext: |
1002 return ReduceJSLoadContext(node); | 1030 return ReduceJSLoadContext(node); |
1003 case IrOpcode::kJSStoreContext: | 1031 case IrOpcode::kJSStoreContext: |
1004 return ReduceJSStoreContext(node); | 1032 return ReduceJSStoreContext(node); |
| 1033 case IrOpcode::kJSCreateClosure: |
| 1034 return ReduceJSCreateClosure(node); |
1005 default: | 1035 default: |
1006 break; | 1036 break; |
1007 } | 1037 } |
1008 return NoChange(); | 1038 return NoChange(); |
1009 } | 1039 } |
1010 | 1040 |
1011 | 1041 |
1012 Node* JSTypedLowering::ConvertPrimitiveToNumber(Node* input) { | 1042 Node* JSTypedLowering::ConvertPrimitiveToNumber(Node* input) { |
1013 DCHECK(NodeProperties::GetBounds(input).upper->Is(Type::PlainPrimitive())); | 1043 DCHECK(NodeProperties::GetBounds(input).upper->Is(Type::PlainPrimitive())); |
1014 // Avoid inserting too many eager ToNumber() operations. | 1044 // Avoid inserting too many eager ToNumber() operations. |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1069 } | 1099 } |
1070 | 1100 |
1071 | 1101 |
1072 MachineOperatorBuilder* JSTypedLowering::machine() const { | 1102 MachineOperatorBuilder* JSTypedLowering::machine() const { |
1073 return jsgraph()->machine(); | 1103 return jsgraph()->machine(); |
1074 } | 1104 } |
1075 | 1105 |
1076 } // namespace compiler | 1106 } // namespace compiler |
1077 } // namespace internal | 1107 } // namespace internal |
1078 } // namespace v8 | 1108 } // namespace v8 |
OLD | NEW |