1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
|
Temporary patch to enable rethinkdb build on ppc64le
until rethinkdb 2.4 release.
* Changes:
Files: configure, blocker_pool.cc, context_switching.cc, build.mk, args.hpp, cluster.cc
Changes were backported from rethinkdb to add support for ppc64le
Files: v8.sh
Backported changes to enable v8 build on ppc64le (as version 3.30.33.16 did not have support)
Files: js_job.cc
Changes related with upgrade of v8 on ppc64le and API break
----------
--- ./configure
+++ ./configure
@@ -84,6 +84,8 @@
arm*)
var_append LDFLAGS -ldl
final_warning="ARM support is still experimental" ;;
+ ppc64le|powerpc64le|powerpc64el)
+ final_warning="PowerPC support is still experimental" ;;
*)
error "unsupported architecture: $MACHINE"
esac
--- ./src/arch/io/blocker_pool.cc
+++ ./src/arch/io/blocker_pool.cc
@@ -93,12 +93,19 @@
// The coroutine stack size should be enough for blocker pool stacks. Right
// now that's 128 KB.
+ #if defined (__powerpc64__)
+ static_assert(COROUTINE_STACK_SIZE == 262144,
+ "Expecting COROUTINE_STACK_SIZE to be 262144. If you changed "
+ "it, please double-check whether the value is appropriate for "
+ "blocker pool threads.");
+ #else
static_assert(COROUTINE_STACK_SIZE == 131072,
"Expecting COROUTINE_STACK_SIZE to be 131072. If you changed "
"it, please double-check whether the value is appropriate for "
"blocker pool threads.");
// Disregard failure -- we'll just use the default stack size if this somehow
// fails.
+ #endif
UNUSED int ignored_res = pthread_attr_setstacksize(&attr, COROUTINE_STACK_SIZE);
res = pthread_create(&threads[i], &attr,
--- ./src/arch/runtime/context_switching.cc
+++ ./src/arch/runtime/context_switching.cc
@@ -101,6 +101,8 @@
#elif defined(__arm__)
/* We must preserve r4, r5, r6, r7, r8, r9, r10, and r11. Because we have to store the LR (r14) in swapcontext as well, we also store r12 in swapcontext to keep the stack double-word-aligned. However, we already accounted for both of those by decrementing sp twice above (once for r14 and once for r12, say). */
sp -= 8;
+#elif defined (__powerpc64__)
+ sp -= 20; // r14-r31, toc, cr.
#else
#error "Unsupported architecture."
#endif
@@ -262,7 +264,7 @@
}
asm(
-#if defined(__i386__) || defined(__x86_64__) || defined(__arm__)
+#if defined(__i386__) || defined(__x86_64__) || defined(__arm__) || defined (__powerpc64__)
// We keep the i386, x86_64, and ARM stuff interleaved in order to enforce commonality.
#if defined(__x86_64__)
#if defined(__LP64__) || defined(__LLP64__)
@@ -281,6 +283,8 @@
/* `current_pointer_out` is in `%rdi`. `dest_pointer` is in `%rsi`. */
#elif defined(__arm__)
/* `current_pointer_out` is in `r0`. `dest_pointer` is in `r1` */
+#elif defined(__powerpc64__)
+ /* `current_pointer_out` is in `r3`. `dest_pointer` is in `r4` */
#endif
/* Save preserved registers (the return address is already on the stack). */
@@ -302,6 +306,31 @@
"push {r12}\n"
"push {r14}\n"
"push {r4-r11}\n"
+#elif defined(__powerpc64__)
+ "addi 1, 1, -(21*8)\n"
+ "std 2, (8*0)(1)\n"
+ "std 14, (8*1)(1)\n"
+ "std 15, (8*2)(1)\n"
+ "std 16, (8*3)(1)\n"
+ "std 17, (8*4)(1)\n"
+ "std 18, (8*5)(1)\n"
+ "std 19, (8*6)(1)\n"
+ "std 20, (8*7)(1)\n"
+ "std 21, (8*8)(1)\n"
+ "std 22, (8*9)(1)\n"
+ "std 23, (8*10)(1)\n"
+ "std 24, (8*11)(1)\n"
+ "std 25, (8*12)(1)\n"
+ "std 26, (8*13)(1)\n"
+ "std 27, (8*14)(1)\n"
+ "std 28, (8*15)(1)\n"
+ "std 29, (8*16)(1)\n"
+ "std 30, (8*17)(1)\n"
+ "std 31, (8*18)(1)\n"
+ "mfcr 0\n"
+ "std 0, (8*19)(1)\n"
+ "mflr 0\n"
+ "std 0, (8*20)(1)\n"
#endif
/* Save old stack pointer. */
@@ -316,6 +345,8 @@
#elif defined(__arm__)
/* On ARM, the first argument is in `r0`. `r13` is the stack pointer. */
"str r13, [r0]\n"
+#elif defined(__powerpc64__)
+ "std 1, 0(3)\n"
#endif
/* Load the new stack pointer and the preserved registers. */
@@ -330,6 +361,8 @@
#elif defined(__arm__)
/* On ARM, the second argument is in `r1` */
"mov r13, r1\n"
+#elif defined(__powerpc64__)
+ "mr 1, 4\n"
#endif
#if defined(__i386__)
@@ -348,6 +381,31 @@
"pop {r4-r11}\n"
"pop {r14}\n"
"pop {r12}\n"
+#elif defined(__powerpc64__)
+ "ld 2, (8*0)(1)\n"
+ "ld 14, (8*1)(1)\n"
+ "ld 15, (8*2)(1)\n"
+ "ld 16, (8*3)(1)\n"
+ "ld 17, (8*4)(1)\n"
+ "ld 18, (8*5)(1)\n"
+ "ld 19, (8*6)(1)\n"
+ "ld 20, (8*7)(1)\n"
+ "ld 21, (8*8)(1)\n"
+ "ld 22, (8*9)(1)\n"
+ "ld 23, (8*10)(1)\n"
+ "ld 24, (8*11)(1)\n"
+ "ld 25, (8*12)(1)\n"
+ "ld 26, (8*13)(1)\n"
+ "ld 27, (8*14)(1)\n"
+ "ld 28, (8*15)(1)\n"
+ "ld 29, (8*16)(1)\n"
+ "ld 30, (8*17)(1)\n"
+ "ld 31, (8*18)(1)\n"
+ "ld 0, (8*19)(1)\n"
+ "mtcr 0\n"
+ "ld 0, (8*20)(1)\n"
+ "mtlr 0\n"
+ "addi 1, 1, (8*21)\n"
#endif
#if defined(__i386__) || defined(__x86_64__)
@@ -360,6 +418,8 @@
/* Above, we popped `LR` (`r14`) off the stack, so the bx instruction will
jump to the correct return address. */
"bx r14\n"
+#elif defined(__powerpc64__)
+ "blr\n"
#endif
#else
--- ./src/build.mk
+++ ./src/build.mk
@@ -54,6 +54,10 @@
ifeq ($(OS),Linux)
RT_LDFLAGS += -Wl,--no-as-needed
+ ifeq ($(GCC_ARCH),ppc64le)
+ RT_CXXFLAGS += "-DV8_NEEDS_BUFFER_ALLOCATOR"
+ RT_LDFLAGS += -no-pie
+ endif
endif
ifeq ($(STATICFORCE),1)
@@ -167,7 +171,11 @@
else # ifeq ($(DEBUG),1)
# use -fno-strict-aliasing to not break things
# march=native used to break the serializer
- RT_CXXFLAGS += -O3 -DNDEBUG -fno-strict-aliasing # -march=native
+ ifeq ($(GCC_ARCH),ppc64le)
+ RT_CXXFLAGS += -O1 -DNDEBUG -fno-strict-aliasing
+ else
+ RT_CXXFLAGS += -O3 -DNDEBUG -fno-strict-aliasing # -march=native
+ endif
ifeq ($(NO_OMIT_FRAME_POINTER),1)
RT_CXXFLAGS += -fno-omit-frame-pointer
endif
--- ./src/config/args.hpp
+++ ./src/config/args.hpp
@@ -151,7 +151,11 @@
// block infos.
#define LBA_RECONSTRUCTION_BATCH_SIZE 1024
+#if defined (__powerpc64__)
+#define COROUTINE_STACK_SIZE 262144
+#else
#define COROUTINE_STACK_SIZE 131072
+#endif
/**
--- ./src/rpc/connectivity/cluster.cc
+++ ./src/rpc/connectivity/cluster.cc
@@ -103,7 +103,7 @@
return false;
}
-#if defined (__x86_64__) || defined (_WIN64)
+#if defined (__x86_64__) || defined (_WIN64) || defined (__powerpc64__)
const std::string connectivity_cluster_t::cluster_arch_bitsize("64bit");
#elif defined (__i386__) || defined(__arm__)
const std::string connectivity_cluster_t::cluster_arch_bitsize("32bit");
--- ./mk/support/pkg/v8.sh
+++ ./mk/support/pkg/v8.sh
@@ -1,13 +1,44 @@
-
-version=3.30.33.16-patched2
# See http://omahaproxy.appspot.com/ for the current stable/beta/dev versions of v8
-src_url=http://commondatastorage.googleapis.com/chromium-browser-official/v8-${version/-patched2/}.tar.bz2
+ARCH=`uname -m`
+if [[ "$ARCH" == "ppc64le" ]]; then
+ # 4.7 has no source distribution, making it harder to build on Linux
+ version=4.7.80.23
+
+ pkg_fetch () {
+ pkg_make_tmp_fetch_dir
+
+ # These steps are inspired by the official docs:
+ # https://github.com/v8/v8/wiki/Using%20Git
+ # with a few additional steps to get an exact version instead of HEAD
+ git clone --depth 1 https://chromium.googlesource.com/chromium/tools/depot_tools.git "$tmp_dir/depot_tools"
+ PATH="$tmp_dir/depot_tools:$PATH"
+ in_dir "$tmp_dir" gclient config --unmanaged https://chromium.googlesource.com/v8/v8.git
+ in_dir "$tmp_dir" git clone https://chromium.googlesource.com/v8/v8.git
+ v8_commit=`in_dir "$tmp_dir/v8" git rev-parse refs/tags/$version`
+ in_dir "$tmp_dir" gclient sync --revision v8@$v8_commit || true
+ find "$tmp_dir" -depth -name .git -exec rm -rf {} \;
+ rm -rf "$src_dir"
+ mv "$tmp_dir/v8" "$src_dir"
+
+ sed -i "s/ucontext->uc_mcontext.regs->nip/ucontext->uc_mcontext.gp_regs[32]/g" "$src_dir/src/profiler/sampler.cc"
+ sed -i "s/ucontext->uc_mcontext.regs->gpr\[PT_R1\]/ucontext->uc_mcontext.gp_regs[1]/g" "$src_dir/src/profiler/sampler.cc"
+ sed -i "s/ucontext->uc_mcontext.regs->gpr\[PT_R31\]/ucontext->uc_mcontext.gp_regs[31]/g" "$src_dir/src/profiler/sampler.cc"
+
+ pkg_remove_tmp_fetch_dir
+ }
+else
+ version=3.30.33.16-patched2
+ src_url=http://commondatastorage.googleapis.com/chromium-browser-official/v8-${version/-patched2/}.tar.bz2
+fi
+
pkg_install-include () {
pkg_copy_src_to_build
- in_dir "$build_dir" patch -fp1 < "$pkg_dir"/patch/v8_2-HandleScope-protected.patch
-
+ if [[ "$ARCH" != "ppc64le" ]]; then
+ in_dir "$build_dir" patch -fp1 < "$pkg_dir"/patch/v8_2-HandleScope-protected.patch
+ fi
+
rm -rf "$install_dir/include"
mkdir -p "$install_dir/include"
cp -RL "$build_dir/include/." "$install_dir/include"
@@ -29,7 +60,10 @@
pkg_install () {
pkg_copy_src_to_build
- in_dir "$build_dir" patch -fp1 < "$pkg_dir"/patch/v8_2-HandleScope-protected.patch
+
+ if [[ "$ARCH" != "ppc64le" ]]; then
+ in_dir "$build_dir" patch -fp1 < "$pkg_dir"/patch/v8_2-HandleScope-protected.patch
+ fi
sed -i.bak '/unittests/d;/cctest/d' "$build_dir/build/all.gyp" # don't build the tests
mkdir -p "$install_dir/lib"
if [[ "$OS" = Darwin ]]; then
@@ -44,6 +78,7 @@
i?86) arch=ia32 ;;
x86_64) arch=x64 ;;
arm*) arch=arm; arch_gypflags=$raspberry_pi_gypflags ;;
+ ppc64le*|powerpc*) arch=ppc64 ;;
*) arch=native ;;
esac
mode=release
@@ -58,10 +93,21 @@
pkg_link-flags () {
# These are the necessary libraries recommended by the docs:
# https://developers.google.com/v8/get_started#hello
- for lib in libv8_{base,libbase,snapshot,libplatform}; do
- echo "$install_dir/lib/$lib.a"
- done
- for lib in libicu{i18n,uc,data}; do
- echo "$install_dir/lib/$lib.a"
- done
+ if [[ "$ARCH" == "ppc64le" ]]; then
+ for lib in libv8_{base,libbase,nosnapshot,libplatform}; do
+ echo "$install_dir/lib/$lib.a"
+ done
+ for lib in libicu{i18n,uc,data}; do
+ echo "$install_dir/lib/$lib.a"
+ done
+ echo "-licui18n -licuuc -ldl -lexecinfo"
+
+ else
+ for lib in libv8_{base,libbase,snapshot,libplatform}; do
+ echo "$install_dir/lib/$lib.a"
+ done
+ for lib in libicu{i18n,uc,data}; do
+ echo "$install_dir/lib/$lib.a"
+ done
+ fi
}
--- ./src/extproc/js_job.cc
+++ ./src/extproc/js_job.cc
files_v8/js_job.cc
@@ -56,7 +56,12 @@
platform.init(v8::platform::CreateDefaultPlatform());
v8::V8::InitializePlatform(platform.get());
v8::V8::Initialize();
+#ifdef __powerpc64__
+ v8::Isolate::CreateParams params;
+ isolate_ = v8::Isolate::New(params);
+#else
isolate_ = v8::Isolate::New();
+#endif
isolate_->Enter();
}
|