equal
deleted
inserted
replaced
1 /* |
1 /* |
2 * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved. |
3 * Copyright (c) 2014, Red Hat Inc. All rights reserved. |
3 * Copyright (c) 2014, Red Hat Inc. All rights reserved. |
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
5 * |
5 * |
6 * This code is free software; you can redistribute it and/or modify it |
6 * This code is free software; you can redistribute it and/or modify it |
7 * under the terms of the GNU General Public License version 2 only, as |
7 * under the terms of the GNU General Public License version 2 only, as |
21 * or visit www.oracle.com if you need additional information or have any |
21 * or visit www.oracle.com if you need additional information or have any |
22 * questions. |
22 * questions. |
23 * |
23 * |
24 */ |
24 */ |
25 |
25 |
26 #include "precompiled.hpp" |
26 // nothing required here |
27 #include "asm/macroAssembler.hpp" |
|
28 #include "asm/macroAssembler.inline.hpp" |
|
29 #include "runtime/os.hpp" |
|
30 #include "runtime/threadLocalStorage.hpp" |
|
31 |
27 |
32 |
28 |
33 // get_thread can be called anywhere inside generated code so we need |
|
34 // to save whatever non-callee save context might get clobbered by the |
|
35 // call to the C thread_local lookup call or, indeed, the call setup |
|
36 // code. x86 appears to save C arg registers. |
|
37 |
|
38 void MacroAssembler::get_thread(Register dst) { |
|
39 // call pthread_getspecific |
|
40 // void * pthread_getspecific(pthread_key_t key); |
|
41 |
|
42 // Save all call-clobbered regs except dst, plus r19 and r20. |
|
43 RegSet saved_regs = RegSet::range(r0, r20) + lr - dst; |
|
44 push(saved_regs, sp); |
|
45 mov(c_rarg0, ThreadLocalStorage::thread_index()); |
|
46 mov(r19, CAST_FROM_FN_PTR(address, pthread_getspecific)); |
|
47 blrt(r19, 1, 0, 1); |
|
48 if (dst != c_rarg0) { |
|
49 mov(dst, c_rarg0); |
|
50 } |
|
51 // restore pushed registers |
|
52 pop(saved_regs, sp); |
|
53 } |
|
54 |
|