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

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

Issue 1292383007: [turbofan] Do not optimize with/block-context allocation in global code. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Same for block context Created 5 years, 4 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 | « no previous file | no next file » | 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 1171 matching lines...) Expand 10 before | Expand all | Expand 10 after
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);
1208 a.Store(AccessBuilder::ForContextSlot(Context::EXTENSION_INDEX), input); 1212 a.Store(AccessBuilder::ForContextSlot(Context::EXTENSION_INDEX), input);
1209 a.Store(AccessBuilder::ForContextSlot(Context::GLOBAL_OBJECT_INDEX), load); 1213 a.Store(AccessBuilder::ForContextSlot(Context::GLOBAL_OBJECT_INDEX), load);
1210 // TODO(mstarzinger): We could mutate {node} into the allocation instead. 1214 // TODO(mstarzinger): We could mutate {node} into the allocation instead.
1211 NodeProperties::SetBounds(a.allocation(), NodeProperties::GetBounds(node)); 1215 NodeProperties::SetBounds(a.allocation(), NodeProperties::GetBounds(node));
1212 ReplaceWithValue(node, node, a.effect()); 1216 ReplaceWithValue(node, node, a.effect());
1213 node->ReplaceInput(0, a.allocation()); 1217 node->ReplaceInput(0, a.allocation());
1214 node->ReplaceInput(1, a.effect()); 1218 node->ReplaceInput(1, a.effect());
1215 node->set_op(common()->Finish(1)); 1219 node->set_op(common()->Finish(1));
1216 node->TrimInputCount(2); 1220 node->TrimInputCount(2);
1217 return Changed(node); 1221 return Changed(node);
1218 } 1222 }
1219 return NoChange(); 1223 return NoChange();
1220 } 1224 }
1221 1225
1222 1226
1223 Reduction JSTypedLowering::ReduceJSCreateBlockContext(Node* node) { 1227 Reduction JSTypedLowering::ReduceJSCreateBlockContext(Node* node) {
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);
1230 Node* const closure = NodeProperties::GetValueInput(node, 1);
1226 HeapObjectMatcher minput(input); 1231 HeapObjectMatcher minput(input);
1227 DCHECK(minput.HasValue()); // TODO(mstarzinger): Make ScopeInfo static. 1232 DCHECK(minput.HasValue()); // TODO(mstarzinger): Make ScopeInfo static.
1228 int context_length = 1233 int context_length =
1229 Handle<ScopeInfo>::cast(minput.Value().handle())->ContextLength(); 1234 Handle<ScopeInfo>::cast(minput.Value().handle())->ContextLength();
1230 if (FLAG_turbo_allocate && context_length < kBlockContextAllocationLimit) { 1235 // The closure can be NumberConstant(0) if the closure is global code
1236 // (rather than a function). We exclude that case here.
1237 // TODO(jarin) Find a better way to check that the closure is a function.
1238 if (FLAG_turbo_allocate && context_length < kBlockContextAllocationLimit &&
1239 closure->opcode() != IrOpcode::kNumberConstant) {
1231 // JSCreateBlockContext(s:scope[length < limit], f) 1240 // JSCreateBlockContext(s:scope[length < limit], f)
1232 Node* const effect = NodeProperties::GetEffectInput(node); 1241 Node* const effect = NodeProperties::GetEffectInput(node);
1233 Node* const control = NodeProperties::GetControlInput(node); 1242 Node* const control = NodeProperties::GetControlInput(node);
1234 Node* const closure = NodeProperties::GetValueInput(node, 1);
1235 Node* const context = NodeProperties::GetContextInput(node); 1243 Node* const context = NodeProperties::GetContextInput(node);
1236 Node* const load = graph()->NewNode( 1244 Node* const load = graph()->NewNode(
1237 simplified()->LoadField( 1245 simplified()->LoadField(
1238 AccessBuilder::ForContextSlot(Context::GLOBAL_OBJECT_INDEX)), 1246 AccessBuilder::ForContextSlot(Context::GLOBAL_OBJECT_INDEX)),
1239 context, effect, control); 1247 context, effect, control);
1240 AllocationBuilder a(jsgraph(), simplified(), effect, control); 1248 AllocationBuilder a(jsgraph(), simplified(), effect, control);
1241 STATIC_ASSERT(Context::MIN_CONTEXT_SLOTS == 4); // Ensure fully covered. 1249 STATIC_ASSERT(Context::MIN_CONTEXT_SLOTS == 4); // Ensure fully covered.
1242 a.AllocateArray(context_length, factory()->block_context_map()); 1250 a.AllocateArray(context_length, factory()->block_context_map());
1243 a.Store(AccessBuilder::ForContextSlot(Context::CLOSURE_INDEX), closure); 1251 a.Store(AccessBuilder::ForContextSlot(Context::CLOSURE_INDEX), closure);
1244 a.Store(AccessBuilder::ForContextSlot(Context::PREVIOUS_INDEX), context); 1252 a.Store(AccessBuilder::ForContextSlot(Context::PREVIOUS_INDEX), context);
(...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after
1707 } 1715 }
1708 1716
1709 1717
1710 MachineOperatorBuilder* JSTypedLowering::machine() const { 1718 MachineOperatorBuilder* JSTypedLowering::machine() const {
1711 return jsgraph()->machine(); 1719 return jsgraph()->machine();
1712 } 1720 }
1713 1721
1714 } // namespace compiler 1722 } // namespace compiler
1715 } // namespace internal 1723 } // namespace internal
1716 } // namespace v8 1724 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698