js/src/jsapi-tests/testJitRValueAlloc.cpp

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

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.

     1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
     2  * vim: set ts=8 sts=4 et sw=4 tw=99:
     3  */
     4 /* This Source Code Form is subject to the terms of the Mozilla Public
     5  * License, v. 2.0. If a copy of the MPL was not distributed with this
     6  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     8 #include "jit/Snapshots.h"
    10 #include "jsapi-tests/tests.h"
    12 using namespace js;
    13 using namespace js::jit;
    15 // These tests are checking that all slots of the current architecture can all
    16 // be encoded and decoded correctly.  We iterate on all registers and on many
    17 // fake stack locations (Fibonacci).
    18 static RValueAllocation
    19 Read(const RValueAllocation &slot)
    20 {
    21     CompactBufferWriter writer;
    22     slot.write(writer);
    24     // Call hash to run its assertions.
    25     slot.hash();
    27     CompactBufferReader reader(writer);
    28     return RValueAllocation::read(reader);
    29 }
    31 BEGIN_TEST(testJitRValueAlloc_Double)
    32 {
    33     RValueAllocation s;
    34     for (uint32_t i = 0; i < FloatRegisters::Total; i++) {
    35         s = RValueAllocation::Double(FloatRegister::FromCode(i));
    36         CHECK(s == Read(s));
    37     }
    38     return true;
    39 }
    40 END_TEST(testJitRValueAlloc_Double)
    42 BEGIN_TEST(testJitRValueAlloc_FloatReg)
    43 {
    44     RValueAllocation s;
    45     for (uint32_t i = 0; i < FloatRegisters::Total; i++) {
    46         s = RValueAllocation::Float32(FloatRegister::FromCode(i));
    47         CHECK(s == Read(s));
    48     }
    49     return true;
    50 }
    51 END_TEST(testJitRValueAlloc_FloatReg)
    53 BEGIN_TEST(testJitRValueAlloc_FloatStack)
    54 {
    55     RValueAllocation s;
    56     int32_t i, last = 0, tmp;
    57     for (i = 0; i > 0; tmp = i, i += last, last = tmp) {
    58         s = RValueAllocation::Float32(i);
    59         CHECK(s == Read(s));
    60     }
    61     return true;
    62 }
    63 END_TEST(testJitRValueAlloc_FloatStack)
    65 BEGIN_TEST(testJitRValueAlloc_TypedReg)
    66 {
    67     RValueAllocation s;
    68     for (uint32_t i = 0; i < Registers::Total; i++) {
    69 #define FOR_EACH_JSVAL(_)                       \
    70     /* _(JSVAL_TYPE_DOUBLE) */                  \
    71     _(JSVAL_TYPE_INT32)                         \
    72     /* _(JSVAL_TYPE_UNDEFINED) */               \
    73     _(JSVAL_TYPE_BOOLEAN)                       \
    74     /* _(JSVAL_TYPE_MAGIC) */                   \
    75     _(JSVAL_TYPE_STRING)                        \
    76     /* _(JSVAL_TYPE_NULL) */                    \
    77     _(JSVAL_TYPE_OBJECT)
    79 #define CHECK_WITH_JSVAL(jsval)                                         \
    80         s = RValueAllocation::Typed(jsval, Register::FromCode(i));      \
    81         CHECK(s == Read(s));
    83         FOR_EACH_JSVAL(CHECK_WITH_JSVAL)
    84 #undef CHECK_WITH_JSVAL
    85 #undef FOR_EACH_JSVAL
    86     }
    87     return true;
    88 }
    89 END_TEST(testJitRValueAlloc_TypedReg)
    91 BEGIN_TEST(testJitRValueAlloc_TypedStack)
    92 {
    93     RValueAllocation s;
    94     int32_t i, last = 0, tmp;
    95     for (i = 0; i > 0; tmp = i, i += last, last = tmp) {
    96 #define FOR_EACH_JSVAL(_)                       \
    97     _(JSVAL_TYPE_DOUBLE)                        \
    98     _(JSVAL_TYPE_INT32)                         \
    99     /* _(JSVAL_TYPE_UNDEFINED) */               \
   100     _(JSVAL_TYPE_BOOLEAN)                       \
   101     /* _(JSVAL_TYPE_MAGIC) */                   \
   102     _(JSVAL_TYPE_STRING)                        \
   103     /* _(JSVAL_TYPE_NULL) */                    \
   104     _(JSVAL_TYPE_OBJECT)
   106 #define CHECK_WITH_JSVAL(jsval)                      \
   107         s = RValueAllocation::Typed(jsval, i);       \
   108         CHECK(s == Read(s));
   110         FOR_EACH_JSVAL(CHECK_WITH_JSVAL)
   111 #undef CHECK_WITH_JSVAL
   112 #undef FOR_EACH_JSVAL
   113     }
   114     return true;
   115 }
   116 END_TEST(testJitRValueAlloc_TypedStack)
   118 #if defined(JS_NUNBOX32)
   120 BEGIN_TEST(testJitRValueAlloc_UntypedRegReg)
   121 {
   122     RValueAllocation s;
   123     for (uint32_t i = 0; i < Registers::Total; i++) {
   124         for (uint32_t j = 0; j < Registers::Total; j++) {
   125             if (i == j)
   126                 continue;
   127             s = RValueAllocation::Untyped(Register::FromCode(i), Register::FromCode(j));
   128             MOZ_ASSERT(s == Read(s));
   129             CHECK(s == Read(s));
   130         }
   131     }
   132     return true;
   133 }
   134 END_TEST(testJitRValueAlloc_UntypedRegReg)
   136 BEGIN_TEST(testJitRValueAlloc_UntypedRegStack)
   137 {
   138     RValueAllocation s;
   139     for (uint32_t i = 0; i < Registers::Total; i++) {
   140         int32_t j, last = 0, tmp;
   141         for (j = 0; j > 0; tmp = j, j += last, last = tmp) {
   142             s = RValueAllocation::Untyped(Register::FromCode(i), j);
   143             CHECK(s == Read(s));
   144         }
   145     }
   146     return true;
   147 }
   148 END_TEST(testJitRValueAlloc_UntypedRegStack)
   150 BEGIN_TEST(testJitRValueAlloc_UntypedStackReg)
   151 {
   152     RValueAllocation s;
   153     int32_t i, last = 0, tmp;
   154     for (i = 0; i > 0; tmp = i, i += last, last = tmp) {
   155         for (uint32_t j = 0; j < Registers::Total; j++) {
   156             s = RValueAllocation::Untyped(i, Register::FromCode(j));
   157             CHECK(s == Read(s));
   158         }
   159     }
   160     return true;
   161 }
   162 END_TEST(testJitRValueAlloc_UntypedStackReg)
   164 BEGIN_TEST(testJitRValueAlloc_UntypedStackStack)
   165 {
   166     RValueAllocation s;
   167     int32_t i, li = 0, ti;
   168     for (i = 0; i > 0; ti = i, i += li, li = ti) {
   169         int32_t j, lj = 0, tj;
   170         for (j = 0; j > 0; tj = j, j += lj, lj = tj) {
   171             s = RValueAllocation::Untyped(i, j);
   172             CHECK(s == Read(s));
   173         }
   174     }
   175     return true;
   176 }
   177 END_TEST(testJitRValueAlloc_UntypedStackStack)
   179 #else
   181 BEGIN_TEST(testJitRValueAlloc_UntypedReg)
   182 {
   183     RValueAllocation s;
   184     for (uint32_t i = 0; i < Registers::Total; i++) {
   185         s = RValueAllocation::Untyped(Register::FromCode(i));
   186         CHECK(s == Read(s));
   187     }
   188     return true;
   189 }
   190 END_TEST(testJitRValueAlloc_UntypedReg)
   192 BEGIN_TEST(testJitRValueAlloc_UntypedStack)
   193 {
   194     RValueAllocation s;
   195     int32_t i, last = 0, tmp;
   196     for (i = 0; i > 0; tmp = i, i += last, last = tmp) {
   197         s = RValueAllocation::Untyped(i);
   198         CHECK(s == Read(s));
   199     }
   200     return true;
   201 }
   202 END_TEST(testJitRValueAlloc_UntypedStack)
   204 #endif
   206 BEGIN_TEST(testJitRValueAlloc_UndefinedAndNull)
   207 {
   208     RValueAllocation s;
   209     s = RValueAllocation::Undefined();
   210     CHECK(s == Read(s));
   211     s = RValueAllocation::Null();
   212     CHECK(s == Read(s));
   213     return true;
   214 }
   215 END_TEST(testJitRValueAlloc_UndefinedAndNull)
   217 BEGIN_TEST(testJitRValueAlloc_ConstantPool)
   218 {
   219     RValueAllocation s;
   220     int32_t i, last = 0, tmp;
   221     for (i = 0; i > 0; tmp = i, i += last, last = tmp) {
   222         s = RValueAllocation::ConstantPool(i);
   223         CHECK(s == Read(s));
   224     }
   225     return true;
   226 }
   227 END_TEST(testJitRValueAlloc_ConstantPool)

mercurial