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

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

Issue 2623633003: [Atomics] Make Atomics.exchange a builtin using TF (Closed)
Patch Set: fix win Created 3 years, 10 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/compilation-info.h" 8 #include "src/compilation-info.h"
9 #include "src/compiler/code-generator-impl.h" 9 #include "src/compiler/code-generator-impl.h"
10 #include "src/compiler/gap-resolver.h" 10 #include "src/compiler/gap-resolver.h"
(...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after
413 } while (0) 413 } while (0)
414 414
415 #define ASSEMBLE_ATOMIC_STORE_INTEGER(asm_instr) \ 415 #define ASSEMBLE_ATOMIC_STORE_INTEGER(asm_instr) \
416 do { \ 416 do { \
417 __ dmb(ISH); \ 417 __ dmb(ISH); \
418 __ asm_instr(i.InputRegister(2), \ 418 __ asm_instr(i.InputRegister(2), \
419 MemOperand(i.InputRegister(0), i.InputRegister(1))); \ 419 MemOperand(i.InputRegister(0), i.InputRegister(1))); \
420 __ dmb(ISH); \ 420 __ dmb(ISH); \
421 } while (0) 421 } while (0)
422 422
423 #define ASSEMBLE_ATOMIC_EXCHANGE_INTEGER(load_instr, store_instr) \
424 do { \
425 Label exchange; \
426 __ dmb(ISH); \
427 __ bind(&exchange); \
428 __ add(i.TempRegister(0), i.InputRegister(0), i.InputRegister(1)); \
429 __ load_instr(i.OutputRegister(0), i.TempRegister(0)); \
430 __ store_instr(i.TempRegister(0), i.InputRegister(2), i.TempRegister(0)); \
431 __ cmp(i.TempRegister(0), Operand(0)); \
432 __ b(ne, &exchange); \
433 __ dmb(ISH); \
434 } while (0)
435
423 #define ASSEMBLE_IEEE754_BINOP(name) \ 436 #define ASSEMBLE_IEEE754_BINOP(name) \
424 do { \ 437 do { \
425 /* TODO(bmeurer): We should really get rid of this special instruction, */ \ 438 /* TODO(bmeurer): We should really get rid of this special instruction, */ \
426 /* and generate a CallAddress instruction instead. */ \ 439 /* and generate a CallAddress instruction instead. */ \
427 FrameScope scope(masm(), StackFrame::MANUAL); \ 440 FrameScope scope(masm(), StackFrame::MANUAL); \
428 __ PrepareCallCFunction(0, 2, kScratchReg); \ 441 __ PrepareCallCFunction(0, 2, kScratchReg); \
429 __ MovToFloatParameters(i.InputDoubleRegister(0), \ 442 __ MovToFloatParameters(i.InputDoubleRegister(0), \
430 i.InputDoubleRegister(1)); \ 443 i.InputDoubleRegister(1)); \
431 __ CallCFunction(ExternalReference::ieee754_##name##_function(isolate()), \ 444 __ CallCFunction(ExternalReference::ieee754_##name##_function(isolate()), \
432 0, 2); \ 445 0, 2); \
(...skipping 1562 matching lines...) Expand 10 before | Expand all | Expand 10 after
1995 2008
1996 case kAtomicStoreWord8: 2009 case kAtomicStoreWord8:
1997 ASSEMBLE_ATOMIC_STORE_INTEGER(strb); 2010 ASSEMBLE_ATOMIC_STORE_INTEGER(strb);
1998 break; 2011 break;
1999 case kAtomicStoreWord16: 2012 case kAtomicStoreWord16:
2000 ASSEMBLE_ATOMIC_STORE_INTEGER(strh); 2013 ASSEMBLE_ATOMIC_STORE_INTEGER(strh);
2001 break; 2014 break;
2002 case kAtomicStoreWord32: 2015 case kAtomicStoreWord32:
2003 ASSEMBLE_ATOMIC_STORE_INTEGER(str); 2016 ASSEMBLE_ATOMIC_STORE_INTEGER(str);
2004 break; 2017 break;
2018 case kAtomicExchangeInt8:
2019 ASSEMBLE_ATOMIC_EXCHANGE_INTEGER(ldrexb, strexb);
2020 __ sxtb(i.OutputRegister(0), i.OutputRegister(0));
2021 break;
2022 case kAtomicExchangeUint8:
2023 ASSEMBLE_ATOMIC_EXCHANGE_INTEGER(ldrexb, strexb);
2024 __ uxtb(i.OutputRegister(0), i.OutputRegister(0));
2025 break;
2026 case kAtomicExchangeInt16:
2027 ASSEMBLE_ATOMIC_EXCHANGE_INTEGER(ldrexh, strexh);
2028 __ sxth(i.OutputRegister(0), i.OutputRegister(0));
2029 break;
2030 case kAtomicExchangeUint16:
2031 ASSEMBLE_ATOMIC_EXCHANGE_INTEGER(ldrexh, strexh);
2032 __ uxth(i.OutputRegister(0), i.OutputRegister(0));
2033 break;
2034 case kAtomicExchangeWord32:
2035 ASSEMBLE_ATOMIC_EXCHANGE_INTEGER(ldrex, strex);
2036 break;
2005 } 2037 }
2006 return kSuccess; 2038 return kSuccess;
2007 } // NOLINT(readability/fn_size) 2039 } // NOLINT(readability/fn_size)
2008 2040
2009 2041
2010 // Assembles branches after an instruction. 2042 // Assembles branches after an instruction.
2011 void CodeGenerator::AssembleArchBranch(Instruction* instr, BranchInfo* branch) { 2043 void CodeGenerator::AssembleArchBranch(Instruction* instr, BranchInfo* branch) {
2012 ArmOperandConverter i(this, instr); 2044 ArmOperandConverter i(this, instr);
2013 Label* tlabel = branch->true_label; 2045 Label* tlabel = branch->true_label;
2014 Label* flabel = branch->false_label; 2046 Label* flabel = branch->false_label;
(...skipping 584 matching lines...) Expand 10 before | Expand all | Expand 10 after
2599 padding_size -= v8::internal::Assembler::kInstrSize; 2631 padding_size -= v8::internal::Assembler::kInstrSize;
2600 } 2632 }
2601 } 2633 }
2602 } 2634 }
2603 2635
2604 #undef __ 2636 #undef __
2605 2637
2606 } // namespace compiler 2638 } // namespace compiler
2607 } // namespace internal 2639 } // namespace internal
2608 } // namespace v8 2640 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698