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

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

Issue 2435023002: Use a different map to distinguish eval contexts (Closed)
Patch Set: Changes from review Created 4 years 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/bytecode-graph-builder.cc ('k') | src/compiler/js-generic-lowering.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 2016 the V8 project authors. All rights reserved. 1 // Copyright 2016 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/compiler/js-create-lowering.h" 5 #include "src/compiler/js-create-lowering.h"
6 6
7 #include "src/allocation-site-scopes.h" 7 #include "src/allocation-site-scopes.h"
8 #include "src/code-factory.h" 8 #include "src/code-factory.h"
9 #include "src/compilation-dependencies.h" 9 #include "src/compilation-dependencies.h"
10 #include "src/compiler/access-builder.h" 10 #include "src/compiler/access-builder.h"
(...skipping 854 matching lines...) Expand 10 before | Expand all | Expand 10 after
865 return Replace(value); 865 return Replace(value);
866 } 866 }
867 } 867 }
868 } 868 }
869 869
870 return NoChange(); 870 return NoChange();
871 } 871 }
872 872
873 Reduction JSCreateLowering::ReduceJSCreateFunctionContext(Node* node) { 873 Reduction JSCreateLowering::ReduceJSCreateFunctionContext(Node* node) {
874 DCHECK_EQ(IrOpcode::kJSCreateFunctionContext, node->opcode()); 874 DCHECK_EQ(IrOpcode::kJSCreateFunctionContext, node->opcode());
875 int slot_count = OpParameter<int>(node->op()); 875 const CreateFunctionContextParameters& parameters =
876 CreateFunctionContextParametersOf(node->op());
877 int slot_count = parameters.slot_count();
878 ScopeType scope_type = parameters.scope_type();
876 Node* const closure = NodeProperties::GetValueInput(node, 0); 879 Node* const closure = NodeProperties::GetValueInput(node, 0);
877 880
878 // Use inline allocation for function contexts up to a size limit. 881 // Use inline allocation for function contexts up to a size limit.
879 if (slot_count < kFunctionContextAllocationLimit) { 882 if (slot_count < kFunctionContextAllocationLimit) {
880 // JSCreateFunctionContext[slot_count < limit]](fun) 883 // JSCreateFunctionContext[slot_count < limit]](fun)
881 Node* effect = NodeProperties::GetEffectInput(node); 884 Node* effect = NodeProperties::GetEffectInput(node);
882 Node* control = NodeProperties::GetControlInput(node); 885 Node* control = NodeProperties::GetControlInput(node);
883 Node* context = NodeProperties::GetContextInput(node); 886 Node* context = NodeProperties::GetContextInput(node);
884 Node* extension = jsgraph()->TheHoleConstant(); 887 Node* extension = jsgraph()->TheHoleConstant();
885 AllocationBuilder a(jsgraph(), effect, control); 888 AllocationBuilder a(jsgraph(), effect, control);
886 STATIC_ASSERT(Context::MIN_CONTEXT_SLOTS == 4); // Ensure fully covered. 889 STATIC_ASSERT(Context::MIN_CONTEXT_SLOTS == 4); // Ensure fully covered.
887 int context_length = slot_count + Context::MIN_CONTEXT_SLOTS; 890 int context_length = slot_count + Context::MIN_CONTEXT_SLOTS;
888 a.AllocateArray(context_length, factory()->function_context_map()); 891 Handle<Map> map;
892 switch (scope_type) {
893 case EVAL_SCOPE:
894 map = factory()->eval_context_map();
895 break;
896 case FUNCTION_SCOPE:
897 map = factory()->function_context_map();
898 break;
899 default:
900 UNREACHABLE();
901 }
902 a.AllocateArray(context_length, map);
889 a.Store(AccessBuilder::ForContextSlot(Context::CLOSURE_INDEX), closure); 903 a.Store(AccessBuilder::ForContextSlot(Context::CLOSURE_INDEX), closure);
890 a.Store(AccessBuilder::ForContextSlot(Context::PREVIOUS_INDEX), context); 904 a.Store(AccessBuilder::ForContextSlot(Context::PREVIOUS_INDEX), context);
891 a.Store(AccessBuilder::ForContextSlot(Context::EXTENSION_INDEX), extension); 905 a.Store(AccessBuilder::ForContextSlot(Context::EXTENSION_INDEX), extension);
892 a.Store(AccessBuilder::ForContextSlot(Context::NATIVE_CONTEXT_INDEX), 906 a.Store(AccessBuilder::ForContextSlot(Context::NATIVE_CONTEXT_INDEX),
893 jsgraph()->HeapConstant(native_context())); 907 jsgraph()->HeapConstant(native_context()));
894 for (int i = Context::MIN_CONTEXT_SLOTS; i < context_length; ++i) { 908 for (int i = Context::MIN_CONTEXT_SLOTS; i < context_length; ++i) {
895 a.Store(AccessBuilder::ForContextSlot(i), jsgraph()->UndefinedConstant()); 909 a.Store(AccessBuilder::ForContextSlot(i), jsgraph()->UndefinedConstant());
896 } 910 }
897 RelaxControls(node); 911 RelaxControls(node);
898 a.FinishAndChange(node); 912 a.FinishAndChange(node);
(...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after
1363 return jsgraph()->simplified(); 1377 return jsgraph()->simplified();
1364 } 1378 }
1365 1379
1366 MachineOperatorBuilder* JSCreateLowering::machine() const { 1380 MachineOperatorBuilder* JSCreateLowering::machine() const {
1367 return jsgraph()->machine(); 1381 return jsgraph()->machine();
1368 } 1382 }
1369 1383
1370 } // namespace compiler 1384 } // namespace compiler
1371 } // namespace internal 1385 } // namespace internal
1372 } // namespace v8 1386 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/bytecode-graph-builder.cc ('k') | src/compiler/js-generic-lowering.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698