Bug 872644 - Rename UnsafeSetElement intrinsic to UnsafePutElements. r=shu

--HG--
extra : rebase_source : 0f7e49b1a29a33b38b6be3c77073e11d3d6373c9
extra : amend_source : 529aa068a6592e8f1b1c818dc7d29612b3528908
This commit is contained in:
Till Schneidereit 2013-07-05 21:57:43 +02:00
parent d917b292bc
commit 3338bb00a8
9 changed files with 56 additions and 62 deletions

View File

@ -239,8 +239,8 @@ function ArrayMap(callbackfn/*, thisArg*/) {
if (k in O) {
/* Step c.i-iii. */
var mappedValue = callFunction(callbackfn, T, O[k], k, O);
// UnsafeSetElement doesn't invoke setters, so we can use it here.
UnsafeSetElement(A, k, mappedValue);
// UnsafePutElements doesn't invoke setters, so we can use it here.
UnsafePutElements(A, k, mappedValue);
}
}

View File

@ -317,7 +317,7 @@ function ParallelArrayBuild(self, shape, func, mode) {
var indexStart = chunkPos << CHUNK_SHIFT;
var indexEnd = std_Math_min(indexStart + CHUNK_SIZE, length);
computefunc(indexStart, indexEnd);
UnsafeSetElement(info, SLICE_POS(sliceId), ++chunkPos);
UnsafePutElements(info, SLICE_POS(sliceId), ++chunkPos);
}
return chunkEnd == info[SLICE_END(sliceId)];
@ -325,14 +325,14 @@ function ParallelArrayBuild(self, shape, func, mode) {
function fill1(indexStart, indexEnd) {
for (var i = indexStart; i < indexEnd; i++)
UnsafeSetElement(buffer, i, func(i));
UnsafePutElements(buffer, i, func(i));
}
function fill2(indexStart, indexEnd) {
var x = (indexStart / yDimension) | 0;
var y = indexStart - x * yDimension;
for (var i = indexStart; i < indexEnd; i++) {
UnsafeSetElement(buffer, i, func(x, y));
UnsafePutElements(buffer, i, func(x, y));
if (++y == yDimension) {
y = 0;
++x;
@ -346,7 +346,7 @@ function ParallelArrayBuild(self, shape, func, mode) {
var y = (r / zDimension) | 0;
var z = r - y * zDimension;
for (var i = indexStart; i < indexEnd; i++) {
UnsafeSetElement(buffer, i, func(x, y, z));
UnsafePutElements(buffer, i, func(x, y, z));
if (++z == zDimension) {
z = 0;
if (++y == yDimension) {
@ -361,7 +361,7 @@ function ParallelArrayBuild(self, shape, func, mode) {
var indices = ComputeIndices(shape, indexStart);
for (var i = indexStart; i < indexEnd; i++) {
var result = callFunction(std_Function_apply, func, null, indices);
UnsafeSetElement(buffer, i, result);
UnsafePutElements(buffer, i, result);
StepIndices(shape, indices);
}
}
@ -398,7 +398,7 @@ function ParallelArrayMap(func, mode) {
for (var i = 0; i < length; i++) {
// Note: Unlike JS arrays, parallel arrays cannot have holes.
var v = func(self.get(i), i, self);
UnsafeSetElement(buffer, i, v);
UnsafePutElements(buffer, i, v);
}
return NewParallelArray(ParallelArrayView, [length], buffer, 0);
@ -414,9 +414,9 @@ function ParallelArrayMap(func, mode) {
var indexEnd = std_Math_min(indexStart + CHUNK_SIZE, length);
for (var i = indexStart; i < indexEnd; i++)
UnsafeSetElement(buffer, i, func(self.get(i), i, self));
UnsafePutElements(buffer, i, func(self.get(i), i, self));
UnsafeSetElement(info, SLICE_POS(sliceId), ++chunkPos);
UnsafePutElements(info, SLICE_POS(sliceId), ++chunkPos);
}
return chunkEnd == info[SLICE_END(sliceId)];
@ -484,8 +484,8 @@ function ParallelArrayReduce(func, mode) {
var indexPos = chunkStart << CHUNK_SHIFT;
var accumulator = reduceChunk(self.get(indexPos), indexPos + 1, indexPos + CHUNK_SIZE);
UnsafeSetElement(subreductions, sliceId, accumulator, // see (*) above
info, SLICE_POS(sliceId), ++chunkPos);
UnsafePutElements(subreductions, sliceId, accumulator, // see (*) above
info, SLICE_POS(sliceId), ++chunkPos);
}
var accumulator = subreductions[sliceId]; // see (*) above
@ -493,8 +493,7 @@ function ParallelArrayReduce(func, mode) {
while (chunkPos < chunkEnd) {
var indexPos = chunkPos << CHUNK_SHIFT;
accumulator = reduceChunk(accumulator, indexPos, indexPos + CHUNK_SIZE);
UnsafeSetElement(subreductions, sliceId, accumulator,
info, SLICE_POS(sliceId), ++chunkPos);
UnsafePutElements(subreductions, sliceId, accumulator, info, SLICE_POS(sliceId), ++chunkPos);
}
return chunkEnd == info[SLICE_END(sliceId)];
@ -569,10 +568,10 @@ function ParallelArrayScan(func, mode) {
return NewParallelArray(ParallelArrayView, [length], buffer, 0);
function scan(accumulator, start, end) {
UnsafeSetElement(buffer, start, accumulator);
UnsafePutElements(buffer, start, accumulator);
for (var i = start + 1; i < end; i++) {
accumulator = func(accumulator, self.get(i));
UnsafeSetElement(buffer, i, accumulator);
UnsafePutElements(buffer, i, accumulator);
}
return accumulator;
}
@ -607,7 +606,7 @@ function ParallelArrayScan(func, mode) {
var indexStart = chunkPos << CHUNK_SHIFT;
var indexEnd = std_Math_min(indexStart + CHUNK_SIZE, length);
scan(self.get(indexStart), indexStart, indexEnd);
UnsafeSetElement(info, SLICE_POS(sliceId), ++chunkPos);
UnsafePutElements(info, SLICE_POS(sliceId), ++chunkPos);
}
while (chunkPos < chunkEnd) {
@ -620,7 +619,7 @@ function ParallelArrayScan(func, mode) {
var indexEnd = std_Math_min(indexStart + CHUNK_SIZE, length);
var accumulator = func(buffer[indexStart - 1], self.get(indexStart));
scan(accumulator, indexStart, indexEnd);
UnsafeSetElement(info, SLICE_POS(sliceId), ++chunkPos);
UnsafePutElements(info, SLICE_POS(sliceId), ++chunkPos);
}
return chunkEnd == info[SLICE_END(sliceId)];
@ -688,8 +687,8 @@ function ParallelArrayScan(func, mode) {
var intermediate = intermediates[sliceId - 1];
for (; indexPos < indexEnd; indexPos++) {
UnsafeSetElement(buffer, indexPos, func(intermediate, buffer[indexPos]),
info, SLICE_POS(sliceId), indexPos + 1);
UnsafePutElements(buffer, indexPos, func(intermediate, buffer[indexPos]),
info, SLICE_POS(sliceId), indexPos + 1);
}
return indexEnd == info[SLICE_END(sliceId)];
@ -817,14 +816,14 @@ function ParallelArrayScatter(targets, defaultValue, conflictFunc, length, mode)
var numSlices = ForkJoinSlices();
var checkpoints = NewDenseArray(numSlices);
for (var i = 0; i < numSlices; i++)
UnsafeSetElement(checkpoints, i, 0);
UnsafePutElements(checkpoints, i, 0);
var buffer = NewDenseArray(length);
var conflicts = NewDenseArray(length);
for (var i = 0; i < length; i++) {
UnsafeSetElement(buffer, i, defaultValue);
UnsafeSetElement(conflicts, i, false);
UnsafePutElements(buffer, i, defaultValue);
UnsafePutElements(conflicts, i, false);
}
ForkJoin(fill, ForkJoinMode(mode));
@ -846,9 +845,7 @@ function ParallelArrayScatter(targets, defaultValue, conflictFunc, length, mode)
continue;
if (conflicts[t])
x = collide(x, buffer[t]);
UnsafeSetElement(buffer, t, x,
conflicts, t, true,
checkpoints, sliceId, indexPos + 1);
UnsafePutElements(buffer, t, x, conflicts, t, true, checkpoints, sliceId, indexPos + 1);
}
return indexEnd == targetsLength;
@ -867,13 +864,13 @@ function ParallelArrayScatter(targets, defaultValue, conflictFunc, length, mode)
// FIXME(bug 844890): Use typed arrays here.
var localBuffers = NewDenseArray(numSlices);
for (var i = 0; i < numSlices; i++)
UnsafeSetElement(localBuffers, i, NewDenseArray(length));
UnsafePutElements(localBuffers, i, NewDenseArray(length));
var localConflicts = NewDenseArray(numSlices);
for (var i = 0; i < numSlices; i++) {
var conflicts_i = NewDenseArray(length);
for (var j = 0; j < length; j++)
UnsafeSetElement(conflicts_i, j, false);
UnsafeSetElement(localConflicts, i, conflicts_i);
UnsafePutElements(conflicts_i, j, false);
UnsafePutElements(localConflicts, i, conflicts_i);
}
// Initialize the 0th buffer, which will become the output. For
@ -882,7 +879,7 @@ function ParallelArrayScatter(targets, defaultValue, conflictFunc, length, mode)
// initialized.
var outputBuffer = localBuffers[0];
for (var i = 0; i < length; i++)
UnsafeSetElement(outputBuffer, i, defaultValue);
UnsafePutElements(outputBuffer, i, defaultValue);
ForkJoin(fill, ForkJoinMode(mode));
mergeBuffers();
@ -901,9 +898,8 @@ function ParallelArrayScatter(targets, defaultValue, conflictFunc, length, mode)
var t = checkTarget(indexPos, targets[indexPos]);
if (conflicts[t])
x = collide(x, localbuffer[t]);
UnsafeSetElement(localbuffer, t, x,
conflicts, t, true,
info, SLICE_POS(sliceId), ++indexPos);
UnsafePutElements(localbuffer, t, x, conflicts, t, true,
info, SLICE_POS(sliceId), ++indexPos);
}
return indexEnd == info[SLICE_END(sliceId)];
@ -939,8 +935,8 @@ function ParallelArrayScatter(targets, defaultValue, conflictFunc, length, mode)
var conflicts = NewDenseArray(length);
for (var i = 0; i < length; i++) {
UnsafeSetElement(buffer, i, defaultValue);
UnsafeSetElement(conflicts, i, false);
UnsafePutElements(buffer, i, defaultValue);
UnsafePutElements(conflicts, i, false);
}
for (var i = 0; i < targetsLength; i++) {
@ -949,8 +945,7 @@ function ParallelArrayScatter(targets, defaultValue, conflictFunc, length, mode)
if (conflicts[t])
x = collide(x, buffer[t]);
UnsafeSetElement(buffer, t, x,
conflicts, t, true);
UnsafePutElements(buffer, t, x, conflicts, t, true);
}
return NewParallelArray(ParallelArrayView, [length], buffer, 0);
@ -1002,7 +997,7 @@ function ParallelArrayFilter(func, mode) {
// FIXME(bug 844890): Use typed arrays here.
var counts = NewDenseArray(numSlices);
for (var i = 0; i < numSlices; i++)
UnsafeSetElement(counts, i, 0);
UnsafePutElements(counts, i, 0);
var survivors = NewDenseArray(chunks);
ForkJoin(findSurvivorsInSlice, ForkJoinMode(mode));
@ -1052,9 +1047,9 @@ function ParallelArrayFilter(func, mode) {
count += keep;
}
UnsafeSetElement(survivors, chunkPos, chunkBits,
counts, sliceId, count,
info, SLICE_POS(sliceId), ++chunkPos);
UnsafePutElements(survivors, chunkPos, chunkBits,
counts, sliceId, count,
info, SLICE_POS(sliceId), ++chunkPos);
}
return chunkEnd == info[SLICE_END(sliceId)];
@ -1093,7 +1088,7 @@ function ParallelArrayFilter(func, mode) {
var indexStart = chunk << CHUNK_SHIFT;
for (var i = 0; i < CHUNK_SIZE; i++) {
if (chunkBits & (1 << i)) {
UnsafeSetElement(buffer, count++, self.get(indexStart + i));
UnsafePutElements(buffer, count++, self.get(indexStart + i));
if (count == total)
break;
}

View File

@ -14,7 +14,7 @@
MakeConstructible: false, DecompileArg: false,
RuntimeDefaultLocale: false,
ParallelDo: false, ParallelSlices: false, NewDenseArray: false,
UnsafeSetElement: false, ShouldForceSequential: false,
UnsafePutElements: false, ShouldForceSequential: false,
ParallelTestsShouldPass: false,
Dump: false,
callFunction: false,

View File

@ -37,7 +37,7 @@ class IonBuilder : public MIRGenerator
// Normal write like a[b] = c.
SetElem_Normal,
// Write due to UnsafeSetElement:
// Write due to UnsafePutElements:
// - assumed to be in bounds,
// - not checked for data races
SetElem_Unsafe,
@ -485,7 +485,7 @@ class IonBuilder : public MIRGenerator
InliningStatus inlineRegExpTest(CallInfo &callInfo);
// Array intrinsics.
InliningStatus inlineUnsafeSetElement(CallInfo &callInfo);
InliningStatus inlineUnsafePutElements(CallInfo &callInfo);
bool inlineUnsafeSetDenseArrayElement(CallInfo &callInfo, uint32_t base);
bool inlineUnsafeSetTypedArrayElement(CallInfo &callInfo, uint32_t base, int arrayType);
InliningStatus inlineNewDenseArray(CallInfo &callInfo);

View File

@ -90,8 +90,8 @@ IonBuilder::inlineNativeCall(CallInfo &callInfo, JSNative native)
return inlineRegExpTest(callInfo);
// Array intrinsics.
if (native == intrinsic_UnsafeSetElement)
return inlineUnsafeSetElement(callInfo);
if (native == intrinsic_UnsafePutElements)
return inlineUnsafePutElements(callInfo);
if (native == intrinsic_NewDenseArray)
return inlineNewDenseArray(callInfo);
@ -954,7 +954,7 @@ IonBuilder::inlineRegExpTest(CallInfo &callInfo)
}
IonBuilder::InliningStatus
IonBuilder::inlineUnsafeSetElement(CallInfo &callInfo)
IonBuilder::inlineUnsafePutElements(CallInfo &callInfo)
{
uint32_t argc = callInfo.argc();
if (argc < 3 || (argc % 3) != 0 || callInfo.constructing())
@ -963,7 +963,7 @@ IonBuilder::inlineUnsafeSetElement(CallInfo &callInfo)
/* Important:
*
* Here we inline each of the stores resulting from a call to
* %UnsafeSetElement(). It is essential that these stores occur
* UnsafePutElements(). It is essential that these stores occur
* atomically and cannot be interrupted by a stack or recursion
* check. If this is not true, race conditions can occur.
*/
@ -1027,10 +1027,10 @@ bool
IonBuilder::inlineUnsafeSetDenseArrayElement(CallInfo &callInfo, uint32_t base)
{
// Note: we do not check the conditions that are asserted as true
// in intrinsic_UnsafeSetElement():
// in intrinsic_UnsafePutElements():
// - arr is a dense array
// - idx < initialized length
// Furthermore, note that inlineUnsafeSetElement ensures the type of the
// Furthermore, note that inlineUnsafePutElements ensures the type of the
// value is reflected in the JSID_VOID property of the array.
MDefinition *obj = callInfo.getArg(base + 0);
@ -1050,7 +1050,7 @@ IonBuilder::inlineUnsafeSetTypedArrayElement(CallInfo &callInfo,
int arrayType)
{
// Note: we do not check the conditions that are asserted as true
// in intrinsic_UnsafeSetElement():
// in intrinsic_UnsafePutElements():
// - arr is a typed array
// - idx < length

View File

@ -2481,7 +2481,7 @@ JSBool intrinsic_IsCallable(JSContext *cx, unsigned argc, Value *vp);
JSBool intrinsic_ThrowError(JSContext *cx, unsigned argc, Value *vp);
JSBool intrinsic_NewDenseArray(JSContext *cx, unsigned argc, Value *vp);
JSBool intrinsic_UnsafeSetElement(JSContext *cx, unsigned argc, Value *vp);
JSBool intrinsic_UnsafePutElements(JSContext *cx, unsigned argc, Value *vp);
JSBool intrinsic_UnsafeSetReservedSlot(JSContext *cx, unsigned argc, Value *vp);
JSBool intrinsic_UnsafeGetReservedSlot(JSContext *cx, unsigned argc, Value *vp);
JSBool intrinsic_NewObjectWithClassPrototype(JSContext *cx, unsigned argc, Value *vp);

View File

@ -1418,8 +1418,8 @@ TypeConstraintCall::newType(JSContext *cx, TypeSet *source, Type type)
}
}
if (native == intrinsic_UnsafeSetElement) {
// UnsafeSetElement(arr0, idx0, elem0, ..., arrN, idxN, elemN)
if (native == intrinsic_UnsafePutElements) {
// UnsafePutElements(arr0, idx0, elem0, ..., arrN, idxN, elemN)
// is (basically) equivalent to arri[idxi] = elemi for i = 0...N
JS_ASSERT((callsite->argumentCount % 3) == 0);
for (size_t i = 0; i < callsite->argumentCount; i += 3) {

View File

@ -98,7 +98,7 @@
// get interesting. In that case, the semantics of parallel
// execution guarantee us that no visible side effects have occurred
// (unless they were performed with the intrinsic
// |UnsafeSetElement()|, which can only be used in self-hosted
// |UnsafePutElements()|, which can only be used in self-hosted
// code). We therefore reinvoke |func()| but with warmup set to
// true. The idea here is that often parallel bailouts result from
// a failed type guard or other similar assumption, so rerunning the

View File

@ -413,10 +413,9 @@ js::intrinsic_NewDenseArray(JSContext *cx, unsigned argc, Value *vp)
}
/*
* UnsafeSetElement(arr0, idx0, elem0, ..., arrN, idxN, elemN): For
* each set of (arr, idx, elem) arguments that are passed, performs
* the assignment |arr[idx] = elem|. |arr| must be either a dense array
* or a typed array.
* UnsafePutElements(arr0, idx0, elem0, ..., arrN, idxN, elemN): For each set of
* (arr, idx, elem) arguments that are passed, performs the assignment
* |arr[idx] = elem|. |arr| must be either a dense array or a typed array.
*
* If |arr| is a dense array, the index must be an int32 less than the
* initialized length of |arr|. Use |%EnsureDenseResultArrayElements|
@ -426,7 +425,7 @@ js::intrinsic_NewDenseArray(JSContext *cx, unsigned argc, Value *vp)
* length of |arr|.
*/
JSBool
js::intrinsic_UnsafeSetElement(JSContext *cx, unsigned argc, Value *vp)
js::intrinsic_UnsafePutElements(JSContext *cx, unsigned argc, Value *vp)
{
CallArgs args = CallArgsFromVp(argc, vp);
@ -605,7 +604,7 @@ const JSFunctionSpec intrinsic_functions[] = {
JS_FN("DecompileArg", intrinsic_DecompileArg, 2,0),
JS_FN("RuntimeDefaultLocale", intrinsic_RuntimeDefaultLocale, 0,0),
JS_FN("UnsafeSetElement", intrinsic_UnsafeSetElement, 3,0),
JS_FN("UnsafePutElements", intrinsic_UnsafePutElements, 3,0),
JS_FN("UnsafeSetReservedSlot", intrinsic_UnsafeSetReservedSlot, 3,0),
JS_FN("UnsafeGetReservedSlot", intrinsic_UnsafeGetReservedSlot, 2,0),