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

Side by Side Diff: src/compiler/arm/code-generator-arm.cc

Issue 2649703002: [Atomics] Make Atomics.compareExchange a builtin using TF (Closed)
Patch Set: rebase and move cmpxchg to builtins-sharedarraybuffer-gen.cc 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/compiler/code-generator.h" 5 #include "src/compiler/code-generator.h"
6 6
7 #include "src/arm/macro-assembler-arm.h" 7 #include "src/arm/macro-assembler-arm.h"
8 #include "src/assembler-inl.h" 8 #include "src/assembler-inl.h"
9 #include "src/compilation-info.h" 9 #include "src/compilation-info.h"
10 #include "src/compiler/code-generator-impl.h" 10 #include "src/compiler/code-generator-impl.h"
(...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after
428 __ dmb(ISH); \ 428 __ dmb(ISH); \
429 __ bind(&exchange); \ 429 __ bind(&exchange); \
430 __ add(i.TempRegister(0), i.InputRegister(0), i.InputRegister(1)); \ 430 __ add(i.TempRegister(0), i.InputRegister(0), i.InputRegister(1)); \
431 __ load_instr(i.OutputRegister(0), i.TempRegister(0)); \ 431 __ load_instr(i.OutputRegister(0), i.TempRegister(0)); \
432 __ store_instr(i.TempRegister(0), i.InputRegister(2), i.TempRegister(0)); \ 432 __ store_instr(i.TempRegister(0), i.InputRegister(2), i.TempRegister(0)); \
433 __ teq(i.TempRegister(0), Operand(0)); \ 433 __ teq(i.TempRegister(0), Operand(0)); \
434 __ b(ne, &exchange); \ 434 __ b(ne, &exchange); \
435 __ dmb(ISH); \ 435 __ dmb(ISH); \
436 } while (0) 436 } while (0)
437 437
438 #define ASSEMBLE_ATOMIC_COMPARE_EXCHANGE_INTEGER(load_instr, store_instr) \
439 do { \
440 Label compareExchange; \
441 Label exit; \
442 __ dmb(ISH); \
443 __ bind(&compareExchange); \
444 __ add(i.TempRegister(0), i.InputRegister(0), i.InputRegister(1)); \
445 __ load_instr(i.OutputRegister(0), i.TempRegister(0)); \
446 __ teq(i.TempRegister(1), Operand(i.OutputRegister(0))); \
447 __ b(ne, &exit); \
448 __ store_instr(i.TempRegister(0), i.InputRegister(3), i.TempRegister(0)); \
449 __ teq(i.TempRegister(0), Operand(0)); \
450 __ b(ne, &compareExchange); \
451 __ bind(&exit); \
452 __ dmb(ISH); \
453 } while (0)
454
438 #define ASSEMBLE_IEEE754_BINOP(name) \ 455 #define ASSEMBLE_IEEE754_BINOP(name) \
439 do { \ 456 do { \
440 /* TODO(bmeurer): We should really get rid of this special instruction, */ \ 457 /* TODO(bmeurer): We should really get rid of this special instruction, */ \
441 /* and generate a CallAddress instruction instead. */ \ 458 /* and generate a CallAddress instruction instead. */ \
442 FrameScope scope(masm(), StackFrame::MANUAL); \ 459 FrameScope scope(masm(), StackFrame::MANUAL); \
443 __ PrepareCallCFunction(0, 2, kScratchReg); \ 460 __ PrepareCallCFunction(0, 2, kScratchReg); \
444 __ MovToFloatParameters(i.InputDoubleRegister(0), \ 461 __ MovToFloatParameters(i.InputDoubleRegister(0), \
445 i.InputDoubleRegister(1)); \ 462 i.InputDoubleRegister(1)); \
446 __ CallCFunction(ExternalReference::ieee754_##name##_function(isolate()), \ 463 __ CallCFunction(ExternalReference::ieee754_##name##_function(isolate()), \
447 0, 2); \ 464 0, 2); \
(...skipping 1687 matching lines...) Expand 10 before | Expand all | Expand 10 after
2135 case kAtomicExchangeInt16: 2152 case kAtomicExchangeInt16:
2136 ASSEMBLE_ATOMIC_EXCHANGE_INTEGER(ldrexh, strexh); 2153 ASSEMBLE_ATOMIC_EXCHANGE_INTEGER(ldrexh, strexh);
2137 __ sxth(i.OutputRegister(0), i.OutputRegister(0)); 2154 __ sxth(i.OutputRegister(0), i.OutputRegister(0));
2138 break; 2155 break;
2139 case kAtomicExchangeUint16: 2156 case kAtomicExchangeUint16:
2140 ASSEMBLE_ATOMIC_EXCHANGE_INTEGER(ldrexh, strexh); 2157 ASSEMBLE_ATOMIC_EXCHANGE_INTEGER(ldrexh, strexh);
2141 break; 2158 break;
2142 case kAtomicExchangeWord32: 2159 case kAtomicExchangeWord32:
2143 ASSEMBLE_ATOMIC_EXCHANGE_INTEGER(ldrex, strex); 2160 ASSEMBLE_ATOMIC_EXCHANGE_INTEGER(ldrex, strex);
2144 break; 2161 break;
2162 case kAtomicCompareExchangeInt8:
2163 __ uxtb(i.TempRegister(1), i.InputRegister(2));
2164 ASSEMBLE_ATOMIC_COMPARE_EXCHANGE_INTEGER(ldrexb, strexb);
2165 __ sxtb(i.OutputRegister(0), i.OutputRegister(0));
2166 break;
2167 case kAtomicCompareExchangeUint8:
2168 __ uxtb(i.TempRegister(1), i.InputRegister(2));
2169 ASSEMBLE_ATOMIC_COMPARE_EXCHANGE_INTEGER(ldrexb, strexb);
2170 break;
2171 case kAtomicCompareExchangeInt16:
2172 __ uxth(i.TempRegister(1), i.InputRegister(2));
2173 ASSEMBLE_ATOMIC_COMPARE_EXCHANGE_INTEGER(ldrexh, strexh);
2174 __ sxth(i.OutputRegister(0), i.OutputRegister(0));
2175 break;
2176 case kAtomicCompareExchangeUint16:
2177 __ uxth(i.TempRegister(1), i.InputRegister(2));
2178 ASSEMBLE_ATOMIC_COMPARE_EXCHANGE_INTEGER(ldrexh, strexh);
2179 break;
2180 case kAtomicCompareExchangeWord32:
2181 __ mov(i.TempRegister(1), i.InputRegister(2));
2182 ASSEMBLE_ATOMIC_COMPARE_EXCHANGE_INTEGER(ldrex, strex);
2183 break;
2145 } 2184 }
2146 return kSuccess; 2185 return kSuccess;
2147 } // NOLINT(readability/fn_size) 2186 } // NOLINT(readability/fn_size)
2148 2187
2149 2188
2150 // Assembles branches after an instruction. 2189 // Assembles branches after an instruction.
2151 void CodeGenerator::AssembleArchBranch(Instruction* instr, BranchInfo* branch) { 2190 void CodeGenerator::AssembleArchBranch(Instruction* instr, BranchInfo* branch) {
2152 ArmOperandConverter i(this, instr); 2191 ArmOperandConverter i(this, instr);
2153 Label* tlabel = branch->true_label; 2192 Label* tlabel = branch->true_label;
2154 Label* flabel = branch->false_label; 2193 Label* flabel = branch->false_label;
(...skipping 584 matching lines...) Expand 10 before | Expand all | Expand 10 after
2739 padding_size -= v8::internal::Assembler::kInstrSize; 2778 padding_size -= v8::internal::Assembler::kInstrSize;
2740 } 2779 }
2741 } 2780 }
2742 } 2781 }
2743 2782
2744 #undef __ 2783 #undef __
2745 2784
2746 } // namespace compiler 2785 } // namespace compiler
2747 } // namespace internal 2786 } // namespace internal
2748 } // namespace v8 2787 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698