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

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

Issue 2649703002: [Atomics] Make Atomics.compareExchange a builtin using TF (Closed)
Patch Set: use TF_BUILTIN macro 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 1675 matching lines...) Expand 10 before | Expand all | Expand 10 after
2123 case kAtomicExchangeInt16: 2140 case kAtomicExchangeInt16:
2124 ASSEMBLE_ATOMIC_EXCHANGE_INTEGER(ldrexh, strexh); 2141 ASSEMBLE_ATOMIC_EXCHANGE_INTEGER(ldrexh, strexh);
2125 __ sxth(i.OutputRegister(0), i.OutputRegister(0)); 2142 __ sxth(i.OutputRegister(0), i.OutputRegister(0));
2126 break; 2143 break;
2127 case kAtomicExchangeUint16: 2144 case kAtomicExchangeUint16:
2128 ASSEMBLE_ATOMIC_EXCHANGE_INTEGER(ldrexh, strexh); 2145 ASSEMBLE_ATOMIC_EXCHANGE_INTEGER(ldrexh, strexh);
2129 break; 2146 break;
2130 case kAtomicExchangeWord32: 2147 case kAtomicExchangeWord32:
2131 ASSEMBLE_ATOMIC_EXCHANGE_INTEGER(ldrex, strex); 2148 ASSEMBLE_ATOMIC_EXCHANGE_INTEGER(ldrex, strex);
2132 break; 2149 break;
2150 case kAtomicCompareExchangeInt8:
2151 __ uxtb(i.TempRegister(1), i.InputRegister(2));
2152 ASSEMBLE_ATOMIC_COMPARE_EXCHANGE_INTEGER(ldrexb, strexb);
2153 __ sxtb(i.OutputRegister(0), i.OutputRegister(0));
2154 break;
2155 case kAtomicCompareExchangeUint8:
2156 __ uxtb(i.TempRegister(1), i.InputRegister(2));
2157 ASSEMBLE_ATOMIC_COMPARE_EXCHANGE_INTEGER(ldrexb, strexb);
2158 break;
2159 case kAtomicCompareExchangeInt16:
2160 __ uxth(i.TempRegister(1), i.InputRegister(2));
2161 ASSEMBLE_ATOMIC_COMPARE_EXCHANGE_INTEGER(ldrexh, strexh);
2162 __ sxth(i.OutputRegister(0), i.OutputRegister(0));
2163 break;
2164 case kAtomicCompareExchangeUint16:
2165 __ uxth(i.TempRegister(1), i.InputRegister(2));
2166 ASSEMBLE_ATOMIC_COMPARE_EXCHANGE_INTEGER(ldrexh, strexh);
2167 break;
2168 case kAtomicCompareExchangeWord32:
2169 __ mov(i.TempRegister(1), i.InputRegister(2));
2170 ASSEMBLE_ATOMIC_COMPARE_EXCHANGE_INTEGER(ldrex, strex);
2171 break;
2133 } 2172 }
2134 return kSuccess; 2173 return kSuccess;
2135 } // NOLINT(readability/fn_size) 2174 } // NOLINT(readability/fn_size)
2136 2175
2137 2176
2138 // Assembles branches after an instruction. 2177 // Assembles branches after an instruction.
2139 void CodeGenerator::AssembleArchBranch(Instruction* instr, BranchInfo* branch) { 2178 void CodeGenerator::AssembleArchBranch(Instruction* instr, BranchInfo* branch) {
2140 ArmOperandConverter i(this, instr); 2179 ArmOperandConverter i(this, instr);
2141 Label* tlabel = branch->true_label; 2180 Label* tlabel = branch->true_label;
2142 Label* flabel = branch->false_label; 2181 Label* flabel = branch->false_label;
(...skipping 584 matching lines...) Expand 10 before | Expand all | Expand 10 after
2727 padding_size -= v8::internal::Assembler::kInstrSize; 2766 padding_size -= v8::internal::Assembler::kInstrSize;
2728 } 2767 }
2729 } 2768 }
2730 } 2769 }
2731 2770
2732 #undef __ 2771 #undef __
2733 2772
2734 } // namespace compiler 2773 } // namespace compiler
2735 } // namespace internal 2774 } // namespace internal
2736 } // namespace v8 2775 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698