Bug 1394835 part 4 - Split js::DefineProperty/DefineElement in separate accessor vs data functions. r=anba

This commit is contained in:
Jan de Mooij 2017-09-07 14:59:24 +02:00
parent 194cbec7a2
commit 15de1c0cb3
32 changed files with 313 additions and 254 deletions

View File

@ -1129,11 +1129,8 @@ AtomicsObject::initClass(JSContext* cx, Handle<GlobalObject*> global)
RootedValue AtomicsValue(cx, ObjectValue(*Atomics));
// Everything is set up, install Atomics on the global object.
if (!DefineProperty(cx, global, cx->names().Atomics, AtomicsValue, nullptr, nullptr,
JSPROP_RESOLVING))
{
if (!DefineDataProperty(cx, global, cx->names().Atomics, AtomicsValue, JSPROP_RESOLVING))
return nullptr;
}
global->setConstructor(JSProto_Atomics, AtomicsValue);
return Atomics;

View File

@ -825,11 +825,8 @@ intl_availableLocales(JSContext* cx, CountAvailable countAvailable,
a = Atomize(cx, lang.get(), strlen(lang.get()));
if (!a)
return false;
if (!DefineProperty(cx, locales, a->asPropertyName(), TrueHandleValue, nullptr, nullptr,
JSPROP_ENUMERATE))
{
if (!DefineDataProperty(cx, locales, a->asPropertyName(), TrueHandleValue))
return false;
}
}
#endif
result.setObject(*locales);
@ -1070,7 +1067,7 @@ CreateCollatorPrototype(JSContext* cx, HandleObject Intl, Handle<GlobalObject*>
// 8.1
RootedValue ctorValue(cx, ObjectValue(*ctor));
if (!DefineProperty(cx, Intl, cx->names().Collator, ctorValue, nullptr, nullptr, 0))
if (!DefineDataProperty(cx, Intl, cx->names().Collator, ctorValue, 0))
return nullptr;
return proto;
@ -1121,7 +1118,7 @@ js::intl_availableCollations(JSContext* cx, unsigned argc, Value* vp)
// The first element of the collations array must be |null| per
// ES2017 Intl, 10.2.3 Internal Slots.
if (!DefineElement(cx, collations, index++, NullHandleValue))
if (!DefineDataElement(cx, collations, index++, NullHandleValue))
return false;
RootedValue element(cx);
@ -1144,7 +1141,7 @@ js::intl_availableCollations(JSContext* cx, unsigned argc, Value* vp)
if (!jscollation)
return false;
element = StringValue(jscollation);
if (!DefineElement(cx, collations, index++, element))
if (!DefineDataElement(cx, collations, index++, element))
return false;
}
@ -1649,13 +1646,13 @@ CreateNumberFormatPrototype(JSContext* cx, HandleObject Intl, Handle<GlobalObjec
return nullptr;
}
if (!DefineProperty(cx, proto, cx->names().formatToParts, ftp, nullptr, nullptr, 0))
if (!DefineDataProperty(cx, proto, cx->names().formatToParts, ftp, 0))
return nullptr;
}
// 8.1
RootedValue ctorValue(cx, ObjectValue(*ctor));
if (!DefineProperty(cx, Intl, cx->names().NumberFormat, ctorValue, nullptr, nullptr, 0))
if (!DefineDataProperty(cx, Intl, cx->names().NumberFormat, ctorValue, 0))
return nullptr;
constructor.set(ctor);
@ -2308,7 +2305,7 @@ intl_FormatNumberToParts(JSContext* cx, UNumberFormat* nf, double x, MutableHand
return false;
propVal.setString(cx->names().*type);
if (!DefineProperty(cx, singlePart, cx->names().type, propVal))
if (!DefineDataProperty(cx, singlePart, cx->names().type, propVal))
return false;
JSLinearString* partSubstr =
@ -2317,11 +2314,11 @@ intl_FormatNumberToParts(JSContext* cx, UNumberFormat* nf, double x, MutableHand
return false;
propVal.setString(partSubstr);
if (!DefineProperty(cx, singlePart, cx->names().value, propVal))
if (!DefineDataProperty(cx, singlePart, cx->names().value, propVal))
return false;
propVal.setObject(*singlePart);
if (!DefineElement(cx, partsArray, partIndex, propVal))
if (!DefineDataElement(cx, partsArray, partIndex, propVal))
return false;
lastEndIndex = endIndex;
@ -2529,7 +2526,7 @@ CreateDateTimeFormatPrototype(JSContext* cx, HandleObject Intl, Handle<GlobalObj
// 8.1
RootedValue ctorValue(cx, ObjectValue(*ctor));
if (!DefineProperty(cx, Intl, cx->names().DateTimeFormat, ctorValue, nullptr, nullptr, 0))
if (!DefineDataProperty(cx, Intl, cx->names().DateTimeFormat, ctorValue, 0))
return nullptr;
constructor.set(ctor);
@ -2616,7 +2613,7 @@ js::intl_availableCalendars(JSContext* cx, unsigned argc, Value* vp)
if (!DefaultCalendar(cx, locale, &element))
return false;
if (!DefineElement(cx, calendars, index++, element))
if (!DefineDataElement(cx, calendars, index++, element))
return false;
// Now get the calendars that "would make a difference", i.e., not the default.
@ -2648,7 +2645,7 @@ js::intl_availableCalendars(JSContext* cx, unsigned argc, Value* vp)
if (!jscalendar)
return false;
element = StringValue(jscalendar);
if (!DefineElement(cx, calendars, index++, element))
if (!DefineDataElement(cx, calendars, index++, element))
return false;
// ICU doesn't return calendar aliases, append them here.
@ -2658,7 +2655,7 @@ js::intl_availableCalendars(JSContext* cx, unsigned argc, Value* vp)
if (!jscalendar)
return false;
element = StringValue(jscalendar);
if (!DefineElement(cx, calendars, index++, element))
if (!DefineDataElement(cx, calendars, index++, element))
return false;
}
}
@ -3385,7 +3382,7 @@ intl_FormatToPartsDateTime(JSContext* cx, UDateFormat* df, double x, MutableHand
return false;
partType = StringValue(cx->names().*type);
if (!DefineProperty(cx, singlePart, cx->names().type, partType))
if (!DefineDataProperty(cx, singlePart, cx->names().type, partType))
return false;
JSLinearString* partSubstr =
@ -3394,11 +3391,11 @@ intl_FormatToPartsDateTime(JSContext* cx, UDateFormat* df, double x, MutableHand
return false;
val = StringValue(partSubstr);
if (!DefineProperty(cx, singlePart, cx->names().value, val))
if (!DefineDataProperty(cx, singlePart, cx->names().value, val))
return false;
val = ObjectValue(*singlePart);
if (!DefineElement(cx, partsArray, partIndex, val))
if (!DefineDataElement(cx, partsArray, partIndex, val))
return false;
lastEndIndex = endIndex;
@ -3593,7 +3590,7 @@ CreatePluralRulesPrototype(JSContext* cx, HandleObject Intl, Handle<GlobalObject
return nullptr;
RootedValue ctorValue(cx, ObjectValue(*ctor));
if (!DefineProperty(cx, Intl, cx->names().PluralRules, ctorValue, nullptr, nullptr, 0))
if (!DefineDataProperty(cx, Intl, cx->names().PluralRules, ctorValue, 0))
return nullptr;
return proto;
@ -3766,7 +3763,7 @@ js::intl_GetPluralCategories(JSContext* cx, unsigned argc, Value* vp)
return false;
element.setString(str);
if (!DefineElement(cx, res, i++, element))
if (!DefineDataElement(cx, res, i++, element))
return false;
} while (true);
@ -3926,12 +3923,12 @@ js::intl_GetCalendarInfo(JSContext* cx, unsigned argc, Value* vp)
int32_t firstDayOfWeek = ucal_getAttribute(cal, UCAL_FIRST_DAY_OF_WEEK);
v.setInt32(firstDayOfWeek);
if (!DefineProperty(cx, info, cx->names().firstDayOfWeek, v))
if (!DefineDataProperty(cx, info, cx->names().firstDayOfWeek, v))
return false;
int32_t minDays = ucal_getAttribute(cal, UCAL_MINIMAL_DAYS_IN_FIRST_WEEK);
v.setInt32(minDays);
if (!DefineProperty(cx, info, cx->names().minDays, v))
if (!DefineDataProperty(cx, info, cx->names().minDays, v))
return false;
UCalendarWeekdayType prevDayType = ucal_getDayOfWeekType(cal, UCAL_SATURDAY, &status);
@ -3979,10 +3976,10 @@ js::intl_GetCalendarInfo(JSContext* cx, unsigned argc, Value* vp)
MOZ_ASSERT(weekendStart.isInt32());
MOZ_ASSERT(weekendEnd.isInt32());
if (!DefineProperty(cx, info, cx->names().weekendStart, weekendStart))
if (!DefineDataProperty(cx, info, cx->names().weekendStart, weekendStart))
return false;
if (!DefineProperty(cx, info, cx->names().weekendEnd, weekendEnd))
if (!DefineDataProperty(cx, info, cx->names().weekendEnd, weekendEnd))
return false;
args.rval().setObject(*info);
@ -4306,7 +4303,7 @@ js::intl_ComputeDisplayNames(JSContext* cx, unsigned argc, Value* vp)
// 5.b. Append the result string to result.
v.setString(displayName);
if (!DefineElement(cx, result, i, v))
if (!DefineDataElement(cx, result, i, v))
return false;
}
@ -4329,14 +4326,14 @@ js::intl_GetLocaleInfo(JSContext* cx, unsigned argc, Value* vp)
if (!info)
return false;
if (!DefineProperty(cx, info, cx->names().locale, args[0]))
if (!DefineDataProperty(cx, info, cx->names().locale, args[0]))
return false;
bool rtl = uloc_isRightToLeft(icuLocale(locale.ptr()));
RootedValue dir(cx, StringValue(rtl ? cx->names().rtl : cx->names().ltr));
if (!DefineProperty(cx, info, cx->names().direction, dir))
if (!DefineDataProperty(cx, info, cx->names().direction, dir))
return false;
args.rval().setObject(*info);
@ -4403,11 +4400,8 @@ GlobalObject::initIntlObject(JSContext* cx, Handle<GlobalObject*> global)
// The |Intl| object is fully set up now, so define the global property.
RootedValue intlValue(cx, ObjectValue(*intl));
if (!DefineProperty(cx, global, cx->names().Intl, intlValue, nullptr, nullptr,
JSPROP_RESOLVING))
{
if (!DefineDataProperty(cx, global, cx->names().Intl, intlValue, JSPROP_RESOLVING))
return false;
}
// Now that the |Intl| object is successfully added, we can OOM-safely fill
// in all relevant reserved global slots.

View File

@ -1989,7 +1989,7 @@ PerformPromiseAll(JSContext *cx, JS::ForOfIterator& iterator, HandleObject C,
// a cross-compartment proxy instead...
JSAutoCompartment ac(cx, valuesArray);
indexId = INT_TO_JSID(index);
if (!DefineProperty(cx, valuesArray, indexId, UndefinedHandleValue))
if (!DefineDataProperty(cx, valuesArray, indexId, UndefinedHandleValue))
return false;
}

View File

@ -240,7 +240,7 @@ js::InitReflect(JSContext* cx, HandleObject obj)
return nullptr;
RootedValue value(cx, ObjectValue(*reflect));
if (!DefineProperty(cx, obj, cx->names().Reflect, value, nullptr, nullptr, JSPROP_RESOLVING))
if (!DefineDataProperty(cx, obj, cx->names().Reflect, value, JSPROP_RESOLVING))
return nullptr;
obj->as<GlobalObject>().setConstructor(JSProto_Reflect, value);

View File

@ -438,7 +438,7 @@ class NodeBuilder
/* Represent "no node" as null and ensure users are not exposed to magic values. */
RootedValue optVal(cx, val.isMagic(JS_SERIALIZE_NO_NODE) ? NullValue() : val);
return DefineProperty(cx, obj, atom->asPropertyName(), optVal);
return DefineDataProperty(cx, obj, atom->asPropertyName(), optVal);
}
MOZ_MUST_USE bool newNodeLoc(TokenPos* pos, MutableHandleValue dst);
@ -679,7 +679,7 @@ NodeBuilder::newArray(NodeVector& elts, MutableHandleValue dst)
if (val.isMagic(JS_SERIALIZE_NO_NODE))
continue;
if (!DefineElement(cx, array, i, val))
if (!DefineDataElement(cx, array, i, val))
return false;
}

View File

@ -561,11 +561,8 @@ GlobalObject::initSimdObject(JSContext* cx, Handle<GlobalObject*> global)
return false;
RootedValue globalSimdValue(cx, ObjectValue(*globalSimdObject));
if (!DefineProperty(cx, global, cx->names().SIMD, globalSimdValue, nullptr, nullptr,
JSPROP_RESOLVING))
{
if (!DefineDataProperty(cx, global, cx->names().SIMD, globalSimdValue, JSPROP_RESOLVING))
return false;
}
global->setConstructor(JSProto_SIMD, globalSimdValue);
return true;
@ -621,8 +618,8 @@ CreateSimdType(JSContext* cx, Handle<GlobalObject*> global, HandlePropertyName s
RootedValue typeValue(cx, ObjectValue(*typeDescr));
if (!JS_DefineFunctions(cx, typeDescr, methods) ||
!DefineProperty(cx, globalSimdObject, stringRepr, typeValue, nullptr, nullptr,
JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_RESOLVING))
!DefineDataProperty(cx, globalSimdObject, stringRepr, typeValue,
JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_RESOLVING))
{
return false;
}

View File

@ -555,30 +555,30 @@ js::CreateUserSizeAndAlignmentProperties(JSContext* cx, HandleTypeDescr descr)
if (descr->transparent()) {
// byteLength
RootedValue typeByteLength(cx, Int32Value(AssertedCast<int32_t>(descr->size())));
if (!DefineProperty(cx, descr, cx->names().byteLength, typeByteLength,
nullptr, nullptr, JSPROP_READONLY | JSPROP_PERMANENT))
if (!DefineDataProperty(cx, descr, cx->names().byteLength, typeByteLength,
JSPROP_READONLY | JSPROP_PERMANENT))
{
return false;
}
// byteAlignment
RootedValue typeByteAlignment(cx, Int32Value(descr->alignment()));
if (!DefineProperty(cx, descr, cx->names().byteAlignment, typeByteAlignment,
nullptr, nullptr, JSPROP_READONLY | JSPROP_PERMANENT))
if (!DefineDataProperty(cx, descr, cx->names().byteAlignment, typeByteAlignment,
JSPROP_READONLY | JSPROP_PERMANENT))
{
return false;
}
} else {
// byteLength
if (!DefineProperty(cx, descr, cx->names().byteLength, UndefinedHandleValue,
nullptr, nullptr, JSPROP_READONLY | JSPROP_PERMANENT))
if (!DefineDataProperty(cx, descr, cx->names().byteLength, UndefinedHandleValue,
JSPROP_READONLY | JSPROP_PERMANENT))
{
return false;
}
// byteAlignment
if (!DefineProperty(cx, descr, cx->names().byteAlignment, UndefinedHandleValue,
nullptr, nullptr, JSPROP_READONLY | JSPROP_PERMANENT))
if (!DefineDataProperty(cx, descr, cx->names().byteAlignment, UndefinedHandleValue,
JSPROP_READONLY | JSPROP_PERMANENT))
{
return false;
}
@ -613,15 +613,15 @@ ArrayMetaTypeDescr::create(JSContext* cx,
obj->initReservedSlot(JS_DESCR_SLOT_ARRAY_LENGTH, Int32Value(length));
RootedValue elementTypeVal(cx, ObjectValue(*elementType));
if (!DefineProperty(cx, obj, cx->names().elementType, elementTypeVal,
nullptr, nullptr, JSPROP_READONLY | JSPROP_PERMANENT))
if (!DefineDataProperty(cx, obj, cx->names().elementType, elementTypeVal,
JSPROP_READONLY | JSPROP_PERMANENT))
{
return nullptr;
}
RootedValue lengthValue(cx, NumberValue(length));
if (!DefineProperty(cx, obj, cx->names().length, lengthValue,
nullptr, nullptr, JSPROP_READONLY | JSPROP_PERMANENT))
if (!DefineDataProperty(cx, obj, cx->names().length, lengthValue,
JSPROP_READONLY | JSPROP_PERMANENT))
{
return nullptr;
}
@ -843,8 +843,8 @@ StructMetaTypeDescr::create(JSContext* cx,
return nullptr;
// userFieldTypes[id] = typeObj
if (!DefineProperty(cx, userFieldTypes, id, fieldTypeObjs[i], nullptr, nullptr,
JSPROP_READONLY | JSPROP_PERMANENT))
if (!DefineDataProperty(cx, userFieldTypes, id, fieldTypeObjs[i],
JSPROP_READONLY | JSPROP_PERMANENT))
{
return nullptr;
}
@ -872,8 +872,8 @@ StructMetaTypeDescr::create(JSContext* cx,
// userFieldOffsets[id] = offset
RootedValue offsetValue(cx, Int32Value(offset.value()));
if (!DefineProperty(cx, userFieldOffsets, id, offsetValue, nullptr, nullptr,
JSPROP_READONLY | JSPROP_PERMANENT))
if (!DefineDataProperty(cx, userFieldOffsets, id, offsetValue,
JSPROP_READONLY | JSPROP_PERMANENT))
{
return nullptr;
}
@ -961,14 +961,14 @@ StructMetaTypeDescr::create(JSContext* cx,
if (!FreezeObject(cx, userFieldTypes))
return nullptr;
RootedValue userFieldOffsetsValue(cx, ObjectValue(*userFieldOffsets));
if (!DefineProperty(cx, descr, cx->names().fieldOffsets, userFieldOffsetsValue,
nullptr, nullptr, JSPROP_READONLY | JSPROP_PERMANENT))
if (!DefineDataProperty(cx, descr, cx->names().fieldOffsets, userFieldOffsetsValue,
JSPROP_READONLY | JSPROP_PERMANENT))
{
return nullptr;
}
RootedValue userFieldTypesValue(cx, ObjectValue(*userFieldTypes));
if (!DefineProperty(cx, descr, cx->names().fieldTypes, userFieldTypesValue,
nullptr, nullptr, JSPROP_READONLY | JSPROP_PERMANENT))
if (!DefineDataProperty(cx, descr, cx->names().fieldTypes, userFieldTypesValue,
JSPROP_READONLY | JSPROP_PERMANENT))
{
return nullptr;
}
@ -1155,7 +1155,7 @@ DefineSimpleTypeDescr(JSContext* cx,
descr->initReservedSlot(JS_DESCR_SLOT_TYPROTO, ObjectValue(*proto));
RootedValue descrValue(cx, ObjectValue(*descr));
if (!DefineProperty(cx, module, className, descrValue, nullptr, nullptr, 0))
if (!DefineDataProperty(cx, module, className, descrValue, 0))
return false;
if (!CreateTraceList(cx, descr))
@ -1202,8 +1202,8 @@ DefineMetaTypeDescr(JSContext* cx,
return nullptr;
RootedValue protoProtoValue(cx, ObjectValue(*protoProto));
if (!DefineProperty(cx, proto, cx->names().prototype, protoProtoValue,
nullptr, nullptr, JSPROP_READONLY | JSPROP_PERMANENT))
if (!DefineDataProperty(cx, proto, cx->names().prototype, protoProtoValue,
JSPROP_READONLY | JSPROP_PERMANENT))
{
return nullptr;
}
@ -1276,8 +1276,8 @@ GlobalObject::initTypedObjectModule(JSContext* cx, Handle<GlobalObject*> global)
return false;
RootedValue arrayTypeValue(cx, ObjectValue(*arrayType));
if (!DefineProperty(cx, module, cx->names().ArrayType, arrayTypeValue,
nullptr, nullptr, JSPROP_READONLY | JSPROP_PERMANENT))
if (!DefineDataProperty(cx, module, cx->names().ArrayType, arrayTypeValue,
JSPROP_READONLY | JSPROP_PERMANENT))
{
return false;
}
@ -1291,16 +1291,16 @@ GlobalObject::initTypedObjectModule(JSContext* cx, Handle<GlobalObject*> global)
return false;
RootedValue structTypeValue(cx, ObjectValue(*structType));
if (!DefineProperty(cx, module, cx->names().StructType, structTypeValue,
nullptr, nullptr, JSPROP_READONLY | JSPROP_PERMANENT))
if (!DefineDataProperty(cx, module, cx->names().StructType, structTypeValue,
JSPROP_READONLY | JSPROP_PERMANENT))
{
return false;
}
// Everything is setup, install module on the global object:
RootedValue moduleValue(cx, ObjectValue(*module));
if (!DefineProperty(cx, global, cx->names().TypedObject, moduleValue, nullptr, nullptr,
JSPROP_RESOLVING))
if (!DefineDataProperty(cx, global, cx->names().TypedObject, moduleValue,
JSPROP_RESOLVING))
{
return false;
}

View File

@ -1042,8 +1042,8 @@ JS_ResolveStandardClass(JSContext* cx, HandleObject obj, HandleId id, bool* reso
JSAtom* undefinedAtom = cx->names().undefined;
if (idAtom == undefinedAtom) {
*resolved = true;
return DefineProperty(cx, global, id, UndefinedHandleValue, nullptr, nullptr,
JSPROP_PERMANENT | JSPROP_READONLY | JSPROP_RESOLVING);
return DefineDataProperty(cx, global, id, UndefinedHandleValue,
JSPROP_PERMANENT | JSPROP_READONLY | JSPROP_RESOLVING);
}
/* Try for class constructors/prototypes named by well-known atoms. */
@ -2133,8 +2133,7 @@ DefinePropertyByDescriptor(JSContext* cx, HandleObject obj, HandleId id,
AssertHeapIsIdle();
CHECK_REQUEST(cx);
assertSameCompartment(cx, obj, id, desc);
return DefineProperty(cx, obj, id, desc.value(), desc.getter(), desc.setter(),
desc.attributes(), result);
return DefineProperty(cx, obj, id, desc, result);
}
JS_PUBLIC_API(bool)
@ -2221,7 +2220,7 @@ DefineAccessorPropertyById(JSContext* cx, HandleObject obj, HandleId id,
? JS_FUNC_TO_DATA_PTR(JSObject*, setter)
: nullptr);
return DefineProperty(cx, obj, id, UndefinedHandleValue, getter, setter, attrs);
return js::DefineAccessorProperty(cx, obj, id, getter, setter, attrs);
}
static bool
@ -2234,7 +2233,7 @@ DefineDataPropertyById(JSContext* cx, HandleObject obj, HandleId id, HandleValue
CHECK_REQUEST(cx);
assertSameCompartment(cx, obj, id, value);
return DefineProperty(cx, obj, id, value, nullptr, nullptr, attrs);
return js::DefineDataProperty(cx, obj, id, value, attrs);
}
/*
@ -2531,7 +2530,7 @@ JS_PUBLIC_API(bool)
JS_DefineElement(JSContext* cx, HandleObject obj, uint32_t index, HandleValue value,
unsigned attrs)
{
return DefineDataElement(cx, obj, index, value, attrs);
return ::DefineDataElement(cx, obj, index, value, attrs);
}
JS_PUBLIC_API(bool)
@ -2546,7 +2545,7 @@ JS_DefineElement(JSContext* cx, HandleObject obj, uint32_t index, HandleObject v
unsigned attrs)
{
RootedValue value(cx, ObjectValue(*valueArg));
return DefineDataElement(cx, obj, index, value, attrs);
return ::DefineDataElement(cx, obj, index, value, attrs);
}
JS_PUBLIC_API(bool)
@ -2554,7 +2553,7 @@ JS_DefineElement(JSContext* cx, HandleObject obj, uint32_t index, HandleString v
unsigned attrs)
{
RootedValue value(cx, StringValue(valueArg));
return DefineDataElement(cx, obj, index, value, attrs);
return ::DefineDataElement(cx, obj, index, value, attrs);
}
JS_PUBLIC_API(bool)
@ -2562,7 +2561,7 @@ JS_DefineElement(JSContext* cx, HandleObject obj, uint32_t index, int32_t valueA
unsigned attrs)
{
Value value = Int32Value(valueArg);
return DefineDataElement(cx, obj, index, HandleValue::fromMarkedLocation(&value), attrs);
return ::DefineDataElement(cx, obj, index, HandleValue::fromMarkedLocation(&value), attrs);
}
JS_PUBLIC_API(bool)
@ -2570,7 +2569,7 @@ JS_DefineElement(JSContext* cx, HandleObject obj, uint32_t index, uint32_t value
unsigned attrs)
{
Value value = NumberValue(valueArg);
return DefineDataElement(cx, obj, index, HandleValue::fromMarkedLocation(&value), attrs);
return ::DefineDataElement(cx, obj, index, HandleValue::fromMarkedLocation(&value), attrs);
}
JS_PUBLIC_API(bool)
@ -2578,7 +2577,7 @@ JS_DefineElement(JSContext* cx, HandleObject obj, uint32_t index, double valueAr
unsigned attrs)
{
Value value = NumberValue(valueArg);
return DefineDataElement(cx, obj, index, HandleValue::fromMarkedLocation(&value), attrs);
return ::DefineDataElement(cx, obj, index, HandleValue::fromMarkedLocation(&value), attrs);
}
JS_PUBLIC_API(bool)

View File

@ -356,7 +356,7 @@ ElementAdder::append(JSContext* cx, HandleValue v)
if (result == DenseElementResult::Failure)
return false;
if (result == DenseElementResult::Incomplete) {
if (!DefineElement(cx, resObj_, index_, v))
if (!DefineDataElement(cx, resObj_, index_, v))
return false;
}
} else {
@ -494,7 +494,7 @@ DefineArrayElement(JSContext* cx, HandleObject obj, uint64_t index, HandleValue
RootedId id(cx);
if (!ToId(cx, index, &id))
return false;
return DefineProperty(cx, obj, id, value);
return DefineDataProperty(cx, obj, id, value);
}
// Set the value of the property at the given index to v.
@ -639,8 +639,7 @@ array_length_setter(JSContext* cx, HandleObject obj, HandleId id, MutableHandleV
// This array .length property was found on the prototype
// chain. Ideally the setter should not have been called, but since
// we're here, do an impression of SetPropertyByDefining.
return DefineProperty(cx, obj, cx->names().length, vp, nullptr, nullptr,
JSPROP_ENUMERATE, result);
return DefineDataProperty(cx, obj, cx->names().length, vp, JSPROP_ENUMERATE, result);
}
Rooted<ArrayObject*> arr(cx, &obj->as<ArrayObject>());
@ -2749,7 +2748,7 @@ CopyArrayElements(JSContext* cx, HandleObject obj, uint64_t begin, uint64_t coun
return false;
MOZ_ASSERT(edResult == DenseElementResult::Incomplete);
if (!DefineElement(cx, nresult, index, value))
if (!DefineDataElement(cx, nresult, index, value))
return false;
break;
@ -3209,7 +3208,7 @@ SliceSparse(JSContext* cx, HandleObject obj, uint64_t begin, uint64_t end, Handl
if (!HasAndGetElement(cx, obj, index, &hole, &value))
return false;
if (!hole && !DefineElement(cx, result, index - uint32_t(begin), value))
if (!hole && !DefineDataElement(cx, result, index - uint32_t(begin), value))
return false;
}
@ -3469,7 +3468,7 @@ array_of(JSContext* cx, unsigned argc, Value* vp)
// Step 8.
for (unsigned k = 0; k < args.length(); k++) {
if (!DefineElement(cx, obj, k, args[k]))
if (!DefineDataElement(cx, obj, k, args[k]))
return false;
}
@ -3697,21 +3696,21 @@ array_proto_finish(JSContext* cx, JS::HandleObject ctor, JS::HandleObject proto)
return false;
RootedValue value(cx, BooleanValue(true));
if (!DefineProperty(cx, unscopables, cx->names().copyWithin, value) ||
!DefineProperty(cx, unscopables, cx->names().entries, value) ||
!DefineProperty(cx, unscopables, cx->names().fill, value) ||
!DefineProperty(cx, unscopables, cx->names().find, value) ||
!DefineProperty(cx, unscopables, cx->names().findIndex, value) ||
!DefineProperty(cx, unscopables, cx->names().includes, value) ||
!DefineProperty(cx, unscopables, cx->names().keys, value) ||
!DefineProperty(cx, unscopables, cx->names().values, value))
if (!DefineDataProperty(cx, unscopables, cx->names().copyWithin, value) ||
!DefineDataProperty(cx, unscopables, cx->names().entries, value) ||
!DefineDataProperty(cx, unscopables, cx->names().fill, value) ||
!DefineDataProperty(cx, unscopables, cx->names().find, value) ||
!DefineDataProperty(cx, unscopables, cx->names().findIndex, value) ||
!DefineDataProperty(cx, unscopables, cx->names().includes, value) ||
!DefineDataProperty(cx, unscopables, cx->names().keys, value) ||
!DefineDataProperty(cx, unscopables, cx->names().values, value))
{
return false;
}
RootedId id(cx, SYMBOL_TO_JSID(cx->wellKnownSymbols().get(JS::SymbolCode::unscopables)));
value.setObject(*unscopables);
return DefineProperty(cx, proto, id, value, nullptr, nullptr, JSPROP_READONLY);
return DefineDataProperty(cx, proto, id, value, JSPROP_READONLY);
}
static const ClassOps ArrayObjectClassOps = {

View File

@ -1056,7 +1056,7 @@ js::CreateErrorNotesArray(JSContext* cx, JSErrorReport* report)
if (!messageStr)
return nullptr;
RootedValue messageVal(cx, StringValue(messageStr));
if (!DefineProperty(cx, noteObj, cx->names().message, messageVal))
if (!DefineDataProperty(cx, noteObj, cx->names().message, messageVal))
return nullptr;
RootedValue filenameVal(cx);
@ -1066,14 +1066,14 @@ js::CreateErrorNotesArray(JSContext* cx, JSErrorReport* report)
return nullptr;
filenameVal = StringValue(filenameStr);
}
if (!DefineProperty(cx, noteObj, cx->names().fileName, filenameVal))
if (!DefineDataProperty(cx, noteObj, cx->names().fileName, filenameVal))
return nullptr;
RootedValue linenoVal(cx, Int32Value(note->lineno));
if (!DefineProperty(cx, noteObj, cx->names().lineNumber, linenoVal))
if (!DefineDataProperty(cx, noteObj, cx->names().lineNumber, linenoVal))
return nullptr;
RootedValue columnVal(cx, Int32Value(note->column));
if (!DefineProperty(cx, noteObj, cx->names().columnNumber, columnVal))
if (!DefineDataProperty(cx, noteObj, cx->names().columnNumber, columnVal))
return nullptr;
if (!NewbornArrayPush(cx, notesArray, ObjectValue(*noteObj)))

View File

@ -665,7 +665,7 @@ JSCompartment::getTemplateLiteralObject(JSContext* cx, HandleObject rawStrings,
} else {
MOZ_ASSERT(templateObj->nonProxyIsExtensible());
RootedValue rawValue(cx, ObjectValue(*rawStrings));
if (!DefineProperty(cx, templateObj, cx->names().raw, rawValue, nullptr, nullptr, 0))
if (!DefineDataProperty(cx, templateObj, cx->names().raw, rawValue, 0))
return false;
if (!FreezeObject(cx, rawStrings))
return false;

View File

@ -438,15 +438,14 @@ ResolveInterpretedFunctionPrototype(JSContext* cx, HandleFunction fun, HandleId
// back with a .constructor.
if (!isStarGenerator && !isAsyncGenerator) {
RootedValue objVal(cx, ObjectValue(*fun));
if (!DefineProperty(cx, proto, cx->names().constructor, objVal, nullptr, nullptr, 0))
if (!DefineDataProperty(cx, proto, cx->names().constructor, objVal, 0))
return false;
}
// Per ES5 15.3.5.2 a user-defined function's .prototype property is
// initially non-configurable, non-enumerable, and writable.
RootedValue protoVal(cx, ObjectValue(*proto));
return DefineProperty(cx, fun, id, protoVal, nullptr, nullptr,
JSPROP_PERMANENT | JSPROP_RESOLVING);
return DefineDataProperty(cx, fun, id, protoVal, JSPROP_PERMANENT | JSPROP_RESOLVING);
}
bool
@ -2441,7 +2440,7 @@ js::DefineFunction(JSContext* cx, HandleObject obj, HandleId id, Native native,
return nullptr;
RootedValue funVal(cx, ObjectValue(*fun));
if (!DefineProperty(cx, obj, id, funVal, nullptr, nullptr, flags & ~JSFUN_FLAGS_MASK))
if (!DefineDataProperty(cx, obj, id, funVal, flags & ~JSFUN_FLAGS_MASK))
return nullptr;
return fun;

View File

@ -589,7 +589,7 @@ NewPropertyIteratorObject(JSContext* cx, unsigned flags)
return nullptr;
RootedValue value(cx, ObjectValue(*next));
if (!DefineProperty(cx, res, cx->names().next, value))
if (!DefineDataProperty(cx, res, cx->names().next, value))
return nullptr;
}
@ -993,12 +993,12 @@ js::CreateIterResultObject(JSContext* cx, HandleValue value, bool done)
return nullptr;
// Step 3.
if (!DefineProperty(cx, resultObj, cx->names().value, value))
if (!DefineDataProperty(cx, resultObj, cx->names().value, value))
return nullptr;
// Step 4.
if (!DefineProperty(cx, resultObj, cx->names().done,
done ? TrueHandleValue : FalseHandleValue))
if (!DefineDataProperty(cx, resultObj, cx->names().done,
done ? TrueHandleValue : FalseHandleValue))
{
return nullptr;
}

View File

@ -1263,7 +1263,7 @@ js::InitNumberClass(JSContext* cx, HandleObject obj)
if (!parseInt)
return nullptr;
RootedValue parseIntValue(cx, ObjectValue(*parseInt));
if (!DefineProperty(cx, ctor, parseIntId, parseIntValue, nullptr, nullptr, 0))
if (!DefineDataProperty(cx, ctor, parseIntId, parseIntValue, 0))
return nullptr;
/* Number.parseFloat should be the same function object as global parseFloat. */
@ -1273,7 +1273,7 @@ js::InitNumberClass(JSContext* cx, HandleObject obj)
if (!parseFloat)
return nullptr;
RootedValue parseFloatValue(cx, ObjectValue(*parseFloat));
if (!DefineProperty(cx, ctor, parseFloatId, parseFloatValue, nullptr, nullptr, 0))
if (!DefineDataProperty(cx, ctor, parseFloatId, parseFloatValue, 0))
return nullptr;
RootedValue valueNaN(cx, cx->runtime()->NaNValue);

View File

@ -161,7 +161,7 @@ js::FromPropertyDescriptorToObject(JSContext* cx, Handle<PropertyDescriptor> des
// Step 4.
if (desc.hasValue()) {
if (!DefineProperty(cx, obj, names.value, desc.value()))
if (!DefineDataProperty(cx, obj, names.value, desc.value()))
return false;
}
@ -169,7 +169,7 @@ js::FromPropertyDescriptorToObject(JSContext* cx, Handle<PropertyDescriptor> des
RootedValue v(cx);
if (desc.hasWritable()) {
v.setBoolean(desc.writable());
if (!DefineProperty(cx, obj, names.writable, v))
if (!DefineDataProperty(cx, obj, names.writable, v))
return false;
}
@ -179,7 +179,7 @@ js::FromPropertyDescriptorToObject(JSContext* cx, Handle<PropertyDescriptor> des
v.setObject(*get);
else
v.setUndefined();
if (!DefineProperty(cx, obj, names.get, v))
if (!DefineDataProperty(cx, obj, names.get, v))
return false;
}
@ -189,21 +189,21 @@ js::FromPropertyDescriptorToObject(JSContext* cx, Handle<PropertyDescriptor> des
v.setObject(*set);
else
v.setUndefined();
if (!DefineProperty(cx, obj, names.set, v))
if (!DefineDataProperty(cx, obj, names.set, v))
return false;
}
// Step 8.
if (desc.hasEnumerable()) {
v.setBoolean(desc.enumerable());
if (!DefineProperty(cx, obj, names.enumerable, v))
if (!DefineDataProperty(cx, obj, names.enumerable, v))
return false;
}
// Step 9.
if (desc.hasConfigurable()) {
v.setBoolean(desc.configurable());
if (!DefineProperty(cx, obj, names.configurable, v))
if (!DefineDataProperty(cx, obj, names.configurable, v))
return false;
}
@ -1749,7 +1749,7 @@ DefineStandardSlot(JSContext* cx, HandleObject obj, JSProtoKey key, JSAtom* atom
HandleValue v, uint32_t attrs, bool& named)
{
RootedId id(cx, AtomToId(atom));
named = DefineProperty(cx, obj, id, v, nullptr, nullptr, attrs);
named = DefineDataProperty(cx, obj, id, v, attrs);
return named;
}
@ -2786,14 +2786,14 @@ js::DefineProperty(JSContext* cx, HandleObject obj, HandleId id, Handle<Property
}
bool
js::DefineProperty(JSContext* cx, HandleObject obj, HandleId id, HandleValue value,
JSGetterOp getter, JSSetterOp setter, unsigned attrs,
ObjectOpResult& result)
js::DefineAccessorProperty(JSContext* cx, HandleObject obj, HandleId id,
JSGetterOp getter, JSSetterOp setter, unsigned attrs,
ObjectOpResult& result)
{
MOZ_ASSERT(!(attrs & JSPROP_PROPOP_ACCESSORS));
Rooted<PropertyDescriptor> desc(cx);
desc.initFields(nullptr, value, attrs, getter, setter);
desc.initFields(nullptr, UndefinedHandleValue, attrs, getter, setter);
if (DefinePropertyOp op = obj->getOpsDefineProperty()) {
MOZ_ASSERT(!cx->helperThread());
return op(cx, obj, id, desc, result);
@ -2802,31 +2802,62 @@ js::DefineProperty(JSContext* cx, HandleObject obj, HandleId id, HandleValue val
}
bool
js::DefineProperty(JSContext* cx, HandleObject obj, PropertyName* name, HandleValue value,
JSGetterOp getter, JSSetterOp setter, unsigned attrs,
ObjectOpResult& result)
js::DefineDataProperty(JSContext* cx, HandleObject obj, HandleId id, HandleValue value,
unsigned attrs, ObjectOpResult& result)
{
RootedId id(cx, NameToId(name));
return DefineProperty(cx, obj, id, value, getter, setter, attrs, result);
Rooted<PropertyDescriptor> desc(cx);
desc.initFields(nullptr, value, attrs, nullptr, nullptr);
if (DefinePropertyOp op = obj->getOpsDefineProperty()) {
MOZ_ASSERT(!cx->helperThread());
return op(cx, obj, id, desc, result);
}
return NativeDefineProperty(cx, obj.as<NativeObject>(), id, desc, result);
}
bool
js::DefineElement(JSContext* cx, HandleObject obj, uint32_t index, HandleValue value,
JSGetterOp getter, JSSetterOp setter, unsigned attrs,
ObjectOpResult& result)
js::DefineAccessorProperty(JSContext* cx, HandleObject obj, PropertyName* name,
JSGetterOp getter, JSSetterOp setter, unsigned attrs,
ObjectOpResult& result)
{
RootedId id(cx, NameToId(name));
return DefineAccessorProperty(cx, obj, id, getter, setter, attrs, result);
}
bool
js::DefineDataProperty(JSContext* cx, HandleObject obj, PropertyName* name, HandleValue value,
unsigned attrs, ObjectOpResult& result)
{
RootedId id(cx, NameToId(name));
return DefineDataProperty(cx, obj, id, value, attrs, result);
}
bool
js::DefineAccessorElement(JSContext* cx, HandleObject obj, uint32_t index,
JSGetterOp getter, JSSetterOp setter, unsigned attrs,
ObjectOpResult& result)
{
RootedId id(cx);
if (!IndexToId(cx, index, &id))
return false;
return DefineProperty(cx, obj, id, value, getter, setter, attrs, result);
return DefineAccessorProperty(cx, obj, id, getter, setter, attrs, result);
}
bool
js::DefineProperty(JSContext* cx, HandleObject obj, HandleId id, HandleValue value,
JSGetterOp getter, JSSetterOp setter, unsigned attrs)
js::DefineDataElement(JSContext* cx, HandleObject obj, uint32_t index, HandleValue value,
unsigned attrs, ObjectOpResult& result)
{
RootedId id(cx);
if (!IndexToId(cx, index, &id))
return false;
return DefineDataProperty(cx, obj, id, value, attrs, result);
}
bool
js::DefineAccessorProperty(JSContext* cx, HandleObject obj, HandleId id,
JSGetterOp getter, JSSetterOp setter, unsigned attrs)
{
ObjectOpResult result;
if (!DefineProperty(cx, obj, id, value, getter, setter, attrs, result))
if (!DefineAccessorProperty(cx, obj, id, getter, setter, attrs, result))
return false;
if (!result) {
MOZ_ASSERT(!cx->helperThread());
@ -2837,23 +2868,55 @@ js::DefineProperty(JSContext* cx, HandleObject obj, HandleId id, HandleValue val
}
bool
js::DefineProperty(JSContext* cx, HandleObject obj, PropertyName* name, HandleValue value,
JSGetterOp getter, JSSetterOp setter, unsigned attrs)
js::DefineDataProperty(JSContext* cx, HandleObject obj, HandleId id, HandleValue value,
unsigned attrs)
{
RootedId id(cx, NameToId(name));
return DefineProperty(cx, obj, id, value, getter, setter, attrs);
ObjectOpResult result;
if (!DefineDataProperty(cx, obj, id, value, attrs, result))
return false;
if (!result) {
MOZ_ASSERT(!cx->helperThread());
result.reportError(cx, obj, id);
return false;
}
return true;
}
bool
js::DefineElement(JSContext* cx, HandleObject obj, uint32_t index, HandleValue value,
JSGetterOp getter, JSSetterOp setter, unsigned attrs)
js::DefineAccessorProperty(JSContext* cx, HandleObject obj, PropertyName* name,
JSGetterOp getter, JSSetterOp setter, unsigned attrs)
{
RootedId id(cx, NameToId(name));
return DefineAccessorProperty(cx, obj, id, getter, setter, attrs);
}
bool
js::DefineDataProperty(JSContext* cx, HandleObject obj, PropertyName* name, HandleValue value,
unsigned attrs)
{
RootedId id(cx, NameToId(name));
return DefineDataProperty(cx, obj, id, value, attrs);
}
bool
js::DefineAccessorElement(JSContext* cx, HandleObject obj, uint32_t index,
JSGetterOp getter, JSSetterOp setter, unsigned attrs)
{
RootedId id(cx);
if (!IndexToId(cx, index, &id))
return false;
return DefineProperty(cx, obj, id, value, getter, setter, attrs);
return DefineAccessorProperty(cx, obj, id, getter, setter, attrs);
}
bool
js::DefineDataElement(JSContext* cx, HandleObject obj, uint32_t index, HandleValue value,
unsigned attrs)
{
RootedId id(cx);
if (!IndexToId(cx, index, &id))
return false;
return DefineDataProperty(cx, obj, id, value, attrs);
}
/*** SpiderMonkey nonstandard internal methods ***************************************************/
@ -2983,7 +3046,7 @@ DefineFunctionFromSpec(JSContext* cx, HandleObject obj, const JSFunctionSpec* fs
fun->setIsIntrinsic();
RootedValue funVal(cx, ObjectValue(*fun));
return DefineProperty(cx, obj, id, funVal, nullptr, nullptr, flags & ~JSFUN_FLAGS_MASK);
return DefineDataProperty(cx, obj, id, funVal, flags & ~JSFUN_FLAGS_MASK);
}
bool

View File

@ -770,16 +770,31 @@ DefineProperty(JSContext* cx, HandleObject obj, HandleId id,
Handle<JS::PropertyDescriptor> desc, ObjectOpResult& result);
extern bool
DefineProperty(JSContext* cx, HandleObject obj, HandleId id, HandleValue value,
JSGetterOp getter, JSSetterOp setter, unsigned attrs, ObjectOpResult& result);
DefineAccessorProperty(JSContext* cx, HandleObject obj, HandleId id,
JSGetterOp getter, JSSetterOp setter, unsigned attrs,
ObjectOpResult& result);
extern bool
DefineProperty(JSContext* cx, HandleObject obj, PropertyName* name, HandleValue value,
JSGetterOp getter, JSSetterOp setter, unsigned attrs, ObjectOpResult& result);
DefineDataProperty(JSContext* cx, HandleObject obj, HandleId id, HandleValue value,
unsigned attrs, ObjectOpResult& result);
extern bool
DefineElement(JSContext* cx, HandleObject obj, uint32_t index, HandleValue value,
JSGetterOp getter, JSSetterOp setter, unsigned attrs, ObjectOpResult& result);
DefineAccessorProperty(JSContext* cx, HandleObject obj, PropertyName* name,
JSGetterOp getter, JSSetterOp setter, unsigned attrs,
ObjectOpResult& result);
extern bool
DefineDataProperty(JSContext* cx, HandleObject obj, PropertyName* name, HandleValue value,
unsigned attrs, ObjectOpResult& result);
extern bool
DefineAccessorElement(JSContext* cx, HandleObject obj, uint32_t index,
JSGetterOp getter, JSSetterOp setter, unsigned attrs,
ObjectOpResult& result);
extern bool
DefineDataElement(JSContext* cx, HandleObject obj, uint32_t index, HandleValue value,
unsigned attrs, ObjectOpResult& result);
/*
* When the 'result' out-param is omitted, the behavior is the same as above, except
@ -789,22 +804,28 @@ extern bool
DefineProperty(JSContext* cx, HandleObject obj, HandleId id, Handle<JS::PropertyDescriptor> desc);
extern bool
DefineProperty(JSContext* cx, HandleObject obj, HandleId id, HandleValue value,
JSGetterOp getter = nullptr,
JSSetterOp setter = nullptr,
unsigned attrs = JSPROP_ENUMERATE);
DefineAccessorProperty(JSContext* cx, HandleObject obj, HandleId id,
JSGetterOp getter, JSSetterOp setter, unsigned attrs = JSPROP_ENUMERATE);
extern bool
DefineProperty(JSContext* cx, HandleObject obj, PropertyName* name, HandleValue value,
JSGetterOp getter = nullptr,
JSSetterOp setter = nullptr,
unsigned attrs = JSPROP_ENUMERATE);
DefineDataProperty(JSContext* cx, HandleObject obj, HandleId id, HandleValue value,
unsigned attrs = JSPROP_ENUMERATE);
extern bool
DefineElement(JSContext* cx, HandleObject obj, uint32_t index, HandleValue value,
JSGetterOp getter = nullptr,
JSSetterOp setter = nullptr,
unsigned attrs = JSPROP_ENUMERATE);
DefineAccessorProperty(JSContext* cx, HandleObject obj, PropertyName* name,
JSGetterOp getter, JSSetterOp setter, unsigned attrs = JSPROP_ENUMERATE);
extern bool
DefineDataProperty(JSContext* cx, HandleObject obj, PropertyName* name, HandleValue value,
unsigned attrs = JSPROP_ENUMERATE);
extern bool
DefineAccessorElement(JSContext* cx, HandleObject obj, uint32_t index,
JSGetterOp getter, JSSetterOp setter, unsigned attrs = JSPROP_ENUMERATE);
extern bool
DefineDataElement(JSContext* cx, HandleObject obj, uint32_t index, HandleValue value,
unsigned attrs = JSPROP_ENUMERATE);
/*
* ES6 [[Has]]. Set *foundp to true if `id in obj` (that is, if obj has an own

View File

@ -872,7 +872,7 @@ Revive(JSContext* cx, HandleValue reviver, MutableHandleValue vp)
if (!obj)
return false;
if (!DefineProperty(cx, obj, cx->names().empty, vp))
if (!DefineDataProperty(cx, obj, cx->names().empty, vp))
return false;
Rooted<jsid> id(cx, NameToId(cx->names().empty));

View File

@ -528,11 +528,8 @@ str_enumerate(JSContext* cx, HandleObject obj)
if (!str1)
return false;
value.setString(str1);
if (!DefineElement(cx, obj, i, value, nullptr, nullptr,
STRING_ELEMENT_ATTRS | JSPROP_RESOLVING))
{
if (!DefineDataElement(cx, obj, i, value, STRING_ELEMENT_ATTRS | JSPROP_RESOLVING))
return false;
}
}
return true;
@ -559,8 +556,8 @@ str_resolve(JSContext* cx, HandleObject obj, HandleId id, bool* resolvedp)
if (!str1)
return false;
RootedValue value(cx, StringValue(str1));
if (!DefineElement(cx, obj, uint32_t(slot), value, nullptr, nullptr,
STRING_ELEMENT_ATTRS | JSPROP_RESOLVING))
if (!DefineDataElement(cx, obj, uint32_t(slot), value,
STRING_ELEMENT_ATTRS | JSPROP_RESOLVING))
{
return false;
}

View File

@ -223,7 +223,7 @@ js::SetPropertyIgnoringNamedGetter(JSContext* cx, HandleObject obj, HandleId id,
? JSPROP_IGNORE_ENUMERATE | JSPROP_IGNORE_READONLY | JSPROP_IGNORE_PERMANENT
: JSPROP_ENUMERATE;
return DefineProperty(cx, receiverObj, id, v, nullptr, nullptr, attrs, result);
return DefineDataProperty(cx, receiverObj, id, v, attrs, result);
}
// Step 6.

View File

@ -1420,8 +1420,8 @@ js::proxy_revocable(JSContext* cx, unsigned argc, Value* vp)
return false;
RootedValue revokeVal(cx, ObjectValue(*revoker));
if (!DefineProperty(cx, result, cx->names().proxy, proxyVal) ||
!DefineProperty(cx, result, cx->names().revoke, revokeVal))
if (!DefineDataProperty(cx, result, cx->names().proxy, proxyVal) ||
!DefineDataProperty(cx, result, cx->names().revoke, revokeVal))
{
return false;
}

View File

@ -6945,22 +6945,22 @@ CreateLastWarningObject(JSContext* cx, JSErrorReport* report)
if (!nameStr)
return false;
RootedValue nameVal(cx, StringValue(nameStr));
if (!DefineProperty(cx, warningObj, cx->names().name, nameVal))
if (!DefineDataProperty(cx, warningObj, cx->names().name, nameVal))
return false;
RootedString messageStr(cx, report->newMessageString(cx));
if (!messageStr)
return false;
RootedValue messageVal(cx, StringValue(messageStr));
if (!DefineProperty(cx, warningObj, cx->names().message, messageVal))
if (!DefineDataProperty(cx, warningObj, cx->names().message, messageVal))
return false;
RootedValue linenoVal(cx, Int32Value(report->lineno));
if (!DefineProperty(cx, warningObj, cx->names().lineNumber, linenoVal))
if (!DefineDataProperty(cx, warningObj, cx->names().lineNumber, linenoVal))
return false;
RootedValue columnVal(cx, Int32Value(report->column));
if (!DefineProperty(cx, warningObj, cx->names().columnNumber, columnVal))
if (!DefineDataProperty(cx, warningObj, cx->names().columnNumber, columnVal))
return false;
RootedObject notesArray(cx, CreateErrorNotesArray(cx, report));
@ -6968,7 +6968,7 @@ CreateLastWarningObject(JSContext* cx, JSErrorReport* report)
return false;
RootedValue notesArrayVal(cx, ObjectValue(*notesArray));
if (!DefineProperty(cx, warningObj, cx->names().notes, notesArrayVal))
if (!DefineDataProperty(cx, warningObj, cx->names().notes, notesArrayVal))
return false;
GetShellContext(cx)->lastWarning.setObject(*warningObj);

View File

@ -1193,7 +1193,7 @@ Debugger::wrapDebuggeeValue(JSContext* cx, MutableHandleValue vp)
}
RootedValue trueVal(cx, BooleanValue(true));
if (!DefineProperty(cx, optObj, name, trueVal))
if (!DefineDataProperty(cx, optObj, name, trueVal))
return false;
vp.setObject(*optObj);
@ -5949,11 +5949,11 @@ class DebuggerScriptGetOffsetLocationMatcher
RootedId id(cx_, NameToId(cx_->names().lineNumber));
RootedValue value(cx_, NumberValue(lineno));
if (!DefineProperty(cx_, result_, id, value))
if (!DefineDataProperty(cx_, result_, id, value))
return false;
value = NumberValue(column);
if (!DefineProperty(cx_, result_, cx_->names().columnNumber, value))
if (!DefineDataProperty(cx_, result_, cx_->names().columnNumber, value))
return false;
// The same entry point test that is used by getAllColumnOffsets.
@ -5962,7 +5962,7 @@ class DebuggerScriptGetOffsetLocationMatcher
(flowData[offset].lineno() != r.frontLineNumber() ||
flowData[offset].column() != r.frontColumnNumber()));
value.setBoolean(isEntryPoint);
if (!DefineProperty(cx_, result_, cx_->names().isEntryPoint, value))
if (!DefineDataProperty(cx_, result_, cx_->names().isEntryPoint, value))
return false;
return true;
@ -5986,15 +5986,15 @@ class DebuggerScriptGetOffsetLocationMatcher
RootedId id(cx_, NameToId(cx_->names().lineNumber));
RootedValue value(cx_, NumberValue(lineno));
if (!DefineProperty(cx_, result_, id, value))
if (!DefineDataProperty(cx_, result_, id, value))
return false;
value = NumberValue(column);
if (!DefineProperty(cx_, result_, cx_->names().columnNumber, value))
if (!DefineDataProperty(cx_, result_, cx_->names().columnNumber, value))
return false;
value.setBoolean(true);
if (!DefineProperty(cx_, result_, cx_->names().isEntryPoint, value))
if (!DefineDataProperty(cx_, result_, cx_->names().isEntryPoint, value))
return false;
return true;
@ -6077,7 +6077,7 @@ DebuggerScript_getAllOffsets(JSContext* cx, unsigned argc, Value* vp)
}
RootedValue value(cx, ObjectValue(*offsets));
if (!DefineProperty(cx, result, id, value))
if (!DefineDataProperty(cx, result, id, value))
return false;
}
@ -6103,16 +6103,16 @@ class DebuggerScriptGetAllColumnOffsetsMatcher
RootedId id(cx_, NameToId(cx_->names().lineNumber));
RootedValue value(cx_, NumberValue(lineno));
if (!DefineProperty(cx_, entry, id, value))
if (!DefineDataProperty(cx_, entry, id, value))
return false;
value = NumberValue(column);
if (!DefineProperty(cx_, entry, cx_->names().columnNumber, value))
if (!DefineDataProperty(cx_, entry, cx_->names().columnNumber, value))
return false;
id = NameToId(cx_->names().offset);
value = NumberValue(offset);
if (!DefineProperty(cx_, entry, id, value))
if (!DefineDataProperty(cx_, entry, id, value))
return false;
return NewbornArrayPush(cx_, result_, ObjectValue(*entry));
@ -6792,10 +6792,10 @@ DebuggerScript_getOffsetsCoverage(JSContext* cx, unsigned argc, Value* vp)
// number of hit counts, and append it to the array.
item = NewObjectWithGivenProto<PlainObject>(cx, nullptr);
if (!item ||
!DefineProperty(cx, item, offsetId, offsetValue) ||
!DefineProperty(cx, item, lineNumberId, lineNumberValue) ||
!DefineProperty(cx, item, columnNumberId, columnNumberValue) ||
!DefineProperty(cx, item, countId, countValue) ||
!DefineDataProperty(cx, item, offsetId, offsetValue) ||
!DefineDataProperty(cx, item, lineNumberId, lineNumberValue) ||
!DefineDataProperty(cx, item, columnNumberId, columnNumberValue) ||
!DefineDataProperty(cx, item, countId, countValue) ||
!NewbornArrayPush(cx, result, ObjectValue(*item)))
{
return false;
@ -11431,7 +11431,7 @@ Builder::Object::definePropertyToTrusted(JSContext* cx, const char* name,
return false;
RootedId id(cx, AtomToId(atom));
return DefineProperty(cx, value, id, trusted);
return DefineDataProperty(cx, value, id, trusted);
}
bool
@ -11556,11 +11556,8 @@ JS_DefineDebuggerObject(JSContext* cx, HandleObject obj)
return false;
debuggeeWouldRunCtor = global->getConstructor(JSProto_DebuggeeWouldRun);
RootedId debuggeeWouldRunId(cx, NameToId(ClassName(JSProto_DebuggeeWouldRun, cx)));
if (!DefineProperty(cx, debugCtor, debuggeeWouldRunId, debuggeeWouldRunCtor,
nullptr, nullptr, 0))
{
if (!DefineDataProperty(cx, debugCtor, debuggeeWouldRunId, debuggeeWouldRunCtor, 0))
return false;
}
debugProto->setReservedSlot(Debugger::JSSLOT_DEBUG_FRAME_PROTO, ObjectValue(*frameProto));
debugProto->setReservedSlot(Debugger::JSSLOT_DEBUG_OBJECT_PROTO, ObjectValue(*objectProto));
@ -11690,7 +11687,7 @@ DefineStringProperty(JSContext* cx, HandleObject obj, PropertyName* propName, co
return false;
val = StringValue(atomized);
}
return DefineProperty(cx, obj, propName, val);
return DefineDataProperty(cx, obj, propName, val);
}
JSObject*
@ -11701,7 +11698,7 @@ GarbageCollectionEvent::toJSObject(JSContext* cx) const
if (!obj ||
!DefineStringProperty(cx, obj, cx->names().nonincrementalReason, nonincrementalReason) ||
!DefineStringProperty(cx, obj, cx->names().reason, reason) ||
!DefineProperty(cx, obj, cx->names().gcCycleNumber, gcCycleNumberVal))
!DefineDataProperty(cx, obj, cx->names().gcCycleNumber, gcCycleNumberVal))
{
return nullptr;
}
@ -11721,19 +11718,19 @@ GarbageCollectionEvent::toJSObject(JSContext* cx) const
RootedValue start(cx), end(cx);
start = NumberValue((range.front().startTimestamp - originTime).ToMilliseconds());
end = NumberValue((range.front().endTimestamp - originTime).ToMilliseconds());
if (!DefineProperty(cx, collectionObj, cx->names().startTimestamp, start) ||
!DefineProperty(cx, collectionObj, cx->names().endTimestamp, end))
if (!DefineDataProperty(cx, collectionObj, cx->names().startTimestamp, start) ||
!DefineDataProperty(cx, collectionObj, cx->names().endTimestamp, end))
{
return nullptr;
}
RootedValue collectionVal(cx, ObjectValue(*collectionObj));
if (!DefineElement(cx, slicesArray, idx++, collectionVal))
if (!DefineDataElement(cx, slicesArray, idx++, collectionVal))
return nullptr;
}
RootedValue slicesValue(cx, ObjectValue(*slicesArray));
if (!DefineProperty(cx, obj, cx->names().collections, slicesValue))
if (!DefineDataProperty(cx, obj, cx->names().collections, slicesValue))
return nullptr;
return obj;

View File

@ -203,34 +203,34 @@ DebuggerMemory::drainAllocationsLog(JSContext* cx, unsigned argc, Value* vp)
Debugger::AllocationsLogEntry& entry = dbg->allocationsLog.front();
RootedValue frame(cx, ObjectOrNullValue(entry.frame));
if (!DefineProperty(cx, obj, cx->names().frame, frame))
if (!DefineDataProperty(cx, obj, cx->names().frame, frame))
return false;
double when = (entry.when -
mozilla::TimeStamp::ProcessCreation()).ToMilliseconds();
RootedValue timestampValue(cx, NumberValue(when));
if (!DefineProperty(cx, obj, cx->names().timestamp, timestampValue))
if (!DefineDataProperty(cx, obj, cx->names().timestamp, timestampValue))
return false;
RootedString className(cx, Atomize(cx, entry.className, strlen(entry.className)));
if (!className)
return false;
RootedValue classNameValue(cx, StringValue(className));
if (!DefineProperty(cx, obj, cx->names().class_, classNameValue))
if (!DefineDataProperty(cx, obj, cx->names().class_, classNameValue))
return false;
RootedValue ctorName(cx, NullValue());
if (entry.ctorName)
ctorName.setString(entry.ctorName);
if (!DefineProperty(cx, obj, cx->names().constructor, ctorName))
if (!DefineDataProperty(cx, obj, cx->names().constructor, ctorName))
return false;
RootedValue size(cx, NumberValue(entry.size));
if (!DefineProperty(cx, obj, cx->names().size, size))
if (!DefineDataProperty(cx, obj, cx->names().size, size))
return false;
RootedValue inNursery(cx, BooleanValue(entry.inNursery));
if (!DefineProperty(cx, obj, cx->names().inNursery, inNursery))
if (!DefineDataProperty(cx, obj, cx->names().inNursery, inNursery))
return false;
result->setDenseElement(i, ObjectValue(*obj));

View File

@ -279,5 +279,5 @@ js::ErrorObject::setStack_impl(JSContext* cx, const CallArgs& args)
return false;
RootedValue val(cx, args[0]);
return DefineProperty(cx, thisObj, cx->names().stack, val);
return DefineDataProperty(cx, thisObj, cx->names().stack, val);
}

View File

@ -226,7 +226,7 @@ GlobalObject::resolveConstructor(JSContext* cx, Handle<GlobalObject*> global, JS
if (isObjectOrFunction) {
if (clasp->specShouldDefineConstructor()) {
RootedValue ctorValue(cx, ObjectValue(*ctor));
if (!DefineProperty(cx, global, id, ctorValue, nullptr, nullptr, JSPROP_RESOLVING))
if (!DefineDataProperty(cx, global, id, ctorValue, JSPROP_RESOLVING))
return false;
}
@ -271,7 +271,7 @@ GlobalObject::resolveConstructor(JSContext* cx, Handle<GlobalObject*> global, JS
// Fallible operation that modifies the global object.
if (clasp->specShouldDefineConstructor()) {
RootedValue ctorValue(cx, ObjectValue(*ctor));
if (!DefineProperty(cx, global, id, ctorValue, nullptr, nullptr, JSPROP_RESOLVING))
if (!DefineDataProperty(cx, global, id, ctorValue, JSPROP_RESOLVING))
return false;
}
@ -297,7 +297,7 @@ GlobalObject::initBuiltinConstructor(JSContext* cx, Handle<GlobalObject*> global
MOZ_ASSERT(!global->lookup(cx, id));
RootedValue ctorValue(cx, ObjectValue(*ctor));
if (!DefineProperty(cx, global, id, ctorValue, nullptr, nullptr, JSPROP_RESOLVING))
if (!DefineDataProperty(cx, global, id, ctorValue, JSPROP_RESOLVING))
return false;
global->setConstructor(key, ObjectValue(*ctor));
@ -405,8 +405,8 @@ GlobalObject::valueIsEval(const Value& val)
GlobalObject::initStandardClasses(JSContext* cx, Handle<GlobalObject*> global)
{
/* Define a top-level property 'undefined' with the undefined value. */
if (!DefineProperty(cx, global, cx->names().undefined, UndefinedHandleValue,
nullptr, nullptr, JSPROP_PERMANENT | JSPROP_READONLY | JSPROP_RESOLVING))
if (!DefineDataProperty(cx, global, cx->names().undefined, UndefinedHandleValue,
JSPROP_PERMANENT | JSPROP_READONLY | JSPROP_RESOLVING))
{
return false;
}
@ -452,8 +452,8 @@ GlobalObject::initSelfHostingBuiltins(JSContext* cx, Handle<GlobalObject*> globa
const JSFunctionSpec* builtins)
{
// Define a top-level property 'undefined' with the undefined value.
if (!DefineProperty(cx, global, cx->names().undefined, UndefinedHandleValue,
nullptr, nullptr, JSPROP_PERMANENT | JSPROP_READONLY))
if (!DefineDataProperty(cx, global, cx->names().undefined, UndefinedHandleValue,
JSPROP_PERMANENT | JSPROP_READONLY))
{
return false;
}
@ -596,10 +596,8 @@ js::LinkConstructorAndPrototype(JSContext* cx, JSObject* ctor_, JSObject* proto_
RootedValue protoVal(cx, ObjectValue(*proto));
RootedValue ctorVal(cx, ObjectValue(*ctor));
return DefineProperty(cx, ctor, cx->names().prototype, protoVal, nullptr, nullptr,
prototypeAttrs) &&
DefineProperty(cx, proto, cx->names().constructor, ctorVal, nullptr, nullptr,
constructorAttrs);
return DefineDataProperty(cx, ctor, cx->names().prototype, protoVal, prototypeAttrs) &&
DefineDataProperty(cx, proto, cx->names().constructor, ctorVal, constructorAttrs);
}
bool
@ -618,7 +616,7 @@ js::DefineToStringTag(JSContext* cx, HandleObject obj, JSAtom* tag)
{
RootedId toStringTagId(cx, SYMBOL_TO_JSID(cx->wellKnownSymbols().toStringTag));
RootedValue tagString(cx, StringValue(tag));
return DefineProperty(cx, obj, toStringTagId, tagString, nullptr, nullptr, JSPROP_READONLY);
return DefineDataProperty(cx, obj, toStringTagId, tagString, JSPROP_READONLY);
}
static void
@ -745,8 +743,8 @@ GlobalObject::getIntrinsicsHolder(JSContext* cx, Handle<GlobalObject*> global)
/* Define a property 'global' with the current global as its value. */
RootedValue globalValue(cx, ObjectValue(*global));
if (!DefineProperty(cx, intrinsicsHolder, cx->names().global, globalValue,
nullptr, nullptr, JSPROP_PERMANENT | JSPROP_READONLY))
if (!DefineDataProperty(cx, intrinsicsHolder, cx->names().global, globalValue,
JSPROP_PERMANENT | JSPROP_READONLY))
{
return nullptr;
}

View File

@ -436,7 +436,7 @@ DefVarOperation(JSContext* cx, HandleObject varobj, HandlePropertyName dn, unsig
/* Steps 8c, 8d. */
if (!prop || (obj2 != varobj && varobj->is<GlobalObject>())) {
if (!DefineProperty(cx, varobj, dn, UndefinedHandleValue, nullptr, nullptr, attrs))
if (!DefineDataProperty(cx, varobj, dn, UndefinedHandleValue, attrs))
return false;
}
@ -648,7 +648,7 @@ InitElemOperation(JSContext* cx, jsbytecode* pc, HandleObject obj, HandleValue i
return false;
unsigned flags = GetInitDataPropAttrs(JSOp(*pc));
return DefineProperty(cx, obj, id, val, nullptr, nullptr, flags);
return DefineDataProperty(cx, obj, id, val, flags);
}
static MOZ_ALWAYS_INLINE bool
@ -682,7 +682,7 @@ InitArrayElemOperation(JSContext* cx, jsbytecode* pc, HandleObject obj, uint32_t
return false;
}
} else {
if (!DefineElement(cx, obj, index, val, nullptr, nullptr, JSPROP_ENUMERATE))
if (!DefineDataElement(cx, obj, index, val, JSPROP_ENUMERATE))
return false;
}

View File

@ -4498,7 +4498,7 @@ js::DefFunOperation(JSContext* cx, HandleScript script, HandleObject envChain,
/* Steps 5d, 5f. */
if (!prop || pobj != parent) {
if (!DefineProperty(cx, parent, name, rval, nullptr, nullptr, attrs))
if (!DefineDataProperty(cx, parent, name, rval, attrs))
return false;
return parent->is<GlobalObject>() ? parent->compartment()->addToVarNames(cx, name) : true;
@ -4517,7 +4517,7 @@ js::DefFunOperation(JSContext* cx, HandleScript script, HandleObject envChain,
if (parent->is<GlobalObject>()) {
Shape* shape = prop.shape();
if (shape->configurable()) {
if (!DefineProperty(cx, parent, name, rval, nullptr, nullptr, attrs))
if (!DefineDataProperty(cx, parent, name, rval, attrs))
return false;
} else {
MOZ_ASSERT(shape->isDataDescriptor());
@ -4835,8 +4835,7 @@ js::InitGetterSetterOperation(JSContext* cx, jsbytecode* pc, HandleObject obj, H
attrs |= JSPROP_SETTER;
}
RootedValue scratch(cx);
return DefineProperty(cx, obj, id, scratch, getter, setter, attrs);
return DefineAccessorProperty(cx, obj, id, getter, setter, attrs);
}
bool

View File

@ -2570,7 +2570,7 @@ js::SetPropertyByDefining(JSContext* cx, HandleId id, HandleValue v, HandleValue
existing
? JSPROP_IGNORE_ENUMERATE | JSPROP_IGNORE_READONLY | JSPROP_IGNORE_PERMANENT
: JSPROP_ENUMERATE;
return DefineProperty(cx, receiver, id, v, nullptr, nullptr, attrs, result);
return DefineDataProperty(cx, receiver, id, v, attrs, result);
}
// When setting |id| for |receiver| and |obj| has no property for id, continue

View File

@ -457,9 +457,8 @@ intrinsic_MakeConstructible(JSContext* cx, unsigned argc, Value* vp)
// Normal .prototype properties aren't enumerable. But for this to clone
// correctly, it must be enumerable.
RootedObject ctor(cx, &args[0].toObject());
if (!DefineProperty(cx, ctor, cx->names().prototype, args[1],
nullptr, nullptr,
JSPROP_READONLY | JSPROP_ENUMERATE | JSPROP_PERMANENT))
if (!DefineDataProperty(cx, ctor, cx->names().prototype, args[1],
JSPROP_READONLY | JSPROP_ENUMERATE | JSPROP_PERMANENT))
{
return false;
}

View File

@ -2557,7 +2557,7 @@ JSStructuredCloneReader::read(MutableHandleValue vp)
if (!ValueToId<CanGC>(context(), key, &id))
return false;
if (!DefineProperty(context(), obj, id, val))
if (!DefineDataProperty(context(), obj, id, val))
return false;
}
}

View File

@ -102,11 +102,11 @@ SimpleCount::report(JSContext* cx, CountBase& countBase, MutableHandleValue repo
return false;
RootedValue countValue(cx, NumberValue(count.total_));
if (reportCount && !DefineProperty(cx, obj, cx->names().count, countValue))
if (reportCount && !DefineDataProperty(cx, obj, cx->names().count, countValue))
return false;
RootedValue bytesValue(cx, NumberValue(count.totalBytes_));
if (reportBytes && !DefineProperty(cx, obj, cx->names().bytes, bytesValue))
if (reportBytes && !DefineDataProperty(cx, obj, cx->names().bytes, bytesValue))
return false;
if (label) {
@ -114,7 +114,7 @@ SimpleCount::report(JSContext* cx, CountBase& countBase, MutableHandleValue repo
if (!labelString)
return false;
RootedValue labelValue(cx, StringValue(labelString));
if (!DefineProperty(cx, obj, cx->names().label, labelValue))
if (!DefineDataProperty(cx, obj, cx->names().label, labelValue))
return false;
}
@ -290,22 +290,22 @@ ByCoarseType::report(JSContext* cx, CountBase& countBase, MutableHandleValue rep
RootedValue objectsReport(cx);
if (!count.objects->report(cx, &objectsReport) ||
!DefineProperty(cx, obj, cx->names().objects, objectsReport))
!DefineDataProperty(cx, obj, cx->names().objects, objectsReport))
return false;
RootedValue scriptsReport(cx);
if (!count.scripts->report(cx, &scriptsReport) ||
!DefineProperty(cx, obj, cx->names().scripts, scriptsReport))
!DefineDataProperty(cx, obj, cx->names().scripts, scriptsReport))
return false;
RootedValue stringsReport(cx);
if (!count.strings->report(cx, &stringsReport) ||
!DefineProperty(cx, obj, cx->names().strings, stringsReport))
!DefineDataProperty(cx, obj, cx->names().strings, stringsReport))
return false;
RootedValue otherReport(cx);
if (!count.other->report(cx, &otherReport) ||
!DefineProperty(cx, obj, cx->names().other, otherReport))
!DefineDataProperty(cx, obj, cx->names().other, otherReport))
return false;
report.setObject(*obj);
@ -378,7 +378,7 @@ countMapToObject(JSContext* cx, Map& map, GetName getName) {
return nullptr;
RootedId entryId(cx, AtomToId(atom));
if (!DefineProperty(cx, obj, entryId, thenReport))
if (!DefineDataProperty(cx, obj, entryId, thenReport))
return nullptr;
}
@ -484,7 +484,7 @@ ByObjectClass::report(JSContext* cx, CountBase& countBase, MutableHandleValue re
RootedValue otherReport(cx);
if (!count.other->report(cx, &otherReport) ||
!DefineProperty(cx, obj, cx->names().other, otherReport))
!DefineDataProperty(cx, obj, cx->names().other, otherReport))
return false;
report.setObject(*obj);
@ -595,7 +595,7 @@ ByUbinodeType::report(JSContext* cx, CountBase& countBase, MutableHandleValue re
return false;
RootedId entryId(cx, AtomToId(atom));
if (!DefineProperty(cx, obj, entryId, typeReport))
if (!DefineDataProperty(cx, obj, entryId, typeReport))
return false;
}
@ -903,7 +903,7 @@ ByFilename::report(JSContext* cx, CountBase& countBase, MutableHandleValue repor
RootedValue noFilenameReport(cx);
if (!count.noFilename->report(cx, &noFilenameReport) ||
!DefineProperty(cx, obj, cx->names().noFilename, noFilenameReport))
!DefineDataProperty(cx, obj, cx->names().noFilename, noFilenameReport))
{
return false;
}

View File

@ -2201,7 +2201,7 @@ InitConstructor(JSContext* cx, HandleObject wasm, const char* name, MutableHandl
RootedId id(cx, AtomToId(className));
RootedValue ctorValue(cx, ObjectValue(*ctor));
return DefineProperty(cx, wasm, id, ctorValue, nullptr, nullptr, 0);
return DefineDataProperty(cx, wasm, id, ctorValue, 0);
}
static bool
@ -2218,7 +2218,7 @@ InitErrorClass(JSContext* cx, HandleObject wasm, const char* name, JSExnType exn
RootedId id(cx, AtomToId(className));
RootedValue ctorValue(cx, global->getConstructor(GetExceptionProtoKey(exn)));
return DefineProperty(cx, wasm, id, ctorValue, nullptr, nullptr, 0);
return DefineDataProperty(cx, wasm, id, ctorValue, 0);
}
JSObject*