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

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

Issue 2655853010: [TypeFeedbackVector] Combine the literals array and the feedback vector. (Closed)
Patch Set: more comments. 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/js-graph.h » ('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 751 matching lines...) Expand 10 before | Expand all | Expand 10 after
762 int const function_map_index = 762 int const function_map_index =
763 Context::FunctionMapIndex(shared->language_mode(), shared->kind()); 763 Context::FunctionMapIndex(shared->language_mode(), shared->kind());
764 Node* function_map = jsgraph()->HeapConstant( 764 Node* function_map = jsgraph()->HeapConstant(
765 handle(Map::cast(native_context()->get(function_map_index)), isolate())); 765 handle(Map::cast(native_context()->get(function_map_index)), isolate()));
766 766
767 // Note that it is only safe to embed the raw entry point of the compile 767 // Note that it is only safe to embed the raw entry point of the compile
768 // lazy stub into the code, because that stub is immortal and immovable. 768 // lazy stub into the code, because that stub is immortal and immovable.
769 Node* compile_entry = jsgraph()->PointerConstant( 769 Node* compile_entry = jsgraph()->PointerConstant(
770 jsgraph()->isolate()->builtins()->CompileLazy()->entry()); 770 jsgraph()->isolate()->builtins()->CompileLazy()->entry());
771 Node* empty_fixed_array = jsgraph()->EmptyFixedArrayConstant(); 771 Node* empty_fixed_array = jsgraph()->EmptyFixedArrayConstant();
772 Node* empty_literals_array = jsgraph()->EmptyLiteralsArrayConstant(); 772 Node* empty_feedback_vector = jsgraph()->EmptyFeedbackVectorConstant();
773 Node* the_hole = jsgraph()->TheHoleConstant(); 773 Node* the_hole = jsgraph()->TheHoleConstant();
774 Node* undefined = jsgraph()->UndefinedConstant(); 774 Node* undefined = jsgraph()->UndefinedConstant();
775 AllocationBuilder a(jsgraph(), effect, control); 775 AllocationBuilder a(jsgraph(), effect, control);
776 STATIC_ASSERT(JSFunction::kSize == 9 * kPointerSize); 776 STATIC_ASSERT(JSFunction::kSize == 9 * kPointerSize);
777 a.Allocate(JSFunction::kSize, p.pretenure()); 777 a.Allocate(JSFunction::kSize, p.pretenure());
778 a.Store(AccessBuilder::ForMap(), function_map); 778 a.Store(AccessBuilder::ForMap(), function_map);
779 a.Store(AccessBuilder::ForJSObjectProperties(), empty_fixed_array); 779 a.Store(AccessBuilder::ForJSObjectProperties(), empty_fixed_array);
780 a.Store(AccessBuilder::ForJSObjectElements(), empty_fixed_array); 780 a.Store(AccessBuilder::ForJSObjectElements(), empty_fixed_array);
781 a.Store(AccessBuilder::ForJSFunctionLiterals(), empty_literals_array); 781 a.Store(AccessBuilder::ForJSFunctionFeedbackVector(), empty_feedback_vector);
782 a.Store(AccessBuilder::ForJSFunctionPrototypeOrInitialMap(), the_hole); 782 a.Store(AccessBuilder::ForJSFunctionPrototypeOrInitialMap(), the_hole);
783 a.Store(AccessBuilder::ForJSFunctionSharedFunctionInfo(), shared); 783 a.Store(AccessBuilder::ForJSFunctionSharedFunctionInfo(), shared);
784 a.Store(AccessBuilder::ForJSFunctionContext(), context); 784 a.Store(AccessBuilder::ForJSFunctionContext(), context);
785 a.Store(AccessBuilder::ForJSFunctionCodeEntry(), compile_entry); 785 a.Store(AccessBuilder::ForJSFunctionCodeEntry(), compile_entry);
786 a.Store(AccessBuilder::ForJSFunctionNextFunctionLink(), undefined); 786 a.Store(AccessBuilder::ForJSFunctionNextFunctionLink(), undefined);
787 RelaxControls(node); 787 RelaxControls(node);
788 a.FinishAndChange(node); 788 a.FinishAndChange(node);
789 return Changed(node); 789 return Changed(node);
790 } 790 }
791 791
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
843 return Changed(node); 843 return Changed(node);
844 } 844 }
845 845
846 Reduction JSCreateLowering::ReduceJSCreateLiteral(Node* node) { 846 Reduction JSCreateLowering::ReduceJSCreateLiteral(Node* node) {
847 DCHECK(node->opcode() == IrOpcode::kJSCreateLiteralArray || 847 DCHECK(node->opcode() == IrOpcode::kJSCreateLiteralArray ||
848 node->opcode() == IrOpcode::kJSCreateLiteralObject); 848 node->opcode() == IrOpcode::kJSCreateLiteralObject);
849 CreateLiteralParameters const& p = CreateLiteralParametersOf(node->op()); 849 CreateLiteralParameters const& p = CreateLiteralParametersOf(node->op());
850 Node* effect = NodeProperties::GetEffectInput(node); 850 Node* effect = NodeProperties::GetEffectInput(node);
851 Node* control = NodeProperties::GetControlInput(node); 851 Node* control = NodeProperties::GetControlInput(node);
852 852
853 Handle<LiteralsArray> literals_array; 853 Handle<TypeFeedbackVector> feedback_vector;
854 if (GetSpecializationLiterals(node).ToHandle(&literals_array)) { 854 if (GetSpecializationTypeFeedbackVector(node).ToHandle(&feedback_vector)) {
855 Handle<Object> literal(literals_array->literal(p.index()), isolate()); 855 FeedbackVectorSlot slot(TypeFeedbackVector::ToSlot(p.index()));
856 Handle<Object> literal(feedback_vector->Get(slot), isolate());
856 if (literal->IsAllocationSite()) { 857 if (literal->IsAllocationSite()) {
857 Handle<AllocationSite> site = Handle<AllocationSite>::cast(literal); 858 Handle<AllocationSite> site = Handle<AllocationSite>::cast(literal);
858 Handle<JSObject> boilerplate(JSObject::cast(site->transition_info()), 859 Handle<JSObject> boilerplate(JSObject::cast(site->transition_info()),
859 isolate()); 860 isolate());
860 int max_properties = kMaxFastLiteralProperties; 861 int max_properties = kMaxFastLiteralProperties;
861 if (IsFastLiteral(boilerplate, kMaxFastLiteralDepth, &max_properties)) { 862 if (IsFastLiteral(boilerplate, kMaxFastLiteralDepth, &max_properties)) {
862 AllocationSiteUsageContext site_context(isolate(), site, false); 863 AllocationSiteUsageContext site_context(isolate(), site, false);
863 site_context.EnterNewScope(); 864 site_context.EnterNewScope();
864 Node* value = effect = 865 Node* value = effect =
865 AllocateFastLiteral(effect, control, boilerplate, &site_context); 866 AllocateFastLiteral(effect, control, boilerplate, &site_context);
(...skipping 470 matching lines...) Expand 10 before | Expand all | Expand 10 after
1336 ElementAccess const access = 1337 ElementAccess const access =
1337 (elements_map->instance_type() == FIXED_DOUBLE_ARRAY_TYPE) 1338 (elements_map->instance_type() == FIXED_DOUBLE_ARRAY_TYPE)
1338 ? AccessBuilder::ForFixedDoubleArrayElement() 1339 ? AccessBuilder::ForFixedDoubleArrayElement()
1339 : AccessBuilder::ForFixedArrayElement(); 1340 : AccessBuilder::ForFixedArrayElement();
1340 for (int i = 0; i < elements_length; ++i) { 1341 for (int i = 0; i < elements_length; ++i) {
1341 builder.Store(access, jsgraph()->Constant(i), elements_values[i]); 1342 builder.Store(access, jsgraph()->Constant(i), elements_values[i]);
1342 } 1343 }
1343 return builder.Finish(); 1344 return builder.Finish();
1344 } 1345 }
1345 1346
1346 MaybeHandle<LiteralsArray> JSCreateLowering::GetSpecializationLiterals( 1347 MaybeHandle<TypeFeedbackVector>
1347 Node* node) { 1348 JSCreateLowering::GetSpecializationTypeFeedbackVector(Node* node) {
1348 Node* const closure = NodeProperties::GetValueInput(node, 0); 1349 Node* const closure = NodeProperties::GetValueInput(node, 0);
1349 switch (closure->opcode()) { 1350 switch (closure->opcode()) {
1350 case IrOpcode::kHeapConstant: { 1351 case IrOpcode::kHeapConstant: {
1351 Handle<HeapObject> object = OpParameter<Handle<HeapObject>>(closure); 1352 Handle<HeapObject> object = OpParameter<Handle<HeapObject>>(closure);
1352 return handle(Handle<JSFunction>::cast(object)->literals()); 1353 return handle(Handle<JSFunction>::cast(object)->feedback_vector());
1353 } 1354 }
1354 case IrOpcode::kParameter: { 1355 case IrOpcode::kParameter: {
1355 int const index = ParameterIndexOf(closure->op()); 1356 int const index = ParameterIndexOf(closure->op());
1356 // The closure is always the last parameter to a JavaScript function, and 1357 // The closure is always the last parameter to a JavaScript function, and
1357 // {Parameter} indices start at -1, so value outputs of {Start} look like 1358 // {Parameter} indices start at -1, so value outputs of {Start} look like
1358 // this: closure, receiver, param0, ..., paramN, context. 1359 // this: closure, receiver, param0, ..., paramN, context.
1359 if (index == -1) { 1360 if (index == -1) {
1360 return literals_array_; 1361 return feedback_vector_;
1361 } 1362 }
1362 break; 1363 break;
1363 } 1364 }
1364 default: 1365 default:
1365 break; 1366 break;
1366 } 1367 }
1367 return MaybeHandle<LiteralsArray>(); 1368 return MaybeHandle<TypeFeedbackVector>();
1368 } 1369 }
1369 1370
1370 Factory* JSCreateLowering::factory() const { return isolate()->factory(); } 1371 Factory* JSCreateLowering::factory() const { return isolate()->factory(); }
1371 1372
1372 Graph* JSCreateLowering::graph() const { return jsgraph()->graph(); } 1373 Graph* JSCreateLowering::graph() const { return jsgraph()->graph(); }
1373 1374
1374 Isolate* JSCreateLowering::isolate() const { return jsgraph()->isolate(); } 1375 Isolate* JSCreateLowering::isolate() const { return jsgraph()->isolate(); }
1375 1376
1376 JSOperatorBuilder* JSCreateLowering::javascript() const { 1377 JSOperatorBuilder* JSCreateLowering::javascript() const {
1377 return jsgraph()->javascript(); 1378 return jsgraph()->javascript();
1378 } 1379 }
1379 1380
1380 CommonOperatorBuilder* JSCreateLowering::common() const { 1381 CommonOperatorBuilder* JSCreateLowering::common() const {
1381 return jsgraph()->common(); 1382 return jsgraph()->common();
1382 } 1383 }
1383 1384
1384 SimplifiedOperatorBuilder* JSCreateLowering::simplified() const { 1385 SimplifiedOperatorBuilder* JSCreateLowering::simplified() const {
1385 return jsgraph()->simplified(); 1386 return jsgraph()->simplified();
1386 } 1387 }
1387 1388
1388 MachineOperatorBuilder* JSCreateLowering::machine() const { 1389 MachineOperatorBuilder* JSCreateLowering::machine() const {
1389 return jsgraph()->machine(); 1390 return jsgraph()->machine();
1390 } 1391 }
1391 1392
1392 } // namespace compiler 1393 } // namespace compiler
1393 } // namespace internal 1394 } // namespace internal
1394 } // namespace v8 1395 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/js-create-lowering.h ('k') | src/compiler/js-graph.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698