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

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

Issue 2680313002: Count closures using the feedback vector cell map, specialize if count==1. (Closed)
Patch Set: Only specialize if compiling from bytecode Created 3 years, 10 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 | « src/compiler/js-create-lowering.h ('k') | src/compiler/pipeline.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 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 } // namespace 203 } // namespace
204 204
205 Reduction JSCreateLowering::Reduce(Node* node) { 205 Reduction JSCreateLowering::Reduce(Node* node) {
206 switch (node->opcode()) { 206 switch (node->opcode()) {
207 case IrOpcode::kJSCreate: 207 case IrOpcode::kJSCreate:
208 return ReduceJSCreate(node); 208 return ReduceJSCreate(node);
209 case IrOpcode::kJSCreateArguments: 209 case IrOpcode::kJSCreateArguments:
210 return ReduceJSCreateArguments(node); 210 return ReduceJSCreateArguments(node);
211 case IrOpcode::kJSCreateArray: 211 case IrOpcode::kJSCreateArray:
212 return ReduceJSCreateArray(node); 212 return ReduceJSCreateArray(node);
213 case IrOpcode::kJSCreateClosure:
214 return ReduceJSCreateClosure(node);
215 case IrOpcode::kJSCreateIterResultObject: 213 case IrOpcode::kJSCreateIterResultObject:
216 return ReduceJSCreateIterResultObject(node); 214 return ReduceJSCreateIterResultObject(node);
217 case IrOpcode::kJSCreateKeyValueArray: 215 case IrOpcode::kJSCreateKeyValueArray:
218 return ReduceJSCreateKeyValueArray(node); 216 return ReduceJSCreateKeyValueArray(node);
219 case IrOpcode::kJSCreateLiteralArray: 217 case IrOpcode::kJSCreateLiteralArray:
220 case IrOpcode::kJSCreateLiteralObject: 218 case IrOpcode::kJSCreateLiteralObject:
221 return ReduceJSCreateLiteral(node); 219 return ReduceJSCreateLiteral(node);
222 case IrOpcode::kJSCreateFunctionContext: 220 case IrOpcode::kJSCreateFunctionContext:
223 return ReduceJSCreateFunctionContext(node); 221 return ReduceJSCreateFunctionContext(node);
224 case IrOpcode::kJSCreateWithContext: 222 case IrOpcode::kJSCreateWithContext:
(...skipping 520 matching lines...) Expand 10 before | Expand all | Expand 10 after
745 length_type->Min() == length_type->Max()) { 743 length_type->Min() == length_type->Max()) {
746 int capacity = static_cast<int>(length_type->Max()); 744 int capacity = static_cast<int>(length_type->Max());
747 return ReduceNewArray(node, length, capacity, site); 745 return ReduceNewArray(node, length, capacity, site);
748 } 746 }
749 } 747 }
750 } 748 }
751 749
752 return ReduceNewArrayToStubCall(node, site); 750 return ReduceNewArrayToStubCall(node, site);
753 } 751 }
754 752
755 Reduction JSCreateLowering::ReduceJSCreateClosure(Node* node) {
756 if (!FLAG_turbo_lower_create_closure) return NoChange();
757 DCHECK_EQ(IrOpcode::kJSCreateClosure, node->opcode());
758 CreateClosureParameters const& p = CreateClosureParametersOf(node->op());
759 Handle<SharedFunctionInfo> shared = p.shared_info();
760 Node* effect = NodeProperties::GetEffectInput(node);
761 Node* control = NodeProperties::GetControlInput(node);
762 Node* context = NodeProperties::GetContextInput(node);
763
764 int const function_map_index =
765 Context::FunctionMapIndex(shared->language_mode(), shared->kind());
766 Node* function_map = jsgraph()->HeapConstant(
767 handle(Map::cast(native_context()->get(function_map_index)), isolate()));
768
769 FeedbackSlot slot = p.feedback().slot();
770 Node* literals_cell = jsgraph()->HeapConstant(
771 handle(Cell::cast(p.feedback().vector()->Get(slot)), isolate()));
772
773 // Note that it is only safe to embed the raw entry point of the compile
774 // lazy stub into the code, because that stub is immortal and immovable.
775 Node* compile_entry = jsgraph()->PointerConstant(
776 jsgraph()->isolate()->builtins()->CompileLazy()->entry());
777 Node* empty_fixed_array = jsgraph()->EmptyFixedArrayConstant();
778 Node* the_hole = jsgraph()->TheHoleConstant();
779 Node* undefined = jsgraph()->UndefinedConstant();
780 AllocationBuilder a(jsgraph(), effect, control);
781 STATIC_ASSERT(JSFunction::kSize == 9 * kPointerSize);
782 a.Allocate(JSFunction::kSize, p.pretenure());
783 a.Store(AccessBuilder::ForMap(), function_map);
784 a.Store(AccessBuilder::ForJSObjectProperties(), empty_fixed_array);
785 a.Store(AccessBuilder::ForJSObjectElements(), empty_fixed_array);
786 a.Store(AccessBuilder::ForJSFunctionFeedbackVector(), literals_cell);
787 a.Store(AccessBuilder::ForJSFunctionPrototypeOrInitialMap(), the_hole);
788 a.Store(AccessBuilder::ForJSFunctionSharedFunctionInfo(), shared);
789 a.Store(AccessBuilder::ForJSFunctionContext(), context);
790 a.Store(AccessBuilder::ForJSFunctionCodeEntry(), compile_entry);
791 a.Store(AccessBuilder::ForJSFunctionNextFunctionLink(), undefined);
792 RelaxControls(node);
793 a.FinishAndChange(node);
794 return Changed(node);
795 }
796
797 Reduction JSCreateLowering::ReduceJSCreateIterResultObject(Node* node) { 753 Reduction JSCreateLowering::ReduceJSCreateIterResultObject(Node* node) {
798 DCHECK_EQ(IrOpcode::kJSCreateIterResultObject, node->opcode()); 754 DCHECK_EQ(IrOpcode::kJSCreateIterResultObject, node->opcode());
799 Node* value = NodeProperties::GetValueInput(node, 0); 755 Node* value = NodeProperties::GetValueInput(node, 0);
800 Node* done = NodeProperties::GetValueInput(node, 1); 756 Node* done = NodeProperties::GetValueInput(node, 1);
801 Node* effect = NodeProperties::GetEffectInput(node); 757 Node* effect = NodeProperties::GetEffectInput(node);
802 758
803 Node* iterator_result_map = jsgraph()->HeapConstant( 759 Node* iterator_result_map = jsgraph()->HeapConstant(
804 handle(native_context()->iterator_result_map(), isolate())); 760 handle(native_context()->iterator_result_map(), isolate()));
805 761
806 // Emit code to allocate the JSIteratorResult instance. 762 // Emit code to allocate the JSIteratorResult instance.
(...skipping 584 matching lines...) Expand 10 before | Expand all | Expand 10 after
1391 return jsgraph()->simplified(); 1347 return jsgraph()->simplified();
1392 } 1348 }
1393 1349
1394 MachineOperatorBuilder* JSCreateLowering::machine() const { 1350 MachineOperatorBuilder* JSCreateLowering::machine() const {
1395 return jsgraph()->machine(); 1351 return jsgraph()->machine();
1396 } 1352 }
1397 1353
1398 } // namespace compiler 1354 } // namespace compiler
1399 } // namespace internal 1355 } // namespace internal
1400 } // namespace v8 1356 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/js-create-lowering.h ('k') | src/compiler/pipeline.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698