зеркало из https://github.com/mozilla/gecko-dev.git
Back out 62ab5e142af3, 387c21d5c4e3, e3138a3efe4a, d8b09e2a11f1, 8add4271e98c, and ead219581dbe for bustage. r=badness-10000 in a CLOSED TREE
This commit is contained in:
Родитель
dc7d7fd07d
Коммит
9bc7583ece
|
@ -704,7 +704,7 @@ struct JSClass {
|
|||
// application.
|
||||
#define JSCLASS_GLOBAL_APPLICATION_SLOTS 5
|
||||
#define JSCLASS_GLOBAL_SLOT_COUNT \
|
||||
(JSCLASS_GLOBAL_APPLICATION_SLOTS + JSProto_LIMIT * 3 + 35)
|
||||
(JSCLASS_GLOBAL_APPLICATION_SLOTS + JSProto_LIMIT * 3 + 33)
|
||||
#define JSCLASS_GLOBAL_FLAGS_WITH_SLOTS(n) \
|
||||
(JSCLASS_IS_GLOBAL | JSCLASS_HAS_RESERVED_SLOTS(JSCLASS_GLOBAL_SLOT_COUNT + (n)))
|
||||
#define JSCLASS_GLOBAL_FLAGS \
|
||||
|
|
|
@ -50,8 +50,7 @@ BaselineFrame::trace(JSTracer* trc, JitFrameIterator& frameIterator)
|
|||
|
||||
if (isEvalFrame()) {
|
||||
TraceRoot(trc, &evalScript_, "baseline-evalscript");
|
||||
if (isFunctionFrame())
|
||||
TraceRoot(trc, evalNewTargetAddress(), "baseline-evalNewTarget");
|
||||
TraceRoot(trc, evalNewTargetAddress(), "baseline-evalNewTarget");
|
||||
}
|
||||
|
||||
if (hasArgsObj())
|
||||
|
|
|
@ -225,7 +225,6 @@ class BaselineFrame
|
|||
private:
|
||||
Value* evalNewTargetAddress() const {
|
||||
MOZ_ASSERT(isEvalFrame());
|
||||
MOZ_ASSERT(isFunctionFrame());
|
||||
return (Value*)(reinterpret_cast<const uint8_t*>(this) +
|
||||
BaselineFrame::Size() +
|
||||
offsetOfEvalNewTarget());
|
||||
|
|
|
@ -2727,7 +2727,7 @@ jit::SetEnterJitData(JSContext* cx, EnterJitData& data, RunState& state, AutoVal
|
|||
data.calleeToken = CalleeToToken(state.script());
|
||||
|
||||
if (state.script()->isForEval() &&
|
||||
(state.asExecute()->type() & InterpreterFrame::FUNCTION))
|
||||
!(state.asExecute()->type() & InterpreterFrame::GLOBAL))
|
||||
{
|
||||
ScriptFrameIter iter(cx);
|
||||
if (iter.isFunctionFrame())
|
||||
|
|
|
@ -1373,96 +1373,86 @@ const Class StopIterationObject::class_ = {
|
|||
};
|
||||
|
||||
/* static */ bool
|
||||
GlobalObject::initArrayIteratorProto(JSContext* cx, Handle<GlobalObject*> global)
|
||||
GlobalObject::initIteratorClasses(JSContext* cx, Handle<GlobalObject*> global)
|
||||
{
|
||||
if (global->getReservedSlot(ARRAY_ITERATOR_PROTO).isObject())
|
||||
return true;
|
||||
RootedObject iteratorProto(cx);
|
||||
Value iteratorProtoVal = global->getPrototype(JSProto_Iterator);
|
||||
if (iteratorProtoVal.isObject()) {
|
||||
iteratorProto = &iteratorProtoVal.toObject();
|
||||
} else {
|
||||
iteratorProto = global->createBlankPrototype(cx, &PropertyIteratorObject::class_);
|
||||
if (!iteratorProto)
|
||||
return false;
|
||||
|
||||
RootedObject iteratorProto(cx, GlobalObject::getOrCreateIteratorPrototype(cx, global));
|
||||
if (!iteratorProto)
|
||||
return false;
|
||||
AutoIdVector blank(cx);
|
||||
NativeIterator* ni = NativeIterator::allocateIterator(cx, 0, blank);
|
||||
if (!ni)
|
||||
return false;
|
||||
ni->init(nullptr, nullptr, 0 /* flags */, 0, 0);
|
||||
|
||||
const Class* cls = &ArrayIteratorPrototypeClass;
|
||||
RootedObject proto(cx, global->createBlankPrototypeInheriting(cx, cls, iteratorProto));
|
||||
if (!proto || !DefinePropertiesAndFunctions(cx, proto, nullptr, array_iterator_methods))
|
||||
return false;
|
||||
iteratorProto->as<PropertyIteratorObject>().setNativeIterator(ni);
|
||||
|
||||
global->setReservedSlot(ARRAY_ITERATOR_PROTO, ObjectValue(*proto));
|
||||
return true;
|
||||
Rooted<JSFunction*> ctor(cx);
|
||||
ctor = global->createConstructor(cx, IteratorConstructor, cx->names().Iterator, 2);
|
||||
if (!ctor)
|
||||
return false;
|
||||
if (!LinkConstructorAndPrototype(cx, ctor, iteratorProto))
|
||||
return false;
|
||||
if (!DefinePropertiesAndFunctions(cx, iteratorProto, nullptr, iterator_methods))
|
||||
return false;
|
||||
if (!GlobalObject::initBuiltinConstructor(cx, global, JSProto_Iterator,
|
||||
ctor, iteratorProto))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
RootedObject proto(cx);
|
||||
if (global->getSlot(ARRAY_ITERATOR_PROTO).isUndefined()) {
|
||||
const Class* cls = &ArrayIteratorPrototypeClass;
|
||||
proto = global->createBlankPrototypeInheriting(cx, cls, iteratorProto);
|
||||
if (!proto || !DefinePropertiesAndFunctions(cx, proto, nullptr, array_iterator_methods))
|
||||
return false;
|
||||
global->setReservedSlot(ARRAY_ITERATOR_PROTO, ObjectValue(*proto));
|
||||
}
|
||||
|
||||
if (global->getSlot(STRING_ITERATOR_PROTO).isUndefined()) {
|
||||
const Class* cls = &StringIteratorPrototypeClass;
|
||||
proto = global->createBlankPrototype(cx, cls);
|
||||
if (!proto || !DefinePropertiesAndFunctions(cx, proto, nullptr, string_iterator_methods))
|
||||
return false;
|
||||
global->setReservedSlot(STRING_ITERATOR_PROTO, ObjectValue(*proto));
|
||||
}
|
||||
|
||||
return GlobalObject::initStopIterationClass(cx, global);
|
||||
}
|
||||
|
||||
/* static */ bool
|
||||
GlobalObject::initStringIteratorProto(JSContext* cx, Handle<GlobalObject*> global)
|
||||
GlobalObject::initStopIterationClass(JSContext* cx, Handle<GlobalObject*> global)
|
||||
{
|
||||
if (global->getReservedSlot(STRING_ITERATOR_PROTO).isObject())
|
||||
if (!global->getPrototype(JSProto_StopIteration).isUndefined())
|
||||
return true;
|
||||
|
||||
RootedObject iteratorProto(cx, GlobalObject::getOrCreateIteratorPrototype(cx, global));
|
||||
if (!iteratorProto)
|
||||
RootedObject proto(cx, global->createBlankPrototype(cx, &StopIterationObject::class_));
|
||||
if (!proto || !FreezeObject(cx, proto))
|
||||
return false;
|
||||
|
||||
const Class* cls = &StringIteratorPrototypeClass;
|
||||
RootedObject proto(cx, global->createBlankPrototypeInheriting(cx, cls, iteratorProto));
|
||||
if (!proto || !DefinePropertiesAndFunctions(cx, proto, nullptr, string_iterator_methods))
|
||||
// This should use a non-JSProtoKey'd slot, but this is easier for now.
|
||||
if (!GlobalObject::initBuiltinConstructor(cx, global, JSProto_StopIteration, proto, proto))
|
||||
return false;
|
||||
|
||||
global->setReservedSlot(STRING_ITERATOR_PROTO, ObjectValue(*proto));
|
||||
global->setConstructor(JSProto_StopIteration, ObjectValue(*proto));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
JSObject*
|
||||
js::InitIteratorClass(JSContext* cx, HandleObject obj)
|
||||
js::InitIteratorClasses(JSContext* cx, HandleObject obj)
|
||||
{
|
||||
Handle<GlobalObject*> global = obj.as<GlobalObject>();
|
||||
|
||||
if (global->getPrototype(JSProto_Iterator).isObject())
|
||||
return &global->getPrototype(JSProto_Iterator).toObject();
|
||||
|
||||
RootedObject iteratorProto(cx);
|
||||
iteratorProto = global->createBlankPrototype(cx, &PropertyIteratorObject::class_);
|
||||
if (!iteratorProto)
|
||||
Rooted<GlobalObject*> global(cx, &obj->as<GlobalObject>());
|
||||
if (!GlobalObject::initIteratorClasses(cx, global))
|
||||
return nullptr;
|
||||
|
||||
AutoIdVector blank(cx);
|
||||
NativeIterator* ni = NativeIterator::allocateIterator(cx, 0, blank);
|
||||
if (!ni)
|
||||
if (!GlobalObject::initGeneratorClasses(cx, global))
|
||||
return nullptr;
|
||||
ni->init(nullptr, nullptr, 0 /* flags */, 0, 0);
|
||||
|
||||
iteratorProto->as<PropertyIteratorObject>().setNativeIterator(ni);
|
||||
|
||||
Rooted<JSFunction*> ctor(cx);
|
||||
ctor = global->createConstructor(cx, IteratorConstructor, cx->names().Iterator, 2);
|
||||
if (!ctor)
|
||||
return nullptr;
|
||||
if (!LinkConstructorAndPrototype(cx, ctor, iteratorProto))
|
||||
return nullptr;
|
||||
if (!DefinePropertiesAndFunctions(cx, iteratorProto, nullptr, iterator_methods))
|
||||
return nullptr;
|
||||
if (!GlobalObject::initBuiltinConstructor(cx, global, JSProto_Iterator,
|
||||
ctor, iteratorProto))
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return &global->getPrototype(JSProto_Iterator).toObject();
|
||||
}
|
||||
|
||||
JSObject*
|
||||
js::InitStopIterationClass(JSContext* cx, HandleObject obj)
|
||||
{
|
||||
Handle<GlobalObject*> global = obj.as<GlobalObject>();
|
||||
if (!global->getPrototype(JSProto_StopIteration).isObject()) {
|
||||
RootedObject proto(cx, global->createBlankPrototype(cx, &StopIterationObject::class_));
|
||||
if (!proto || !FreezeObject(cx, proto))
|
||||
return nullptr;
|
||||
|
||||
// This should use a non-JSProtoKey'd slot, but this is easier for now.
|
||||
if (!GlobalObject::initBuiltinConstructor(cx, global, JSProto_StopIteration, proto, proto))
|
||||
return nullptr;
|
||||
|
||||
global->setConstructor(JSProto_StopIteration, ObjectValue(*proto));
|
||||
}
|
||||
|
||||
return &global->getPrototype(JSProto_StopIteration).toObject();
|
||||
return global->getIteratorPrototype();
|
||||
}
|
||||
|
|
|
@ -208,10 +208,7 @@ extern JSObject*
|
|||
CreateItrResultObject(JSContext* cx, HandleValue value, bool done);
|
||||
|
||||
extern JSObject*
|
||||
InitIteratorClass(JSContext* cx, HandleObject obj);
|
||||
|
||||
extern JSObject*
|
||||
InitStopIterationClass(JSContext* cx, HandleObject obj);
|
||||
InitIteratorClasses(JSContext* cx, HandleObject obj);
|
||||
|
||||
} /* namespace js */
|
||||
|
||||
|
|
|
@ -76,8 +76,8 @@
|
|||
real(SyntaxError, 16, InitViaClassSpec, ERROR_CLASP(JSEXN_SYNTAXERR)) \
|
||||
real(TypeError, 17, InitViaClassSpec, ERROR_CLASP(JSEXN_TYPEERR)) \
|
||||
real(URIError, 18, InitViaClassSpec, ERROR_CLASP(JSEXN_URIERR)) \
|
||||
real(Iterator, 19, InitIteratorClass, OCLASP(PropertyIterator)) \
|
||||
real(StopIteration, 20, InitStopIterationClass, OCLASP(StopIteration)) \
|
||||
real(Iterator, 19, InitIteratorClasses, OCLASP(PropertyIterator)) \
|
||||
real(StopIteration, 20, InitIteratorClasses, OCLASP(StopIteration)) \
|
||||
real(ArrayBuffer, 21, InitArrayBufferClass, &js::ArrayBufferObject::protoClass) \
|
||||
real(Int8Array, 22, InitViaClassSpec, TYPED_ARRAY_CLASP(Int8)) \
|
||||
real(Uint8Array, 23, InitViaClassSpec, TYPED_ARRAY_CLASP(Uint8)) \
|
||||
|
@ -97,7 +97,7 @@
|
|||
IF_SAB(real,imaginary)(SharedArrayBuffer, 37, InitSharedArrayBufferClass, &js::SharedArrayBufferObject::protoClass) \
|
||||
IF_INTL(real,imaginary) (Intl, 38, InitIntlClass, CLASP(Intl)) \
|
||||
IF_BDATA(real,imaginary)(TypedObject, 39, InitTypedObjectModuleObject, OCLASP(TypedObjectModule)) \
|
||||
real(Reflect, 40, InitReflect, nullptr) \
|
||||
imaginary(GeneratorFunction, 40, InitIteratorClasses, dummy) \
|
||||
IF_BDATA(real,imaginary)(SIMD, 41, InitSIMDClass, OCLASP(SIMD)) \
|
||||
real(WeakSet, 42, InitWeakSetClass, OCLASP(WeakSet)) \
|
||||
IF_SAB(real,imaginary)(SharedInt8Array, 43, InitViaClassSpec, SHARED_TYPED_ARRAY_CLASP(Int8)) \
|
||||
|
@ -112,9 +112,10 @@ IF_SAB(real,imaginary)(SharedUint8ClampedArray, 51, InitViaClassSpec,
|
|||
real(TypedArray, 52, InitViaClassSpec, &js::TypedArrayObject::sharedTypedArrayPrototypeClass) \
|
||||
IF_SAB(real,imaginary)(Atomics, 53, InitAtomicsClass, OCLASP(Atomics)) \
|
||||
real(SavedFrame, 54, InitViaClassSpec, &js::SavedFrame::class_) \
|
||||
real(Module, 55, InitModuleClass, OCLASP(Module)) \
|
||||
real(ImportEntry, 56, InitImportEntryClass, OCLASP(ImportEntry)) \
|
||||
real(ExportEntry, 57, InitExportEntryClass, OCLASP(ExportEntry)) \
|
||||
real(Reflect, 55, InitReflect, nullptr) \
|
||||
real(Module, 56, InitModuleClass, OCLASP(Module)) \
|
||||
real(ImportEntry, 57, InitImportEntryClass, OCLASP(ImportEntry)) \
|
||||
real(ExportEntry, 58, InitExportEntryClass, OCLASP(ExportEntry)) \
|
||||
|
||||
#define JS_FOR_EACH_PROTOTYPE(macro) JS_FOR_PROTOTYPES(macro,macro)
|
||||
|
||||
|
|
|
@ -93,7 +93,6 @@
|
|||
macro(frame, frame, "frame") \
|
||||
macro(from, from, "from") \
|
||||
macro(gcCycleNumber, gcCycleNumber, "gcCycleNumber") \
|
||||
macro(GeneratorFunction, GeneratorFunction, "GeneratorFunction") \
|
||||
macro(get, get, "get") \
|
||||
macro(getInternals, getInternals, "getInternals") \
|
||||
macro(getOwnPropertyDescriptor, getOwnPropertyDescriptor, "getOwnPropertyDescriptor") \
|
||||
|
|
|
@ -287,52 +287,45 @@ NewSingletonObjectWithFunctionPrototype(JSContext* cx, Handle<GlobalObject*> glo
|
|||
}
|
||||
|
||||
/* static */ bool
|
||||
GlobalObject::initLegacyGeneratorProto(JSContext* cx, Handle<GlobalObject*> global)
|
||||
GlobalObject::initGeneratorClasses(JSContext* cx, Handle<GlobalObject*> global)
|
||||
{
|
||||
if (global->getReservedSlot(LEGACY_GENERATOR_OBJECT_PROTO).isObject())
|
||||
return true;
|
||||
if (global->getSlot(LEGACY_GENERATOR_OBJECT_PROTO).isUndefined()) {
|
||||
RootedObject proto(cx, NewSingletonObjectWithObjectPrototype(cx, global));
|
||||
if (!proto || !DefinePropertiesAndFunctions(cx, proto, nullptr, legacy_generator_methods))
|
||||
return false;
|
||||
global->setReservedSlot(LEGACY_GENERATOR_OBJECT_PROTO, ObjectValue(*proto));
|
||||
}
|
||||
|
||||
RootedObject proto(cx, NewSingletonObjectWithObjectPrototype(cx, global));
|
||||
if (!proto || !DefinePropertiesAndFunctions(cx, proto, nullptr, legacy_generator_methods))
|
||||
return false;
|
||||
if (global->getSlot(STAR_GENERATOR_OBJECT_PROTO).isUndefined()) {
|
||||
RootedObject genObjectProto(cx, NewSingletonObjectWithObjectPrototype(cx, global));
|
||||
if (!genObjectProto)
|
||||
return false;
|
||||
if (!DefinePropertiesAndFunctions(cx, genObjectProto, nullptr, star_generator_methods))
|
||||
return false;
|
||||
|
||||
RootedObject genFunctionProto(cx, NewSingletonObjectWithFunctionPrototype(cx, global));
|
||||
if (!genFunctionProto)
|
||||
return false;
|
||||
if (!LinkConstructorAndPrototype(cx, genFunctionProto, genObjectProto))
|
||||
return false;
|
||||
|
||||
RootedValue function(cx, global->getConstructor(JSProto_Function));
|
||||
if (!function.toObjectOrNull())
|
||||
return false;
|
||||
RootedObject proto(cx, &function.toObject());
|
||||
RootedAtom name(cx, cx->names().GeneratorFunction);
|
||||
RootedObject genFunction(cx, NewFunctionWithProto(cx, Generator, 1,
|
||||
JSFunction::NATIVE_CTOR, nullptr, name,
|
||||
proto));
|
||||
if (!genFunction)
|
||||
return false;
|
||||
if (!LinkConstructorAndPrototype(cx, genFunction, genFunctionProto))
|
||||
return false;
|
||||
|
||||
global->setSlot(STAR_GENERATOR_OBJECT_PROTO, ObjectValue(*genObjectProto));
|
||||
global->setConstructor(JSProto_GeneratorFunction, ObjectValue(*genFunction));
|
||||
global->setPrototype(JSProto_GeneratorFunction, ObjectValue(*genFunctionProto));
|
||||
}
|
||||
|
||||
global->setReservedSlot(LEGACY_GENERATOR_OBJECT_PROTO, ObjectValue(*proto));
|
||||
return true;
|
||||
}
|
||||
|
||||
/* static */ bool
|
||||
GlobalObject::initStarGenerators(JSContext* cx, Handle<GlobalObject*> global)
|
||||
{
|
||||
if (global->getReservedSlot(STAR_GENERATOR_OBJECT_PROTO).isObject())
|
||||
return true;
|
||||
|
||||
RootedObject genObjectProto(cx, NewSingletonObjectWithObjectPrototype(cx, global));
|
||||
if (!genObjectProto)
|
||||
return false;
|
||||
if (!DefinePropertiesAndFunctions(cx, genObjectProto, nullptr, star_generator_methods))
|
||||
return false;
|
||||
|
||||
RootedObject genFunctionProto(cx, NewSingletonObjectWithFunctionPrototype(cx, global));
|
||||
if (!genFunctionProto)
|
||||
return false;
|
||||
if (!LinkConstructorAndPrototype(cx, genFunctionProto, genObjectProto))
|
||||
return false;
|
||||
|
||||
RootedValue function(cx, global->getConstructor(JSProto_Function));
|
||||
if (!function.toObjectOrNull())
|
||||
return false;
|
||||
RootedObject proto(cx, &function.toObject());
|
||||
RootedAtom name(cx, cx->names().GeneratorFunction);
|
||||
RootedObject genFunction(cx, NewFunctionWithProto(cx, Generator, 1,
|
||||
JSFunction::NATIVE_CTOR, nullptr, name,
|
||||
proto));
|
||||
if (!genFunction)
|
||||
return false;
|
||||
if (!LinkConstructorAndPrototype(cx, genFunction, genFunctionProto))
|
||||
return false;
|
||||
|
||||
global->setReservedSlot(STAR_GENERATOR_OBJECT_PROTO, ObjectValue(*genObjectProto));
|
||||
global->setReservedSlot(STAR_GENERATOR_FUNCTION, ObjectValue(*genFunction));
|
||||
global->setReservedSlot(STAR_GENERATOR_FUNCTION_PROTO, ObjectValue(*genFunctionProto));
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -406,7 +406,7 @@ GlobalObject::initSelfHostingBuiltins(JSContext* cx, Handle<GlobalObject*> globa
|
|||
InitBareBuiltinCtor(cx, global, JSProto_Uint8Array) &&
|
||||
InitBareBuiltinCtor(cx, global, JSProto_Uint32Array) &&
|
||||
InitBareWeakMapCtor(cx, global) &&
|
||||
InitStopIterationClass(cx, global) &&
|
||||
initStopIterationClass(cx, global) &&
|
||||
InitSelfHostingCollectionIteratorFunctions(cx, global) &&
|
||||
JS_DefineFunctions(cx, global, builtins);
|
||||
}
|
||||
|
|
|
@ -95,8 +95,6 @@ class GlobalObject : public NativeObject
|
|||
STRING_ITERATOR_PROTO,
|
||||
LEGACY_GENERATOR_OBJECT_PROTO,
|
||||
STAR_GENERATOR_OBJECT_PROTO,
|
||||
STAR_GENERATOR_FUNCTION_PROTO,
|
||||
STAR_GENERATOR_FUNCTION,
|
||||
MAP_ITERATOR_PROTO,
|
||||
SET_ITERATOR_PROTO,
|
||||
COLLATOR_PROTO,
|
||||
|
@ -536,40 +534,53 @@ class GlobalObject : public NativeObject
|
|||
return &global->getSlot(slot).toObject().as<NativeObject>();
|
||||
}
|
||||
|
||||
static NativeObject* getOrCreateArrayIteratorPrototype(JSContext* cx, Handle<GlobalObject*> global)
|
||||
static NativeObject* getOrCreateArrayIteratorPrototype(JSContext* cx,
|
||||
Handle<GlobalObject*> global)
|
||||
{
|
||||
return MaybeNativeObject(global->getOrCreateObject(cx, ARRAY_ITERATOR_PROTO, initArrayIteratorProto));
|
||||
if (!ensureConstructor(cx, global, JSProto_Iterator))
|
||||
return nullptr;
|
||||
return &global->getSlot(ARRAY_ITERATOR_PROTO).toObject().as<NativeObject>();
|
||||
}
|
||||
|
||||
static NativeObject* getOrCreateStringIteratorPrototype(JSContext* cx,
|
||||
Handle<GlobalObject*> global)
|
||||
{
|
||||
return MaybeNativeObject(global->getOrCreateObject(cx, STRING_ITERATOR_PROTO, initStringIteratorProto));
|
||||
if (!ensureConstructor(cx, global, JSProto_Iterator))
|
||||
return nullptr;
|
||||
return &global->getSlot(STRING_ITERATOR_PROTO).toObject().as<NativeObject>();
|
||||
}
|
||||
|
||||
static NativeObject* getOrCreateLegacyGeneratorObjectPrototype(JSContext* cx,
|
||||
Handle<GlobalObject*> global)
|
||||
{
|
||||
return MaybeNativeObject(global->getOrCreateObject(cx, LEGACY_GENERATOR_OBJECT_PROTO,
|
||||
initLegacyGeneratorProto));
|
||||
if (!ensureConstructor(cx, global, JSProto_Iterator))
|
||||
return nullptr;
|
||||
return &global->getSlot(LEGACY_GENERATOR_OBJECT_PROTO).toObject().as<NativeObject>();
|
||||
}
|
||||
|
||||
static NativeObject* getOrCreateStarGeneratorObjectPrototype(JSContext* cx,
|
||||
Handle<GlobalObject*> global)
|
||||
{
|
||||
return MaybeNativeObject(global->getOrCreateObject(cx, STAR_GENERATOR_OBJECT_PROTO, initStarGenerators));
|
||||
if (!ensureConstructor(cx, global, JSProto_Iterator))
|
||||
return nullptr;
|
||||
return &global->getSlot(STAR_GENERATOR_OBJECT_PROTO).toObject().as<NativeObject>();
|
||||
}
|
||||
|
||||
static NativeObject* getOrCreateStarGeneratorFunctionPrototype(JSContext* cx,
|
||||
Handle<GlobalObject*> global)
|
||||
{
|
||||
return MaybeNativeObject(global->getOrCreateObject(cx, STAR_GENERATOR_FUNCTION_PROTO, initStarGenerators));
|
||||
if (!ensureConstructor(cx, global, JSProto_Iterator))
|
||||
return nullptr;
|
||||
size_t slot = APPLICATION_SLOTS + JSProto_LIMIT + JSProto_GeneratorFunction;
|
||||
return &global->getSlot(slot).toObject().as<NativeObject>();
|
||||
}
|
||||
|
||||
static JSObject* getOrCreateStarGeneratorFunction(JSContext* cx,
|
||||
Handle<GlobalObject*> global)
|
||||
{
|
||||
return global->getOrCreateObject(cx, STAR_GENERATOR_FUNCTION, initStarGenerators);
|
||||
if (!ensureConstructor(cx, global, JSProto_Iterator))
|
||||
return nullptr;
|
||||
return &global->getSlot(APPLICATION_SLOTS + JSProto_GeneratorFunction).toObject();
|
||||
}
|
||||
|
||||
static JSObject* getOrCreateMapIteratorPrototype(JSContext* cx,
|
||||
|
@ -696,12 +707,11 @@ class GlobalObject : public NativeObject
|
|||
bool valueIsEval(Value val);
|
||||
|
||||
// Implemented in jsiter.cpp.
|
||||
static bool initArrayIteratorProto(JSContext* cx, Handle<GlobalObject*> global);
|
||||
static bool initStringIteratorProto(JSContext* cx, Handle<GlobalObject*> global);
|
||||
static bool initIteratorClasses(JSContext* cx, Handle<GlobalObject*> global);
|
||||
static bool initStopIterationClass(JSContext* cx, Handle<GlobalObject*> global);
|
||||
|
||||
// Implemented in vm/GeneratorObject.cpp.
|
||||
static bool initLegacyGeneratorProto(JSContext* cx, Handle<GlobalObject*> global);
|
||||
static bool initStarGenerators(JSContext* cx, Handle<GlobalObject*> global);
|
||||
static bool initGeneratorClasses(JSContext* cx, Handle<GlobalObject*> global);
|
||||
|
||||
// Implemented in builtin/MapObject.cpp.
|
||||
static bool initMapIteratorProto(JSContext* cx, Handle<GlobalObject*> global);
|
||||
|
@ -754,10 +764,6 @@ class GlobalObject : public NativeObject
|
|||
|
||||
return &value.toObject().as<JSFunction>();
|
||||
}
|
||||
|
||||
// A highly-dodgy function whose sole intended use is in the equally-dodgy
|
||||
// GlobalHelperThreadState::mergeParseTaskCompartment().
|
||||
JSObject* transliterateStarGeneratorFunctionPrototype(JSObject* proto);
|
||||
};
|
||||
|
||||
template<>
|
||||
|
|
|
@ -929,8 +929,7 @@ GlobalHelperThreadState::finishParseTask(JSContext* maybecx, JSRuntime* rt, void
|
|||
!EnsureConstructor(cx, global, JSProto_Function) ||
|
||||
!EnsureConstructor(cx, global, JSProto_RegExp) ||
|
||||
!EnsureConstructor(cx, global, JSProto_Iterator) ||
|
||||
!GlobalObject::initLegacyGeneratorProto(cx, global) ||
|
||||
!GlobalObject::initStarGenerators(cx, global))
|
||||
!EnsureConstructor(cx, global, JSProto_GeneratorFunction))
|
||||
{
|
||||
LeaveParseTaskZone(rt, parseTask);
|
||||
return nullptr;
|
||||
|
@ -966,17 +965,6 @@ GlobalHelperThreadState::finishParseTask(JSContext* maybecx, JSRuntime* rt, void
|
|||
return script;
|
||||
}
|
||||
|
||||
JSObject*
|
||||
GlobalObject::transliterateStarGeneratorFunctionPrototype(JSObject* proto)
|
||||
{
|
||||
JSObject* genFuncProto =
|
||||
&proto->global().getReservedSlot(STAR_GENERATOR_FUNCTION_PROTO).toObject();
|
||||
if (proto != genFuncProto)
|
||||
return nullptr;
|
||||
|
||||
return &getReservedSlot(STAR_GENERATOR_FUNCTION_PROTO).toObject();
|
||||
}
|
||||
|
||||
void
|
||||
GlobalHelperThreadState::mergeParseTaskCompartment(JSRuntime* rt, ParseTask* parseTask,
|
||||
Handle<GlobalObject*> global,
|
||||
|
@ -1004,24 +992,22 @@ GlobalHelperThreadState::mergeParseTaskCompartment(JSRuntime* rt, ParseTask* par
|
|||
if (!proto.isObject())
|
||||
continue;
|
||||
|
||||
JSObject* protoObj = proto.toObject();
|
||||
|
||||
// Generator functions don't have Function.prototype as prototype but a
|
||||
// different function object, so IdentifyStandardPrototype won't work.
|
||||
// Just special-case it here.
|
||||
JSObject* newProto = global->transliterateStarGeneratorFunctionPrototype(protoObj);
|
||||
if (!newProto) {
|
||||
JSProtoKey key = JS::IdentifyStandardPrototype(protoObj);
|
||||
if (key == JSProto_Null)
|
||||
JSProtoKey key = JS::IdentifyStandardPrototype(proto.toObject());
|
||||
if (key == JSProto_Null) {
|
||||
// Generator functions don't have Function.prototype as prototype
|
||||
// but a different function object, so IdentifyStandardPrototype
|
||||
// doesn't work. Just special-case it here.
|
||||
if (IsStandardPrototype(proto.toObject(), JSProto_GeneratorFunction))
|
||||
key = JSProto_GeneratorFunction;
|
||||
else
|
||||
continue;
|
||||
|
||||
MOZ_ASSERT(key == JSProto_Object || key == JSProto_Array ||
|
||||
key == JSProto_Function || key == JSProto_RegExp ||
|
||||
key == JSProto_Iterator);
|
||||
|
||||
newProto = GetBuiltinPrototypePure(global, key);
|
||||
MOZ_ASSERT(newProto);
|
||||
}
|
||||
MOZ_ASSERT(key == JSProto_Object || key == JSProto_Array ||
|
||||
key == JSProto_Function || key == JSProto_RegExp ||
|
||||
key == JSProto_Iterator || key == JSProto_GeneratorFunction);
|
||||
|
||||
JSObject* newProto = GetBuiltinPrototypePure(global, key);
|
||||
MOZ_ASSERT(newProto);
|
||||
|
||||
group->setProtoUnchecked(TaggedProto(newProto));
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче