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 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. |
7 * published by the Free Software Foundation. |
24 |
24 |
25 #include "precompiled.hpp" |
25 #include "precompiled.hpp" |
26 #include "asm/macroAssembler.hpp" |
26 #include "asm/macroAssembler.hpp" |
27 #include "asm/macroAssembler.inline.hpp" |
27 #include "asm/macroAssembler.inline.hpp" |
28 #include "runtime/os.hpp" |
28 #include "runtime/os.hpp" |
29 #include "runtime/threadLocalStorage.hpp" |
|
30 |
29 |
31 #ifndef _LP64 |
|
32 void MacroAssembler::int3() { |
30 void MacroAssembler::int3() { |
33 call(RuntimeAddress(CAST_FROM_FN_PTR(address, os::breakpoint))); |
31 call(RuntimeAddress(CAST_FROM_FN_PTR(address, os::breakpoint))); |
34 } |
32 } |
35 |
|
36 #ifdef MINIMIZE_RAM_USAGE |
|
37 |
|
38 void MacroAssembler::get_thread(Register thread) { |
|
39 // call pthread_getspecific |
|
40 // void * pthread_getspecific(pthread_key_t key); |
|
41 if (thread != rax) push(rax); |
|
42 push(rcx); |
|
43 push(rdx); |
|
44 |
|
45 push(ThreadLocalStorage::thread_index()); |
|
46 call(RuntimeAddress(CAST_FROM_FN_PTR(address, pthread_getspecific))); |
|
47 increment(rsp, wordSize); |
|
48 |
|
49 pop(rdx); |
|
50 pop(rcx); |
|
51 if (thread != rax) { |
|
52 mov(thread, rax); |
|
53 pop(rax); |
|
54 } |
|
55 } |
|
56 |
|
57 #else |
|
58 void MacroAssembler::get_thread(Register thread) { |
|
59 movl(thread, rsp); |
|
60 shrl(thread, PAGE_SHIFT); |
|
61 |
|
62 ExternalAddress tls_base((address)ThreadLocalStorage::sp_map_addr()); |
|
63 Address index(noreg, thread, Address::times_4); |
|
64 ArrayAddress tls(tls_base, index); |
|
65 |
|
66 movptr(thread, tls); |
|
67 } |
|
68 #endif // MINIMIZE_RAM_USAGE |
|
69 #else |
|
70 void MacroAssembler::int3() { |
|
71 call(RuntimeAddress(CAST_FROM_FN_PTR(address, os::breakpoint))); |
|
72 } |
|
73 |
|
74 void MacroAssembler::get_thread(Register thread) { |
|
75 // call pthread_getspecific |
|
76 // void * pthread_getspecific(pthread_key_t key); |
|
77 if (thread != rax) { |
|
78 push(rax); |
|
79 } |
|
80 push(rdi); |
|
81 push(rsi); |
|
82 push(rdx); |
|
83 push(rcx); |
|
84 push(r8); |
|
85 push(r9); |
|
86 push(r10); |
|
87 // XXX |
|
88 mov(r10, rsp); |
|
89 andq(rsp, -16); |
|
90 push(r10); |
|
91 push(r11); |
|
92 |
|
93 movl(rdi, ThreadLocalStorage::thread_index()); |
|
94 call(RuntimeAddress(CAST_FROM_FN_PTR(address, pthread_getspecific))); |
|
95 |
|
96 pop(r11); |
|
97 pop(rsp); |
|
98 pop(r10); |
|
99 pop(r9); |
|
100 pop(r8); |
|
101 pop(rcx); |
|
102 pop(rdx); |
|
103 pop(rsi); |
|
104 pop(rdi); |
|
105 if (thread != rax) { |
|
106 mov(thread, rax); |
|
107 pop(rax); |
|
108 } |
|
109 } |
|
110 #endif |
|