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

Side by Side Diff: src/code-stubs-hydrogen.cc

Issue 2024253002: [stubs] Remove N-argument Hydrogen-based Array constructor stub (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix arm64 Created 4 years, 6 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
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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-stubs.h" 5 #include "src/code-stubs.h"
6 6
7 #include "src/bailout-reason.h" 7 #include "src/bailout-reason.h"
8 #include "src/crankshaft/hydrogen.h" 8 #include "src/crankshaft/hydrogen.h"
9 #include "src/crankshaft/lithium.h" 9 #include "src/crankshaft/lithium.h"
10 #include "src/field-index.h" 10 #include "src/field-index.h"
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 Representation representation, 78 Representation representation,
79 bool transition_to_field); 79 bool transition_to_field);
80 80
81 HValue* BuildPushElement(HValue* object, HValue* argc, 81 HValue* BuildPushElement(HValue* object, HValue* argc,
82 HValue* argument_elements, ElementsKind kind); 82 HValue* argument_elements, ElementsKind kind);
83 83
84 HValue* UnmappedCase(HValue* elements, HValue* key, HValue* value); 84 HValue* UnmappedCase(HValue* elements, HValue* key, HValue* value);
85 HValue* EmitKeyedSloppyArguments(HValue* receiver, HValue* key, 85 HValue* EmitKeyedSloppyArguments(HValue* receiver, HValue* key,
86 HValue* value); 86 HValue* value);
87 87
88 HValue* BuildArrayConstructor(ElementsKind kind,
89 AllocationSiteOverrideMode override_mode);
90 HValue* BuildInternalArrayConstructor(ElementsKind kind);
91
92 HValue* BuildToString(HValue* input, bool convert); 88 HValue* BuildToString(HValue* input, bool convert);
93 HValue* BuildToPrimitive(HValue* input, HValue* input_map); 89 HValue* BuildToPrimitive(HValue* input, HValue* input_map);
94 90
95 private: 91 private:
96 HValue* BuildArraySingleArgumentConstructor(JSArrayBuilder* builder);
97 HValue* BuildArrayNArgumentsConstructor(JSArrayBuilder* builder,
98 ElementsKind kind);
99
100 base::SmartArrayPointer<HParameter*> parameters_; 92 base::SmartArrayPointer<HParameter*> parameters_;
101 HValue* arguments_length_; 93 HValue* arguments_length_;
102 CompilationInfo* info_; 94 CompilationInfo* info_;
103 CodeStub* code_stub_; 95 CodeStub* code_stub_;
104 CodeStubDescriptor descriptor_; 96 CodeStubDescriptor descriptor_;
105 HContext* context_; 97 HContext* context_;
106 }; 98 };
107 99
108 100
109 bool CodeStubGraphBuilderBase::BuildGraph() { 101 bool CodeStubGraphBuilderBase::BuildGraph() {
(...skipping 1339 matching lines...) Expand 10 before | Expand all | Expand 10 after
1449 casted_stub()->is_js_array()); 1441 casted_stub()->is_js_array());
1450 1442
1451 return GetParameter(0); 1443 return GetParameter(0);
1452 } 1444 }
1453 1445
1454 1446
1455 Handle<Code> TransitionElementsKindStub::GenerateCode() { 1447 Handle<Code> TransitionElementsKindStub::GenerateCode() {
1456 return DoGenerateCode(this); 1448 return DoGenerateCode(this);
1457 } 1449 }
1458 1450
1459 HValue* CodeStubGraphBuilderBase::BuildArrayConstructor(
1460 ElementsKind kind, AllocationSiteOverrideMode override_mode) {
1461 HValue* constructor = GetParameter(ArrayConstructorStubBase::kConstructor);
1462 HValue* alloc_site = GetParameter(ArrayConstructorStubBase::kAllocationSite);
1463 JSArrayBuilder array_builder(this, kind, alloc_site, constructor,
1464 override_mode);
1465 return BuildArrayNArgumentsConstructor(&array_builder, kind);
1466 }
1467
1468 HValue* CodeStubGraphBuilderBase::BuildInternalArrayConstructor(
1469 ElementsKind kind) {
1470 HValue* constructor = GetParameter(
1471 InternalArrayConstructorStubBase::kConstructor);
1472 JSArrayBuilder array_builder(this, kind, constructor);
1473 return BuildArrayNArgumentsConstructor(&array_builder, kind);
1474 }
1475
1476
1477 HValue* CodeStubGraphBuilderBase::BuildArraySingleArgumentConstructor(
1478 JSArrayBuilder* array_builder) {
1479 // Smi check and range check on the input arg.
1480 HValue* constant_one = graph()->GetConstant1();
1481 HValue* constant_zero = graph()->GetConstant0();
1482
1483 HInstruction* elements = Add<HArgumentsElements>(false);
1484 HInstruction* argument = Add<HAccessArgumentsAt>(
1485 elements, constant_one, constant_zero);
1486
1487 return BuildAllocateArrayFromLength(array_builder, argument);
1488 }
1489
1490
1491 HValue* CodeStubGraphBuilderBase::BuildArrayNArgumentsConstructor(
1492 JSArrayBuilder* array_builder, ElementsKind kind) {
1493 // Insert a bounds check because the number of arguments might exceed
1494 // the kInitialMaxFastElementArray limit. This cannot happen for code
1495 // that was parsed, but calling via Array.apply(thisArg, [...]) might
1496 // trigger it.
1497 HValue* length = GetArgumentsLength();
1498 HConstant* max_alloc_length =
1499 Add<HConstant>(JSArray::kInitialMaxFastElementArray);
1500 HValue* checked_length = Add<HBoundsCheck>(length, max_alloc_length);
1501
1502 // We need to fill with the hole if it's a smi array in the multi-argument
1503 // case because we might have to bail out while copying arguments into
1504 // the array because they aren't compatible with a smi array.
1505 // If it's a double array, no problem, and if it's fast then no
1506 // problem either because doubles are boxed.
1507 //
1508 // TODO(mvstanton): consider an instruction to memset fill the array
1509 // with zero in this case instead.
1510 JSArrayBuilder::FillMode fill_mode = IsFastSmiElementsKind(kind)
1511 ? JSArrayBuilder::FILL_WITH_HOLE
1512 : JSArrayBuilder::DONT_FILL_WITH_HOLE;
1513 HValue* new_object = array_builder->AllocateArray(checked_length,
1514 checked_length,
1515 fill_mode);
1516 HValue* elements = array_builder->GetElementsLocation();
1517 DCHECK(elements != NULL);
1518
1519 // Now populate the elements correctly.
1520 LoopBuilder builder(this,
1521 context(),
1522 LoopBuilder::kPostIncrement);
1523 HValue* start = graph()->GetConstant0();
1524 HValue* key = builder.BeginBody(start, checked_length, Token::LT);
1525 HInstruction* argument_elements = Add<HArgumentsElements>(false);
1526 HInstruction* argument = Add<HAccessArgumentsAt>(
1527 argument_elements, checked_length, key);
1528
1529 Add<HStoreKeyed>(elements, key, argument, nullptr, kind);
1530 builder.EndBody();
1531 return new_object;
1532 }
1533
1534
1535 template <>
1536 HValue* CodeStubGraphBuilder<ArrayNArgumentsConstructorStub>::BuildCodeStub() {
1537 ElementsKind kind = casted_stub()->elements_kind();
1538 AllocationSiteOverrideMode override_mode = casted_stub()->override_mode();
1539 return BuildArrayConstructor(kind, override_mode);
1540 }
1541
1542
1543 Handle<Code> ArrayNArgumentsConstructorStub::GenerateCode() {
1544 return DoGenerateCode(this);
1545 }
1546
1547
1548 template <>
1549 HValue* CodeStubGraphBuilder<InternalArrayNArgumentsConstructorStub>::
1550 BuildCodeStub() {
1551 ElementsKind kind = casted_stub()->elements_kind();
1552 return BuildInternalArrayConstructor(kind);
1553 }
1554
1555
1556 Handle<Code> InternalArrayNArgumentsConstructorStub::GenerateCode() {
1557 return DoGenerateCode(this);
1558 }
1559
1560
1561 template <> 1451 template <>
1562 HValue* CodeStubGraphBuilder<BinaryOpICStub>::BuildCodeInitializedStub() { 1452 HValue* CodeStubGraphBuilder<BinaryOpICStub>::BuildCodeInitializedStub() {
1563 BinaryOpICState state = casted_stub()->state(); 1453 BinaryOpICState state = casted_stub()->state();
1564 1454
1565 HValue* left = GetParameter(BinaryOpICStub::kLeft); 1455 HValue* left = GetParameter(BinaryOpICStub::kLeft);
1566 HValue* right = GetParameter(BinaryOpICStub::kRight); 1456 HValue* right = GetParameter(BinaryOpICStub::kRight);
1567 1457
1568 Type* left_type = state.GetLeftType(); 1458 Type* left_type = state.GetLeftType();
1569 Type* right_type = state.GetRightType(); 1459 Type* right_type = state.GetRightType();
1570 Type* result_type = state.GetResultType(); 1460 Type* result_type = state.GetResultType();
(...skipping 793 matching lines...) Expand 10 before | Expand all | Expand 10 after
2364 return Pop(); 2254 return Pop();
2365 } 2255 }
2366 2256
2367 2257
2368 Handle<Code> KeyedLoadGenericStub::GenerateCode() { 2258 Handle<Code> KeyedLoadGenericStub::GenerateCode() {
2369 return DoGenerateCode(this); 2259 return DoGenerateCode(this);
2370 } 2260 }
2371 2261
2372 } // namespace internal 2262 } // namespace internal
2373 } // namespace v8 2263 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698