mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1200642 - Add checkSimulatedOOM() to AllocPolicy r=Waldo
This commit is contained in:
parent
e6588e56df
commit
3f067cd557
@ -559,6 +559,9 @@ class LifoAllocPolicy
|
||||
}
|
||||
void reportAllocOverflow() const {
|
||||
}
|
||||
bool checkSimulatedOOM() const {
|
||||
return fb == Infallible || !js::oom::ShouldFailWithOOM();
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace js
|
||||
|
@ -103,6 +103,9 @@ class JitAllocPolicy
|
||||
}
|
||||
void reportAllocOverflow() const {
|
||||
}
|
||||
bool checkSimulatedOOM() const {
|
||||
return !js::oom::ShouldFailWithOOM();
|
||||
}
|
||||
};
|
||||
|
||||
class OldJitAllocPolicy
|
||||
@ -120,6 +123,9 @@ class OldJitAllocPolicy
|
||||
}
|
||||
void reportAllocOverflow() const {
|
||||
}
|
||||
bool checkSimulatedOOM() const {
|
||||
return !js::oom::ShouldFailWithOOM();
|
||||
}
|
||||
};
|
||||
|
||||
class AutoJitContextAlloc
|
||||
|
@ -38,8 +38,14 @@ class SystemAllocPolicy
|
||||
}
|
||||
void free_(void* p) { js_free(p); }
|
||||
void reportAllocOverflow() const {}
|
||||
bool checkSimulatedOOM() const {
|
||||
return !js::oom::ShouldFailWithOOM();
|
||||
}
|
||||
};
|
||||
|
||||
class ExclusiveContext;
|
||||
void ReportOutOfMemory(ExclusiveContext* cxArg);
|
||||
|
||||
/*
|
||||
* Allocation policy that calls the system memory functions and reports errors
|
||||
* to the context. Since the JSContext given on construction is stored for
|
||||
@ -93,6 +99,15 @@ class TempAllocPolicy
|
||||
}
|
||||
|
||||
JS_FRIEND_API(void) reportAllocOverflow() const;
|
||||
|
||||
bool checkSimulatedOOM() const {
|
||||
if (js::oom::ShouldFailWithOOM()) {
|
||||
js::ReportOutOfMemory(reinterpret_cast<ExclusiveContext*>(cx_));
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
} /* namespace js */
|
||||
|
@ -2087,6 +2087,10 @@ class RuntimeAllocPolicy
|
||||
|
||||
void free_(void* p) { js_free(p); }
|
||||
void reportAllocOverflow() const {}
|
||||
|
||||
bool checkSimulatedOOM() const {
|
||||
return !js::oom::ShouldFailWithOOM();
|
||||
}
|
||||
};
|
||||
|
||||
extern const JSSecurityCallbacks NullSecurityCallbacks;
|
||||
|
@ -70,6 +70,7 @@ private:
|
||||
void *realloc_(void *p, size_t bytes) { return ::realloc(p, bytes); }
|
||||
void free_(void *p) { ::free(p); }
|
||||
void reportAllocOverflow() const {}
|
||||
bool checkSimulatedOOM() const { return true; }
|
||||
};
|
||||
|
||||
typedef js::HashMap<nsIContent*, CacheEntry, js::DefaultHasher<nsIContent*>,
|
||||
|
@ -225,6 +225,7 @@ public:
|
||||
}
|
||||
|
||||
static void reportAllocOverflow() { ExitOnFailure(nullptr); }
|
||||
bool checkSimulatedOOM() const { return true; }
|
||||
};
|
||||
|
||||
// This is only needed because of the |const void*| vs |void*| arg mismatch.
|
||||
|
@ -39,6 +39,18 @@ namespace mozilla {
|
||||
* to allocate more than the available memory space -- think allocating an
|
||||
* array of large-size objects, where N * size overflows) before null is
|
||||
* returned.
|
||||
* - bool checkSimulatedOOM() const
|
||||
* Some clients generally allocate memory yet in some circumstances won't
|
||||
* need to do so. For example, appending to a vector with a small amount of
|
||||
* inline storage generally allocates memory, but no allocation occurs
|
||||
* unless appending exceeds inline storage. But for testing purposes, it
|
||||
* can be useful to treat *every* operation as allocating.
|
||||
* Clients (such as this hypothetical append method implementation) should
|
||||
* call this method in situations that don't allocate, but could generally,
|
||||
* to support this. The default behavior should return true; more
|
||||
* complicated behavior might be to return false only after a certain
|
||||
* number of allocations-or-check-simulated-OOMs (coordinating with the
|
||||
* other AllocPolicy methods) have occurred.
|
||||
*
|
||||
* mfbt provides (and typically uses by default) only MallocAllocPolicy, which
|
||||
* does nothing more than delegate to the malloc/alloc/free functions.
|
||||
@ -83,6 +95,11 @@ public:
|
||||
void reportAllocOverflow() const
|
||||
{
|
||||
}
|
||||
|
||||
bool checkSimulatedOOM() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace mozilla
|
||||
|
Loading…
Reference in New Issue
Block a user