OLD | NEW |
---|---|
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 434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
445 __ load_instr(i.OutputRegister(0), i.TempRegister(0)); \ | 445 __ load_instr(i.OutputRegister(0), i.TempRegister(0)); \ |
446 __ teq(i.TempRegister(1), Operand(i.OutputRegister(0))); \ | 446 __ teq(i.TempRegister(1), Operand(i.OutputRegister(0))); \ |
447 __ b(ne, &exit); \ | 447 __ b(ne, &exit); \ |
448 __ store_instr(i.TempRegister(0), i.InputRegister(3), i.TempRegister(0)); \ | 448 __ store_instr(i.TempRegister(0), i.InputRegister(3), i.TempRegister(0)); \ |
449 __ teq(i.TempRegister(0), Operand(0)); \ | 449 __ teq(i.TempRegister(0), Operand(0)); \ |
450 __ b(ne, &compareExchange); \ | 450 __ b(ne, &compareExchange); \ |
451 __ bind(&exit); \ | 451 __ bind(&exit); \ |
452 __ dmb(ISH); \ | 452 __ dmb(ISH); \ |
453 } while (0) | 453 } while (0) |
454 | 454 |
455 #define ASSEMBLE_ATOMIC_BINOP(load_instr, store_instr, bin_instr) \ | |
456 do { \ | |
457 Label binop; \ | |
458 __ add(i.TempRegister(0), i.InputRegister(0), i.InputRegister(1)); \ | |
459 __ dmb(ISH); \ | |
460 __ bind(&binop); \ | |
461 __ load_instr(i.OutputRegister(0), i.TempRegister(0)); \ | |
462 __ bin_instr(i.TempRegister(1), i.OutputRegister(0), \ | |
463 Operand(i.InputRegister(2))); \ | |
464 __ store_instr(i.TempRegister(1), i.TempRegister(1), i.TempRegister(0)); \ | |
465 __ teq(i.TempRegister(1), Operand(0)); \ | |
466 __ b(ne, &binop); \ | |
467 } while (0) | |
binji
2017/04/06 19:04:50
need dmb(ISH) after too
aseemgarg
2017/04/06 21:03:56
Done.
| |
468 | |
455 #define ASSEMBLE_IEEE754_BINOP(name) \ | 469 #define ASSEMBLE_IEEE754_BINOP(name) \ |
456 do { \ | 470 do { \ |
457 /* TODO(bmeurer): We should really get rid of this special instruction, */ \ | 471 /* TODO(bmeurer): We should really get rid of this special instruction, */ \ |
458 /* and generate a CallAddress instruction instead. */ \ | 472 /* and generate a CallAddress instruction instead. */ \ |
459 FrameScope scope(masm(), StackFrame::MANUAL); \ | 473 FrameScope scope(masm(), StackFrame::MANUAL); \ |
460 __ PrepareCallCFunction(0, 2, kScratchReg); \ | 474 __ PrepareCallCFunction(0, 2, kScratchReg); \ |
461 __ MovToFloatParameters(i.InputDoubleRegister(0), \ | 475 __ MovToFloatParameters(i.InputDoubleRegister(0), \ |
462 i.InputDoubleRegister(1)); \ | 476 i.InputDoubleRegister(1)); \ |
463 __ CallCFunction(ExternalReference::ieee754_##name##_function(isolate()), \ | 477 __ CallCFunction(ExternalReference::ieee754_##name##_function(isolate()), \ |
464 0, 2); \ | 478 0, 2); \ |
(...skipping 1717 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2182 __ sxth(i.OutputRegister(0), i.OutputRegister(0)); | 2196 __ sxth(i.OutputRegister(0), i.OutputRegister(0)); |
2183 break; | 2197 break; |
2184 case kAtomicCompareExchangeUint16: | 2198 case kAtomicCompareExchangeUint16: |
2185 __ uxth(i.TempRegister(1), i.InputRegister(2)); | 2199 __ uxth(i.TempRegister(1), i.InputRegister(2)); |
2186 ASSEMBLE_ATOMIC_COMPARE_EXCHANGE_INTEGER(ldrexh, strexh); | 2200 ASSEMBLE_ATOMIC_COMPARE_EXCHANGE_INTEGER(ldrexh, strexh); |
2187 break; | 2201 break; |
2188 case kAtomicCompareExchangeWord32: | 2202 case kAtomicCompareExchangeWord32: |
2189 __ mov(i.TempRegister(1), i.InputRegister(2)); | 2203 __ mov(i.TempRegister(1), i.InputRegister(2)); |
2190 ASSEMBLE_ATOMIC_COMPARE_EXCHANGE_INTEGER(ldrex, strex); | 2204 ASSEMBLE_ATOMIC_COMPARE_EXCHANGE_INTEGER(ldrex, strex); |
2191 break; | 2205 break; |
2206 #define ATOMIC_BINOP_CASE(op, inst) \ | |
2207 case kAtomic##op##Int8: \ | |
2208 ASSEMBLE_ATOMIC_BINOP(ldrexb, strexb, inst); \ | |
2209 __ sxtb(i.OutputRegister(0), i.OutputRegister(0)); \ | |
2210 break; \ | |
2211 case kAtomic##op##Uint8: \ | |
2212 ASSEMBLE_ATOMIC_BINOP(ldrexb, strexb, inst); \ | |
2213 break; \ | |
2214 case kAtomic##op##Int16: \ | |
2215 ASSEMBLE_ATOMIC_BINOP(ldrexh, strexh, inst); \ | |
2216 __ sxth(i.OutputRegister(0), i.OutputRegister(0)); \ | |
2217 break; \ | |
2218 case kAtomic##op##Uint16: \ | |
2219 ASSEMBLE_ATOMIC_BINOP(ldrexh, strexh, inst); \ | |
2220 break; \ | |
2221 case kAtomic##op##Word32: \ | |
2222 ASSEMBLE_ATOMIC_BINOP(ldrex, strex, inst); \ | |
2223 break; | |
2224 ATOMIC_BINOP_CASE(Add, add) | |
2225 ATOMIC_BINOP_CASE(Sub, sub) | |
2226 ATOMIC_BINOP_CASE(And, and_) | |
2227 ATOMIC_BINOP_CASE(Or, orr) | |
2228 ATOMIC_BINOP_CASE(Xor, eor) | |
2229 #undef ATOMIC_BINOP_CASE | |
2192 } | 2230 } |
2193 return kSuccess; | 2231 return kSuccess; |
2194 } // NOLINT(readability/fn_size) | 2232 } // NOLINT(readability/fn_size) |
2195 | 2233 |
2196 | 2234 |
2197 // Assembles branches after an instruction. | 2235 // Assembles branches after an instruction. |
2198 void CodeGenerator::AssembleArchBranch(Instruction* instr, BranchInfo* branch) { | 2236 void CodeGenerator::AssembleArchBranch(Instruction* instr, BranchInfo* branch) { |
2199 ArmOperandConverter i(this, instr); | 2237 ArmOperandConverter i(this, instr); |
2200 Label* tlabel = branch->true_label; | 2238 Label* tlabel = branch->true_label; |
2201 Label* flabel = branch->false_label; | 2239 Label* flabel = branch->false_label; |
(...skipping 629 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2831 padding_size -= v8::internal::Assembler::kInstrSize; | 2869 padding_size -= v8::internal::Assembler::kInstrSize; |
2832 } | 2870 } |
2833 } | 2871 } |
2834 } | 2872 } |
2835 | 2873 |
2836 #undef __ | 2874 #undef __ |
2837 | 2875 |
2838 } // namespace compiler | 2876 } // namespace compiler |
2839 } // namespace internal | 2877 } // namespace internal |
2840 } // namespace v8 | 2878 } // namespace v8 |
OLD | NEW |