Chromium Code Reviews| 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/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 1171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1182 return Changed(node); | 1182 return Changed(node); |
| 1183 } | 1183 } |
| 1184 | 1184 |
| 1185 return NoChange(); | 1185 return NoChange(); |
| 1186 } | 1186 } |
| 1187 | 1187 |
| 1188 | 1188 |
| 1189 Reduction JSTypedLowering::ReduceJSCreateWithContext(Node* node) { | 1189 Reduction JSTypedLowering::ReduceJSCreateWithContext(Node* node) { |
| 1190 DCHECK_EQ(IrOpcode::kJSCreateWithContext, node->opcode()); | 1190 DCHECK_EQ(IrOpcode::kJSCreateWithContext, node->opcode()); |
| 1191 Node* const input = NodeProperties::GetValueInput(node, 0); | 1191 Node* const input = NodeProperties::GetValueInput(node, 0); |
| 1192 Node* const closure = NodeProperties::GetValueInput(node, 1); | |
| 1192 Type* input_type = NodeProperties::GetBounds(input).upper; | 1193 Type* input_type = NodeProperties::GetBounds(input).upper; |
| 1193 if (FLAG_turbo_allocate && input_type->Is(Type::Receiver())) { | 1194 // The closure can be NumberConstant(0) if the closure is global code |
| 1195 // (rather than a function). We exclude that case here. | |
| 1196 // TODO(jarin) Find a better way to check that the closure is a function. | |
| 1197 if (FLAG_turbo_allocate && input_type->Is(Type::Receiver()) && | |
| 1198 closure->opcode() != IrOpcode::kNumberConstant) { | |
| 1194 // JSCreateWithContext(o:receiver, f) | 1199 // JSCreateWithContext(o:receiver, f) |
| 1195 Node* const effect = NodeProperties::GetEffectInput(node); | 1200 Node* const effect = NodeProperties::GetEffectInput(node); |
| 1196 Node* const control = NodeProperties::GetControlInput(node); | 1201 Node* const control = NodeProperties::GetControlInput(node); |
| 1197 Node* const closure = NodeProperties::GetValueInput(node, 1); | |
| 1198 Node* const context = NodeProperties::GetContextInput(node); | 1202 Node* const context = NodeProperties::GetContextInput(node); |
| 1199 Node* const load = graph()->NewNode( | 1203 Node* const load = graph()->NewNode( |
| 1200 simplified()->LoadField( | 1204 simplified()->LoadField( |
| 1201 AccessBuilder::ForContextSlot(Context::GLOBAL_OBJECT_INDEX)), | 1205 AccessBuilder::ForContextSlot(Context::GLOBAL_OBJECT_INDEX)), |
| 1202 context, effect, control); | 1206 context, effect, control); |
| 1203 AllocationBuilder a(jsgraph(), simplified(), effect, control); | 1207 AllocationBuilder a(jsgraph(), simplified(), effect, control); |
| 1204 STATIC_ASSERT(Context::MIN_CONTEXT_SLOTS == 4); // Ensure fully covered. | 1208 STATIC_ASSERT(Context::MIN_CONTEXT_SLOTS == 4); // Ensure fully covered. |
| 1205 a.AllocateArray(Context::MIN_CONTEXT_SLOTS, factory()->with_context_map()); | 1209 a.AllocateArray(Context::MIN_CONTEXT_SLOTS, factory()->with_context_map()); |
| 1206 a.Store(AccessBuilder::ForContextSlot(Context::CLOSURE_INDEX), closure); | 1210 a.Store(AccessBuilder::ForContextSlot(Context::CLOSURE_INDEX), closure); |
| 1207 a.Store(AccessBuilder::ForContextSlot(Context::PREVIOUS_INDEX), context); | 1211 a.Store(AccessBuilder::ForContextSlot(Context::PREVIOUS_INDEX), context); |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 1224 DCHECK_EQ(IrOpcode::kJSCreateBlockContext, node->opcode()); | 1228 DCHECK_EQ(IrOpcode::kJSCreateBlockContext, node->opcode()); |
| 1225 Node* const input = NodeProperties::GetValueInput(node, 0); | 1229 Node* const input = NodeProperties::GetValueInput(node, 0); |
| 1226 HeapObjectMatcher minput(input); | 1230 HeapObjectMatcher minput(input); |
| 1227 DCHECK(minput.HasValue()); // TODO(mstarzinger): Make ScopeInfo static. | 1231 DCHECK(minput.HasValue()); // TODO(mstarzinger): Make ScopeInfo static. |
| 1228 int context_length = | 1232 int context_length = |
| 1229 Handle<ScopeInfo>::cast(minput.Value().handle())->ContextLength(); | 1233 Handle<ScopeInfo>::cast(minput.Value().handle())->ContextLength(); |
| 1230 if (FLAG_turbo_allocate && context_length < kBlockContextAllocationLimit) { | 1234 if (FLAG_turbo_allocate && context_length < kBlockContextAllocationLimit) { |
| 1231 // JSCreateBlockContext(s:scope[length < limit], f) | 1235 // JSCreateBlockContext(s:scope[length < limit], f) |
| 1232 Node* const effect = NodeProperties::GetEffectInput(node); | 1236 Node* const effect = NodeProperties::GetEffectInput(node); |
| 1233 Node* const control = NodeProperties::GetControlInput(node); | 1237 Node* const control = NodeProperties::GetControlInput(node); |
| 1234 Node* const closure = NodeProperties::GetValueInput(node, 1); | 1238 Node* const closure = NodeProperties::GetValueInput(node, 1); |
|
Michael Starzinger
2015/08/19 14:19:24
The same can happen for block contexts as well.
Jarin
2015/08/20 05:26:01
Done.
| |
| 1235 Node* const context = NodeProperties::GetContextInput(node); | 1239 Node* const context = NodeProperties::GetContextInput(node); |
| 1236 Node* const load = graph()->NewNode( | 1240 Node* const load = graph()->NewNode( |
| 1237 simplified()->LoadField( | 1241 simplified()->LoadField( |
| 1238 AccessBuilder::ForContextSlot(Context::GLOBAL_OBJECT_INDEX)), | 1242 AccessBuilder::ForContextSlot(Context::GLOBAL_OBJECT_INDEX)), |
| 1239 context, effect, control); | 1243 context, effect, control); |
| 1240 AllocationBuilder a(jsgraph(), simplified(), effect, control); | 1244 AllocationBuilder a(jsgraph(), simplified(), effect, control); |
| 1241 STATIC_ASSERT(Context::MIN_CONTEXT_SLOTS == 4); // Ensure fully covered. | 1245 STATIC_ASSERT(Context::MIN_CONTEXT_SLOTS == 4); // Ensure fully covered. |
| 1242 a.AllocateArray(context_length, factory()->block_context_map()); | 1246 a.AllocateArray(context_length, factory()->block_context_map()); |
| 1243 a.Store(AccessBuilder::ForContextSlot(Context::CLOSURE_INDEX), closure); | 1247 a.Store(AccessBuilder::ForContextSlot(Context::CLOSURE_INDEX), closure); |
| 1244 a.Store(AccessBuilder::ForContextSlot(Context::PREVIOUS_INDEX), context); | 1248 a.Store(AccessBuilder::ForContextSlot(Context::PREVIOUS_INDEX), context); |
| (...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1707 } | 1711 } |
| 1708 | 1712 |
| 1709 | 1713 |
| 1710 MachineOperatorBuilder* JSTypedLowering::machine() const { | 1714 MachineOperatorBuilder* JSTypedLowering::machine() const { |
| 1711 return jsgraph()->machine(); | 1715 return jsgraph()->machine(); |
| 1712 } | 1716 } |
| 1713 | 1717 |
| 1714 } // namespace compiler | 1718 } // namespace compiler |
| 1715 } // namespace internal | 1719 } // namespace internal |
| 1716 } // namespace v8 | 1720 } // namespace v8 |
| OLD | NEW |