Sat, 03 Jan 2015 20:18:00 +0100
Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.
michael@0 | 1 | /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- |
michael@0 | 2 | * vim: set ts=8 sts=4 et sw=4 tw=99: |
michael@0 | 3 | * This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 4 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 5 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 6 | |
michael@0 | 7 | #ifndef builtin_SIMD_h |
michael@0 | 8 | #define builtin_SIMD_h |
michael@0 | 9 | |
michael@0 | 10 | #include "jsapi.h" |
michael@0 | 11 | #include "jsobj.h" |
michael@0 | 12 | #include "builtin/TypedObject.h" |
michael@0 | 13 | #include "vm/GlobalObject.h" |
michael@0 | 14 | |
michael@0 | 15 | /* |
michael@0 | 16 | * JS SIMD functions. |
michael@0 | 17 | * Spec matching polyfill: |
michael@0 | 18 | * https://github.com/johnmccutchan/ecmascript_simd/blob/master/src/ecmascript_simd.js |
michael@0 | 19 | */ |
michael@0 | 20 | |
michael@0 | 21 | #define FLOAT32X4_NULLARY_FUNCTION_LIST(V) \ |
michael@0 | 22 | V(zero, (FuncZero<Float32x4>), 0, 0, Zero) |
michael@0 | 23 | |
michael@0 | 24 | #define FLOAT32X4_UNARY_FUNCTION_LIST(V) \ |
michael@0 | 25 | V(abs, (Func<Float32x4, Abs<float, Float32x4>, Float32x4>), 1, 0, Abs) \ |
michael@0 | 26 | V(bitsToInt32x4, (FuncConvertBits<Float32x4, Int32x4>), 1, 0, BitsToInt32x4) \ |
michael@0 | 27 | V(neg, (Func<Float32x4, Neg<float, Float32x4>, Float32x4>), 1, 0, Neg) \ |
michael@0 | 28 | V(reciprocal, (Func<Float32x4, Rec<float, Float32x4>, Float32x4>), 1, 0, Reciprocal) \ |
michael@0 | 29 | V(reciprocalSqrt, (Func<Float32x4, RecSqrt<float, Float32x4>, Float32x4>), 1, 0, ReciprocalSqrt) \ |
michael@0 | 30 | V(splat, (FuncSplat<Float32x4>), 1, 0, Splat) \ |
michael@0 | 31 | V(sqrt, (Func<Float32x4, Sqrt<float, Float32x4>, Float32x4>), 1, 0, Sqrt) \ |
michael@0 | 32 | V(toInt32x4, (FuncConvert<Float32x4, Int32x4>), 1, 0, ToInt32x4) |
michael@0 | 33 | |
michael@0 | 34 | #define FLOAT32X4_BINARY_FUNCTION_LIST(V) \ |
michael@0 | 35 | V(add, (Func<Float32x4, Add<float, Float32x4>, Float32x4>), 2, 0, Add) \ |
michael@0 | 36 | V(div, (Func<Float32x4, Div<float, Float32x4>, Float32x4>), 2, 0, Div) \ |
michael@0 | 37 | V(equal, (Func<Float32x4, Equal<float, Int32x4>, Int32x4>), 2, 0, Equal) \ |
michael@0 | 38 | V(greaterThan, (Func<Float32x4, GreaterThan<float, Int32x4>, Int32x4>), 2, 0, GreaterThan) \ |
michael@0 | 39 | V(greaterThanOrEqual, (Func<Float32x4, GreaterThanOrEqual<float, Int32x4>, Int32x4>), 2, 0, GreaterThanOrEqual) \ |
michael@0 | 40 | V(lessThan, (Func<Float32x4, LessThan<float, Int32x4>, Int32x4>), 2, 0, LessThan) \ |
michael@0 | 41 | V(lessThanOrEqual, (Func<Float32x4, LessThanOrEqual<float, Int32x4>, Int32x4>), 2, 0, LessThanOrEqual) \ |
michael@0 | 42 | V(max, (Func<Float32x4, Maximum<float, Float32x4>, Float32x4>), 2, 0, Max) \ |
michael@0 | 43 | V(min, (Func<Float32x4, Minimum<float, Float32x4>, Float32x4>), 2, 0, Min) \ |
michael@0 | 44 | V(mul, (Func<Float32x4, Mul<float, Float32x4>, Float32x4>), 2, 0, Mul) \ |
michael@0 | 45 | V(notEqual, (Func<Float32x4, NotEqual<float, Int32x4>, Int32x4>), 2, 0, NotEqual) \ |
michael@0 | 46 | V(shuffle, (FuncShuffle<Float32x4, Shuffle<float, Float32x4>, Float32x4>), 2, 0, Shuffle) \ |
michael@0 | 47 | V(scale, (FuncWith<Float32x4, Scale<float, Float32x4>, Float32x4>), 2, 0, Scale) \ |
michael@0 | 48 | V(sub, (Func<Float32x4, Sub<float, Float32x4>, Float32x4>), 2, 0, Sub) \ |
michael@0 | 49 | V(withX, (FuncWith<Float32x4, WithX<float, Float32x4>, Float32x4>), 2, 0, WithX) \ |
michael@0 | 50 | V(withY, (FuncWith<Float32x4, WithY<float, Float32x4>, Float32x4>), 2, 0, WithY) \ |
michael@0 | 51 | V(withZ, (FuncWith<Float32x4, WithZ<float, Float32x4>, Float32x4>), 2, 0, WithZ) \ |
michael@0 | 52 | V(withW, (FuncWith<Float32x4, WithW<float, Float32x4>, Float32x4>), 2, 0, WithW) |
michael@0 | 53 | |
michael@0 | 54 | #define FLOAT32X4_TERNARY_FUNCTION_LIST(V) \ |
michael@0 | 55 | V(clamp, Float32x4Clamp, 3, 0, Clamp) \ |
michael@0 | 56 | V(shuffleMix, (FuncShuffle<Float32x4, Shuffle<float, Float32x4>, Float32x4>), 3, 0, ShuffleMix) |
michael@0 | 57 | |
michael@0 | 58 | #define FLOAT32X4_FUNCTION_LIST(V) \ |
michael@0 | 59 | FLOAT32X4_NULLARY_FUNCTION_LIST(V) \ |
michael@0 | 60 | FLOAT32X4_UNARY_FUNCTION_LIST(V) \ |
michael@0 | 61 | FLOAT32X4_BINARY_FUNCTION_LIST(V) \ |
michael@0 | 62 | FLOAT32X4_TERNARY_FUNCTION_LIST(V) |
michael@0 | 63 | |
michael@0 | 64 | #define INT32X4_NULLARY_FUNCTION_LIST(V) \ |
michael@0 | 65 | V(zero, (FuncZero<Int32x4>), 0, 0, Zero) |
michael@0 | 66 | |
michael@0 | 67 | #define INT32X4_UNARY_FUNCTION_LIST(V) \ |
michael@0 | 68 | V(bitsToFloat32x4, (FuncConvertBits<Int32x4, Float32x4>), 1, 0, BitsToFloat32x4) \ |
michael@0 | 69 | V(neg, (Func<Int32x4, Neg<int32_t, Int32x4>, Int32x4>), 1, 0, Neg) \ |
michael@0 | 70 | V(not, (Func<Int32x4, Not<int32_t, Int32x4>, Int32x4>), 1, 0, Not) \ |
michael@0 | 71 | V(splat, (FuncSplat<Int32x4>), 0, 0, Splat) \ |
michael@0 | 72 | V(toFloat32x4, (FuncConvert<Int32x4, Float32x4>), 1, 0, ToFloat32x4) |
michael@0 | 73 | |
michael@0 | 74 | #define INT32X4_BINARY_FUNCTION_LIST(V) \ |
michael@0 | 75 | V(add, (Func<Int32x4, Add<int32_t, Int32x4>, Int32x4>), 2, 0, Add) \ |
michael@0 | 76 | V(and, (Func<Int32x4, And<int32_t, Int32x4>, Int32x4>), 2, 0, And) \ |
michael@0 | 77 | V(mul, (Func<Int32x4, Mul<int32_t, Int32x4>, Int32x4>), 2, 0, Mul) \ |
michael@0 | 78 | V(or, (Func<Int32x4, Or<int32_t, Int32x4>, Int32x4>), 2, 0, Or) \ |
michael@0 | 79 | V(sub, (Func<Int32x4, Sub<int32_t, Int32x4>, Int32x4>), 2, 0, Sub) \ |
michael@0 | 80 | V(shuffle, (FuncShuffle<Int32x4, Shuffle<int32_t, Int32x4>, Int32x4>), 2, 0, Shuffle) \ |
michael@0 | 81 | V(withFlagX, (FuncWith<Int32x4, WithFlagX<int32_t, Int32x4>, Int32x4>), 2, 0, WithFlagX) \ |
michael@0 | 82 | V(withFlagY, (FuncWith<Int32x4, WithFlagY<int32_t, Int32x4>, Int32x4>), 2, 0, WithFlagY) \ |
michael@0 | 83 | V(withFlagZ, (FuncWith<Int32x4, WithFlagZ<int32_t, Int32x4>, Int32x4>), 2, 0, WithFlagZ) \ |
michael@0 | 84 | V(withFlagW, (FuncWith<Int32x4, WithFlagW<int32_t, Int32x4>, Int32x4>), 2, 0, WithFlagW) \ |
michael@0 | 85 | V(withX, (FuncWith<Int32x4, WithX<int32_t, Int32x4>, Int32x4>), 2, 0, WithX) \ |
michael@0 | 86 | V(withY, (FuncWith<Int32x4, WithY<int32_t, Int32x4>, Int32x4>), 2, 0, WithY) \ |
michael@0 | 87 | V(withZ, (FuncWith<Int32x4, WithZ<int32_t, Int32x4>, Int32x4>), 2, 0, WithZ) \ |
michael@0 | 88 | V(withW, (FuncWith<Int32x4, WithW<int32_t, Int32x4>, Int32x4>), 2, 0, WithW) \ |
michael@0 | 89 | V(xor, (Func<Int32x4, Xor<int32_t, Int32x4>, Int32x4>), 2, 0, Xor) |
michael@0 | 90 | |
michael@0 | 91 | #define INT32X4_TERNARY_FUNCTION_LIST(V) \ |
michael@0 | 92 | V(select, Int32x4Select, 3, 0, Select) \ |
michael@0 | 93 | V(shuffleMix, (FuncShuffle<Int32x4, Shuffle<int32_t, Int32x4>, Int32x4>), 3, 0, ShuffleMix) |
michael@0 | 94 | |
michael@0 | 95 | #define INT32X4_QUARTERNARY_FUNCTION_LIST(V) \ |
michael@0 | 96 | V(bool, Int32x4Bool, 4, 0, Bool) |
michael@0 | 97 | |
michael@0 | 98 | #define INT32X4_FUNCTION_LIST(V) \ |
michael@0 | 99 | INT32X4_NULLARY_FUNCTION_LIST(V) \ |
michael@0 | 100 | INT32X4_UNARY_FUNCTION_LIST(V) \ |
michael@0 | 101 | INT32X4_BINARY_FUNCTION_LIST(V) \ |
michael@0 | 102 | INT32X4_TERNARY_FUNCTION_LIST(V) \ |
michael@0 | 103 | INT32X4_QUARTERNARY_FUNCTION_LIST(V) |
michael@0 | 104 | |
michael@0 | 105 | namespace js { |
michael@0 | 106 | |
michael@0 | 107 | class SIMDObject : public JSObject |
michael@0 | 108 | { |
michael@0 | 109 | public: |
michael@0 | 110 | static const Class class_; |
michael@0 | 111 | static JSObject* initClass(JSContext *cx, Handle<GlobalObject *> global); |
michael@0 | 112 | static bool toString(JSContext *cx, unsigned int argc, jsval *vp); |
michael@0 | 113 | }; |
michael@0 | 114 | |
michael@0 | 115 | // These classes exist for use with templates below. |
michael@0 | 116 | |
michael@0 | 117 | struct Float32x4 { |
michael@0 | 118 | typedef float Elem; |
michael@0 | 119 | static const int32_t lanes = 4; |
michael@0 | 120 | static const X4TypeDescr::Type type = X4TypeDescr::TYPE_FLOAT32; |
michael@0 | 121 | |
michael@0 | 122 | static TypeDescr &GetTypeDescr(GlobalObject &global) { |
michael@0 | 123 | return global.float32x4TypeDescr().as<TypeDescr>(); |
michael@0 | 124 | } |
michael@0 | 125 | static Elem toType(Elem a) { |
michael@0 | 126 | return a; |
michael@0 | 127 | } |
michael@0 | 128 | static bool toType(JSContext *cx, JS::HandleValue v, Elem *out) { |
michael@0 | 129 | *out = v.toNumber(); |
michael@0 | 130 | return true; |
michael@0 | 131 | } |
michael@0 | 132 | static void setReturn(CallArgs &args, Elem value) { |
michael@0 | 133 | args.rval().setDouble(JS::CanonicalizeNaN(value)); |
michael@0 | 134 | } |
michael@0 | 135 | }; |
michael@0 | 136 | |
michael@0 | 137 | struct Int32x4 { |
michael@0 | 138 | typedef int32_t Elem; |
michael@0 | 139 | static const int32_t lanes = 4; |
michael@0 | 140 | static const X4TypeDescr::Type type = X4TypeDescr::TYPE_INT32; |
michael@0 | 141 | |
michael@0 | 142 | static TypeDescr &GetTypeDescr(GlobalObject &global) { |
michael@0 | 143 | return global.int32x4TypeDescr().as<TypeDescr>(); |
michael@0 | 144 | } |
michael@0 | 145 | static Elem toType(Elem a) { |
michael@0 | 146 | return ToInt32(a); |
michael@0 | 147 | } |
michael@0 | 148 | static bool toType(JSContext *cx, JS::HandleValue v, Elem *out) { |
michael@0 | 149 | return ToInt32(cx, v, out); |
michael@0 | 150 | } |
michael@0 | 151 | static void setReturn(CallArgs &args, Elem value) { |
michael@0 | 152 | args.rval().setInt32(value); |
michael@0 | 153 | } |
michael@0 | 154 | }; |
michael@0 | 155 | |
michael@0 | 156 | template<typename V> |
michael@0 | 157 | JSObject *Create(JSContext *cx, typename V::Elem *data); |
michael@0 | 158 | |
michael@0 | 159 | #define DECLARE_SIMD_FLOAT32X4_FUNCTION(Name, Func, Operands, Flags, MIRId) \ |
michael@0 | 160 | extern bool \ |
michael@0 | 161 | simd_float32x4_##Name(JSContext *cx, unsigned argc, Value *vp); |
michael@0 | 162 | FLOAT32X4_FUNCTION_LIST(DECLARE_SIMD_FLOAT32X4_FUNCTION) |
michael@0 | 163 | #undef DECLARE_SIMD_FLOAT32X4_FUNCTION |
michael@0 | 164 | |
michael@0 | 165 | #define DECLARE_SIMD_INT32x4_FUNCTION(Name, Func, Operands, Flags, MIRId) \ |
michael@0 | 166 | extern bool \ |
michael@0 | 167 | simd_int32x4_##Name(JSContext *cx, unsigned argc, Value *vp); |
michael@0 | 168 | INT32X4_FUNCTION_LIST(DECLARE_SIMD_INT32x4_FUNCTION) |
michael@0 | 169 | #undef DECLARE_SIMD_INT32x4_FUNCTION |
michael@0 | 170 | |
michael@0 | 171 | } /* namespace js */ |
michael@0 | 172 | |
michael@0 | 173 | JSObject * |
michael@0 | 174 | js_InitSIMDClass(JSContext *cx, js::HandleObject obj); |
michael@0 | 175 | |
michael@0 | 176 | #endif /* builtin_SIMD_h */ |