OLD | NEW |
---|---|
1 | |
2 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 the V8 project authors. All rights reserved. |
3 // 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 |
4 // found in the LICENSE file. | 3 // found in the LICENSE file. |
5 | 4 |
6 #include "src/compiler/js-intrinsic-lowering.h" | 5 #include "src/compiler/js-intrinsic-lowering.h" |
7 | 6 |
8 #include <stack> | 7 #include <stack> |
9 | 8 |
10 #include "src/code-factory.h" | 9 #include "src/code-factory.h" |
11 #include "src/compiler/access-builder.h" | 10 #include "src/compiler/access-builder.h" |
12 #include "src/compiler/js-graph.h" | 11 #include "src/compiler/js-graph.h" |
13 #include "src/compiler/linkage.h" | 12 #include "src/compiler/linkage.h" |
14 #include "src/compiler/node-matchers.h" | 13 #include "src/compiler/node-matchers.h" |
15 #include "src/compiler/node-properties.h" | 14 #include "src/compiler/node-properties.h" |
15 #include "src/compiler/operator-properties.h" | |
16 | 16 |
17 namespace v8 { | 17 namespace v8 { |
18 namespace internal { | 18 namespace internal { |
19 namespace compiler { | 19 namespace compiler { |
20 | 20 |
21 JSIntrinsicLowering::JSIntrinsicLowering(JSGraph* jsgraph) | 21 JSIntrinsicLowering::JSIntrinsicLowering(JSGraph* jsgraph) |
22 : jsgraph_(jsgraph), simplified_(jsgraph->zone()) {} | 22 : jsgraph_(jsgraph), simplified_(jsgraph->zone()) {} |
23 | 23 |
24 | 24 |
25 Reduction JSIntrinsicLowering::Reduce(Node* node) { | 25 Reduction JSIntrinsicLowering::Reduce(Node* node) { |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
107 int flags = FastD2I(mflags.Value()); | 107 int flags = FastD2I(mflags.Value()); |
108 | 108 |
109 // Use the FastCloneShallowArrayStub only for shallow boilerplates up to the | 109 // Use the FastCloneShallowArrayStub only for shallow boilerplates up to the |
110 // initial length limit for arrays with "fast" elements kind. | 110 // initial length limit for arrays with "fast" elements kind. |
111 if ((flags & ArrayLiteral::kShallowElements) != 0 && | 111 if ((flags & ArrayLiteral::kShallowElements) != 0 && |
112 length < JSObject::kInitialMaxFastElementArray) { | 112 length < JSObject::kInitialMaxFastElementArray) { |
113 Isolate* isolate = jsgraph()->isolate(); | 113 Isolate* isolate = jsgraph()->isolate(); |
114 Callable callable = CodeFactory::FastCloneShallowArray(isolate); | 114 Callable callable = CodeFactory::FastCloneShallowArray(isolate); |
115 CallDescriptor* desc = Linkage::GetStubCallDescriptor( | 115 CallDescriptor* desc = Linkage::GetStubCallDescriptor( |
116 isolate, graph()->zone(), callable.descriptor(), 0, | 116 isolate, graph()->zone(), callable.descriptor(), 0, |
117 FLAG_turbo_deoptimization ? CallDescriptor::kNeedsFrameState | 117 (OperatorProperties::GetFrameStateInputCount(node->op()) != 0) |
118 : CallDescriptor::kNoFlags); | 118 ? CallDescriptor::kNeedsFrameState |
119 : CallDescriptor::kNoFlags); | |
119 const Operator* new_op = common()->Call(desc); | 120 const Operator* new_op = common()->Call(desc); |
120 Node* stub_code = jsgraph()->HeapConstant(callable.code()); | 121 Node* stub_code = jsgraph()->HeapConstant(callable.code()); |
121 node->RemoveInput(3); // Remove flags input from node. | 122 node->RemoveInput(3); // Remove flags input from node. |
122 node->InsertInput(graph()->zone(), 0, stub_code); | 123 node->InsertInput(graph()->zone(), 0, stub_code); |
123 node->set_op(new_op); | 124 node->set_op(new_op); |
124 return Changed(node); | 125 return Changed(node); |
125 } | 126 } |
126 | 127 |
127 return NoChange(); | 128 return NoChange(); |
128 } | 129 } |
129 | 130 |
130 | 131 |
131 Reduction JSIntrinsicLowering::ReduceCreateObjectLiteral(Node* node) { | 132 Reduction JSIntrinsicLowering::ReduceCreateObjectLiteral(Node* node) { |
132 HeapObjectMatcher<FixedArray> mconst(NodeProperties::GetValueInput(node, 2)); | 133 HeapObjectMatcher<FixedArray> mconst(NodeProperties::GetValueInput(node, 2)); |
133 NumberMatcher mflags(NodeProperties::GetValueInput(node, 3)); | 134 NumberMatcher mflags(NodeProperties::GetValueInput(node, 3)); |
134 // Constants are pairs, see ObjectLiteral::properties_count(). | 135 // Constants are pairs, see ObjectLiteral::properties_count(). |
135 int length = mconst.Value().handle()->length() / 2; | 136 int length = mconst.Value().handle()->length() / 2; |
136 int flags = FastD2I(mflags.Value()); | 137 int flags = FastD2I(mflags.Value()); |
137 | 138 |
138 // Use the FastCloneShallowObjectStub only for shallow boilerplates without | 139 // Use the FastCloneShallowObjectStub only for shallow boilerplates without |
139 // elements up to the number of properties that the stubs can handle. | 140 // elements up to the number of properties that the stubs can handle. |
140 if ((flags & ObjectLiteral::kShallowProperties) != 0 && | 141 if ((flags & ObjectLiteral::kShallowProperties) != 0 && |
141 length <= FastCloneShallowObjectStub::kMaximumClonedProperties) { | 142 length <= FastCloneShallowObjectStub::kMaximumClonedProperties) { |
142 Isolate* isolate = jsgraph()->isolate(); | 143 Isolate* isolate = jsgraph()->isolate(); |
143 Callable callable = CodeFactory::FastCloneShallowObject(isolate, length); | 144 Callable callable = CodeFactory::FastCloneShallowObject(isolate, length); |
144 CallDescriptor* desc = Linkage::GetStubCallDescriptor( | 145 CallDescriptor* desc = Linkage::GetStubCallDescriptor( |
145 isolate, graph()->zone(), callable.descriptor(), 0, | 146 isolate, graph()->zone(), callable.descriptor(), 0, |
146 FLAG_turbo_deoptimization ? CallDescriptor::kNeedsFrameState | 147 (OperatorProperties::GetFrameStateInputCount(node->op()) != 0) |
147 : CallDescriptor::kNoFlags); | 148 ? CallDescriptor::kNeedsFrameState |
149 : CallDescriptor::kNoFlags); | |
148 const Operator* new_op = common()->Call(desc); | 150 const Operator* new_op = common()->Call(desc); |
149 Node* stub_code = jsgraph()->HeapConstant(callable.code()); | 151 Node* stub_code = jsgraph()->HeapConstant(callable.code()); |
150 node->InsertInput(graph()->zone(), 0, stub_code); | 152 node->InsertInput(graph()->zone(), 0, stub_code); |
151 node->set_op(new_op); | 153 node->set_op(new_op); |
152 return Changed(node); | 154 return Changed(node); |
153 } | 155 } |
154 | 156 |
155 return NoChange(); | 157 return NoChange(); |
156 } | 158 } |
157 | 159 |
158 | 160 |
159 Reduction JSIntrinsicLowering::ReduceDeoptimizeNow(Node* node) { | 161 Reduction JSIntrinsicLowering::ReduceDeoptimizeNow(Node* node) { |
160 if (!FLAG_turbo_deoptimization) return NoChange(); | 162 // TODO(bmeurer): if (!FLAG_turbo_deoptimization) return NoChange(); |
Jarin
2015/04/23 08:33:08
I think we should keep the check here, so that we
Benedikt Meurer
2015/04/23 08:35:34
Done.
| |
161 | 163 |
162 Node* frame_state = NodeProperties::GetFrameStateInput(node, 0); | 164 Node* frame_state = NodeProperties::GetFrameStateInput(node, 0); |
163 DCHECK_EQ(frame_state->opcode(), IrOpcode::kFrameState); | 165 DCHECK_EQ(frame_state->opcode(), IrOpcode::kFrameState); |
164 | 166 |
165 Node* effect = NodeProperties::GetEffectInput(node); | 167 Node* effect = NodeProperties::GetEffectInput(node); |
166 Node* control = NodeProperties::GetControlInput(node); | 168 Node* control = NodeProperties::GetControlInput(node); |
167 | 169 |
168 // We are making the continuation after the call dead. To | 170 // We are making the continuation after the call dead. To |
169 // model this, we generate if (true) statement with deopt | 171 // model this, we generate if (true) statement with deopt |
170 // in the true branch and continuation in the false branch. | 172 // in the true branch and continuation in the false branch. |
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
486 } | 488 } |
487 | 489 |
488 | 490 |
489 MachineOperatorBuilder* JSIntrinsicLowering::machine() const { | 491 MachineOperatorBuilder* JSIntrinsicLowering::machine() const { |
490 return jsgraph()->machine(); | 492 return jsgraph()->machine(); |
491 } | 493 } |
492 | 494 |
493 } // namespace compiler | 495 } // namespace compiler |
494 } // namespace internal | 496 } // namespace internal |
495 } // namespace v8 | 497 } // namespace v8 |
OLD | NEW |