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

Side by Side Diff: src/compiler/ia32/instruction-selector-ia32.cc

Issue 2649703002: [Atomics] Make Atomics.compareExchange a builtin using TF (Closed)
Patch Set: dmb Created 3 years, 9 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 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 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/base/adapters.h" 5 #include "src/base/adapters.h"
6 #include "src/compiler/instruction-selector-impl.h" 6 #include "src/compiler/instruction-selector-impl.h"
7 #include "src/compiler/node-matchers.h" 7 #include "src/compiler/node-matchers.h"
8 #include "src/compiler/node-properties.h" 8 #include "src/compiler/node-properties.h"
9 9
10 namespace v8 { 10 namespace v8 {
(...skipping 1738 matching lines...) Expand 10 before | Expand all | Expand 10 after
1749 addressing_mode = kMode_MRI; 1749 addressing_mode = kMode_MRI;
1750 } else { 1750 } else {
1751 inputs[input_count++] = g.UseUniqueRegister(index); 1751 inputs[input_count++] = g.UseUniqueRegister(index);
1752 addressing_mode = kMode_MR1; 1752 addressing_mode = kMode_MR1;
1753 } 1753 }
1754 outputs[0] = g.DefineSameAsFirst(node); 1754 outputs[0] = g.DefineSameAsFirst(node);
1755 InstructionCode code = opcode | AddressingModeField::encode(addressing_mode); 1755 InstructionCode code = opcode | AddressingModeField::encode(addressing_mode);
1756 Emit(code, 1, outputs, input_count, inputs); 1756 Emit(code, 1, outputs, input_count, inputs);
1757 } 1757 }
1758 1758
1759 void InstructionSelector::VisitAtomicCompareExchange(Node* node) {
1760 IA32OperandGenerator g(this);
1761 Node* base = node->InputAt(0);
1762 Node* index = node->InputAt(1);
1763 Node* old_value = node->InputAt(2);
1764 Node* new_value = node->InputAt(3);
1765
1766 MachineType type = AtomicCompareExchangeRepresentationOf(node->op());
1767 ArchOpcode opcode = kArchNop;
1768 if (type == MachineType::Int8()) {
1769 opcode = kAtomicCompareExchangeInt8;
1770 } else if (type == MachineType::Uint8()) {
1771 opcode = kAtomicCompareExchangeUint8;
1772 } else if (type == MachineType::Int16()) {
1773 opcode = kAtomicCompareExchangeInt16;
1774 } else if (type == MachineType::Uint16()) {
1775 opcode = kAtomicCompareExchangeUint16;
1776 } else if (type == MachineType::Int32() || type == MachineType::Uint32()) {
1777 opcode = kAtomicCompareExchangeWord32;
1778 } else {
1779 UNREACHABLE();
1780 return;
1781 }
1782 InstructionOperand outputs[1];
1783 AddressingMode addressing_mode;
1784 InstructionOperand inputs[4];
1785 size_t input_count = 0;
1786 inputs[input_count++] = g.UseFixed(old_value, eax);
1787 inputs[input_count++] = g.UseUniqueRegister(new_value);
1788 inputs[input_count++] = g.UseUniqueRegister(base);
1789 if (g.CanBeImmediate(index)) {
1790 inputs[input_count++] = g.UseImmediate(index);
1791 addressing_mode = kMode_MRI;
1792 } else {
1793 inputs[input_count++] = g.UseUniqueRegister(index);
1794 addressing_mode = kMode_MR1;
1795 }
1796 outputs[0] = g.DefineAsFixed(node, eax);
1797 InstructionCode code = opcode | AddressingModeField::encode(addressing_mode);
1798 Emit(code, 1, outputs, input_count, inputs);
1799 }
1800
1759 // static 1801 // static
1760 MachineOperatorBuilder::Flags 1802 MachineOperatorBuilder::Flags
1761 InstructionSelector::SupportedMachineOperatorFlags() { 1803 InstructionSelector::SupportedMachineOperatorFlags() {
1762 MachineOperatorBuilder::Flags flags = 1804 MachineOperatorBuilder::Flags flags =
1763 MachineOperatorBuilder::kWord32ShiftIsSafe | 1805 MachineOperatorBuilder::kWord32ShiftIsSafe |
1764 MachineOperatorBuilder::kWord32Ctz; 1806 MachineOperatorBuilder::kWord32Ctz;
1765 if (CpuFeatures::IsSupported(POPCNT)) { 1807 if (CpuFeatures::IsSupported(POPCNT)) {
1766 flags |= MachineOperatorBuilder::kWord32Popcnt; 1808 flags |= MachineOperatorBuilder::kWord32Popcnt;
1767 } 1809 }
1768 if (CpuFeatures::IsSupported(SSE4_1)) { 1810 if (CpuFeatures::IsSupported(SSE4_1)) {
(...skipping 12 matching lines...) Expand all
1781 // static 1823 // static
1782 MachineOperatorBuilder::AlignmentRequirements 1824 MachineOperatorBuilder::AlignmentRequirements
1783 InstructionSelector::AlignmentRequirements() { 1825 InstructionSelector::AlignmentRequirements() {
1784 return MachineOperatorBuilder::AlignmentRequirements:: 1826 return MachineOperatorBuilder::AlignmentRequirements::
1785 FullUnalignedAccessSupport(); 1827 FullUnalignedAccessSupport();
1786 } 1828 }
1787 1829
1788 } // namespace compiler 1830 } // namespace compiler
1789 } // namespace internal 1831 } // namespace internal
1790 } // namespace v8 1832 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698