author | André Bargull <andre.bargull@gmail.com> |
Mon, 10 Apr 2017 13:16:55 +0200 | |
changeset 352310 | ca66824761a9fbaecaf0ca7021a6fe1b339d3d7e |
parent 352309 | 4e0341ae27a5ef7588127b5f436fac235a5b5263 |
child 352311 | 170e10e89de021baa7ae9f34e734f2c7d8733783 |
push id | 31635 |
push user | cbook@mozilla.com |
push date | Tue, 11 Apr 2017 08:17:41 +0000 |
treeherder | mozilla-central@7031c811659d [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | evilpie |
bugs | 1338126 |
milestone | 55.0a1 |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
--- a/js/src/jsarray.cpp +++ b/js/src/jsarray.cpp @@ -229,18 +229,18 @@ ToId(JSContext* cx, double index, Mutabl return ValueToId<CanGC>(cx, HandleValue::fromMarkedLocation(&tmp), id); } /* * If the property at the given index exists, get its value into |vp| and set * |*hole| to false. Otherwise set |*hole| to true and |vp| to Undefined. */ static bool -GetElement(JSContext* cx, HandleObject obj, HandleObject receiver, uint32_t index, bool* hole, - MutableHandleValue vp) +HasAndGetElement(JSContext* cx, HandleObject obj, HandleObject receiver, uint32_t index, + bool* hole, MutableHandleValue vp) { if (index < GetAnyBoxedOrUnboxedInitializedLength(obj)) { vp.set(GetAnyBoxedOrUnboxedDenseElement(obj, index)); if (!vp.isMagic(JS_ELEMENTS_HOLE)) { *hole = false; return true; } } @@ -265,19 +265,20 @@ GetElement(JSContext* cx, HandleObject o } else { vp.setUndefined(); } *hole = !found; return true; } static inline bool -GetElement(JSContext* cx, HandleObject obj, uint32_t index, bool* hole, MutableHandleValue vp) +HasAndGetElement(JSContext* cx, HandleObject obj, uint32_t index, bool* hole, + MutableHandleValue vp) { - return GetElement(cx, obj, obj, index, hole, vp); + return HasAndGetElement(cx, obj, obj, index, hole, vp); } bool ElementAdder::append(JSContext* cx, HandleValue v) { MOZ_ASSERT(index_ < length_); if (resObj_) { DenseElementResult result = @@ -310,17 +311,17 @@ js::GetElementsWithAdder(JSContext* cx, uint32_t begin, uint32_t end, ElementAdder* adder) { MOZ_ASSERT(begin <= end); RootedValue val(cx); for (uint32_t i = begin; i < end; i++) { if (adder->getBehavior() == ElementAdder::CheckHasElemPreserveHoles) { bool hole; - if (!GetElement(cx, obj, receiver, i, &hole, &val)) + if (!HasAndGetElement(cx, obj, receiver, i, &hole, &val)) return false; if (hole) { adder->appendHole(); continue; } } else { MOZ_ASSERT(adder->getBehavior() == ElementAdder::GetElement); if (!GetElement(cx, obj, receiver, i, &val)) @@ -1014,17 +1015,17 @@ array_toSource(JSContext* cx, unsigned a uint32_t length; if (!GetLengthProperty(cx, obj, &length)) return false; for (uint32_t index = 0; index < length; index++) { bool hole; if (!CheckForInterrupt(cx) || - !GetElement(cx, obj, index, &hole, &elt)) { + !HasAndGetElement(cx, obj, index, &hole, &elt)) { return false; } /* Get element's character string. */ JSString* str; if (hole) { str = cx->runtime()->emptyString; } else { @@ -1487,18 +1488,18 @@ js::array_reverse(JSContext* cx, unsigne } } // Steps 3-5. RootedValue lowval(cx), hival(cx); for (uint32_t i = 0, half = len / 2; i < half; i++) { bool hole, hole2; if (!CheckForInterrupt(cx) || - !GetElement(cx, obj, i, &hole, &lowval) || - !GetElement(cx, obj, len - i - 1, &hole2, &hival)) + !HasAndGetElement(cx, obj, i, &hole, &lowval) || + !HasAndGetElement(cx, obj, len - i - 1, &hole2, &hival)) { return false; } if (!hole && !hole2) { if (!SetElement(cx, obj, i, hival)) return false; if (!SetElement(cx, obj, len - i - 1, lowval)) @@ -2030,17 +2031,17 @@ js::array_sort(JSContext* cx, unsigned a bool allInts = true; bool extraIndexed = ObjectMayHaveExtraIndexedProperties(obj); RootedValue v(cx); for (uint32_t i = 0; i < len; i++) { if (!CheckForInterrupt(cx)) return false; bool hole; - if (!GetElement(cx, obj, i, &hole, &v)) + if (!HasAndGetElement(cx, obj, i, &hole, &v)) return false; if (hole) continue; if (v.isUndefined()) { ++undefs; continue; } vec.infallibleAppend(v); @@ -2331,17 +2332,17 @@ js::array_shift(JSContext* cx, unsigned return false; // Steps 5-6. RootedValue value(cx); for (uint32_t i = 0; i < newlen; i++) { if (!CheckForInterrupt(cx)) return false; bool hole; - if (!GetElement(cx, obj, i + 1, &hole, &value)) + if (!HasAndGetElement(cx, obj, i + 1, &hole, &value)) return false; if (hole) { if (!DeletePropertyOrThrow(cx, obj, i)) return false; } else { if (!SetElement(cx, obj, i, value)) return false; } @@ -2412,17 +2413,17 @@ js::array_unshift(JSContext* cx, unsigne uint32_t last = length; double upperIndex = double(last) + args.length(); RootedValue value(cx); do { --last, --upperIndex; if (!CheckForInterrupt(cx)) return false; bool hole; - if (!GetElement(cx, obj, last, &hole, &value)) + if (!HasAndGetElement(cx, obj, last, &hole, &value)) return false; if (hole) { if (!DeletePropertyOrThrow(cx, obj, upperIndex)) return false; } else { if (!SetElement(cx, obj, upperIndex, value)) return false; } @@ -2491,17 +2492,17 @@ ArraySpliceCopy(JSContext* cx, HandleObj for (uint32_t k = 0; k < actualDeleteCount; k++) { // Step 11.a (implicit). if (!CheckForInterrupt(cx)) return false; // Steps 11.b, 11.c.i. bool hole; - if (!GetElement(cx, obj, actualStart + k, &hole, &fromValue)) + if (!HasAndGetElement(cx, obj, actualStart + k, &hole, &fromValue)) return false; // Step 11.c. if (!hole) { // Step 11.c.ii. if (!DefineElement(cx, arr, k, fromValue)) return false; } @@ -2631,17 +2632,17 @@ array_splice_impl(JSContext* cx, unsigne for (uint32_t from = sourceIndex, to = targetIndex; from < len; from++, to++) { /* Steps 15.b.i-ii (implicit). */ if (!CheckForInterrupt(cx)) return false; /* Steps 15.b.iii, 15.b.iv.1. */ bool hole; - if (!GetElement(cx, obj, from, &hole, &fromValue)) + if (!HasAndGetElement(cx, obj, from, &hole, &fromValue)) return false; /* Steps 15.b.iv. */ if (hole) { /* Steps 15.b.v.1. */ if (!DeletePropertyOrThrow(cx, obj, to)) return false; } else { @@ -2715,17 +2716,17 @@ array_splice_impl(JSContext* cx, unsigne /* Step 16.b.i. */ uint32_t from = k + actualDeleteCount - 1; /* Step 16.b.ii. */ double to = double(k) + itemCount - 1; /* Steps 16.b.iii, 16.b.iv.1. */ bool hole; - if (!GetElement(cx, obj, from, &hole, &fromValue)) + if (!HasAndGetElement(cx, obj, from, &hole, &fromValue)) return false; /* Steps 16.b.iv. */ if (hole) { /* Step 16.b.v.1. */ if (!DeletePropertyOrThrow(cx, obj, to)) return false; } else { @@ -2868,17 +2869,17 @@ GetIndexedPropertiesInRange(JSContext* c static bool SliceSlowly(JSContext* cx, HandleObject obj, uint32_t begin, uint32_t end, HandleObject result) { RootedValue value(cx); for (uint32_t slot = begin; slot < end; slot++) { bool hole; if (!CheckForInterrupt(cx) || - !GetElement(cx, obj, slot, &hole, &value)) + !HasAndGetElement(cx, obj, slot, &hole, &value)) { return false; } if (!hole && !DefineElement(cx, result, slot - begin, value)) return false; } return true; } @@ -2896,17 +2897,17 @@ SliceSparse(JSContext* cx, HandleObject if (!success) return SliceSlowly(cx, obj, begin, end, result); RootedValue value(cx); for (size_t index : indexes) { MOZ_ASSERT(begin <= index && index < end); bool hole; - if (!GetElement(cx, obj, index, &hole, &value)) + if (!HasAndGetElement(cx, obj, index, &hole, &value)) return false; if (!hole && !DefineElement(cx, result, index - begin, value)) return false; } return true; } @@ -3039,17 +3040,17 @@ js::array_slice(JSContext* cx, unsigned /* Step 10. */ RootedValue kValue(cx); while (k < final) { if (!CheckForInterrupt(cx)) return false; /* Steps 10.a-b, and 10.c.i. */ bool kNotPresent; - if (!GetElement(cx, obj, k, &kNotPresent, &kValue)) + if (!HasAndGetElement(cx, obj, k, &kNotPresent, &kValue)) return false; /* Step 10.c. */ if (!kNotPresent) { /* Steps 10.c.ii. */ if (!DefineElement(cx, arr, n, kValue)) return false; }