зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1251529: Pass AutoEnterOOMUnsafeRegion to allocation metadata builder methods. r=fitzgen
--HG-- extra : rebase_source : a0f34c84c6c0bfb287864ed915b9110664ca56a9
This commit is contained in:
Родитель
49a9f03a0a
Коммит
62682b1571
|
@ -1691,16 +1691,16 @@ DisplayName(JSContext* cx, unsigned argc, Value* vp)
|
|||
|
||||
class ShellAllocationMetadataBuilder : public AllocationMetadataBuilder {
|
||||
public:
|
||||
virtual JSObject* build(JSContext *cx, HandleObject) const override;
|
||||
virtual JSObject* build(JSContext *cx, HandleObject,
|
||||
AutoEnterOOMUnsafeRegion& oomUnsafe) const override;
|
||||
|
||||
static const ShellAllocationMetadataBuilder metadataBuilder;
|
||||
};
|
||||
|
||||
JSObject*
|
||||
ShellAllocationMetadataBuilder::build(JSContext* cx, HandleObject) const
|
||||
ShellAllocationMetadataBuilder::build(JSContext* cx, HandleObject,
|
||||
AutoEnterOOMUnsafeRegion& oomUnsafe) const
|
||||
{
|
||||
AutoEnterOOMUnsafeRegion oomUnsafe;
|
||||
|
||||
RootedObject obj(cx, NewBuiltinClassInstance<PlainObject>(cx));
|
||||
if (!obj)
|
||||
oomUnsafe.crash("ShellAllocationMetadataBuilder::build");
|
||||
|
|
|
@ -894,8 +894,8 @@ JSCompartment::setNewObjectMetadata(JSContext* cx, HandleObject obj)
|
|||
{
|
||||
assertSameCompartment(cx, this, obj);
|
||||
|
||||
if (JSObject* metadata = allocationMetadataBuilder->build(cx, obj)) {
|
||||
AutoEnterOOMUnsafeRegion oomUnsafe;
|
||||
AutoEnterOOMUnsafeRegion oomUnsafe;
|
||||
if (JSObject* metadata = allocationMetadataBuilder->build(cx, obj, oomUnsafe)) {
|
||||
assertSameCompartment(cx, metadata);
|
||||
if (!objectMetadataTable) {
|
||||
objectMetadataTable = cx->new_<ObjectWeakMap>(cx);
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
#include "js/CallArgs.h"
|
||||
#include "js/CallNonGenericMethod.h"
|
||||
#include "js/Class.h"
|
||||
#include "js/Utility.h"
|
||||
|
||||
#if JS_STACK_GROWTH_DIRECTION > 0
|
||||
# define JS_CHECK_STACK_SIZE(limit, sp) (MOZ_LIKELY((uintptr_t)(sp) < (limit)))
|
||||
|
@ -2672,8 +2673,13 @@ struct AllocationMetadataBuilder {
|
|||
// nullptr if there's no metadata to attach.
|
||||
//
|
||||
// Implementations should treat all errors as fatal; there is no way to
|
||||
// report errors from this callback.
|
||||
virtual JSObject* build(JSContext *cx, JS::HandleObject obj) const { return nullptr; }
|
||||
// report errors from this callback. In particular, the caller provides an
|
||||
// oomUnsafe for overriding implementations to use.
|
||||
virtual JSObject* build(JSContext* cx, JS::HandleObject obj,
|
||||
AutoEnterOOMUnsafeRegion& oomUnsafe) const
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
@ -1475,7 +1475,8 @@ SavedStacks::chooseSamplingProbability(JSCompartment* compartment)
|
|||
}
|
||||
|
||||
JSObject*
|
||||
SavedStacks::MetadataBuilder::build(JSContext* cx, HandleObject target) const
|
||||
SavedStacks::MetadataBuilder::build(JSContext* cx, HandleObject target,
|
||||
AutoEnterOOMUnsafeRegion& oomUnsafe) const
|
||||
{
|
||||
RootedObject obj(cx, target);
|
||||
|
||||
|
@ -1483,7 +1484,6 @@ SavedStacks::MetadataBuilder::build(JSContext* cx, HandleObject target) const
|
|||
if (!stacks.bernoulli.trial())
|
||||
return nullptr;
|
||||
|
||||
AutoEnterOOMUnsafeRegion oomUnsafe;
|
||||
RootedSavedFrame frame(cx);
|
||||
if (!stacks.saveCurrentStack(cx, &frame))
|
||||
oomUnsafe.crash("SavedStacksMetadataBuilder");
|
||||
|
|
|
@ -182,7 +182,8 @@ class SavedStacks {
|
|||
// An alloction metadata builder that marks cells with the JavaScript stack
|
||||
// at which they were allocated.
|
||||
class MetadataBuilder : public AllocationMetadataBuilder {
|
||||
virtual JSObject* build(JSContext *cx, HandleObject obj) const override;
|
||||
virtual JSObject* build(JSContext *cx, HandleObject obj,
|
||||
AutoEnterOOMUnsafeRegion& oomUnsafe) const override;
|
||||
};
|
||||
|
||||
static const MetadataBuilder metadataBuilder;
|
||||
|
|
Загрузка…
Ссылка в новой задаче