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

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

Issue 2322373002: [stubs] Port StoreGlobalStub to TurboFan. (Closed)
Patch Set: Created 4 years, 3 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/code-stubs.cc ('k') | 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 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 <memory> 7 #include <memory>
8 8
9 #include "src/bailout-reason.h" 9 #include "src/bailout-reason.h"
10 #include "src/crankshaft/hydrogen.h" 10 #include "src/crankshaft/hydrogen.h"
(...skipping 1502 matching lines...) Expand 10 before | Expand all | Expand 10 after
1513 if_true.Then(); 1513 if_true.Then();
1514 if_true.Return(graph()->GetConstantTrue()); 1514 if_true.Return(graph()->GetConstantTrue());
1515 if_true.Else(); 1515 if_true.Else();
1516 if_true.End(); 1516 if_true.End();
1517 return graph()->GetConstantFalse(); 1517 return graph()->GetConstantFalse();
1518 } 1518 }
1519 1519
1520 Handle<Code> ToBooleanICStub::GenerateCode() { return DoGenerateCode(this); } 1520 Handle<Code> ToBooleanICStub::GenerateCode() { return DoGenerateCode(this); }
1521 1521
1522 template <> 1522 template <>
1523 HValue* CodeStubGraphBuilder<StoreGlobalStub>::BuildCodeInitializedStub() {
1524 StoreGlobalStub* stub = casted_stub();
1525 HParameter* value = GetParameter(Descriptor::kValue);
1526 if (stub->check_global()) {
1527 // Check that the map of the global has not changed: use a placeholder map
1528 // that will be replaced later with the global object's map.
1529 HParameter* proxy = GetParameter(Descriptor::kReceiver);
1530 HValue* proxy_map =
1531 Add<HLoadNamedField>(proxy, nullptr, HObjectAccess::ForMap());
1532 HValue* global =
1533 Add<HLoadNamedField>(proxy_map, nullptr, HObjectAccess::ForPrototype());
1534 HValue* map_cell = Add<HConstant>(isolate()->factory()->NewWeakCell(
1535 StoreGlobalStub::global_map_placeholder(isolate())));
1536 HValue* expected_map = Add<HLoadNamedField>(
1537 map_cell, nullptr, HObjectAccess::ForWeakCellValue());
1538 HValue* map =
1539 Add<HLoadNamedField>(global, nullptr, HObjectAccess::ForMap());
1540 IfBuilder map_check(this);
1541 map_check.IfNot<HCompareObjectEqAndBranch>(expected_map, map);
1542 map_check.ThenDeopt(DeoptimizeReason::kUnknownMap);
1543 map_check.End();
1544 }
1545
1546 HValue* weak_cell = Add<HConstant>(isolate()->factory()->NewWeakCell(
1547 StoreGlobalStub::property_cell_placeholder(isolate())));
1548 HValue* cell = Add<HLoadNamedField>(weak_cell, nullptr,
1549 HObjectAccess::ForWeakCellValue());
1550 Add<HCheckHeapObject>(cell);
1551 HObjectAccess access = HObjectAccess::ForPropertyCellValue();
1552 // Load the payload of the global parameter cell. A hole indicates that the
1553 // cell has been invalidated and that the store must be handled by the
1554 // runtime.
1555 HValue* cell_contents = Add<HLoadNamedField>(cell, nullptr, access);
1556
1557 auto cell_type = stub->cell_type();
1558 if (cell_type == PropertyCellType::kConstant ||
1559 cell_type == PropertyCellType::kUndefined) {
1560 // This is always valid for all states a cell can be in.
1561 IfBuilder builder(this);
1562 builder.If<HCompareObjectEqAndBranch>(cell_contents, value);
1563 builder.Then();
1564 builder.ElseDeopt(
1565 DeoptimizeReason::kUnexpectedCellContentsInConstantGlobalStore);
1566 builder.End();
1567 } else {
1568 IfBuilder builder(this);
1569 HValue* hole_value = graph()->GetConstantHole();
1570 builder.If<HCompareObjectEqAndBranch>(cell_contents, hole_value);
1571 builder.Then();
1572 builder.Deopt(DeoptimizeReason::kUnexpectedCellContentsInGlobalStore);
1573 builder.Else();
1574 // When dealing with constant types, the type may be allowed to change, as
1575 // long as optimized code remains valid.
1576 if (cell_type == PropertyCellType::kConstantType) {
1577 switch (stub->constant_type()) {
1578 case PropertyCellConstantType::kSmi:
1579 access = access.WithRepresentation(Representation::Smi());
1580 break;
1581 case PropertyCellConstantType::kStableMap: {
1582 // It is sufficient here to check that the value and cell contents
1583 // have identical maps, no matter if they are stable or not or if they
1584 // are the maps that were originally in the cell or not. If optimized
1585 // code will deopt when a cell has a unstable map and if it has a
1586 // dependency on a stable map, it will deopt if the map destabilizes.
1587 Add<HCheckHeapObject>(value);
1588 Add<HCheckHeapObject>(cell_contents);
1589 HValue* expected_map = Add<HLoadNamedField>(cell_contents, nullptr,
1590 HObjectAccess::ForMap());
1591 HValue* map =
1592 Add<HLoadNamedField>(value, nullptr, HObjectAccess::ForMap());
1593 IfBuilder map_check(this);
1594 map_check.IfNot<HCompareObjectEqAndBranch>(expected_map, map);
1595 map_check.ThenDeopt(DeoptimizeReason::kUnknownMap);
1596 map_check.End();
1597 access = access.WithRepresentation(Representation::HeapObject());
1598 break;
1599 }
1600 }
1601 }
1602 Add<HStoreNamedField>(cell, access, value);
1603 builder.End();
1604 }
1605
1606 return value;
1607 }
1608
1609
1610 Handle<Code> StoreGlobalStub::GenerateCode() {
1611 return DoGenerateCode(this);
1612 }
1613
1614
1615 template <>
1616 HValue* CodeStubGraphBuilder<ElementsTransitionAndStoreStub>::BuildCodeStub() { 1523 HValue* CodeStubGraphBuilder<ElementsTransitionAndStoreStub>::BuildCodeStub() {
1617 HValue* object = GetParameter(StoreTransitionHelper::ReceiverIndex()); 1524 HValue* object = GetParameter(StoreTransitionHelper::ReceiverIndex());
1618 HValue* key = GetParameter(StoreTransitionHelper::NameIndex()); 1525 HValue* key = GetParameter(StoreTransitionHelper::NameIndex());
1619 HValue* value = GetParameter(StoreTransitionHelper::ValueIndex()); 1526 HValue* value = GetParameter(StoreTransitionHelper::ValueIndex());
1620 HValue* map = GetParameter(StoreTransitionHelper::MapIndex()); 1527 HValue* map = GetParameter(StoreTransitionHelper::MapIndex());
1621 1528
1622 if (FLAG_trace_elements_transitions) { 1529 if (FLAG_trace_elements_transitions) {
1623 // Tracing elements transitions is the job of the runtime. 1530 // Tracing elements transitions is the job of the runtime.
1624 Add<HDeoptimize>(DeoptimizeReason::kTracingElementsTransitions, 1531 Add<HDeoptimize>(DeoptimizeReason::kTracingElementsTransitions,
1625 Deoptimizer::EAGER); 1532 Deoptimizer::EAGER);
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after
1932 return Pop(); 1839 return Pop();
1933 } 1840 }
1934 1841
1935 1842
1936 Handle<Code> KeyedLoadGenericStub::GenerateCode() { 1843 Handle<Code> KeyedLoadGenericStub::GenerateCode() {
1937 return DoGenerateCode(this); 1844 return DoGenerateCode(this);
1938 } 1845 }
1939 1846
1940 } // namespace internal 1847 } // namespace internal
1941 } // namespace v8 1848 } // namespace v8
OLDNEW
« no previous file with comments | « src/code-stubs.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698