summaryrefslogtreecommitdiff
path: root/debian/patches/dyson-solaris-amd64-memory-layout.patch
blob: 4a4cffe8d7f5423d0f95fc5cc84f395c2ab7c934 (plain)
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
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
Description: fix for Solaris/amd64 memory layout
 This patch:
 1. Fixes C++ classes
 2. Disables JIT and enables LLInt
 3. Fixes LLInt

 TODO: Fix JIT
Index: qt5webkit/Source/WTF/wtf/Platform.h
===================================================================
--- qt5webkit.orig/Source/WTF/wtf/Platform.h
+++ qt5webkit/Source/WTF/wtf/Platform.h
@@ -433,6 +433,15 @@
 #define WTF_OS_SOLARIS 1
 #endif
 
+#if CPU(X86_64) && OS(SOLARIS)
+#  define WTF_OS_SOLARIS_AMD64 1
+# endif
+
+// Let's port LLInt first:
+#if OS(SOLARIS_AMD64)
+#define ENABLE_JIT 0
+#endif
+
 /* OS(WINCE) - Windows CE; note that for this platform OS(WINDOWS) is also defined */
 #if defined(_WIN32_WCE)
 #define WTF_OS_WINCE 1
@@ -815,7 +824,7 @@
    low-level interpreter. */
 #if !defined(ENABLE_LLINT) \
     && ENABLE(JIT) \
-    && (OS(DARWIN) || OS(LINUX)) \
+    && (OS(DARWIN) || OS(LINUX) || OS(SOLARIS)) \
     && (PLATFORM(MAC) || PLATFORM(IOS) || PLATFORM(GTK) || PLATFORM(QT)) \
     && (CPU(X86) || CPU(X86_64) || CPU(ARM_THUMB2) || CPU(ARM_TRADITIONAL) || CPU(MIPS) || CPU(SH4))
 #define ENABLE_LLINT 1
@@ -823,7 +832,7 @@
 
 #if !defined(ENABLE_DFG_JIT) && ENABLE(JIT) && !COMPILER(MSVC)
 /* Enable the DFG JIT on X86 and X86_64.  Only tested on Mac and GNU/Linux. */
-#if (CPU(X86) || CPU(X86_64)) && (OS(DARWIN) || OS(LINUX))
+#if (CPU(X86) || CPU(X86_64)) && (OS(DARWIN) || OS(LINUX) || OS(SOLARIS))
 #define ENABLE_DFG_JIT 1
 #endif
 /* Enable the DFG JIT on ARMv7.  Only tested on iOS and Qt Linux. */
Index: qt5webkit/Source/JavaScriptCore/runtime/JSCJSValue.h
===================================================================
--- qt5webkit.orig/Source/JavaScriptCore/runtime/JSCJSValue.h
+++ qt5webkit/Source/JavaScriptCore/runtime/JSCJSValue.h
@@ -387,6 +387,14 @@ private:
     // alignment for a GC cell, and in the zero page).
     #define ValueEmpty   0x0ll
     #define ValueDeleted 0x4ll
+#if OS(SOLARIS_AMD64)
+// https://bugzilla.mozilla.org/show_bug.cgi?id=577056
+// Memory layout for 64-bit Solaris is different than other 64-bit systems.
+// User space memory may locate on PART-A (0xFFFFFD80.00000000 - 0xFFFF8000.00000000)
+// and PART-B (0x00008000.00000000 - 0x00000000.04000000).
+    bool isSolarisAMD64StackPointer() const;
+#endif
+
 #endif
 
     EncodedValueDescriptor u;
Index: qt5webkit/Source/JavaScriptCore/runtime/JSCJSValueInlines.h
===================================================================
--- qt5webkit.orig/Source/JavaScriptCore/runtime/JSCJSValueInlines.h
+++ qt5webkit/Source/JavaScriptCore/runtime/JSCJSValueInlines.h
@@ -336,6 +336,13 @@ inline bool JSValue::asBoolean() const
 
 #else // !USE(JSVALUE32_64) i.e. USE(JSVALUE64)
 
+#if OS(SOLARIS_AMD64)
+inline bool JSValue::isSolarisAMD64StackPointer() const
+{
+    return ((u.asInt64 & 0xFFFF800000000000LL) == 0xFFFF800000000000LL);
+}
+#endif
+
 // 0x0 can never occur naturally because it has a tag of 00, indicating a pointer value, but a payload of 0x0, which is in the (invalid) zero page.
 inline JSValue::JSValue()
 {
@@ -412,6 +419,10 @@ inline int32_t JSValue::asInt32() const
 
 inline bool JSValue::isDouble() const
 {
+#if OS(SOLARIS_AMD64)
+    if (isSolarisAMD64StackPointer())
+        return false;
+#endif
     return isNumber() && !isInt32();
 }
 
@@ -437,22 +448,38 @@ inline JSValue::JSValue(JSFalseTag)
 
 inline bool JSValue::isUndefinedOrNull() const
 {
+#if OS(SOLARIS_AMD64)
+    if (isSolarisAMD64StackPointer())
+        return false;
+#endif
     // Undefined and null share the same value, bar the 'undefined' bit in the extended tag.
     return (u.asInt64 & ~TagBitUndefined) == ValueNull;
 }
 
 inline bool JSValue::isBoolean() const
 {
+#if OS(SOLARIS_AMD64)
+    if (isSolarisAMD64StackPointer())
+        return false;
+#endif
     return (u.asInt64 & ~1) == ValueFalse;
 }
 
 inline bool JSValue::isCell() const
 {
+#if OS(SOLARIS_AMD64)
+    if (isSolarisAMD64StackPointer())
+        return true; // TRUE!
+#endif
     return !(u.asInt64 & TagMask);
 }
 
 inline bool JSValue::isInt32() const
 {
+#if OS(SOLARIS_AMD64)
+    if (isSolarisAMD64StackPointer())
+        return false;
+#endif
     return (u.asInt64 & TagTypeNumber) == TagTypeNumber;
 }
 
@@ -483,6 +510,10 @@ inline double JSValue::asDouble() const
 
 inline bool JSValue::isNumber() const
 {
+#if OS(SOLARIS_AMD64)
+    if (isSolarisAMD64StackPointer())
+        return false;
+#endif
     return u.asInt64 & TagTypeNumber;
 }
 
Index: qt5webkit/Source/JavaScriptCore/jit/JITInlines.h
===================================================================
--- qt5webkit.orig/Source/JavaScriptCore/jit/JITInlines.h
+++ qt5webkit/Source/JavaScriptCore/jit/JITInlines.h
@@ -799,7 +799,14 @@ ALWAYS_INLINE void JIT::emitInitRegister
 
 ALWAYS_INLINE JIT::Jump JIT::emitJumpIfJSCell(RegisterID reg)
 {
+#if OS(SOLARIS_AMD64)
+    // Does "reg" hold solaris 64-bit stack pointer?
+    move(TrustedImm64(static_cast<uint64_t>(0xFFFF800000000000)), scratchRegister);
+    and64(reg, scratchRegister);
+    return branch64(Equal, scratchRegister, TrustedImm64(static_cast<uint64_t>(0xFFFF800000000000)));
+#else
     return branchTest64(Zero, reg, tagMaskRegister);
+#endif
 }
 
 ALWAYS_INLINE JIT::Jump JIT::emitJumpIfBothJSCells(RegisterID reg1, RegisterID reg2, RegisterID scratch)
Index: qt5webkit/Source/JavaScriptCore/llint/LowLevelInterpreter64.asm
===================================================================
--- qt5webkit.orig/Source/JavaScriptCore/llint/LowLevelInterpreter64.asm
+++ qt5webkit/Source/JavaScriptCore/llint/LowLevelInterpreter64.asm
@@ -31,6 +31,9 @@ const ValueFalse      = TagBitTypeOther
 const ValueTrue       = TagBitTypeOther | TagBitBool | 1
 const ValueUndefined  = TagBitTypeOther | TagBitUndefined
 const ValueNull       = TagBitTypeOther
+if SOLARIS_AMD64
+const solarisAMD64StackBottom = 0xFFFF800000000000
+end
 
 # Utilities.
 macro jumpToInstruction()
@@ -167,12 +170,21 @@ end
 
 macro loadConstantOrVariableInt32(index, value, slow)
     loadConstantOrVariable(index, value)
+if SOLARIS_AMD64
+    bqaeq value, solarisAMD64StackBottom, slow
+end
     bqb value, tagTypeNumber, slow
 end
 
 macro loadConstantOrVariableCell(index, value, slow)
     loadConstantOrVariable(index, value)
+if SOLARIS_AMD64
+    bqaeq value, solarisAMD64StackBottom, .done
+end
     btqnz value, tagMask, slow
+if SOLARIS_AMD64
+.done:
+end
 end
 
 macro writeBarrier(value)
@@ -280,7 +292,13 @@ _llint_op_convert_this:
     traceExecution()
     loadisFromInstruction(1, t0)
     loadq [cfr, t0, 8], t0
+if SOLARIS_AMD64
+    bqaeq t0, solarisAMD64StackBottom, .opConvertThisSolarisAMD64StackPointer
+end
     btqnz t0, tagMask, .opConvertThisSlow
+if SOLARIS_AMD64
+.opConvertThisSolarisAMD64StackPointer:
+end
     loadp JSCell::m_structure[t0], t0
     bbb Structure::m_typeInfo + TypeInfo::m_type[t0], ObjectType, .opConvertThisSlow
     loadpFromInstruction(2, t1)
@@ -364,7 +382,13 @@ _llint_op_neq:
 macro equalNullComparison()
     loadisFromInstruction(2, t0)
     loadq [cfr, t0, 8], t0
+if SOLARIS_AMD64
+    bqaeq t0, solarisAMD64StackBottom, .solarisAMD64StackPointer
+end
     btqnz t0, tagMask, .immediate
+if SOLARIS_AMD64
+.solarisAMD64StackPointer:
+end
     loadp JSCell::m_structure[t0], t2
     btbnz Structure::m_typeInfo + TypeInfo::m_flags[t2], MasqueradesAsUndefined, .masqueradesAsUndefined
     move 0, t0
@@ -404,6 +428,10 @@ macro strictEq(equalityOperation, slowPa
     loadisFromInstruction(2, t2)
     loadConstantOrVariable(t0, t1)
     loadConstantOrVariable(t2, t0)
+if SOLARIS_AMD64
+    bqaeq t0, solarisAMD64StackBottom, .slow
+    bqaeq t1, solarisAMD64StackBottom, .slow
+end
     move t0, t2
     orq t1, t2
     btqz t2, tagMask, .slow
@@ -440,6 +468,9 @@ macro preOp(arithmeticOperation, slowPat
     traceExecution()
     loadisFromInstruction(1, t0)
     loadq [cfr, t0, 8], t1
+if SOLARIS_AMD64
+    bqaeq t1, solarisAMD64StackBottom, .slow
+end
     bqb t1, tagTypeNumber, .slow
     arithmeticOperation(t1, .slow)
     orq tagTypeNumber, t1
@@ -468,6 +499,9 @@ _llint_op_to_number:
     loadisFromInstruction(2, t0)
     loadisFromInstruction(1, t1)
     loadConstantOrVariable(t0, t2)
+if SOLARIS_AMD64
+    bqaeq t2, solarisAMD64StackBottom, .opToNumberSlow
+end
     bqaeq t2, tagTypeNumber, .opToNumberIsImmediate
     btqz t2, tagTypeNumber, .opToNumberSlow
 .opToNumberIsImmediate:
@@ -484,6 +518,9 @@ _llint_op_negate:
     loadisFromInstruction(2, t0)
     loadisFromInstruction(1, t1)
     loadConstantOrVariable(t0, t2)
+if SOLARIS_AMD64
+    bqaeq t2, solarisAMD64StackBottom, .opNegateSlow
+end
     bqb t2, tagTypeNumber, .opNegateNotInt
     btiz t2, 0x7fffffff, .opNegateSlow
     negi t2
@@ -506,7 +543,13 @@ macro binaryOpCustomStore(integerOperati
     loadisFromInstruction(2, t2)
     loadConstantOrVariable(t0, t1)
     loadConstantOrVariable(t2, t0)
+if SOLARIS_AMD64
+    bqaeq t0, solarisAMD64StackBottom, .slow
+end
     bqb t0, tagTypeNumber, .op1NotInt
+if SOLARIS_AMD64
+    bqaeq t1, solarisAMD64StackBottom, .op2NotInt
+end
     bqb t1, tagTypeNumber, .op2NotInt
     loadisFromInstruction(1, t2)
     integerOperationAndStore(t1, t0, .slow, t2)
@@ -515,6 +558,9 @@ macro binaryOpCustomStore(integerOperati
 .op1NotInt:
     # First operand is definitely not an int, the second operand could be anything.
     btqz t0, tagTypeNumber, .slow
+if SOLARIS_AMD64
+    bqaeq t1, solarisAMD64StackBottom, .slow
+end
     bqaeq t1, tagTypeNumber, .op1NotIntOp2Int
     btqz t1, tagTypeNumber, .slow
     addq tagTypeNumber, t1
@@ -535,6 +581,9 @@ macro binaryOpCustomStore(integerOperati
 .op2NotInt:
     # First operand is definitely an int, the second is definitely not.
     loadisFromInstruction(1, t2)
+if SOLARIS_AMD64
+    bqaeq t1, solarisAMD64StackBottom, .slow
+end
     btqz t1, tagTypeNumber, .slow
     ci2d t0, ft0
     addq tagTypeNumber, t1
@@ -624,6 +673,10 @@ macro bitOp(operation, slowPath, advance
     loadisFromInstruction(1, t3)
     loadConstantOrVariable(t0, t1)
     loadConstantOrVariable(t2, t0)
+if SOLARIS_AMD64
+    bqaeq t0, solarisAMD64StackBottom, .slow
+    bqaeq t1, solarisAMD64StackBottom, .slow
+end
     bqb t0, tagTypeNumber, .slow
     bqb t1, tagTypeNumber, .slow
     operation(t1, t0, .slow)
@@ -717,6 +770,9 @@ _llint_op_instanceof:
     loadp JSCell::m_structure[t2], t2
     loadq Structure::m_prototype[t2], t2
     bqeq t2, t1, .opInstanceofDone
+if SOLARIS_AMD64
+    bqaeq t2, solarisAMD64StackBottom, .opInstanceofLoop
+end
     btqz t2, tagMask, .opInstanceofLoop
 
     move 0, t0
@@ -735,6 +791,9 @@ _llint_op_is_undefined:
     loadisFromInstruction(2, t1)
     loadisFromInstruction(1, t2)
     loadConstantOrVariable(t1, t0)
+if SOLARIS_AMD64
+    bqaeq t0, solarisAMD64StackBottom, .opIsUndefinedCell
+end
     btqz t0, tagMask, .opIsUndefinedCell
     cqeq t0, ValueUndefined, t3
     orq ValueFalse, t3
@@ -772,6 +831,12 @@ _llint_op_is_number:
     loadisFromInstruction(2, t1)
     loadisFromInstruction(1, t2)
     loadConstantOrVariable(t1, t0)
+if SOLARIS_AMD64
+    bqb t0, solarisAMD64StackBottom, .opIsNumberNotSolarisAMD64StackPointer
+    storeq ValueFalse, [cfr, t2, 8]
+    dispatch(3)
+.opIsNumberNotSolarisAMD64StackPointer:
+end
     tqnz t0, tagTypeNumber, t1
     orq ValueFalse, t1
     storeq t1, [cfr, t2, 8]
@@ -783,7 +848,13 @@ _llint_op_is_string:
     loadisFromInstruction(2, t1)
     loadisFromInstruction(1, t2)
     loadConstantOrVariable(t1, t0)
+if SOLARIS_AMD64
+    bqaeq t0, solarisAMD64StackBottom, .opIsStringSolarisAMD64StackPointer
+end
     btqnz t0, tagMask, .opIsStringNotCell
+if SOLARIS_AMD64
+.opIsStringSolarisAMD64StackPointer:
+end
     loadp JSCell::m_structure[t0], t0
     cbeq Structure::m_typeInfo + TypeInfo::m_type[t0], StringType, t1
     orq ValueFalse, t1
@@ -1150,6 +1221,9 @@ _llint_op_put_by_val:
     contiguousPutByVal(
         macro (operand, scratch, address)
             loadConstantOrVariable(operand, scratch)
+if SOLARIS_AMD64
+            bqaeq scratch, solarisAMD64StackBottom, .opPutByValSlow
+end
             bpb scratch, tagTypeNumber, .opPutByValSlow
             storep scratch, address
         end)
@@ -1159,6 +1233,9 @@ _llint_op_put_by_val:
     contiguousPutByVal(
         macro (operand, scratch, address)
             loadConstantOrVariable(operand, scratch)
+if SOLARIS_AMD64
+            bqaeq scratch, solarisAMD64StackBottom, .notInt
+end
             bqb scratch, tagTypeNumber, .notInt
             ci2d scratch, ft0
             jmp .ready
@@ -1237,7 +1314,13 @@ macro equalNull(cellHandler, immediateHa
     loadisFromInstruction(1, t0)
     assertNotConstant(t0)
     loadq [cfr, t0, 8], t0
+if SOLARIS_AMD64
+    bqaeq t0, solarisAMD64StackBottom, .solarisAMD64StackPointer
+end
     btqnz t0, tagMask, .immediate
+if SOLARIS_AMD64
+.solarisAMD64StackPointer:
+end
     loadp JSCell::m_structure[t0], t2
     cellHandler(t2, Structure::m_typeInfo + TypeInfo::m_flags[t2], .target)
     dispatch(3)
@@ -1295,6 +1378,10 @@ macro compare(integerCompare, doubleComp
     loadisFromInstruction(2, t3)
     loadConstantOrVariable(t2, t0)
     loadConstantOrVariable(t3, t1)
+if SOLARIS_AMD64
+    bqaeq t0, solarisAMD64StackBottom, .slow
+    bqaeq t1, solarisAMD64StackBottom, .slow
+end
     bqb t0, tagTypeNumber, .op1NotInt
     bqb t1, tagTypeNumber, .op2NotInt
     integerCompare(t0, t1, .jumpTarget)
@@ -1342,6 +1429,9 @@ _llint_op_switch_imm:
     muli sizeof SimpleJumpTable, t3    # FIXME: would be nice to peephole this!
     loadp CodeBlock::RareData::m_immediateSwitchJumpTables + VectorBufferOffset[t2], t2
     addp t3, t2
+if SOLARIS_AMD64
+    bqaeq t1, solarisAMD64StackBottom, .opSwitchImmFallThrough
+end
     bqb t1, tagTypeNumber, .opSwitchImmNotInt
     subi SimpleJumpTable::min[t2], t1
     biaeq t1, SimpleJumpTable::branchOffsets + VectorSizeOffset[t2], .opSwitchImmFallThrough
@@ -1370,7 +1460,13 @@ _llint_op_switch_char:
     muli sizeof SimpleJumpTable, t3
     loadp CodeBlock::RareData::m_characterSwitchJumpTables + VectorBufferOffset[t2], t2
     addp t3, t2
+if SOLARIS_AMD64
+    bqaeq t1, solarisAMD64StackBottom, .opSwitchCharSolarisAMD64StackPointer
+end
     btqnz t1, tagMask, .opSwitchCharFallThrough
+if SOLARIS_AMD64
+.opSwitchCharSolarisAMD64StackPointer:
+end
     loadp JSCell::m_structure[t1], t0
     bbneq Structure::m_typeInfo + TypeInfo::m_type[t0], StringType, .opSwitchCharFallThrough
     bineq JSString::m_length[t1], 1, .opSwitchCharFallThrough
@@ -1414,7 +1510,13 @@ macro arrayProfileForCall()
     if VALUE_PROFILER
         loadisFromInstruction(3, t3)
         loadq ThisArgumentOffset[cfr, t3, 8], t0
+if SOLARIS_AMD64
+        bqaeq t0, solarisAMD64StackBottom, .solarisAMD64StackPointer
+end
         btqnz t0, tagMask, .done
+if SOLARIS_AMD64
+.solarisAMD64StackPointer:
+end
         loadp JSCell::m_structure[t0], t0
         loadpFromInstruction(5, t1)
         storep t0, ArrayProfile::m_lastSeenStructure[t1]
@@ -1488,7 +1590,13 @@ _llint_op_ret_object_or_this:
     checkSwitchToJITForEpilogue()
     loadisFromInstruction(1, t2)
     loadConstantOrVariable(t2, t0)
+if SOLARIS_AMD64
+    bqaeq t0, solarisAMD64StackBottom, .opRetObjectOrThisSolarisAMD64StackPointer
+end
     btqnz t0, tagMask, .opRetObjectOrThisNotObject
+if SOLARIS_AMD64
+.opRetObjectOrThisSolarisAMD64StackPointer:
+end
     loadp JSCell::m_structure[t0], t2
     bbb Structure::m_typeInfo + TypeInfo::m_type[t2], ObjectType, .opRetObjectOrThisNotObject
     doReturn()
@@ -1504,7 +1612,13 @@ _llint_op_to_primitive:
     loadisFromInstruction(2, t2)
     loadisFromInstruction(1, t3)
     loadConstantOrVariable(t2, t0)
+if SOLARIS_AMD64
+    bqaeq t0, solarisAMD64StackBottom, .opToPrimitiveSolarisAMD64StackPointer
+end
     btqnz t0, tagMask, .opToPrimitiveIsImm
+if SOLARIS_AMD64
+.opToPrimitiveSolarisAMD64StackPointer:
+end
     loadp JSCell::m_structure[t0], t2
     bbneq Structure::m_typeInfo + TypeInfo::m_type[t2], StringType, .opToPrimitiveSlowCase
 .opToPrimitiveIsImm:
Index: qt5webkit/Source/JavaScriptCore/llint/LLIntOfflineAsmConfig.h
===================================================================
--- qt5webkit.orig/Source/JavaScriptCore/llint/LLIntOfflineAsmConfig.h
+++ qt5webkit/Source/JavaScriptCore/llint/LLIntOfflineAsmConfig.h
@@ -104,6 +104,12 @@
 #define OFFLINE_ASM_JSVALUE64 0
 #endif
 
+#if OS(SOLARIS_AMD64)
+#define OFFLINE_ASM_SOLARIS_AMD64 1
+#else
+#define OFFLINE_ASM_SOLARIS_AMD64 0
+#endif
+
 #if !ASSERT_DISABLED
 #define OFFLINE_ASM_ASSERT_ENABLED 1
 #else