mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Remove gcIteratorTable (557914, r=Waldo).
This commit is contained in:
parent
26d8277a75
commit
d0f2401879
@ -795,12 +795,6 @@ struct JSRuntime {
|
||||
size_t gcMarkLaterCount;
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Table for tracking iterators to ensure that we close iterator's state
|
||||
* before finalizing the iterable object.
|
||||
*/
|
||||
js::Vector<JSObject*, 0, js::SystemAllocPolicy> gcIteratorTable;
|
||||
|
||||
/*
|
||||
* The trace operation and its data argument to trace embedding-specific
|
||||
* GC roots.
|
||||
|
@ -1149,7 +1149,6 @@ js_FinishGC(JSRuntime *rt)
|
||||
js_DumpGCStats(rt, stdout);
|
||||
#endif
|
||||
|
||||
rt->gcIteratorTable.clear();
|
||||
FinishGCArenaLists(rt);
|
||||
|
||||
if (rt->gcRootsHash.ops) {
|
||||
@ -1336,39 +1335,6 @@ js_MapGCRoots(JSRuntime *rt, JSGCRootMapFun map, void *data)
|
||||
return rv;
|
||||
}
|
||||
|
||||
JSBool
|
||||
js_RegisterCloseableIterator(JSContext *cx, JSObject *obj)
|
||||
{
|
||||
JSRuntime *rt;
|
||||
JSBool ok;
|
||||
|
||||
rt = cx->runtime;
|
||||
JS_ASSERT(!rt->gcRunning);
|
||||
|
||||
JS_LOCK_GC(rt);
|
||||
ok = rt->gcIteratorTable.append(obj);
|
||||
JS_UNLOCK_GC(rt);
|
||||
return ok;
|
||||
}
|
||||
|
||||
static void
|
||||
CloseNativeIterators(JSContext *cx)
|
||||
{
|
||||
JSRuntime *rt = cx->runtime;
|
||||
size_t length = rt->gcIteratorTable.length();
|
||||
JSObject **array = rt->gcIteratorTable.begin();
|
||||
|
||||
size_t newLength = 0;
|
||||
for (size_t i = 0; i < length; ++i) {
|
||||
JSObject *obj = array[i];
|
||||
if (js_IsAboutToBeFinalized(obj))
|
||||
js_CloseNativeIterator(cx, obj);
|
||||
else
|
||||
array[newLength++] = obj;
|
||||
}
|
||||
rt->gcIteratorTable.resize(newLength);
|
||||
}
|
||||
|
||||
void
|
||||
JSRuntime::setGCTriggerFactor(uint32 factor)
|
||||
{
|
||||
@ -3217,9 +3183,6 @@ js_GC(JSContext *cx, JSGCInvocationKind gckind)
|
||||
TIMESTAMP(gcTimer.startSweep);
|
||||
js_SweepAtomState(cx);
|
||||
|
||||
/* Finalize iterator states before the objects they iterate over. */
|
||||
CloseNativeIterators(cx);
|
||||
|
||||
/* Finalize watch points associated with unreachable objects. */
|
||||
js_SweepWatchPoints(cx);
|
||||
|
||||
|
@ -74,6 +74,12 @@
|
||||
|
||||
using namespace js;
|
||||
|
||||
/*
|
||||
* Native iterator object slots.
|
||||
*/
|
||||
const uint32 JSSLOT_ITER_STATE = JSSLOT_PRIVATE;
|
||||
const uint32 JSSLOT_ITER_FLAGS = JSSLOT_PRIVATE + 1;
|
||||
|
||||
JS_STATIC_ASSERT(JSSLOT_ITER_FLAGS < JS_INITIAL_NSLOTS);
|
||||
|
||||
#if JS_HAS_GENERATORS
|
||||
@ -87,8 +93,8 @@ CloseGenerator(JSContext *cx, JSObject *genobj);
|
||||
* Shared code to close iterator's state either through an explicit call or
|
||||
* when GC detects that the iterator is no longer reachable.
|
||||
*/
|
||||
void
|
||||
js_CloseNativeIterator(JSContext *cx, JSObject *iterobj)
|
||||
static void
|
||||
CloseNativeIterator(JSContext *cx, JSObject *iterobj)
|
||||
{
|
||||
jsval state;
|
||||
JSObject *iterable;
|
||||
@ -115,6 +121,12 @@ js_CloseNativeIterator(JSContext *cx, JSObject *iterobj)
|
||||
iterobj->setSlot(JSSLOT_ITER_STATE, JSVAL_NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
iterator_finalize(JSContext *cx, JSObject *obj)
|
||||
{
|
||||
CloseNativeIterator(cx, obj);
|
||||
}
|
||||
|
||||
static void
|
||||
iterator_trace(JSTracer *trc, JSObject *obj)
|
||||
{
|
||||
@ -139,7 +151,7 @@ JSClass js_IteratorClass = {
|
||||
JSCLASS_HAS_CACHED_PROTO(JSProto_Iterator) |
|
||||
JSCLASS_MARK_IS_TRACE,
|
||||
JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, JS_PropertyStub,
|
||||
JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, NULL,
|
||||
JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, iterator_finalize,
|
||||
NULL, NULL, NULL, NULL,
|
||||
NULL, NULL, JS_CLASS_TRACE(iterator_trace), NULL
|
||||
};
|
||||
@ -156,8 +168,6 @@ InitNativeIterator(JSContext *cx, JSObject *iterobj, JSObject *obj, uintN flags)
|
||||
iterobj->setParent(obj);
|
||||
iterobj->setSlot(JSSLOT_ITER_STATE, JSVAL_NULL);
|
||||
iterobj->setSlot(JSSLOT_ITER_FLAGS, INT_TO_JSVAL(flags));
|
||||
if (!js_RegisterCloseableIterator(cx, iterobj))
|
||||
return JS_FALSE;
|
||||
if (!obj)
|
||||
return JS_TRUE;
|
||||
|
||||
@ -433,7 +443,7 @@ js_CloseIterator(JSContext *cx, jsval v)
|
||||
clasp = obj->getClass();
|
||||
|
||||
if (clasp == &js_IteratorClass) {
|
||||
js_CloseNativeIterator(cx, obj);
|
||||
CloseNativeIterator(cx, obj);
|
||||
}
|
||||
#if JS_HAS_GENERATORS
|
||||
else if (clasp == &js_GeneratorClass) {
|
||||
|
@ -58,12 +58,6 @@ JS_BEGIN_EXTERN_C
|
||||
#define JSITER_FOREACH 0x2 /* return [key, value] pair rather than key */
|
||||
#define JSITER_KEYVALUE 0x4 /* destructuring for-in wants [key, value] */
|
||||
|
||||
/*
|
||||
* Native iterator object slots, shared between jsiter.cpp and jstracer.cpp.
|
||||
*/
|
||||
const uint32 JSSLOT_ITER_STATE = JSSLOT_PRIVATE;
|
||||
const uint32 JSSLOT_ITER_FLAGS = JSSLOT_PRIVATE + 1;
|
||||
|
||||
/*
|
||||
* Convert the value stored in *vp to its iteration object. The flags should
|
||||
* contain JSITER_ENUMERATE if js_ValueToIterator is called when enumerating
|
||||
@ -83,12 +77,6 @@ js_CloseIterator(JSContext *cx, jsval v);
|
||||
extern JS_FRIEND_API(JSBool)
|
||||
js_CallIteratorNext(JSContext *cx, JSObject *iterobj, jsval *rval);
|
||||
|
||||
/*
|
||||
* Close iterobj, whose class must be js_IteratorClass.
|
||||
*/
|
||||
extern void
|
||||
js_CloseNativeIterator(JSContext *cx, JSObject *iterobj);
|
||||
|
||||
extern JSBool
|
||||
js_ThrowStopIteration(JSContext *cx);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user