2010-02-03 02:42:07 -08:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
* Menu of -D flags for enabling instrumentation, as a commented-out CFLAGS += setting for convenient testing. * js_FindProperty and js_LookupPropertyWithFlags return indexes into the scope and prototype chains, respectively, to support internal instrumentation, and to pave the way for the return of the property cache (bug 365851).. * jsutil.[ch] JSBasicStats struct and functions for computing mean/sigma/max and auto-scaling histogram. * JS_SCOPE_DEPTH_METER instrumentation for compile- and run-time scope chain length instrumentation: + At compile time, rt->hostenvScopeDepthStats and rt->lexicalScopeDepthStats meter scope chains passed into the compile and evaluate APIs. + At runtime, rt->protoLookupDepthStats and rt->scopeSearchDepthStats track steps along the prototype and scope chains until the sought-after property is found. * JS_ARENAMETER uses JSBasicStats now. * Added rt->liveScopePropsPreSweep to fix the property tree stats code that rotted when property tree sweeping moved to after the finalization phase. * Un-bitrotted some DEBUG_brendan code, turned some off for myself via XXX. * Mac OS X toolchain requires initialized data shared across dynamic library member files, outlaws common data, so initialize extern metering vars. * Old HASHMETER code in jshash.[ch] is now JS_HASHMETER-controlled and based on JSBasicStats. * DEBUG_scopemeters macro renamed JS_DUMP_SCOPE_METERS; uses JSBasicStats now. * Disentangle DEBUG and DUMP_SCOPE_STATS (now JS_DUMP_PROPTREE_STATS) and fix inconsistent thread safety for liveScopeProps (sometimes atomic-incremented, sometimes runtime-locked). * Compiler-modeled maxScopeDepth will propagate via JSScript to runtime for capability-based, interpreter-inlined cache hit qualifier bits, to bypass scope and prototype chain lookup by optimizing for common monomorphic get, set, and call site referencing a prototype property in a well-named object (no shadowing or mutation in 99.9% of the cases).
2008-01-12 16:31:31 -08:00
|
|
|
* vim: set ts=8 sw=4 et tw=78:
|
2007-03-22 10:30:00 -07:00
|
|
|
*
|
2012-05-21 04:12:37 -07:00
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
#ifndef jsobj_h___
|
|
|
|
#define jsobj_h___
|
2011-01-18 14:25:46 -08:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
/*
|
|
|
|
* JS object definitions.
|
|
|
|
*
|
|
|
|
* A JS object consists of a possibly-shared object descriptor containing
|
|
|
|
* ordered property names, called the map; and a dense vector of property
|
|
|
|
* values, called slots. The map/slot pointer pair is GC'ed, while the map
|
|
|
|
* is reference counted and the slot vector is malloc'ed.
|
|
|
|
*/
|
2010-04-14 18:57:30 -07:00
|
|
|
#include "jsapi.h"
|
2011-12-27 00:27:02 -08:00
|
|
|
#include "jsatom.h"
|
2011-09-20 11:40:24 -07:00
|
|
|
#include "jsclass.h"
|
2011-10-04 07:06:54 -07:00
|
|
|
#include "jsfriendapi.h"
|
2009-06-05 12:56:45 -07:00
|
|
|
|
2011-10-25 16:07:42 -07:00
|
|
|
#include "gc/Barrier.h"
|
2012-05-01 20:04:36 -07:00
|
|
|
#include "gc/Heap.h"
|
2012-02-09 18:54:28 -08:00
|
|
|
|
|
|
|
#include "vm/ObjectImpl.h"
|
2011-09-15 11:44:10 -07:00
|
|
|
#include "vm/String.h"
|
|
|
|
|
2013-01-08 10:27:50 -08:00
|
|
|
ForwardDeclareJS(Object);
|
|
|
|
|
2012-11-21 17:07:42 -08:00
|
|
|
namespace JS {
|
|
|
|
struct ObjectsExtraSizes;
|
|
|
|
}
|
|
|
|
|
2010-07-14 23:19:36 -07:00
|
|
|
namespace js {
|
|
|
|
|
|
|
|
class AutoPropDescArrayRooter;
|
2012-05-17 04:19:37 -07:00
|
|
|
class BaseProxyHandler;
|
2011-09-08 10:53:43 -07:00
|
|
|
class CallObject;
|
2011-06-03 20:48:16 -07:00
|
|
|
struct GCMarker;
|
2011-09-02 17:23:26 -07:00
|
|
|
struct NativeIterator;
|
2012-11-29 10:22:10 -08:00
|
|
|
ForwardDeclare(Shape);
|
|
|
|
struct StackShape;
|
2010-07-14 23:19:36 -07:00
|
|
|
|
2010-10-29 08:05:55 -07:00
|
|
|
namespace mjit { class Compiler; }
|
2010-08-30 15:13:32 -07:00
|
|
|
|
2010-07-14 23:19:36 -07:00
|
|
|
inline JSObject *
|
|
|
|
CastAsObject(PropertyOp op)
|
|
|
|
{
|
|
|
|
return JS_FUNC_TO_DATA_PTR(JSObject *, op);
|
|
|
|
}
|
|
|
|
|
2011-02-09 11:31:40 -08:00
|
|
|
inline JSObject *
|
|
|
|
CastAsObject(StrictPropertyOp op)
|
|
|
|
{
|
|
|
|
return JS_FUNC_TO_DATA_PTR(JSObject *, op);
|
|
|
|
}
|
|
|
|
|
2010-07-14 23:19:36 -07:00
|
|
|
inline Value
|
|
|
|
CastAsObjectJsval(PropertyOp op)
|
|
|
|
{
|
2010-07-16 11:14:05 -07:00
|
|
|
return ObjectOrNullValue(CastAsObject(op));
|
2010-07-14 23:19:36 -07:00
|
|
|
}
|
|
|
|
|
2011-02-09 11:31:40 -08:00
|
|
|
inline Value
|
|
|
|
CastAsObjectJsval(StrictPropertyOp op)
|
|
|
|
{
|
|
|
|
return ObjectOrNullValue(CastAsObject(op));
|
|
|
|
}
|
|
|
|
|
2011-09-20 11:40:24 -07:00
|
|
|
/*
|
|
|
|
* JSPropertySpec uses JSAPI JSPropertyOp and JSStrictPropertyOp in function
|
|
|
|
* signatures, but with JSPROP_NATIVE_ACCESSORS the actual values must be
|
|
|
|
* JSNatives. To avoid widespread casting, have JS_PSG and JS_PSGS perform
|
|
|
|
* type-safe casts.
|
|
|
|
*/
|
2012-08-07 22:26:18 -07:00
|
|
|
#define JS_PSG(name,getter,flags) \
|
|
|
|
{name, 0, (flags) | JSPROP_SHARED | JSPROP_NATIVE_ACCESSORS, \
|
|
|
|
JSOP_WRAPPER((JSPropertyOp)getter), JSOP_NULLWRAPPER}
|
|
|
|
#define JS_PSGS(name,getter,setter,flags) \
|
|
|
|
{name, 0, (flags) | JSPROP_SHARED | JSPROP_NATIVE_ACCESSORS, \
|
|
|
|
JSOP_WRAPPER((JSPropertyOp)getter), JSOP_WRAPPER((JSStrictPropertyOp)setter)}
|
|
|
|
#define JS_PS_END {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER}
|
2011-09-20 11:40:24 -07:00
|
|
|
|
|
|
|
/******************************************************************************/
|
|
|
|
|
2010-07-07 00:53:50 -07:00
|
|
|
typedef Vector<PropDesc, 1> PropDescArray;
|
|
|
|
|
2012-05-19 15:03:45 -07:00
|
|
|
/*
|
|
|
|
* The baseops namespace encapsulates the default behavior when performing
|
|
|
|
* various operations on an object, irrespective of hooks installed in the
|
|
|
|
* object's class. In general, instance methods on the object itself should be
|
|
|
|
* called instead of calling these methods directly.
|
|
|
|
*/
|
|
|
|
namespace baseops {
|
2010-07-07 00:53:50 -07:00
|
|
|
|
2010-06-12 09:29:04 -07:00
|
|
|
/*
|
2011-01-21 05:10:16 -08:00
|
|
|
* On success, and if id was found, return true with *objp non-null and with a
|
|
|
|
* property of *objp stored in *propp. If successful but id was not found,
|
|
|
|
* return true with both *objp and *propp null.
|
2010-06-12 09:29:04 -07:00
|
|
|
*/
|
2013-01-24 19:18:34 -08:00
|
|
|
template <AllowGC allowGC>
|
|
|
|
extern JSBool
|
|
|
|
LookupProperty(JSContext *cx,
|
|
|
|
typename MaybeRooted<JSObject*, allowGC>::HandleType obj,
|
|
|
|
typename MaybeRooted<jsid, allowGC>::HandleType id,
|
|
|
|
typename MaybeRooted<JSObject*, allowGC>::MutableHandleType objp,
|
|
|
|
typename MaybeRooted<Shape*, allowGC>::MutableHandleType propp);
|
2011-12-27 00:27:02 -08:00
|
|
|
|
|
|
|
inline bool
|
2012-05-19 15:03:45 -07:00
|
|
|
LookupProperty(JSContext *cx, HandleObject obj, PropertyName *name,
|
2012-07-04 19:34:06 -07:00
|
|
|
MutableHandleObject objp, MutableHandleShape propp)
|
2011-12-27 00:27:02 -08:00
|
|
|
{
|
2012-06-14 19:13:27 -07:00
|
|
|
Rooted<jsid> id(cx, NameToId(name));
|
2013-01-24 19:18:34 -08:00
|
|
|
return LookupProperty<CanGC>(cx, obj, id, objp, propp);
|
2011-12-27 00:27:02 -08:00
|
|
|
}
|
|
|
|
|
2013-01-24 19:18:34 -08:00
|
|
|
extern JSBool
|
2012-05-19 15:03:45 -07:00
|
|
|
LookupElement(JSContext *cx, HandleObject obj, uint32_t index,
|
2012-07-04 19:34:06 -07:00
|
|
|
MutableHandleObject objp, MutableHandleShape propp);
|
2011-08-10 14:54:52 -07:00
|
|
|
|
2010-06-12 09:29:04 -07:00
|
|
|
extern JSBool
|
2012-07-30 04:19:09 -07:00
|
|
|
DefineGeneric(JSContext *cx, HandleObject obj, HandleId id, HandleValue value,
|
2012-05-19 15:03:45 -07:00
|
|
|
JSPropertyOp getter, JSStrictPropertyOp setter, unsigned attrs);
|
2010-06-12 09:29:04 -07:00
|
|
|
|
2012-06-14 19:13:27 -07:00
|
|
|
inline JSBool
|
2012-07-30 04:19:09 -07:00
|
|
|
DefineProperty(JSContext *cx, HandleObject obj, PropertyName *name, HandleValue value,
|
2012-06-14 19:13:27 -07:00
|
|
|
JSPropertyOp getter, JSStrictPropertyOp setter, unsigned attrs)
|
|
|
|
{
|
|
|
|
Rooted<jsid> id(cx, NameToId(name));
|
|
|
|
return DefineGeneric(cx, obj, id, value, getter, setter, attrs);
|
|
|
|
}
|
|
|
|
|
2011-08-10 14:54:52 -07:00
|
|
|
extern JSBool
|
2012-07-30 04:19:09 -07:00
|
|
|
DefineElement(JSContext *cx, HandleObject obj, uint32_t index, HandleValue value,
|
2012-05-19 15:03:45 -07:00
|
|
|
JSPropertyOp getter, JSStrictPropertyOp setter, unsigned attrs);
|
2011-08-10 14:54:52 -07:00
|
|
|
|
2010-06-12 09:29:04 -07:00
|
|
|
extern JSBool
|
2012-07-30 04:19:09 -07:00
|
|
|
GetProperty(JSContext *cx, HandleObject obj, HandleObject receiver, HandleId id, MutableHandleValue vp);
|
2010-10-29 10:42:35 -07:00
|
|
|
|
2013-01-24 19:18:34 -08:00
|
|
|
extern JSBool
|
|
|
|
GetPropertyNoGC(JSContext *cx, JSObject *obj, JSObject *receiver, jsid id, Value *vp);
|
|
|
|
|
2011-08-10 14:54:52 -07:00
|
|
|
extern JSBool
|
2012-07-30 04:19:09 -07:00
|
|
|
GetElement(JSContext *cx, HandleObject obj, HandleObject receiver, uint32_t index, MutableHandleValue vp);
|
2011-08-10 14:54:52 -07:00
|
|
|
|
2010-10-29 10:42:35 -07:00
|
|
|
inline JSBool
|
2012-07-30 04:19:09 -07:00
|
|
|
GetProperty(JSContext *cx, HandleObject obj, HandleId id, MutableHandleValue vp)
|
2010-10-29 10:42:35 -07:00
|
|
|
{
|
2012-05-19 15:03:45 -07:00
|
|
|
return GetProperty(cx, obj, obj, id, vp);
|
2010-10-29 10:42:35 -07:00
|
|
|
}
|
2010-06-12 09:29:04 -07:00
|
|
|
|
2011-08-10 14:54:52 -07:00
|
|
|
inline JSBool
|
2012-07-30 04:19:09 -07:00
|
|
|
GetElement(JSContext *cx, HandleObject obj, uint32_t index, MutableHandleValue vp)
|
2011-08-10 14:54:52 -07:00
|
|
|
{
|
2012-05-19 15:03:45 -07:00
|
|
|
return GetElement(cx, obj, obj, index, vp);
|
2011-08-10 14:54:52 -07:00
|
|
|
}
|
|
|
|
|
2010-10-19 09:00:51 -07:00
|
|
|
extern JSBool
|
2012-07-30 04:19:09 -07:00
|
|
|
GetPropertyDefault(JSContext *cx, HandleObject obj, HandleId id, HandleValue def, MutableHandleValue vp);
|
2010-10-19 09:00:51 -07:00
|
|
|
|
2010-06-12 09:29:04 -07:00
|
|
|
extern JSBool
|
2012-06-27 20:21:39 -07:00
|
|
|
SetPropertyHelper(JSContext *cx, HandleObject obj, HandleObject receiver, HandleId id,
|
2012-07-30 04:19:09 -07:00
|
|
|
unsigned defineHow, MutableHandleValue vp, JSBool strict);
|
2011-12-27 00:27:02 -08:00
|
|
|
|
|
|
|
inline bool
|
2012-06-27 20:21:39 -07:00
|
|
|
SetPropertyHelper(JSContext *cx, HandleObject obj, HandleObject receiver, PropertyName *name,
|
2012-07-30 04:19:09 -07:00
|
|
|
unsigned defineHow, MutableHandleValue vp, JSBool strict)
|
2011-12-27 00:27:02 -08:00
|
|
|
{
|
2012-06-14 19:13:27 -07:00
|
|
|
Rooted<jsid> id(cx, NameToId(name));
|
2012-06-27 20:21:39 -07:00
|
|
|
return SetPropertyHelper(cx, obj, receiver, id, defineHow, vp, strict);
|
2011-12-27 00:27:02 -08:00
|
|
|
}
|
|
|
|
|
2011-08-10 14:54:52 -07:00
|
|
|
extern JSBool
|
2012-06-27 20:21:39 -07:00
|
|
|
SetElementHelper(JSContext *cx, HandleObject obj, HandleObject Receiver, uint32_t index,
|
2012-07-30 04:19:09 -07:00
|
|
|
unsigned defineHow, MutableHandleValue vp, JSBool strict);
|
2011-08-10 14:54:52 -07:00
|
|
|
|
2012-05-19 15:03:45 -07:00
|
|
|
extern JSType
|
|
|
|
TypeOf(JSContext *cx, HandleObject obj);
|
2010-05-07 17:52:52 -07:00
|
|
|
|
2011-08-10 14:54:52 -07:00
|
|
|
extern JSBool
|
2012-05-19 15:03:45 -07:00
|
|
|
GetAttributes(JSContext *cx, HandleObject obj, HandleId id, unsigned *attrsp);
|
2011-08-10 14:54:52 -07:00
|
|
|
|
2010-06-12 09:29:04 -07:00
|
|
|
extern JSBool
|
2012-05-19 15:03:45 -07:00
|
|
|
SetAttributes(JSContext *cx, HandleObject obj, HandleId id, unsigned *attrsp);
|
2010-06-12 09:29:04 -07:00
|
|
|
|
2011-08-10 14:54:52 -07:00
|
|
|
extern JSBool
|
2012-05-19 15:03:45 -07:00
|
|
|
GetElementAttributes(JSContext *cx, HandleObject obj, uint32_t index, unsigned *attrsp);
|
2011-08-10 14:54:52 -07:00
|
|
|
|
2010-06-12 09:29:04 -07:00
|
|
|
extern JSBool
|
2012-05-19 15:03:45 -07:00
|
|
|
SetElementAttributes(JSContext *cx, HandleObject obj, uint32_t index, unsigned *attrsp);
|
2010-06-12 09:29:04 -07:00
|
|
|
|
2011-08-10 14:54:52 -07:00
|
|
|
extern JSBool
|
2012-07-30 04:19:09 -07:00
|
|
|
DeleteProperty(JSContext *cx, HandleObject obj, HandlePropertyName name, MutableHandleValue rval, JSBool strict);
|
2011-08-10 14:54:52 -07:00
|
|
|
|
2011-12-28 14:33:20 -08:00
|
|
|
extern JSBool
|
2012-07-30 04:19:09 -07:00
|
|
|
DeleteElement(JSContext *cx, HandleObject obj, uint32_t index, MutableHandleValue rval, JSBool strict);
|
2011-12-28 14:33:20 -08:00
|
|
|
|
|
|
|
extern JSBool
|
2012-07-30 04:19:09 -07:00
|
|
|
DeleteSpecial(JSContext *cx, HandleObject obj, HandleSpecialId sid, MutableHandleValue rval, JSBool strict);
|
2011-12-28 14:33:20 -08:00
|
|
|
|
2012-05-19 15:03:45 -07:00
|
|
|
extern JSBool
|
2012-07-30 04:19:09 -07:00
|
|
|
DeleteGeneric(JSContext *cx, HandleObject obj, HandleId id, MutableHandleValue rval, JSBool strict);
|
2010-06-12 09:29:04 -07:00
|
|
|
|
2012-05-19 15:03:45 -07:00
|
|
|
} /* namespace js::baseops */
|
2010-10-10 15:37:22 -07:00
|
|
|
|
2011-04-01 15:24:21 -07:00
|
|
|
/* ES5 8.12.8. */
|
|
|
|
extern JSBool
|
2012-07-30 04:19:09 -07:00
|
|
|
DefaultValue(JSContext *cx, HandleObject obj, JSType hint, MutableHandleValue vp);
|
2011-04-01 15:24:21 -07:00
|
|
|
|
2011-09-02 17:23:26 -07:00
|
|
|
extern Class ArrayClass;
|
|
|
|
extern Class ArrayBufferClass;
|
|
|
|
extern Class BlockClass;
|
|
|
|
extern Class BooleanClass;
|
|
|
|
extern Class CallableObjectClass;
|
2012-03-25 19:14:27 -07:00
|
|
|
extern Class DataViewClass;
|
2011-09-02 17:23:26 -07:00
|
|
|
extern Class DateClass;
|
|
|
|
extern Class ErrorClass;
|
2012-02-07 10:57:16 -08:00
|
|
|
extern Class ElementIteratorClass;
|
2011-09-02 17:23:26 -07:00
|
|
|
extern Class GeneratorClass;
|
2012-11-12 13:23:01 -08:00
|
|
|
extern Class IntlClass;
|
2011-09-02 17:23:26 -07:00
|
|
|
extern Class JSONClass;
|
2012-07-04 08:24:25 -07:00
|
|
|
extern Class MapIteratorClass;
|
2011-09-02 17:23:26 -07:00
|
|
|
extern Class MathClass;
|
2013-01-18 05:18:07 -08:00
|
|
|
extern Class ModuleClass;
|
2011-09-02 17:23:26 -07:00
|
|
|
extern Class NumberClass;
|
|
|
|
extern Class NormalArgumentsObjectClass;
|
|
|
|
extern Class ObjectClass;
|
|
|
|
extern Class ProxyClass;
|
|
|
|
extern Class RegExpClass;
|
2012-01-30 18:12:03 -08:00
|
|
|
extern Class RegExpStaticsClass;
|
2012-07-04 08:24:25 -07:00
|
|
|
extern Class SetIteratorClass;
|
2011-09-02 17:23:26 -07:00
|
|
|
extern Class StopIterationClass;
|
|
|
|
extern Class StringClass;
|
|
|
|
extern Class StrictArgumentsObjectClass;
|
|
|
|
extern Class WeakMapClass;
|
|
|
|
extern Class WithClass;
|
2010-10-10 15:37:22 -07:00
|
|
|
|
2011-09-02 17:23:26 -07:00
|
|
|
class ArgumentsObject;
|
2012-03-28 14:43:01 -07:00
|
|
|
class ArrayBufferObject;
|
2012-01-02 15:02:05 -08:00
|
|
|
class BlockObject;
|
2011-10-20 22:47:30 -07:00
|
|
|
class BooleanObject;
|
2012-01-02 15:02:05 -08:00
|
|
|
class ClonedBlockObject;
|
2012-03-25 19:14:27 -07:00
|
|
|
class DataViewObject;
|
2011-12-20 17:42:45 -08:00
|
|
|
class DebugScopeObject;
|
2012-01-02 15:02:05 -08:00
|
|
|
class DeclEnvObject;
|
2012-02-07 10:57:16 -08:00
|
|
|
class ElementIteratorObject;
|
2011-09-02 17:23:26 -07:00
|
|
|
class GlobalObject;
|
2012-07-04 08:24:25 -07:00
|
|
|
class MapObject;
|
|
|
|
class MapIteratorObject;
|
2013-01-18 05:18:07 -08:00
|
|
|
class Module;
|
2012-01-02 15:02:05 -08:00
|
|
|
class NestedScopeObject;
|
2012-01-12 19:03:25 -08:00
|
|
|
class NewObjectCache;
|
2011-09-02 17:23:26 -07:00
|
|
|
class NormalArgumentsObject;
|
2011-05-13 14:12:15 -07:00
|
|
|
class NumberObject;
|
2012-07-03 14:34:40 -07:00
|
|
|
class PropertyIteratorObject;
|
2012-01-02 15:02:05 -08:00
|
|
|
class ScopeObject;
|
2012-07-04 08:24:25 -07:00
|
|
|
class SetObject;
|
|
|
|
class SetIteratorObject;
|
2012-01-02 15:02:05 -08:00
|
|
|
class StaticBlockObject;
|
2011-09-02 17:23:26 -07:00
|
|
|
class StrictArgumentsObject;
|
|
|
|
class StringObject;
|
2011-10-04 23:48:32 -07:00
|
|
|
class RegExpObject;
|
2012-01-02 15:02:05 -08:00
|
|
|
class WithObject;
|
2010-07-23 14:41:56 -07:00
|
|
|
|
2011-09-02 17:23:26 -07:00
|
|
|
} /* namespace js */
|
2010-10-18 12:55:56 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
/*
|
2012-02-09 18:54:28 -08:00
|
|
|
* The public interface for an object.
|
2011-08-11 09:42:41 -07:00
|
|
|
*
|
2012-02-09 18:54:28 -08:00
|
|
|
* Implementation of the underlying structure occurs in ObjectImpl, from which
|
|
|
|
* this struct inherits. This inheritance is currently public, but it will
|
|
|
|
* eventually be made protected. For full details, see vm/ObjectImpl.{h,cpp}.
|
2010-10-18 12:55:56 -07:00
|
|
|
*
|
2012-02-09 18:54:28 -08:00
|
|
|
* The JSFunction struct is an extension of this struct allocated from a larger
|
|
|
|
* GC size-class.
|
2007-03-22 10:30:00 -07:00
|
|
|
*/
|
2012-12-31 12:40:21 -08:00
|
|
|
class JSObject : public js::ObjectImpl
|
2011-10-10 11:41:03 -07:00
|
|
|
{
|
|
|
|
private:
|
2012-12-21 16:16:50 -08:00
|
|
|
friend class js::Shape;
|
2011-12-07 05:22:47 -08:00
|
|
|
friend struct js::GCMarker;
|
2012-01-12 19:03:25 -08:00
|
|
|
friend class js::NewObjectCache;
|
2011-10-10 11:41:03 -07:00
|
|
|
|
|
|
|
/* Make the type object to use for LAZY_TYPE objects. */
|
2013-02-13 17:24:00 -08:00
|
|
|
static js::types::TypeObject *makeLazyType(JSContext *cx, js::HandleObject obj);
|
2011-10-10 11:41:03 -07:00
|
|
|
|
2010-08-29 11:57:08 -07:00
|
|
|
public:
|
2011-10-10 11:41:03 -07:00
|
|
|
/*
|
|
|
|
* Update the last property, keeping the number of allocated slots in sync
|
|
|
|
* with the object's new slot span.
|
|
|
|
*/
|
2012-11-29 10:22:10 -08:00
|
|
|
static bool setLastProperty(JSContext *cx, JS::HandleObject obj, js::HandleShape shape);
|
2011-10-10 11:41:03 -07:00
|
|
|
|
|
|
|
/* As above, but does not change the slot span. */
|
2012-11-29 10:22:10 -08:00
|
|
|
inline void setLastPropertyInfallible(js::UnrootedShape shape);
|
2011-10-10 11:41:03 -07:00
|
|
|
|
2011-11-18 14:59:31 -08:00
|
|
|
/* Make a non-array object with the specified initial state. */
|
|
|
|
static inline JSObject *create(JSContext *cx,
|
|
|
|
js::gc::AllocKind kind,
|
2013-01-28 11:01:54 -08:00
|
|
|
js::gc::InitialHeap heap,
|
2011-12-31 06:32:04 -08:00
|
|
|
js::HandleShape shape,
|
|
|
|
js::HandleTypeObject type,
|
2012-02-17 18:43:48 -08:00
|
|
|
js::HeapSlot *slots);
|
2011-11-18 14:59:31 -08:00
|
|
|
|
2013-01-10 16:53:11 -08:00
|
|
|
/* Make an array object with the specified initial state. */
|
|
|
|
static inline JSObject *createArray(JSContext *cx,
|
|
|
|
js::gc::AllocKind kind,
|
2013-01-28 11:01:54 -08:00
|
|
|
js::gc::InitialHeap heap,
|
2013-01-10 16:53:11 -08:00
|
|
|
js::HandleShape shape,
|
|
|
|
js::HandleTypeObject type,
|
|
|
|
uint32_t length);
|
2011-10-10 11:41:03 -07:00
|
|
|
|
2011-10-13 20:21:36 -07:00
|
|
|
/*
|
|
|
|
* Remove the last property of an object, provided that it is safe to do so
|
|
|
|
* (the shape and previous shape do not carry conflicting information about
|
|
|
|
* the object itself).
|
|
|
|
*/
|
|
|
|
inline void removeLastProperty(JSContext *cx);
|
|
|
|
inline bool canRemoveLastProperty();
|
|
|
|
|
2011-10-10 11:41:03 -07:00
|
|
|
/*
|
|
|
|
* Update the slot span directly for a dictionary object, and allocate
|
|
|
|
* slots to cover the new span if necessary.
|
|
|
|
*/
|
2012-11-14 16:06:27 -08:00
|
|
|
static bool setSlotSpan(JSContext *cx, JS::HandleObject obj, uint32_t span);
|
2011-10-10 11:41:03 -07:00
|
|
|
|
2011-10-14 11:06:15 -07:00
|
|
|
/* Upper bound on the number of elements in an object. */
|
Bug 708735 - Use <stdint.h> types in JSAPI and throughout SpiderMonkey. Continue to provide the {u,}int{8,16,32,64} and JS{Uint,Int}{8,16,32,64} integer types through a single header, however, for a simpler backout strategy -- and also to ease the transition for embedders. r=timeless on switching the jsd API to use the <stdint.h> types, r=luke, r=dmandelin
2011-12-08 19:54:10 -08:00
|
|
|
static const uint32_t NELEMENTS_LIMIT = JS_BIT(28);
|
2011-10-14 11:06:15 -07:00
|
|
|
|
2011-04-08 19:51:40 -07:00
|
|
|
public:
|
2011-10-14 13:51:21 -07:00
|
|
|
inline bool setDelegate(JSContext *cx);
|
2009-08-27 22:53:26 -07:00
|
|
|
|
2011-10-14 13:51:21 -07:00
|
|
|
inline bool isBoundFunction() const;
|
2009-08-27 22:53:26 -07:00
|
|
|
|
2011-10-14 13:51:21 -07:00
|
|
|
inline bool hasSpecialEquality() const;
|
2010-11-12 10:40:12 -08:00
|
|
|
|
2011-10-14 13:51:21 -07:00
|
|
|
inline bool watched() const;
|
|
|
|
inline bool setWatched(JSContext *cx);
|
2010-11-12 10:40:12 -08:00
|
|
|
|
2011-10-14 13:51:21 -07:00
|
|
|
/* See StackFrame::varObj. */
|
2011-12-20 17:42:45 -08:00
|
|
|
inline bool isVarObj();
|
2011-10-14 13:51:21 -07:00
|
|
|
inline bool setVarObj(JSContext *cx);
|
2011-05-24 15:05:30 -07:00
|
|
|
|
2011-11-16 12:52:47 -08:00
|
|
|
/*
|
|
|
|
* Objects with an uncacheable proto can have their prototype mutated
|
|
|
|
* without inducing a shape change on the object. Property cache entries
|
|
|
|
* and JIT inline caches should not be filled for lookups across prototype
|
|
|
|
* lookups on the object.
|
|
|
|
*/
|
|
|
|
inline bool hasUncacheableProto() const;
|
2011-11-29 13:37:18 -08:00
|
|
|
inline bool setUncacheableProto(JSContext *cx);
|
2011-11-16 12:52:47 -08:00
|
|
|
|
2012-01-05 06:38:46 -08:00
|
|
|
bool generateOwnShape(JSContext *cx, js::Shape *newShape = NULL) {
|
|
|
|
return replaceWithNewEquivalentShape(cx, lastProperty(), newShape);
|
|
|
|
}
|
2010-08-29 11:57:08 -07:00
|
|
|
|
2011-11-02 13:34:19 -07:00
|
|
|
private:
|
2012-01-05 06:38:46 -08:00
|
|
|
js::Shape *replaceWithNewEquivalentShape(JSContext *cx, js::Shape *existingShape,
|
|
|
|
js::Shape *newShape = NULL);
|
|
|
|
|
2011-10-14 13:51:21 -07:00
|
|
|
enum GenerateShape {
|
|
|
|
GENERATE_NONE,
|
|
|
|
GENERATE_SHAPE
|
|
|
|
};
|
|
|
|
|
Bug 708735 - Use <stdint.h> types in JSAPI and throughout SpiderMonkey. Continue to provide the {u,}int{8,16,32,64} and JS{Uint,Int}{8,16,32,64} integer types through a single header, however, for a simpler backout strategy -- and also to ease the transition for embedders. r=timeless on switching the jsd API to use the <stdint.h> types, r=luke, r=dmandelin
2011-12-08 19:54:10 -08:00
|
|
|
bool setFlag(JSContext *cx, /*BaseShape::Flag*/ uint32_t flag,
|
2011-10-14 13:51:21 -07:00
|
|
|
GenerateShape generateShape = GENERATE_NONE);
|
2013-01-29 18:50:41 -08:00
|
|
|
bool clearFlag(JSContext *cx, /*BaseShape::Flag*/ uint32_t flag);
|
2011-10-14 13:51:21 -07:00
|
|
|
|
2010-08-29 11:57:08 -07:00
|
|
|
public:
|
|
|
|
inline bool nativeEmpty() const;
|
2009-08-27 22:53:26 -07:00
|
|
|
|
2011-09-28 15:04:55 -07:00
|
|
|
bool shadowingShapeChange(JSContext *cx, const js::Shape &shape);
|
2010-08-29 11:57:08 -07:00
|
|
|
|
2013-01-10 16:53:11 -08:00
|
|
|
/*
|
|
|
|
* Whether there may be indexed properties on this object, excluding any in
|
|
|
|
* the object's elements.
|
|
|
|
*/
|
2011-10-14 13:51:21 -07:00
|
|
|
inline bool isIndexed() const;
|
2011-11-18 16:22:52 -08:00
|
|
|
|
Bug 708735 - Use <stdint.h> types in JSAPI and throughout SpiderMonkey. Continue to provide the {u,}int{8,16,32,64} and JS{Uint,Int}{8,16,32,64} integer types through a single header, however, for a simpler backout strategy -- and also to ease the transition for embedders. r=timeless on switching the jsd API to use the <stdint.h> types, r=luke, r=dmandelin
2011-12-08 19:54:10 -08:00
|
|
|
inline uint32_t propertyCount() const;
|
2010-08-29 11:57:08 -07:00
|
|
|
|
2012-05-02 14:33:17 -07:00
|
|
|
inline bool hasShapeTable() const;
|
2010-08-29 11:57:08 -07:00
|
|
|
|
2012-01-30 18:12:03 -08:00
|
|
|
inline size_t computedSizeOfThisSlotsElements() const;
|
2012-01-23 15:35:37 -08:00
|
|
|
|
2012-11-21 17:07:42 -08:00
|
|
|
inline void sizeOfExcludingThis(JSMallocSizeOfFun mallocSizeOf, JS::ObjectsExtraSizes *sizes);
|
2010-09-01 14:09:54 -07:00
|
|
|
|
2012-07-10 19:45:14 -07:00
|
|
|
bool hasIdempotentProtoChain() const;
|
2012-07-09 15:13:32 -07:00
|
|
|
|
Bug 708735 - Use <stdint.h> types in JSAPI and throughout SpiderMonkey. Continue to provide the {u,}int{8,16,32,64} and JS{Uint,Int}{8,16,32,64} integer types through a single header, however, for a simpler backout strategy -- and also to ease the transition for embedders. r=timeless on switching the jsd API to use the <stdint.h> types, r=luke, r=dmandelin
2011-12-08 19:54:10 -08:00
|
|
|
static const uint32_t MAX_FIXED_SLOTS = 16;
|
2011-10-10 17:14:38 -07:00
|
|
|
|
2011-10-10 11:41:03 -07:00
|
|
|
public:
|
2011-04-08 19:51:40 -07:00
|
|
|
|
2011-10-10 11:41:03 -07:00
|
|
|
/* Accessors for properties. */
|
2011-04-08 19:51:40 -07:00
|
|
|
|
|
|
|
/* Whether a slot is at a fixed offset from this object. */
|
|
|
|
inline bool isFixedSlot(size_t slot);
|
|
|
|
|
|
|
|
/* Index into the dynamic slots array to use for a dynamic slot. */
|
|
|
|
inline size_t dynamicSlotIndex(size_t slot);
|
|
|
|
|
2011-10-10 11:41:03 -07:00
|
|
|
/* Get a raw pointer to the object's properties. */
|
2012-02-17 18:43:48 -08:00
|
|
|
inline const js::HeapSlot *getRawSlots();
|
2011-09-08 10:53:43 -07:00
|
|
|
|
2011-10-10 11:41:03 -07:00
|
|
|
/*
|
|
|
|
* Grow or shrink slots immediately before changing the slot span.
|
|
|
|
* The number of allocated slots is not stored explicitly, and changes to
|
|
|
|
* the slots must track changes in the slot span.
|
|
|
|
*/
|
2012-09-16 16:32:02 -07:00
|
|
|
static bool growSlots(JSContext *cx, js::HandleObject obj, uint32_t oldCount,
|
|
|
|
uint32_t newCount);
|
|
|
|
static void shrinkSlots(JSContext *cx, js::HandleObject obj, uint32_t oldCount,
|
|
|
|
uint32_t newCount);
|
2010-10-13 11:49:22 -07:00
|
|
|
|
2011-10-10 11:41:03 -07:00
|
|
|
bool hasDynamicSlots() const { return slots != NULL; }
|
|
|
|
|
|
|
|
protected:
|
2012-09-16 16:32:02 -07:00
|
|
|
static inline bool updateSlotsForSpan(JSContext *cx, js::HandleObject obj, size_t oldSpan,
|
|
|
|
size_t newSpan);
|
2011-10-10 11:41:03 -07:00
|
|
|
|
|
|
|
public:
|
2011-10-25 16:07:42 -07:00
|
|
|
/*
|
|
|
|
* Trigger the write barrier on a range of slots that will no longer be
|
|
|
|
* reachable.
|
|
|
|
*/
|
|
|
|
inline void prepareSlotRangeForOverwrite(size_t start, size_t end);
|
2011-11-14 09:13:33 -08:00
|
|
|
inline void prepareElementRangeForOverwrite(size_t start, size_t end);
|
2011-04-08 19:51:40 -07:00
|
|
|
|
Bug 708735 - Use <stdint.h> types in JSAPI and throughout SpiderMonkey. Continue to provide the {u,}int{8,16,32,64} and JS{Uint,Int}{8,16,32,64} integer types through a single header, however, for a simpler backout strategy -- and also to ease the transition for embedders. r=timeless on switching the jsd API to use the <stdint.h> types, r=luke, r=dmandelin
2011-12-08 19:54:10 -08:00
|
|
|
void rollbackProperties(JSContext *cx, uint32_t slotSpan);
|
2011-05-12 20:07:23 -07:00
|
|
|
|
2012-02-28 15:11:11 -08:00
|
|
|
inline void nativeSetSlot(unsigned slot, const js::Value &value);
|
2012-09-16 16:32:02 -07:00
|
|
|
static inline void nativeSetSlotWithType(JSContext *cx, js::HandleObject, js::Shape *shape,
|
|
|
|
const js::Value &value);
|
2010-03-30 14:42:48 -07:00
|
|
|
|
2012-02-28 15:11:11 -08:00
|
|
|
inline const js::Value &getReservedSlot(unsigned index) const;
|
|
|
|
inline js::HeapSlot &getReservedSlotRef(unsigned index);
|
|
|
|
inline void initReservedSlot(unsigned index, const js::Value &v);
|
|
|
|
inline void setReservedSlot(unsigned index, const js::Value &v);
|
2011-04-27 16:22:28 -07:00
|
|
|
|
2011-07-15 10:14:07 -07:00
|
|
|
/*
|
|
|
|
* Marks this object as having a singleton type, and leave the type lazy.
|
|
|
|
* Constructs a new, unique shape for the object.
|
|
|
|
*/
|
2012-08-21 12:13:28 -07:00
|
|
|
static inline bool setSingletonType(JSContext *cx, js::HandleObject obj);
|
2011-07-15 10:14:07 -07:00
|
|
|
|
|
|
|
inline js::types::TypeObject *getType(JSContext *cx);
|
|
|
|
|
2012-02-17 11:46:11 -08:00
|
|
|
const js::HeapPtr<js::types::TypeObject> &typeFromGC() const {
|
2011-07-15 10:14:07 -07:00
|
|
|
/* Direct field access for use by GC. */
|
|
|
|
return type_;
|
|
|
|
}
|
|
|
|
|
2012-09-26 09:49:20 -07:00
|
|
|
/*
|
|
|
|
* We allow the prototype of an object to be lazily computed if the object
|
|
|
|
* is a proxy. In the lazy case, we store (JSObject *)0x1 in the proto field
|
|
|
|
* of the object's TypeObject. We offer three ways of getting the prototype:
|
|
|
|
*
|
|
|
|
* 1. obj->getProto() returns the prototype, but asserts if obj is a proxy.
|
|
|
|
* 2. obj->getTaggedProto() returns a TaggedProto, which can be tested to
|
|
|
|
* check if the proto is an object, NULL, or lazily computed.
|
|
|
|
* 3. JSObject::getProto(cx, obj, &proto) computes the proto of an object.
|
|
|
|
* If obj is a proxy and the proto is lazy, this code may allocate or
|
|
|
|
* GC in order to compute the proto. Currently, it will not run JS code.
|
|
|
|
*/
|
|
|
|
inline JSObject *getProto() const;
|
|
|
|
inline js::TaggedProto getTaggedProto() const;
|
|
|
|
static inline bool getProto(JSContext *cx, js::HandleObject obj,
|
|
|
|
js::MutableHandleObject protop);
|
|
|
|
|
2010-12-18 20:44:51 -08:00
|
|
|
inline void setType(js::types::TypeObject *newType);
|
|
|
|
|
2013-01-23 11:57:55 -08:00
|
|
|
js::types::TypeObject *getNewType(JSContext *cx, js::Class *clasp, JSFunction *fun = NULL);
|
2011-10-07 20:09:09 -07:00
|
|
|
|
|
|
|
#ifdef DEBUG
|
2013-01-23 11:57:55 -08:00
|
|
|
bool hasNewType(js::Class *clasp, js::types::TypeObject *newType);
|
2011-10-07 20:09:09 -07:00
|
|
|
#endif
|
2011-07-15 10:14:07 -07:00
|
|
|
|
2011-11-08 18:34:11 -08:00
|
|
|
/*
|
|
|
|
* Mark an object that has been iterated over and is a singleton. We need
|
|
|
|
* to recover this information in the object's type information after it
|
|
|
|
* is purged on GC.
|
|
|
|
*/
|
2011-10-14 13:51:21 -07:00
|
|
|
inline bool setIteratedSingleton(JSContext *cx);
|
|
|
|
|
2011-11-08 18:34:11 -08:00
|
|
|
/*
|
|
|
|
* Mark an object as requiring its default 'new' type to have unknown
|
2011-11-18 13:59:48 -08:00
|
|
|
* properties.
|
2011-11-08 18:34:11 -08:00
|
|
|
*/
|
2013-01-23 11:57:55 -08:00
|
|
|
static bool setNewTypeUnknown(JSContext *cx, js::Class *clasp, JS::HandleObject obj);
|
2011-11-08 18:34:11 -08:00
|
|
|
|
2011-07-15 10:14:07 -07:00
|
|
|
/* Set a new prototype for an object with a singleton type. */
|
2013-01-23 11:57:55 -08:00
|
|
|
bool splicePrototype(JSContext *cx, js::Class *clasp, js::Handle<js::TaggedProto> proto);
|
2011-07-15 10:14:07 -07:00
|
|
|
|
|
|
|
/*
|
|
|
|
* For bootstrapping, whether to splice a prototype for Function.prototype
|
|
|
|
* or the global object.
|
|
|
|
*/
|
|
|
|
bool shouldSplicePrototype(JSContext *cx);
|
2009-08-27 22:53:26 -07:00
|
|
|
|
2011-11-09 09:52:59 -08:00
|
|
|
/*
|
|
|
|
* Parents and scope chains.
|
|
|
|
*
|
|
|
|
* All script-accessible objects with a NULL parent are global objects,
|
|
|
|
* and all global objects have a NULL parent. Some builtin objects which
|
|
|
|
* are not script-accessible also have a NULL parent, such as parser
|
|
|
|
* created functions for non-compileAndGo scripts.
|
|
|
|
*
|
|
|
|
* Except for the non-script-accessible builtins, the global with which an
|
|
|
|
* object is associated can be reached by following parent links to that
|
2012-01-02 15:02:05 -08:00
|
|
|
* global (see global()).
|
2011-11-09 09:52:59 -08:00
|
|
|
*
|
|
|
|
* The scope chain of an object is the link in the search path when a
|
|
|
|
* script does a name lookup on a scope object. For JS internal scope
|
2012-01-02 15:02:05 -08:00
|
|
|
* objects --- Call, DeclEnv and block --- the chain is stored in
|
2011-11-09 09:52:59 -08:00
|
|
|
* the first fixed slot of the object, and the object's parent is the
|
|
|
|
* associated global. For other scope objects, the chain is stored in the
|
|
|
|
* object's parent.
|
|
|
|
*
|
|
|
|
* In compileAndGo code, scope chains can contain only internal scope
|
|
|
|
* objects with a global object at the root as the scope of the outermost
|
|
|
|
* non-function script. In non-compileAndGo code, the scope of the
|
|
|
|
* outermost non-function script might not be a global object, and can have
|
|
|
|
* a mix of other objects above it before the global object is reached.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* Access the parent link of an object. */
|
2011-10-12 22:29:43 -07:00
|
|
|
inline JSObject *getParent() const;
|
2012-04-30 17:10:30 -07:00
|
|
|
static bool setParent(JSContext *cx, js::HandleObject obj, js::HandleObject newParent);
|
2009-08-27 22:53:26 -07:00
|
|
|
|
2011-11-09 09:52:59 -08:00
|
|
|
/*
|
2012-01-02 15:02:05 -08:00
|
|
|
* Get the enclosing scope of an object. When called on non-scope object,
|
|
|
|
* this will just be the global (the name "enclosing scope" still applies
|
|
|
|
* in this situation because non-scope objects can be on the scope chain).
|
2011-11-09 09:52:59 -08:00
|
|
|
*/
|
2012-01-02 15:02:05 -08:00
|
|
|
inline JSObject *enclosingScope();
|
2011-10-12 22:29:43 -07:00
|
|
|
|
2012-01-02 15:02:05 -08:00
|
|
|
inline js::GlobalObject &global() const;
|
2011-10-12 22:29:43 -07:00
|
|
|
|
2011-10-13 20:21:36 -07:00
|
|
|
/* Remove the type (and prototype) or parent from a new object. */
|
2012-07-10 18:17:29 -07:00
|
|
|
static inline bool clearType(JSContext *cx, js::HandleObject obj);
|
|
|
|
static bool clearParent(JSContext *cx, js::HandleObject obj);
|
2011-10-13 20:21:36 -07:00
|
|
|
|
2010-09-21 11:35:29 -07:00
|
|
|
/*
|
|
|
|
* ES5 meta-object properties and operations.
|
|
|
|
*/
|
|
|
|
|
|
|
|
private:
|
2010-11-12 16:15:55 -08:00
|
|
|
enum ImmutabilityType { SEAL, FREEZE };
|
|
|
|
|
2010-09-21 11:35:29 -07:00
|
|
|
/*
|
|
|
|
* The guts of Object.seal (ES5 15.2.3.8) and Object.freeze (ES5 15.2.3.9): mark the
|
|
|
|
* object as non-extensible, and adjust each property's attributes appropriately: each
|
|
|
|
* property becomes non-configurable, and if |freeze|, data properties become
|
|
|
|
* read-only as well.
|
|
|
|
*/
|
2012-08-21 12:13:28 -07:00
|
|
|
static bool sealOrFreeze(JSContext *cx, js::HandleObject obj, ImmutabilityType it);
|
2010-09-21 11:35:29 -07:00
|
|
|
|
2012-07-12 11:36:27 -07:00
|
|
|
static bool isSealedOrFrozen(JSContext *cx, js::HandleObject obj, ImmutabilityType it, bool *resultp);
|
2011-07-14 09:05:52 -07:00
|
|
|
|
2012-02-28 15:11:11 -08:00
|
|
|
static inline unsigned getSealedOrFrozenAttributes(unsigned attrs, ImmutabilityType it);
|
2012-01-05 19:51:08 -08:00
|
|
|
|
2010-09-21 11:35:29 -07:00
|
|
|
public:
|
2012-04-27 14:09:32 -07:00
|
|
|
bool preventExtensions(JSContext *cx);
|
2010-11-12 16:15:55 -08:00
|
|
|
|
2010-09-21 11:35:29 -07:00
|
|
|
/* ES5 15.2.3.8: non-extensible, all props non-configurable */
|
2012-08-21 12:13:28 -07:00
|
|
|
static inline bool seal(JSContext *cx, js::HandleObject obj) { return sealOrFreeze(cx, obj, SEAL); }
|
2010-09-21 11:35:29 -07:00
|
|
|
/* ES5 15.2.3.9: non-extensible, all properties non-configurable, all data props read-only */
|
2012-08-21 12:13:28 -07:00
|
|
|
static inline bool freeze(JSContext *cx, js::HandleObject obj) { return sealOrFreeze(cx, obj, FREEZE); }
|
2011-07-14 09:05:52 -07:00
|
|
|
|
2012-07-12 11:36:27 -07:00
|
|
|
static inline bool isSealed(JSContext *cx, js::HandleObject obj, bool *resultp) {
|
|
|
|
return isSealedOrFrozen(cx, obj, SEAL, resultp);
|
|
|
|
}
|
|
|
|
static inline bool isFrozen(JSContext *cx, js::HandleObject obj, bool *resultp) {
|
|
|
|
return isSealedOrFrozen(cx, obj, FREEZE, resultp);
|
|
|
|
}
|
2012-02-07 10:57:16 -08:00
|
|
|
|
2011-10-10 11:41:03 -07:00
|
|
|
/* Accessors for elements. */
|
|
|
|
|
2012-02-28 15:11:11 -08:00
|
|
|
inline bool ensureElements(JSContext *cx, unsigned cap);
|
|
|
|
bool growElements(JSContext *cx, unsigned cap);
|
2013-01-24 21:12:44 -08:00
|
|
|
bool growElements(js::Allocator *alloc, unsigned cap);
|
2012-02-28 15:11:11 -08:00
|
|
|
void shrinkElements(JSContext *cx, unsigned cap);
|
2012-08-23 21:29:42 -07:00
|
|
|
inline void setDynamicElements(js::ObjectElements *header);
|
2012-02-07 10:57:16 -08:00
|
|
|
|
2013-01-10 16:53:11 -08:00
|
|
|
inline uint32_t getDenseCapacity();
|
|
|
|
inline void setDenseInitializedLength(uint32_t length);
|
|
|
|
inline void ensureDenseInitializedLength(JSContext *cx, unsigned index, unsigned extra);
|
|
|
|
inline void setDenseElement(unsigned idx, const js::Value &val);
|
|
|
|
inline void initDenseElement(unsigned idx, const js::Value &val);
|
2013-01-29 15:20:03 -08:00
|
|
|
inline void setDenseElementMaybeConvertDouble(unsigned idx, const js::Value &val);
|
2013-01-10 16:53:11 -08:00
|
|
|
static inline void setDenseElementWithType(JSContext *cx, js::HandleObject obj,
|
|
|
|
unsigned idx, const js::Value &val);
|
|
|
|
static inline void initDenseElementWithType(JSContext *cx, js::HandleObject obj,
|
|
|
|
unsigned idx, const js::Value &val);
|
|
|
|
static inline void setDenseElementHole(JSContext *cx, js::HandleObject obj, unsigned idx);
|
|
|
|
static inline void removeDenseElementForSparseIndex(JSContext *cx, js::HandleObject obj,
|
|
|
|
unsigned idx);
|
|
|
|
inline void copyDenseElements(unsigned dstStart, const js::Value *src, unsigned count);
|
|
|
|
inline void initDenseElements(unsigned dstStart, const js::Value *src, unsigned count);
|
|
|
|
inline void moveDenseElements(unsigned dstStart, unsigned srcStart, unsigned count);
|
|
|
|
inline void moveDenseElementsUnbarriered(unsigned dstStart, unsigned srcStart, unsigned count);
|
2013-01-29 15:20:03 -08:00
|
|
|
inline bool shouldConvertDoubleElements();
|
|
|
|
inline void setShouldConvertDoubleElements();
|
2013-01-10 16:53:11 -08:00
|
|
|
|
|
|
|
/* Packed information for this object's elements. */
|
|
|
|
inline void markDenseElementsNotPacked(JSContext *cx);
|
2010-11-05 07:37:09 -07:00
|
|
|
|
2010-10-14 07:12:19 -07:00
|
|
|
/*
|
2013-01-10 16:53:11 -08:00
|
|
|
* ensureDenseElements ensures that the object can hold at least
|
2010-10-14 07:12:19 -07:00
|
|
|
* index + extra elements. It returns ED_OK on success, ED_FAILED on
|
2013-01-10 16:53:11 -08:00
|
|
|
* failure to grow the array, ED_SPARSE when the object is too sparse to
|
2010-10-14 07:12:19 -07:00
|
|
|
* grow (this includes the case of index + extra overflow). In the last
|
2013-01-10 16:53:11 -08:00
|
|
|
* two cases the object is kept intact.
|
2010-10-14 07:12:19 -07:00
|
|
|
*/
|
|
|
|
enum EnsureDenseResult { ED_OK, ED_FAILED, ED_SPARSE };
|
2013-01-10 16:53:11 -08:00
|
|
|
inline EnsureDenseResult ensureDenseElements(JSContext *cx, unsigned index, unsigned extra);
|
2013-01-24 21:12:44 -08:00
|
|
|
inline EnsureDenseResult parExtendDenseElements(js::Allocator *alloc, js::Value *v,
|
|
|
|
uint32_t extra);
|
|
|
|
template<typename CONTEXT>
|
|
|
|
inline EnsureDenseResult extendDenseElements(CONTEXT *cx, unsigned requiredCapacity, unsigned extra);
|
2010-10-14 07:12:19 -07:00
|
|
|
|
2013-01-10 16:53:11 -08:00
|
|
|
/* Convert a single dense element to a sparse property. */
|
|
|
|
static bool sparsifyDenseElement(JSContext *cx, js::HandleObject obj, unsigned index);
|
2010-10-14 07:12:19 -07:00
|
|
|
|
2013-01-10 16:53:11 -08:00
|
|
|
/* Convert all dense elements to sparse properties. */
|
|
|
|
static bool sparsifyDenseElements(JSContext *cx, js::HandleObject obj);
|
2010-06-02 23:44:24 -07:00
|
|
|
|
2013-01-29 18:50:41 -08:00
|
|
|
/* Small objects are dense, no matter what. */
|
|
|
|
static const unsigned MIN_SPARSE_INDEX = 1000;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Element storage for an object will be sparse if fewer than 1/8 indexes
|
|
|
|
* are filled in.
|
|
|
|
*/
|
|
|
|
static const unsigned SPARSE_DENSITY_RATIO = 8;
|
|
|
|
|
2011-06-28 12:46:00 -07:00
|
|
|
/*
|
2013-01-10 16:53:11 -08:00
|
|
|
* Check if after growing the object's elements will be too sparse.
|
|
|
|
* newElementsHint is an estimated number of elements to be added.
|
2011-06-28 12:46:00 -07:00
|
|
|
*/
|
2013-01-10 16:53:11 -08:00
|
|
|
bool willBeSparseElements(unsigned requiredCapacity, unsigned newElementsHint);
|
|
|
|
|
2013-01-29 18:50:41 -08:00
|
|
|
/*
|
|
|
|
* After adding a sparse index to obj, see if it should be converted to use
|
|
|
|
* dense elements.
|
|
|
|
*/
|
|
|
|
static EnsureDenseResult maybeDensifySparseElements(JSContext *cx, js::HandleObject obj);
|
|
|
|
|
2013-01-10 16:53:11 -08:00
|
|
|
/* Array specific accessors. */
|
|
|
|
inline uint32_t getArrayLength() const;
|
|
|
|
static inline void setArrayLength(JSContext *cx, js::HandleObject obj, uint32_t length);
|
|
|
|
inline void setArrayLengthInt32(uint32_t length);
|
2011-06-28 12:46:00 -07:00
|
|
|
|
2011-09-08 10:53:43 -07:00
|
|
|
public:
|
2010-04-14 18:57:30 -07:00
|
|
|
/*
|
|
|
|
* Date-specific getters and setters.
|
|
|
|
*/
|
|
|
|
|
Bug 708735 - Use <stdint.h> types in JSAPI and throughout SpiderMonkey. Continue to provide the {u,}int{8,16,32,64} and JS{Uint,Int}{8,16,32,64} integer types through a single header, however, for a simpler backout strategy -- and also to ease the transition for embedders. r=timeless on switching the jsd API to use the <stdint.h> types, r=luke, r=dmandelin
2011-12-08 19:54:10 -08:00
|
|
|
static const uint32_t JSSLOT_DATE_UTC_TIME = 0;
|
2012-07-13 15:56:08 -07:00
|
|
|
static const uint32_t JSSLOT_DATE_TZA = 1;
|
2010-04-14 18:57:30 -07:00
|
|
|
|
2010-08-17 10:42:57 -07:00
|
|
|
/*
|
|
|
|
* Cached slots holding local properties of the date.
|
|
|
|
* These are undefined until the first actual lookup occurs
|
|
|
|
* and are reset to undefined whenever the date's time is modified.
|
|
|
|
*/
|
2012-07-13 15:56:08 -07:00
|
|
|
static const uint32_t JSSLOT_DATE_COMPONENTS_START = 2;
|
2010-04-14 18:57:30 -07:00
|
|
|
|
2012-07-13 15:56:08 -07:00
|
|
|
static const uint32_t JSSLOT_DATE_LOCAL_TIME = JSSLOT_DATE_COMPONENTS_START + 0;
|
|
|
|
static const uint32_t JSSLOT_DATE_LOCAL_YEAR = JSSLOT_DATE_COMPONENTS_START + 1;
|
|
|
|
static const uint32_t JSSLOT_DATE_LOCAL_MONTH = JSSLOT_DATE_COMPONENTS_START + 2;
|
|
|
|
static const uint32_t JSSLOT_DATE_LOCAL_DATE = JSSLOT_DATE_COMPONENTS_START + 3;
|
|
|
|
static const uint32_t JSSLOT_DATE_LOCAL_DAY = JSSLOT_DATE_COMPONENTS_START + 4;
|
|
|
|
static const uint32_t JSSLOT_DATE_LOCAL_HOURS = JSSLOT_DATE_COMPONENTS_START + 5;
|
|
|
|
static const uint32_t JSSLOT_DATE_LOCAL_MINUTES = JSSLOT_DATE_COMPONENTS_START + 6;
|
|
|
|
static const uint32_t JSSLOT_DATE_LOCAL_SECONDS = JSSLOT_DATE_COMPONENTS_START + 7;
|
2010-08-17 10:42:57 -07:00
|
|
|
|
2012-07-13 15:56:08 -07:00
|
|
|
static const uint32_t DATE_CLASS_RESERVED_SLOTS = JSSLOT_DATE_LOCAL_SECONDS + 1;
|
2010-04-14 18:57:30 -07:00
|
|
|
|
2010-07-14 23:19:36 -07:00
|
|
|
inline const js::Value &getDateUTCTime() const;
|
|
|
|
inline void setDateUTCTime(const js::Value &pthis);
|
2010-04-14 18:57:30 -07:00
|
|
|
|
2010-07-23 14:41:56 -07:00
|
|
|
/*
|
|
|
|
* Function-specific getters and setters.
|
|
|
|
*/
|
|
|
|
|
2012-12-21 16:16:50 -08:00
|
|
|
friend class JSFunction;
|
2010-07-23 14:41:56 -07:00
|
|
|
|
2011-10-11 15:28:54 -07:00
|
|
|
inline JSFunction *toFunction();
|
|
|
|
inline const JSFunction *toFunction() const;
|
2010-08-29 11:57:08 -07:00
|
|
|
|
2010-04-14 18:57:30 -07:00
|
|
|
public:
|
2010-05-07 17:52:52 -07:00
|
|
|
/*
|
|
|
|
* Iterator-specific getters and setters.
|
|
|
|
*/
|
|
|
|
|
Bug 708735 - Use <stdint.h> types in JSAPI and throughout SpiderMonkey. Continue to provide the {u,}int{8,16,32,64} and JS{Uint,Int}{8,16,32,64} integer types through a single header, however, for a simpler backout strategy -- and also to ease the transition for embedders. r=timeless on switching the jsd API to use the <stdint.h> types, r=luke, r=dmandelin
2011-12-08 19:54:10 -08:00
|
|
|
static const uint32_t ITER_CLASS_NFIXED_SLOTS = 1;
|
2011-10-10 17:14:38 -07:00
|
|
|
|
2010-04-05 18:32:16 -07:00
|
|
|
/*
|
|
|
|
* Back to generic stuff.
|
|
|
|
*/
|
2010-05-18 19:21:43 -07:00
|
|
|
inline bool isCallable();
|
2010-02-22 14:07:50 -08:00
|
|
|
|
2012-03-19 07:34:55 -07:00
|
|
|
inline void finish(js::FreeOp *fop);
|
|
|
|
JS_ALWAYS_INLINE void finalize(js::FreeOp *fop);
|
2009-08-11 13:05:44 -07:00
|
|
|
|
2012-08-21 12:13:28 -07:00
|
|
|
static inline bool hasProperty(JSContext *cx, js::HandleObject obj,
|
|
|
|
js::HandleId id, bool *foundp, unsigned flags = 0);
|
2010-08-29 11:57:08 -07:00
|
|
|
|
2010-12-06 16:27:39 -08:00
|
|
|
/*
|
2011-09-28 15:04:55 -07:00
|
|
|
* Allocate and free an object slot.
|
2010-12-07 08:36:21 -08:00
|
|
|
*
|
|
|
|
* FIXME: bug 593129 -- slot allocation should be done by object methods
|
|
|
|
* after calling object-parameter-free shape methods, avoiding coupling
|
|
|
|
* logic across the object vs. shape module wall.
|
|
|
|
*/
|
2012-11-29 10:22:10 -08:00
|
|
|
static bool allocSlot(JSContext *cx, JS::HandleObject obj, uint32_t *slotp);
|
2012-09-30 21:13:53 -07:00
|
|
|
void freeSlot(uint32_t slot);
|
2010-08-29 11:57:08 -07:00
|
|
|
|
2011-01-14 14:18:53 -08:00
|
|
|
public:
|
2012-06-13 01:11:18 -07:00
|
|
|
static bool reportReadOnly(JSContext *cx, jsid id, unsigned report = JSREPORT_ERROR);
|
2012-02-28 15:11:11 -08:00
|
|
|
bool reportNotConfigurable(JSContext* cx, jsid id, unsigned report = JSREPORT_ERROR);
|
|
|
|
bool reportNotExtensible(JSContext *cx, unsigned report = JSREPORT_ERROR);
|
2010-08-29 11:57:08 -07:00
|
|
|
|
2011-03-28 20:01:53 -07:00
|
|
|
/*
|
|
|
|
* Get the property with the given id, then call it as a function with the
|
|
|
|
* given arguments, providing this object as |this|. If the property isn't
|
|
|
|
* callable a TypeError will be thrown. On success the value returned by
|
|
|
|
* the call is stored in *vp.
|
|
|
|
*/
|
2012-07-30 04:19:09 -07:00
|
|
|
bool callMethod(JSContext *cx, js::HandleId id, unsigned argc, js::Value *argv,
|
|
|
|
js::MutableHandleValue vp);
|
2011-03-28 20:01:53 -07:00
|
|
|
|
2010-09-16 11:56:54 -07:00
|
|
|
private:
|
2012-11-29 10:22:10 -08:00
|
|
|
static js::UnrootedShape getChildProperty(JSContext *cx, JS::HandleObject obj,
|
|
|
|
js::HandleShape parent, js::StackShape &child);
|
2010-08-29 11:57:08 -07:00
|
|
|
|
2012-01-02 15:02:05 -08:00
|
|
|
protected:
|
2010-09-16 11:56:54 -07:00
|
|
|
/*
|
|
|
|
* Internal helper that adds a shape not yet mapped by this object.
|
|
|
|
*
|
|
|
|
* Notes:
|
|
|
|
* 1. getter and setter must be normalized based on flags (see jsscope.cpp).
|
|
|
|
* 2. !isExtensible() checking must be done by callers.
|
|
|
|
*/
|
2012-11-29 10:22:10 -08:00
|
|
|
static js::UnrootedShape addPropertyInternal(JSContext *cx,
|
|
|
|
JS::HandleObject obj, JS::HandleId id,
|
|
|
|
JSPropertyOp getter, JSStrictPropertyOp setter,
|
|
|
|
uint32_t slot, unsigned attrs,
|
|
|
|
unsigned flags, int shortid, js::Shape **spp,
|
|
|
|
bool allowDictionary);
|
2010-08-29 11:57:08 -07:00
|
|
|
|
2012-01-02 15:02:05 -08:00
|
|
|
private:
|
2010-08-29 11:57:08 -07:00
|
|
|
bool toDictionaryMode(JSContext *cx);
|
|
|
|
|
2011-06-03 20:48:16 -07:00
|
|
|
struct TradeGutsReserved;
|
|
|
|
static bool ReserveForTradeGuts(JSContext *cx, JSObject *a, JSObject *b,
|
|
|
|
TradeGutsReserved &reserved);
|
|
|
|
|
|
|
|
static void TradeGuts(JSContext *cx, JSObject *a, JSObject *b,
|
|
|
|
TradeGutsReserved &reserved);
|
|
|
|
|
2010-08-29 11:57:08 -07:00
|
|
|
public:
|
|
|
|
/* Add a property whose id is not yet in this scope. */
|
2012-11-29 10:22:10 -08:00
|
|
|
static js::UnrootedShape addProperty(JSContext *cx, JS::HandleObject, JS::HandleId id,
|
|
|
|
JSPropertyOp getter, JSStrictPropertyOp setter,
|
|
|
|
uint32_t slot, unsigned attrs, unsigned flags,
|
|
|
|
int shortid, bool allowDictionary = true);
|
2010-08-29 11:57:08 -07:00
|
|
|
|
|
|
|
/* Add a data property whose id is not yet in this scope. */
|
2012-11-29 10:22:10 -08:00
|
|
|
js::UnrootedShape addDataProperty(JSContext *cx, jsid id_, uint32_t slot, unsigned attrs) {
|
2010-08-29 11:57:08 -07:00
|
|
|
JS_ASSERT(!(attrs & (JSPROP_GETTER | JSPROP_SETTER)));
|
2012-11-29 10:22:10 -08:00
|
|
|
js::RootedObject self(cx, this);
|
|
|
|
js::RootedId id(cx, id_);
|
|
|
|
return addProperty(cx, self, id, NULL, NULL, slot, attrs, 0, 0);
|
2010-08-29 11:57:08 -07:00
|
|
|
}
|
|
|
|
|
2012-12-27 09:20:22 -08:00
|
|
|
js::UnrootedShape addDataProperty(JSContext *cx, js::HandlePropertyName name, uint32_t slot, unsigned attrs) {
|
|
|
|
JS_ASSERT(!(attrs & (JSPROP_GETTER | JSPROP_SETTER)));
|
|
|
|
js::RootedObject self(cx, this);
|
|
|
|
js::RootedId id(cx, NameToId(name));
|
|
|
|
return addProperty(cx, self, id, NULL, NULL, slot, attrs, 0, 0);
|
|
|
|
}
|
|
|
|
|
2010-08-29 11:57:08 -07:00
|
|
|
/* Add or overwrite a property for id in this scope. */
|
2012-11-29 10:22:10 -08:00
|
|
|
static js::UnrootedShape putProperty(JSContext *cx, JS::HandleObject obj, JS::HandleId id,
|
|
|
|
JSPropertyOp getter, JSStrictPropertyOp setter,
|
|
|
|
uint32_t slot, unsigned attrs,
|
|
|
|
unsigned flags, int shortid);
|
|
|
|
static js::UnrootedShape putProperty(JSContext *cx, JS::HandleObject obj,
|
|
|
|
js::PropertyName *name,
|
|
|
|
JSPropertyOp getter, JSStrictPropertyOp setter,
|
|
|
|
uint32_t slot, unsigned attrs,
|
|
|
|
unsigned flags, int shortid)
|
|
|
|
{
|
|
|
|
js::RootedId id(cx, js::NameToId(name));
|
|
|
|
return putProperty(cx, obj, id, getter, setter, slot, attrs, flags, shortid);
|
2011-12-27 00:27:02 -08:00
|
|
|
}
|
2010-08-29 11:57:08 -07:00
|
|
|
|
|
|
|
/* Change the given property into a sibling with the same id in this scope. */
|
2012-11-29 10:22:10 -08:00
|
|
|
static js::UnrootedShape changeProperty(JSContext *cx, js::HandleObject obj,
|
2013-01-21 09:41:49 -08:00
|
|
|
js::HandleShape shape, unsigned attrs, unsigned mask,
|
2012-11-29 10:22:10 -08:00
|
|
|
JSPropertyOp getter, JSStrictPropertyOp setter);
|
2010-08-29 11:57:08 -07:00
|
|
|
|
2012-08-21 12:13:28 -07:00
|
|
|
static inline bool changePropertyAttributes(JSContext *cx, js::HandleObject obj,
|
2013-01-21 09:41:49 -08:00
|
|
|
js::HandleShape shape, unsigned attrs);
|
2012-03-23 17:59:56 -07:00
|
|
|
|
2010-09-16 11:56:54 -07:00
|
|
|
/* Remove the property named by id from this object. */
|
2010-08-29 11:57:08 -07:00
|
|
|
bool removeProperty(JSContext *cx, jsid id);
|
|
|
|
|
|
|
|
/* Clear the scope, making it empty. */
|
2012-09-16 16:32:02 -07:00
|
|
|
static void clear(JSContext *cx, js::HandleObject obj);
|
2010-08-29 11:57:08 -07:00
|
|
|
|
2012-08-21 12:13:28 -07:00
|
|
|
static inline JSBool lookupGeneric(JSContext *cx, js::HandleObject obj,
|
|
|
|
js::HandleId id,
|
|
|
|
js::MutableHandleObject objp, js::MutableHandleShape propp);
|
|
|
|
static inline JSBool lookupProperty(JSContext *cx, js::HandleObject obj,
|
|
|
|
js::PropertyName *name,
|
|
|
|
js::MutableHandleObject objp, js::MutableHandleShape propp);
|
|
|
|
static inline JSBool lookupElement(JSContext *cx, js::HandleObject obj,
|
|
|
|
uint32_t index,
|
|
|
|
js::MutableHandleObject objp, js::MutableHandleShape propp);
|
|
|
|
static inline JSBool lookupSpecial(JSContext *cx, js::HandleObject obj,
|
|
|
|
js::SpecialId sid,
|
|
|
|
js::MutableHandleObject objp, js::MutableHandleShape propp);
|
|
|
|
|
|
|
|
static inline JSBool defineGeneric(JSContext *cx, js::HandleObject obj,
|
|
|
|
js::HandleId id, js::HandleValue value,
|
|
|
|
JSPropertyOp getter = JS_PropertyStub,
|
|
|
|
JSStrictPropertyOp setter = JS_StrictPropertyStub,
|
|
|
|
unsigned attrs = JSPROP_ENUMERATE);
|
|
|
|
static inline JSBool defineProperty(JSContext *cx, js::HandleObject obj,
|
|
|
|
js::PropertyName *name, js::HandleValue value,
|
|
|
|
JSPropertyOp getter = JS_PropertyStub,
|
|
|
|
JSStrictPropertyOp setter = JS_StrictPropertyStub,
|
|
|
|
unsigned attrs = JSPROP_ENUMERATE);
|
|
|
|
|
|
|
|
static inline JSBool defineElement(JSContext *cx, js::HandleObject obj,
|
|
|
|
uint32_t index, js::HandleValue value,
|
|
|
|
JSPropertyOp getter = JS_PropertyStub,
|
|
|
|
JSStrictPropertyOp setter = JS_StrictPropertyStub,
|
|
|
|
unsigned attrs = JSPROP_ENUMERATE);
|
|
|
|
static inline JSBool defineSpecial(JSContext *cx, js::HandleObject obj,
|
|
|
|
js::SpecialId sid, js::HandleValue value,
|
|
|
|
JSPropertyOp getter = JS_PropertyStub,
|
|
|
|
JSStrictPropertyOp setter = JS_StrictPropertyStub,
|
|
|
|
unsigned attrs = JSPROP_ENUMERATE);
|
|
|
|
|
|
|
|
static inline JSBool getGeneric(JSContext *cx, js::HandleObject obj,
|
|
|
|
js::HandleObject receiver,
|
|
|
|
js::HandleId id, js::MutableHandleValue vp);
|
2013-01-24 19:18:34 -08:00
|
|
|
static inline JSBool getGenericNoGC(JSContext *cx, JSObject *obj, JSObject *receiver,
|
|
|
|
jsid id, js::Value *vp);
|
2012-08-21 12:13:28 -07:00
|
|
|
static inline JSBool getProperty(JSContext *cx, js::HandleObject obj,
|
|
|
|
js::HandleObject receiver,
|
|
|
|
js::PropertyName *name, js::MutableHandleValue vp);
|
2013-01-24 19:18:34 -08:00
|
|
|
static inline JSBool getPropertyNoGC(JSContext *cx, JSObject *obj, JSObject *receiver,
|
|
|
|
js::PropertyName *name, js::Value *vp);
|
2012-08-21 12:13:28 -07:00
|
|
|
static inline JSBool getElement(JSContext *cx, js::HandleObject obj,
|
|
|
|
js::HandleObject receiver,
|
|
|
|
uint32_t index, js::MutableHandleValue vp);
|
2013-01-24 19:18:34 -08:00
|
|
|
static inline JSBool getElementNoGC(JSContext *cx, JSObject *obj, JSObject *receiver,
|
|
|
|
uint32_t index, js::Value *vp);
|
2011-11-04 09:18:52 -07:00
|
|
|
/* If element is not present (e.g. array hole) *present is set to
|
|
|
|
false and the contents of *vp are unusable garbage. */
|
2012-08-21 12:13:28 -07:00
|
|
|
static inline JSBool getElementIfPresent(JSContext *cx, js::HandleObject obj,
|
|
|
|
js::HandleObject receiver, uint32_t index,
|
|
|
|
js::MutableHandleValue vp, bool *present);
|
|
|
|
static inline JSBool getSpecial(JSContext *cx, js::HandleObject obj,
|
|
|
|
js::HandleObject receiver, js::SpecialId sid,
|
|
|
|
js::MutableHandleValue vp);
|
|
|
|
|
|
|
|
static inline JSBool setGeneric(JSContext *cx, js::HandleObject obj, js::HandleObject receiver,
|
|
|
|
js::HandleId id,
|
|
|
|
js::MutableHandleValue vp, JSBool strict);
|
|
|
|
static inline JSBool setProperty(JSContext *cx, js::HandleObject obj, js::HandleObject receiver,
|
|
|
|
js::PropertyName *name,
|
|
|
|
js::MutableHandleValue vp, JSBool strict);
|
|
|
|
static inline JSBool setElement(JSContext *cx, js::HandleObject obj, js::HandleObject receiver,
|
|
|
|
uint32_t index,
|
|
|
|
js::MutableHandleValue vp, JSBool strict);
|
|
|
|
static inline JSBool setSpecial(JSContext *cx, js::HandleObject obj, js::HandleObject receiver,
|
|
|
|
js::SpecialId sid,
|
|
|
|
js::MutableHandleValue vp, JSBool strict);
|
|
|
|
|
|
|
|
static JSBool nonNativeSetProperty(JSContext *cx, js::HandleObject obj,
|
|
|
|
js::HandleId id, js::MutableHandleValue vp, JSBool strict);
|
|
|
|
static JSBool nonNativeSetElement(JSContext *cx, js::HandleObject obj,
|
|
|
|
uint32_t index, js::MutableHandleValue vp, JSBool strict);
|
|
|
|
|
|
|
|
static inline JSBool getGenericAttributes(JSContext *cx, js::HandleObject obj,
|
|
|
|
js::HandleId id, unsigned *attrsp);
|
|
|
|
static inline JSBool getPropertyAttributes(JSContext *cx, js::HandleObject obj,
|
|
|
|
js::PropertyName *name, unsigned *attrsp);
|
|
|
|
static inline JSBool getElementAttributes(JSContext *cx, js::HandleObject obj,
|
|
|
|
uint32_t index, unsigned *attrsp);
|
|
|
|
static inline JSBool getSpecialAttributes(JSContext *cx, js::HandleObject obj,
|
|
|
|
js::SpecialId sid, unsigned *attrsp);
|
|
|
|
|
|
|
|
static inline JSBool setGenericAttributes(JSContext *cx, js::HandleObject obj,
|
|
|
|
js::HandleId id, unsigned *attrsp);
|
|
|
|
static inline JSBool setPropertyAttributes(JSContext *cx, js::HandleObject obj,
|
|
|
|
js::PropertyName *name, unsigned *attrsp);
|
|
|
|
static inline JSBool setElementAttributes(JSContext *cx, js::HandleObject obj,
|
|
|
|
uint32_t index, unsigned *attrsp);
|
|
|
|
static inline JSBool setSpecialAttributes(JSContext *cx, js::HandleObject obj,
|
|
|
|
js::SpecialId sid, unsigned *attrsp);
|
|
|
|
|
|
|
|
static inline bool deleteProperty(JSContext *cx, js::HandleObject obj,
|
|
|
|
js::HandlePropertyName name,
|
|
|
|
js::MutableHandleValue rval, bool strict);
|
|
|
|
static inline bool deleteElement(JSContext *cx, js::HandleObject obj,
|
|
|
|
uint32_t index,
|
|
|
|
js::MutableHandleValue rval, bool strict);
|
|
|
|
static inline bool deleteSpecial(JSContext *cx, js::HandleObject obj,
|
|
|
|
js::HandleSpecialId sid,
|
|
|
|
js::MutableHandleValue rval, bool strict);
|
|
|
|
static bool deleteByValue(JSContext *cx, js::HandleObject obj,
|
|
|
|
const js::Value &property, js::MutableHandleValue rval, bool strict);
|
|
|
|
|
2012-09-04 16:40:12 -07:00
|
|
|
static inline bool enumerate(JSContext *cx, JS::HandleObject obj, JSIterateOp iterop,
|
|
|
|
JS::MutableHandleValue statep, JS::MutableHandleId idp);
|
2012-08-21 12:13:28 -07:00
|
|
|
static inline bool defaultValue(JSContext *cx, js::HandleObject obj,
|
|
|
|
JSType hint, js::MutableHandleValue vp);
|
|
|
|
static inline JSObject *thisObject(JSContext *cx, js::HandleObject obj);
|
2010-06-12 09:29:04 -07:00
|
|
|
|
2010-07-14 23:19:36 -07:00
|
|
|
static bool thisObject(JSContext *cx, const js::Value &v, js::Value *vp);
|
2009-08-11 13:05:44 -07:00
|
|
|
|
2010-11-15 17:21:25 -08:00
|
|
|
bool swap(JSContext *cx, JSObject *other);
|
2010-05-18 19:21:43 -07:00
|
|
|
|
2012-01-02 15:02:05 -08:00
|
|
|
inline void initArrayClass();
|
|
|
|
|
|
|
|
/*
|
|
|
|
* In addition to the generic object interface provided by JSObject,
|
|
|
|
* specific types of objects may provide additional operations. To access,
|
|
|
|
* these addition operations, callers should use the pattern:
|
|
|
|
*
|
|
|
|
* if (obj.isX()) {
|
|
|
|
* XObject &x = obj.asX();
|
|
|
|
* x.foo();
|
|
|
|
* }
|
|
|
|
*
|
|
|
|
* These XObject classes form a hierarchy. For example, for a cloned block
|
|
|
|
* object, the following predicates are true: isClonedBlock, isBlock,
|
|
|
|
* isNestedScope and isScope. Each of these has a respective class that
|
|
|
|
* derives and adds operations.
|
|
|
|
*
|
|
|
|
* A class XObject is defined in a vm/XObject{.h, .cpp, -inl.h} file
|
|
|
|
* triplet (along with any class YObject that derives XObject).
|
|
|
|
*
|
|
|
|
* Note that X represents a low-level representation and does not query the
|
|
|
|
* [[Class]] property of object defined by the spec (for this, see
|
|
|
|
* js::ObjectClassIs).
|
|
|
|
*
|
|
|
|
* SpiderMonkey has not been completely switched to the isX/asX/XObject
|
|
|
|
* pattern so in some cases there is no XObject class and the engine
|
|
|
|
* instead pokes directly at reserved slots and getPrivate. In such cases,
|
|
|
|
* consider adding the missing XObject class.
|
|
|
|
*/
|
2010-09-20 12:05:21 -07:00
|
|
|
|
2012-01-02 15:02:05 -08:00
|
|
|
/* Direct subtypes of JSObject: */
|
2013-01-10 16:53:11 -08:00
|
|
|
inline bool isArray() const;
|
2011-10-04 18:46:03 -07:00
|
|
|
inline bool isArguments() const;
|
|
|
|
inline bool isArrayBuffer() const;
|
2012-03-25 19:14:27 -07:00
|
|
|
inline bool isDataView() const;
|
2011-10-04 18:46:03 -07:00
|
|
|
inline bool isDate() const;
|
2012-02-07 10:57:16 -08:00
|
|
|
inline bool isElementIterator() const;
|
2012-01-02 15:02:05 -08:00
|
|
|
inline bool isError() const;
|
2011-10-04 18:46:03 -07:00
|
|
|
inline bool isFunction() const;
|
2012-01-02 15:02:05 -08:00
|
|
|
inline bool isGenerator() const;
|
|
|
|
inline bool isGlobal() const;
|
2012-07-04 08:24:25 -07:00
|
|
|
inline bool isMapIterator() const;
|
2013-01-18 05:18:07 -08:00
|
|
|
inline bool isModule() const;
|
2011-10-04 18:46:03 -07:00
|
|
|
inline bool isObject() const;
|
2012-01-02 15:02:05 -08:00
|
|
|
inline bool isPrimitive() const;
|
2012-07-03 14:34:40 -07:00
|
|
|
inline bool isPropertyIterator() const;
|
2012-01-02 15:02:05 -08:00
|
|
|
inline bool isProxy() const;
|
2011-10-04 18:46:03 -07:00
|
|
|
inline bool isRegExp() const;
|
2012-01-30 18:12:03 -08:00
|
|
|
inline bool isRegExpStatics() const;
|
2012-01-02 15:02:05 -08:00
|
|
|
inline bool isScope() const;
|
2011-10-04 18:46:03 -07:00
|
|
|
inline bool isScript() const;
|
2012-07-04 08:24:25 -07:00
|
|
|
inline bool isSetIterator() const;
|
2011-10-04 18:46:03 -07:00
|
|
|
inline bool isStopIteration() const;
|
2012-04-04 16:39:25 -07:00
|
|
|
inline bool isTypedArray() const;
|
2011-10-04 18:46:03 -07:00
|
|
|
inline bool isWeakMap() const;
|
2010-05-18 19:21:43 -07:00
|
|
|
|
2012-01-02 15:02:05 -08:00
|
|
|
/* Subtypes of ScopeObject. */
|
|
|
|
inline bool isBlock() const;
|
|
|
|
inline bool isCall() const;
|
|
|
|
inline bool isDeclEnv() const;
|
|
|
|
inline bool isNestedScope() const;
|
|
|
|
inline bool isWith() const;
|
|
|
|
inline bool isClonedBlock() const;
|
|
|
|
inline bool isStaticBlock() const;
|
|
|
|
|
|
|
|
/* Subtypes of PrimitiveObject. */
|
|
|
|
inline bool isBoolean() const;
|
|
|
|
inline bool isNumber() const;
|
|
|
|
inline bool isString() const;
|
|
|
|
|
|
|
|
/* Subtypes of ArgumentsObject. */
|
|
|
|
inline bool isNormalArguments() const;
|
|
|
|
inline bool isStrictArguments() const;
|
|
|
|
|
|
|
|
/* Subtypes of Proxy. */
|
2011-12-20 17:42:45 -08:00
|
|
|
inline bool isDebugScope() const;
|
2011-10-04 07:06:54 -07:00
|
|
|
inline bool isWrapper() const;
|
2012-01-02 15:02:05 -08:00
|
|
|
inline bool isFunctionProxy() const;
|
2011-10-04 07:06:54 -07:00
|
|
|
inline bool isCrossCompartmentWrapper() const;
|
2010-06-24 14:45:32 -07:00
|
|
|
|
2012-01-02 15:02:05 -08:00
|
|
|
inline js::ArgumentsObject &asArguments();
|
2012-03-28 14:43:01 -07:00
|
|
|
inline js::ArrayBufferObject &asArrayBuffer();
|
2012-01-30 18:12:03 -08:00
|
|
|
inline const js::ArgumentsObject &asArguments() const;
|
2012-01-02 15:02:05 -08:00
|
|
|
inline js::BlockObject &asBlock();
|
|
|
|
inline js::BooleanObject &asBoolean();
|
|
|
|
inline js::CallObject &asCall();
|
|
|
|
inline js::ClonedBlockObject &asClonedBlock();
|
2012-03-25 19:14:27 -07:00
|
|
|
inline js::DataViewObject &asDataView();
|
2012-01-02 15:02:05 -08:00
|
|
|
inline js::DeclEnvObject &asDeclEnv();
|
2011-12-20 17:42:45 -08:00
|
|
|
inline js::DebugScopeObject &asDebugScope();
|
2012-01-02 15:02:05 -08:00
|
|
|
inline js::GlobalObject &asGlobal();
|
2012-07-04 08:24:25 -07:00
|
|
|
inline js::MapObject &asMap();
|
|
|
|
inline js::MapIteratorObject &asMapIterator();
|
2013-01-18 05:18:07 -08:00
|
|
|
inline js::Module &asModule();
|
2012-01-02 15:02:05 -08:00
|
|
|
inline js::NestedScopeObject &asNestedScope();
|
|
|
|
inline js::NormalArgumentsObject &asNormalArguments();
|
|
|
|
inline js::NumberObject &asNumber();
|
2012-07-03 14:34:40 -07:00
|
|
|
inline js::PropertyIteratorObject &asPropertyIterator();
|
2012-11-01 16:51:04 -07:00
|
|
|
inline const js::PropertyIteratorObject &asPropertyIterator() const;
|
2012-01-02 15:02:05 -08:00
|
|
|
inline js::RegExpObject &asRegExp();
|
|
|
|
inline js::ScopeObject &asScope();
|
2012-07-04 08:24:25 -07:00
|
|
|
inline js::SetObject &asSet();
|
|
|
|
inline js::SetIteratorObject &asSetIterator();
|
2012-01-02 15:02:05 -08:00
|
|
|
inline js::StrictArgumentsObject &asStrictArguments();
|
|
|
|
inline js::StaticBlockObject &asStaticBlock();
|
|
|
|
inline js::StringObject &asString();
|
|
|
|
inline js::WithObject &asWith();
|
2011-11-14 09:13:33 -08:00
|
|
|
|
2011-12-31 06:32:04 -08:00
|
|
|
static inline js::ThingRootKind rootKind() { return js::THING_ROOT_OBJECT; }
|
|
|
|
|
2012-01-31 18:03:41 -08:00
|
|
|
#ifdef DEBUG
|
|
|
|
void dump();
|
|
|
|
#endif
|
|
|
|
|
2011-10-04 14:49:42 -07:00
|
|
|
private:
|
2011-10-04 07:06:54 -07:00
|
|
|
static void staticAsserts() {
|
2012-02-16 15:02:15 -08:00
|
|
|
MOZ_STATIC_ASSERT(sizeof(JSObject) == sizeof(js::shadow::Object),
|
|
|
|
"shadow interface must match actual interface");
|
|
|
|
MOZ_STATIC_ASSERT(sizeof(JSObject) == sizeof(js::ObjectImpl),
|
|
|
|
"JSObject itself must not have any fields");
|
|
|
|
MOZ_STATIC_ASSERT(sizeof(JSObject) % sizeof(js::Value) == 0,
|
|
|
|
"fixed slots after an object must be aligned");
|
2011-10-04 07:06:54 -07:00
|
|
|
}
|
2012-05-07 16:45:19 -07:00
|
|
|
|
|
|
|
JSObject() MOZ_DELETE;
|
|
|
|
JSObject(const JSObject &other) MOZ_DELETE;
|
|
|
|
void operator=(const JSObject &other) MOZ_DELETE;
|
2009-08-27 22:53:26 -07:00
|
|
|
};
|
2010-09-20 12:05:21 -07:00
|
|
|
|
2011-04-08 10:52:48 -07:00
|
|
|
/*
|
|
|
|
* The only sensible way to compare JSObject with == is by identity. We use
|
|
|
|
* const& instead of * as a syntactic way to assert non-null. This leads to an
|
|
|
|
* abundance of address-of operators to identity. Hence this overload.
|
|
|
|
*/
|
|
|
|
static JS_ALWAYS_INLINE bool
|
|
|
|
operator==(const JSObject &lhs, const JSObject &rhs)
|
|
|
|
{
|
|
|
|
return &lhs == &rhs;
|
|
|
|
}
|
|
|
|
|
2011-05-24 16:04:18 -07:00
|
|
|
static JS_ALWAYS_INLINE bool
|
|
|
|
operator!=(const JSObject &lhs, const JSObject &rhs)
|
|
|
|
{
|
|
|
|
return &lhs != &rhs;
|
|
|
|
}
|
|
|
|
|
2010-10-13 11:49:22 -07:00
|
|
|
struct JSObject_Slots2 : JSObject { js::Value fslots[2]; };
|
|
|
|
struct JSObject_Slots4 : JSObject { js::Value fslots[4]; };
|
|
|
|
struct JSObject_Slots8 : JSObject { js::Value fslots[8]; };
|
|
|
|
struct JSObject_Slots12 : JSObject { js::Value fslots[12]; };
|
|
|
|
struct JSObject_Slots16 : JSObject { js::Value fslots[16]; };
|
|
|
|
|
|
|
|
#define JSSLOT_FREE(clasp) JSCLASS_RESERVED_SLOTS(clasp)
|
2009-04-24 16:28:21 -07:00
|
|
|
|
2010-07-14 23:19:36 -07:00
|
|
|
class JSValueArray {
|
2010-06-16 14:13:28 -07:00
|
|
|
public:
|
|
|
|
jsval *array;
|
|
|
|
size_t length;
|
|
|
|
|
2010-07-14 23:19:36 -07:00
|
|
|
JSValueArray(jsval *v, size_t c) : array(v), length(c) {}
|
2010-06-16 14:13:28 -07:00
|
|
|
};
|
2009-08-11 13:05:44 -07:00
|
|
|
|
2010-07-14 23:19:36 -07:00
|
|
|
class ValueArray {
|
|
|
|
public:
|
|
|
|
js::Value *array;
|
|
|
|
size_t length;
|
|
|
|
|
|
|
|
ValueArray(js::Value *v, size_t c) : array(v), length(c) {}
|
|
|
|
};
|
|
|
|
|
2011-01-24 15:32:44 -08:00
|
|
|
namespace js {
|
2011-07-20 08:39:01 -07:00
|
|
|
|
2013-01-26 06:42:20 -08:00
|
|
|
template <AllowGC allowGC>
|
|
|
|
extern JSBool
|
|
|
|
HasOwnProperty(JSContext *cx, LookupGenericOp lookup,
|
|
|
|
typename MaybeRooted<JSObject*, allowGC>::HandleType obj,
|
|
|
|
typename MaybeRooted<jsid, allowGC>::HandleType id,
|
|
|
|
typename MaybeRooted<JSObject*, allowGC>::MutableHandleType objp,
|
|
|
|
typename MaybeRooted<Shape*, allowGC>::MutableHandleType propp);
|
|
|
|
|
Bug 642772: Don't recreate a class during enumeration, if it has been deleted (r=bhackett)
In SM, classes are lazily resolved. If we detect that a class about to be used
has not yet been resolved, then we resolve it. However, the way that we decided
that they were resolved was broken. If the global object had a String property,
then it had been resolved. So what happened when we deleted the String
property? Well, it got resolved again.
Instead of using the String property of the global object, we now use the
contructor slot on the global object. This works fine for String, but some
classes don't have a constructor, like Math and JSON. For those classes, we set
the constructor slot to True. In either case, we can now tell that a class is
resolved if the constructor slot in not Undefined.
2011-04-27 04:13:56 -07:00
|
|
|
bool
|
|
|
|
IsStandardClassResolved(JSObject *obj, js::Class *clasp);
|
|
|
|
|
|
|
|
void
|
|
|
|
MarkStandardClassInitializedNoProto(JSObject *obj, js::Class *clasp);
|
|
|
|
|
2011-11-18 14:40:14 -08:00
|
|
|
} /* namespace js */
|
2011-01-24 15:32:44 -08:00
|
|
|
|
2009-02-27 22:32:38 -08:00
|
|
|
/*
|
|
|
|
* Select Object.prototype method names shared between jsapi.cpp and jsobj.cpp.
|
|
|
|
*/
|
2007-03-22 10:30:00 -07:00
|
|
|
extern const char js_watch_str[];
|
|
|
|
extern const char js_unwatch_str[];
|
|
|
|
extern const char js_hasOwnProperty_str[];
|
|
|
|
extern const char js_isPrototypeOf_str[];
|
|
|
|
extern const char js_propertyIsEnumerable_str[];
|
2009-10-06 12:35:33 -07:00
|
|
|
|
|
|
|
#ifdef OLD_GETTER_SETTER_METHODS
|
2007-03-22 10:30:00 -07:00
|
|
|
extern const char js_defineGetter_str[];
|
|
|
|
extern const char js_defineSetter_str[];
|
|
|
|
extern const char js_lookupGetter_str[];
|
|
|
|
extern const char js_lookupSetter_str[];
|
2009-10-06 12:35:33 -07:00
|
|
|
#endif
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2010-05-18 19:21:43 -07:00
|
|
|
extern JSBool
|
2012-07-10 18:17:29 -07:00
|
|
|
js_PopulateObject(JSContext *cx, js::HandleObject newborn, js::HandleObject props);
|
2010-05-18 19:21:43 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
/*
|
|
|
|
* Fast access to immutable standard objects (constructors and prototypes).
|
|
|
|
*/
|
2012-07-04 11:12:16 -07:00
|
|
|
extern bool
|
2012-07-23 13:37:31 -07:00
|
|
|
js_GetClassObject(JSContext *cx, js::RawObject obj, JSProtoKey key,
|
2012-07-04 11:12:16 -07:00
|
|
|
js::MutableHandleObject objp);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-07-27 03:15:46 -07:00
|
|
|
/*
|
|
|
|
* Determine if the given object is a prototype for a standard class. If so,
|
|
|
|
* return the associated JSProtoKey. If not, return JSProto_Null.
|
|
|
|
*/
|
|
|
|
extern JSProtoKey
|
|
|
|
js_IdentifyClassPrototype(JSObject *obj);
|
|
|
|
|
2010-02-19 09:44:23 -08:00
|
|
|
/*
|
|
|
|
* If protoKey is not JSProto_Null, then clasp is ignored. If protoKey is
|
|
|
|
* JSProto_Null, clasp must non-null.
|
|
|
|
*/
|
2012-07-04 11:12:16 -07:00
|
|
|
bool
|
2012-08-17 11:21:57 -07:00
|
|
|
js_FindClassObject(JSContext *cx, JSProtoKey protoKey, js::MutableHandleValue vp,
|
|
|
|
js::Class *clasp = NULL);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Find or create a property named by id in obj's scope, with the given getter
|
|
|
|
* and setter, slot, attributes, and other members.
|
|
|
|
*/
|
2012-11-29 10:22:10 -08:00
|
|
|
extern js::UnrootedShape
|
|
|
|
js_AddNativeProperty(JSContext *cx, JS::HandleObject obj, JS::HandleId id,
|
Bug 708735 - Use <stdint.h> types in JSAPI and throughout SpiderMonkey. Continue to provide the {u,}int{8,16,32,64} and JS{Uint,Int}{8,16,32,64} integer types through a single header, however, for a simpler backout strategy -- and also to ease the transition for embedders. r=timeless on switching the jsd API to use the <stdint.h> types, r=luke, r=dmandelin
2011-12-08 19:54:10 -08:00
|
|
|
JSPropertyOp getter, JSStrictPropertyOp setter, uint32_t slot,
|
2012-02-28 15:11:11 -08:00
|
|
|
unsigned attrs, unsigned flags, int shortid);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2010-03-24 12:36:42 -07:00
|
|
|
extern JSBool
|
2012-11-29 10:22:10 -08:00
|
|
|
js_DefineOwnProperty(JSContext *cx, JS::HandleObject obj, JS::HandleId id,
|
|
|
|
const JS::Value &descriptor, JSBool *bp);
|
2010-03-24 12:36:42 -07:00
|
|
|
|
2011-01-21 05:10:16 -08:00
|
|
|
namespace js {
|
|
|
|
|
2013-01-28 11:01:54 -08:00
|
|
|
/*
|
|
|
|
* The NewObjectKind allows an allocation site to specify the type properties
|
|
|
|
* and lifetime requirements that must be fixed at allocation time.
|
|
|
|
*/
|
|
|
|
enum NewObjectKind {
|
|
|
|
/* This is the default. Most objects are generic. */
|
|
|
|
GenericObject,
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Singleton objects are treated specially by the type system. This flag
|
|
|
|
* ensures that the new object is automatically set up correctly as a
|
|
|
|
* singleton and is allocated in the correct heap.
|
|
|
|
*/
|
|
|
|
SingletonObject,
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Objects which may be marked as a singleton after allocation must still
|
|
|
|
* be allocated on the correct heap, but are not automatically setup as a
|
|
|
|
* singleton after allocation.
|
|
|
|
*/
|
|
|
|
MaybeSingletonObject
|
|
|
|
};
|
|
|
|
|
|
|
|
inline gc::InitialHeap
|
|
|
|
InitialHeapForNewKind(NewObjectKind newKind)
|
|
|
|
{
|
|
|
|
return newKind == GenericObject ? gc::DefaultHeap : gc::TenuredHeap;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Specialized call for constructing |this| with a known function callee,
|
|
|
|
// and a known prototype.
|
|
|
|
extern JSObject *
|
|
|
|
CreateThisForFunctionWithProto(JSContext *cx, js::HandleObject callee, JSObject *proto,
|
|
|
|
NewObjectKind newKind = GenericObject);
|
|
|
|
|
|
|
|
// Specialized call for constructing |this| with a known function callee.
|
|
|
|
extern JSObject *
|
|
|
|
CreateThisForFunction(JSContext *cx, js::HandleObject callee, bool newType);
|
|
|
|
|
|
|
|
// Generic call for constructing |this|.
|
|
|
|
extern JSObject *
|
|
|
|
CreateThis(JSContext *cx, js::Class *clasp, js::HandleObject callee);
|
|
|
|
|
|
|
|
extern JSObject *
|
2012-09-26 09:49:20 -07:00
|
|
|
CloneObject(JSContext *cx, HandleObject obj, Handle<js::TaggedProto> proto, HandleObject parent);
|
|
|
|
|
2009-05-15 02:43:19 -07:00
|
|
|
/*
|
|
|
|
* Flags for the defineHow parameter of js_DefineNativeProperty.
|
|
|
|
*/
|
2012-02-28 15:11:11 -08:00
|
|
|
const unsigned DNP_CACHE_RESULT = 1; /* an interpreter call from JSOP_INITPROP */
|
|
|
|
const unsigned DNP_DONT_PURGE = 2; /* suppress js_PurgeScopeChain */
|
2012-03-23 17:59:56 -07:00
|
|
|
const unsigned DNP_UNQUALIFIED = 4; /* Unqualified property set. Only used in
|
2010-04-26 07:06:25 -07:00
|
|
|
the defineHow argument of
|
|
|
|
js_SetPropertyHelper. */
|
2012-03-23 17:59:56 -07:00
|
|
|
const unsigned DNP_SKIP_TYPE = 8; /* Don't update type information */
|
2009-05-15 02:43:19 -07:00
|
|
|
|
2009-08-26 14:28:36 -07:00
|
|
|
/*
|
2011-01-21 05:10:16 -08:00
|
|
|
* Return successfully added or changed shape or NULL on error.
|
2009-08-26 14:28:36 -07:00
|
|
|
*/
|
2012-11-29 10:22:10 -08:00
|
|
|
extern bool
|
2012-07-30 04:19:09 -07:00
|
|
|
DefineNativeProperty(JSContext *cx, HandleObject obj, HandleId id, HandleValue value,
|
2012-02-28 15:11:11 -08:00
|
|
|
PropertyOp getter, StrictPropertyOp setter, unsigned attrs,
|
|
|
|
unsigned flags, int shortid, unsigned defineHow = 0);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-11-29 10:22:10 -08:00
|
|
|
inline bool
|
2012-07-30 04:19:09 -07:00
|
|
|
DefineNativeProperty(JSContext *cx, HandleObject obj, PropertyName *name, HandleValue value,
|
2012-02-28 15:11:11 -08:00
|
|
|
PropertyOp getter, StrictPropertyOp setter, unsigned attrs,
|
|
|
|
unsigned flags, int shortid, unsigned defineHow = 0)
|
2011-12-27 00:27:02 -08:00
|
|
|
{
|
2012-06-14 19:13:27 -07:00
|
|
|
Rooted<jsid> id(cx, NameToId(name));
|
|
|
|
return DefineNativeProperty(cx, obj, id, value, getter, setter, attrs, flags,
|
2011-12-27 00:27:02 -08:00
|
|
|
shortid, defineHow);
|
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
/*
|
2011-01-21 05:10:16 -08:00
|
|
|
* Specialized subroutine that allows caller to preset JSRESOLVE_* flags.
|
2007-03-22 10:30:00 -07:00
|
|
|
*/
|
2011-01-21 05:10:16 -08:00
|
|
|
extern bool
|
2012-05-19 15:03:45 -07:00
|
|
|
LookupPropertyWithFlags(JSContext *cx, HandleObject obj, HandleId id, unsigned flags,
|
2012-07-04 19:34:06 -07:00
|
|
|
js::MutableHandleObject objp, js::MutableHandleShape propp);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-12-27 00:27:02 -08:00
|
|
|
inline bool
|
2012-05-19 15:03:45 -07:00
|
|
|
LookupPropertyWithFlags(JSContext *cx, HandleObject obj, PropertyName *name, unsigned flags,
|
2012-07-04 19:34:06 -07:00
|
|
|
js::MutableHandleObject objp, js::MutableHandleShape propp)
|
2011-12-27 00:27:02 -08:00
|
|
|
{
|
2012-06-14 19:13:27 -07:00
|
|
|
Rooted<jsid> id(cx, NameToId(name));
|
|
|
|
return LookupPropertyWithFlags(cx, obj, id, flags, objp, propp);
|
2011-12-27 00:27:02 -08:00
|
|
|
}
|
2011-07-12 18:19:13 -07:00
|
|
|
|
|
|
|
/*
|
2011-07-21 15:36:09 -07:00
|
|
|
* Call the [[DefineOwnProperty]] internal method of obj.
|
|
|
|
*
|
|
|
|
* If obj is an array, this follows ES5 15.4.5.1.
|
|
|
|
* If obj is any other native object, this follows ES5 8.12.9.
|
|
|
|
* If obj is a proxy, this calls the proxy handler's defineProperty method.
|
|
|
|
* Otherwise, this reports an error and returns false.
|
2011-07-12 18:19:13 -07:00
|
|
|
*/
|
|
|
|
extern bool
|
2012-04-12 09:23:51 -07:00
|
|
|
DefineProperty(JSContext *cx, js::HandleObject obj,
|
|
|
|
js::HandleId id, const PropDesc &desc, bool throwError,
|
2011-07-12 18:19:13 -07:00
|
|
|
bool *rval);
|
|
|
|
|
2011-07-13 04:46:23 -07:00
|
|
|
/*
|
|
|
|
* Read property descriptors from props, as for Object.defineProperties. See
|
|
|
|
* ES5 15.2.3.7 steps 3-5.
|
|
|
|
*/
|
|
|
|
extern bool
|
2012-07-10 18:17:29 -07:00
|
|
|
ReadPropertyDescriptors(JSContext *cx, HandleObject props, bool checkAccessors,
|
2011-07-13 04:46:23 -07:00
|
|
|
AutoIdVector *ids, AutoPropDescArrayRooter *descs);
|
|
|
|
|
2011-03-07 14:00:00 -08:00
|
|
|
/*
|
|
|
|
* Constant to pass to js_LookupPropertyWithFlags to infer bits from current
|
|
|
|
* bytecode.
|
|
|
|
*/
|
2012-02-28 15:11:11 -08:00
|
|
|
static const unsigned RESOLVE_INFER = 0xffff;
|
2011-02-22 22:25:10 -08:00
|
|
|
|
2012-08-17 18:09:43 -07:00
|
|
|
/* Read the name using a dynamic lookup on the scopeChain. */
|
2012-01-09 06:29:50 -08:00
|
|
|
extern bool
|
2012-08-17 18:09:43 -07:00
|
|
|
LookupName(JSContext *cx, HandlePropertyName name, HandleObject scopeChain,
|
|
|
|
MutableHandleObject objp, MutableHandleObject pobjp, MutableHandleShape propp);
|
2008-02-07 15:18:45 -08:00
|
|
|
|
2013-01-23 14:22:10 -08:00
|
|
|
extern bool
|
|
|
|
LookupNameNoGC(JSContext *cx, PropertyName *name, JSObject *scopeChain,
|
|
|
|
JSObject **objp, JSObject **pobjp, Shape **propp);
|
|
|
|
|
* Menu of -D flags for enabling instrumentation, as a commented-out CFLAGS += setting for convenient testing. * js_FindProperty and js_LookupPropertyWithFlags return indexes into the scope and prototype chains, respectively, to support internal instrumentation, and to pave the way for the return of the property cache (bug 365851).. * jsutil.[ch] JSBasicStats struct and functions for computing mean/sigma/max and auto-scaling histogram. * JS_SCOPE_DEPTH_METER instrumentation for compile- and run-time scope chain length instrumentation: + At compile time, rt->hostenvScopeDepthStats and rt->lexicalScopeDepthStats meter scope chains passed into the compile and evaluate APIs. + At runtime, rt->protoLookupDepthStats and rt->scopeSearchDepthStats track steps along the prototype and scope chains until the sought-after property is found. * JS_ARENAMETER uses JSBasicStats now. * Added rt->liveScopePropsPreSweep to fix the property tree stats code that rotted when property tree sweeping moved to after the finalization phase. * Un-bitrotted some DEBUG_brendan code, turned some off for myself via XXX. * Mac OS X toolchain requires initialized data shared across dynamic library member files, outlaws common data, so initialize extern metering vars. * Old HASHMETER code in jshash.[ch] is now JS_HASHMETER-controlled and based on JSBasicStats. * DEBUG_scopemeters macro renamed JS_DUMP_SCOPE_METERS; uses JSBasicStats now. * Disentangle DEBUG and DUMP_SCOPE_STATS (now JS_DUMP_PROPTREE_STATS) and fix inconsistent thread safety for liveScopeProps (sometimes atomic-incremented, sometimes runtime-locked). * Compiler-modeled maxScopeDepth will propagate via JSScript to runtime for capability-based, interpreter-inlined cache hit qualifier bits, to bypass scope and prototype chain lookup by optimizing for common monomorphic get, set, and call site referencing a prototype property in a well-named object (no shadowing or mutation in 99.9% of the cases).
2008-01-12 16:31:31 -08:00
|
|
|
/*
|
2012-08-17 18:09:43 -07:00
|
|
|
* Like LookupName except returns the global object if 'name' is not found in
|
2012-10-02 10:51:10 -07:00
|
|
|
* any preceding non-global scope.
|
2012-08-17 18:09:43 -07:00
|
|
|
*
|
|
|
|
* Additionally, pobjp and propp are not needed by callers so they are not
|
|
|
|
* returned.
|
* Menu of -D flags for enabling instrumentation, as a commented-out CFLAGS += setting for convenient testing. * js_FindProperty and js_LookupPropertyWithFlags return indexes into the scope and prototype chains, respectively, to support internal instrumentation, and to pave the way for the return of the property cache (bug 365851).. * jsutil.[ch] JSBasicStats struct and functions for computing mean/sigma/max and auto-scaling histogram. * JS_SCOPE_DEPTH_METER instrumentation for compile- and run-time scope chain length instrumentation: + At compile time, rt->hostenvScopeDepthStats and rt->lexicalScopeDepthStats meter scope chains passed into the compile and evaluate APIs. + At runtime, rt->protoLookupDepthStats and rt->scopeSearchDepthStats track steps along the prototype and scope chains until the sought-after property is found. * JS_ARENAMETER uses JSBasicStats now. * Added rt->liveScopePropsPreSweep to fix the property tree stats code that rotted when property tree sweeping moved to after the finalization phase. * Un-bitrotted some DEBUG_brendan code, turned some off for myself via XXX. * Mac OS X toolchain requires initialized data shared across dynamic library member files, outlaws common data, so initialize extern metering vars. * Old HASHMETER code in jshash.[ch] is now JS_HASHMETER-controlled and based on JSBasicStats. * DEBUG_scopemeters macro renamed JS_DUMP_SCOPE_METERS; uses JSBasicStats now. * Disentangle DEBUG and DUMP_SCOPE_STATS (now JS_DUMP_PROPTREE_STATS) and fix inconsistent thread safety for liveScopeProps (sometimes atomic-incremented, sometimes runtime-locked). * Compiler-modeled maxScopeDepth will propagate via JSScript to runtime for capability-based, interpreter-inlined cache hit qualifier bits, to bypass scope and prototype chain lookup by optimizing for common monomorphic get, set, and call site referencing a prototype property in a well-named object (no shadowing or mutation in 99.9% of the cases).
2008-01-12 16:31:31 -08:00
|
|
|
*/
|
2011-12-27 00:27:02 -08:00
|
|
|
extern bool
|
2012-10-02 10:51:10 -07:00
|
|
|
LookupNameWithGlobalDefault(JSContext *cx, HandlePropertyName name, HandleObject scopeChain,
|
|
|
|
MutableHandleObject objp);
|
2011-12-27 00:27:02 -08:00
|
|
|
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
extern JSObject *
|
|
|
|
js_FindVariableScope(JSContext *cx, JSFunction **funp);
|
|
|
|
|
2012-05-19 15:03:45 -07:00
|
|
|
/* JSGET_CACHE_RESULT is the analogue of DNP_CACHE_RESULT for GetMethod. */
|
2012-03-23 17:59:56 -07:00
|
|
|
const unsigned JSGET_CACHE_RESULT = 1; // from a caching interpreter opcode
|
2009-09-03 14:41:19 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
/*
|
2010-08-29 11:57:08 -07:00
|
|
|
* NB: js_NativeGet and js_NativeSet are called with the scope containing shape
|
2009-04-17 12:41:00 -07:00
|
|
|
* (pobj's scope for Get, obj's for Set) locked, and on successful return, that
|
|
|
|
* scope is again locked. But on failure, both functions return false with the
|
2010-08-29 11:57:08 -07:00
|
|
|
* scope containing shape unlocked.
|
2007-03-22 10:30:00 -07:00
|
|
|
*/
|
|
|
|
extern JSBool
|
2012-06-14 19:13:27 -07:00
|
|
|
js_NativeGet(JSContext *cx, js::Handle<JSObject*> obj, js::Handle<JSObject*> pobj,
|
2012-11-29 10:22:10 -08:00
|
|
|
js::Handle<js::Shape*> shape, unsigned getHow, js::MutableHandle<js::Value> vp);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
extern JSBool
|
2012-06-27 20:21:39 -07:00
|
|
|
js_NativeSet(JSContext *cx, js::Handle<JSObject*> obj, js::Handle<JSObject*> receiver,
|
2013-01-29 18:50:41 -08:00
|
|
|
js::Handle<js::Shape*> shape, bool strict, js::MutableHandleValue vp);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-07-11 18:22:25 -07:00
|
|
|
namespace js {
|
|
|
|
|
2011-12-27 00:27:02 -08:00
|
|
|
bool
|
2012-07-30 04:19:09 -07:00
|
|
|
GetPropertyHelper(JSContext *cx, HandleObject obj, HandleId id, uint32_t getHow, MutableHandleValue vp);
|
2011-12-27 00:27:02 -08:00
|
|
|
|
|
|
|
inline bool
|
2012-07-30 04:19:09 -07:00
|
|
|
GetPropertyHelper(JSContext *cx, HandleObject obj, PropertyName *name, uint32_t getHow, MutableHandleValue vp)
|
2011-12-27 00:27:02 -08:00
|
|
|
{
|
2012-07-30 04:19:09 -07:00
|
|
|
RootedId id(cx, NameToId(name));
|
|
|
|
return GetPropertyHelper(cx, obj, id, getHow, vp);
|
2011-12-27 00:27:02 -08:00
|
|
|
}
|
|
|
|
|
2011-07-11 18:22:25 -07:00
|
|
|
bool
|
2012-04-12 09:23:51 -07:00
|
|
|
GetOwnPropertyDescriptor(JSContext *cx, HandleObject obj, HandleId id, PropertyDescriptor *desc);
|
2011-07-11 18:22:25 -07:00
|
|
|
|
|
|
|
bool
|
2013-01-11 00:43:00 -08:00
|
|
|
GetOwnPropertyDescriptor(JSContext *cx, HandleObject obj, HandleId id, MutableHandleValue vp);
|
2011-07-11 18:22:25 -07:00
|
|
|
|
|
|
|
bool
|
2013-01-11 00:43:00 -08:00
|
|
|
NewPropertyDescriptorObject(JSContext *cx, const PropertyDescriptor *desc, MutableHandleValue vp);
|
2011-07-11 18:22:25 -07:00
|
|
|
|
2009-08-26 00:38:13 -07:00
|
|
|
extern JSBool
|
2012-07-30 04:19:09 -07:00
|
|
|
GetMethod(JSContext *cx, HandleObject obj, HandleId id, unsigned getHow, MutableHandleValue vp);
|
2011-12-27 00:27:02 -08:00
|
|
|
|
|
|
|
inline bool
|
2012-07-30 04:19:09 -07:00
|
|
|
GetMethod(JSContext *cx, HandleObject obj, PropertyName *name, unsigned getHow, MutableHandleValue vp)
|
2011-12-27 00:27:02 -08:00
|
|
|
{
|
2012-06-14 19:13:27 -07:00
|
|
|
Rooted<jsid> id(cx, NameToId(name));
|
|
|
|
return GetMethod(cx, obj, id, getHow, vp);
|
2011-12-27 00:27:02 -08:00
|
|
|
}
|
|
|
|
|
2010-11-02 17:36:26 -07:00
|
|
|
/*
|
2012-02-27 23:49:02 -08:00
|
|
|
* If obj has an already-resolved data property for id, return true and
|
2012-05-06 13:45:19 -07:00
|
|
|
* store the property value in *vp.
|
2010-11-02 17:36:26 -07:00
|
|
|
*/
|
|
|
|
extern bool
|
2013-01-23 14:22:10 -08:00
|
|
|
HasDataProperty(JSContext *cx, JSObject *obj, jsid id, Value *vp);
|
2012-02-27 23:49:02 -08:00
|
|
|
|
|
|
|
inline bool
|
2013-01-23 14:22:10 -08:00
|
|
|
HasDataProperty(JSContext *cx, JSObject *obj, PropertyName *name, Value *vp)
|
2012-02-27 23:49:02 -08:00
|
|
|
{
|
2013-01-23 14:22:10 -08:00
|
|
|
return HasDataProperty(cx, obj, NameToId(name), vp);
|
2012-02-27 23:49:02 -08:00
|
|
|
}
|
2010-07-07 00:53:47 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
extern JSBool
|
2012-05-19 15:03:45 -07:00
|
|
|
CheckAccess(JSContext *cx, JSObject *obj, HandleId id, JSAccessMode mode,
|
2012-09-04 16:40:12 -07:00
|
|
|
MutableHandleValue v, unsigned *attrsp);
|
2010-06-17 05:32:26 -07:00
|
|
|
|
2010-07-14 23:19:36 -07:00
|
|
|
extern bool
|
2012-09-26 09:49:20 -07:00
|
|
|
IsDelegate(JSContext *cx, HandleObject obj, const Value &v, bool *result);
|
|
|
|
|
|
|
|
} /* namespace js */
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2007-06-14 00:07:01 -07:00
|
|
|
/*
|
|
|
|
* Wrap boolean, number or string as Boolean, Number or String object.
|
|
|
|
* *vp must not be an object, null or undefined.
|
|
|
|
*/
|
|
|
|
extern JSBool
|
2010-07-14 23:19:36 -07:00
|
|
|
js_PrimitiveToObject(JSContext *cx, js::Value *vp);
|
2007-06-14 00:07:01 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
extern JSBool
|
2012-07-23 13:37:31 -07:00
|
|
|
js_ValueToObjectOrNull(JSContext *cx, const js::Value &v, JS::MutableHandleObject objp);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-01-09 06:29:50 -08:00
|
|
|
/* Throws if v could not be converted to an object. */
|
|
|
|
extern JSObject *
|
|
|
|
js_ValueToNonNullObject(JSContext *cx, const js::Value &v);
|
|
|
|
|
2011-01-26 13:37:45 -08:00
|
|
|
namespace js {
|
|
|
|
|
|
|
|
/*
|
2012-08-12 18:50:49 -07:00
|
|
|
* Invokes the ES5 ToObject algorithm on vp, returning the result. If vp might
|
|
|
|
* already be an object, use ToObject. reportCantConvert controls how null and
|
|
|
|
* undefined errors are reported.
|
2011-01-26 13:37:45 -08:00
|
|
|
*/
|
|
|
|
extern JSObject *
|
2012-08-12 18:50:49 -07:00
|
|
|
ToObjectSlow(JSContext *cx, HandleValue vp, bool reportScanStack);
|
2011-01-26 13:37:45 -08:00
|
|
|
|
2012-08-12 18:50:49 -07:00
|
|
|
/* For object conversion in e.g. native functions. */
|
2011-01-26 13:37:45 -08:00
|
|
|
JS_ALWAYS_INLINE JSObject *
|
2012-08-12 18:50:49 -07:00
|
|
|
ToObject(JSContext *cx, HandleValue vp)
|
2011-01-26 13:37:45 -08:00
|
|
|
{
|
2012-08-12 18:50:49 -07:00
|
|
|
if (vp.isObject())
|
|
|
|
return &vp.toObject();
|
|
|
|
return ToObjectSlow(cx, vp, false);
|
2011-01-26 13:37:45 -08:00
|
|
|
}
|
|
|
|
|
2012-08-12 18:50:49 -07:00
|
|
|
/* For converting stack values to objects. */
|
|
|
|
JS_ALWAYS_INLINE JSObject *
|
|
|
|
ToObjectFromStack(JSContext *cx, HandleValue vp)
|
2012-01-09 06:29:50 -08:00
|
|
|
{
|
2012-08-12 18:50:49 -07:00
|
|
|
if (vp.isObject())
|
|
|
|
return &vp.toObject();
|
|
|
|
return ToObjectSlow(cx, vp, true);
|
2012-01-09 06:29:50 -08:00
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-10-11 02:53:02 -07:00
|
|
|
extern JSObject *
|
|
|
|
CloneObjectLiteral(JSContext *cx, HandleObject parent, HandleObject srcObj);
|
|
|
|
|
2012-01-09 06:29:50 -08:00
|
|
|
} /* namespace js */
|
2012-01-06 04:49:52 -08:00
|
|
|
|
2008-02-18 13:01:47 -08:00
|
|
|
extern void
|
2012-01-13 17:19:19 -08:00
|
|
|
js_GetObjectSlotName(JSTracer *trc, char *buf, size_t bufsize);
|
2008-02-18 13:01:47 -08:00
|
|
|
|
2009-12-08 17:00:42 -08:00
|
|
|
extern JSBool
|
2009-04-22 03:39:08 -07:00
|
|
|
js_ReportGetterOnlyAssignment(JSContext *cx);
|
|
|
|
|
2012-02-28 15:11:11 -08:00
|
|
|
extern unsigned
|
|
|
|
js_InferFlags(JSContext *cx, unsigned defaultFlags);
|
2009-07-05 21:42:13 -07:00
|
|
|
|
2009-07-29 09:58:19 -07:00
|
|
|
|
2012-02-07 11:45:18 -08:00
|
|
|
/*
|
|
|
|
* If protoKey is not JSProto_Null, then clasp is ignored. If protoKey is
|
|
|
|
* JSProto_Null, clasp must non-null.
|
|
|
|
*
|
|
|
|
* If protoKey is constant and scope is non-null, use GlobalObject's prototype
|
|
|
|
* methods instead.
|
|
|
|
*/
|
2013-01-11 11:59:50 -08:00
|
|
|
extern bool
|
2012-08-17 11:21:57 -07:00
|
|
|
js_GetClassPrototype(JSContext *cx, JSProtoKey protoKey, js::MutableHandleObject protop,
|
|
|
|
js::Class *clasp = NULL);
|
2012-02-07 11:45:18 -08:00
|
|
|
|
2010-06-17 15:23:17 -07:00
|
|
|
namespace js {
|
|
|
|
|
|
|
|
extern bool
|
2013-01-23 11:57:55 -08:00
|
|
|
SetClassAndProto(JSContext *cx, HandleObject obj,
|
|
|
|
Class *clasp, Handle<TaggedProto> proto, bool checkForCycles);
|
2010-06-17 15:23:17 -07:00
|
|
|
|
2011-04-16 21:23:44 -07:00
|
|
|
extern JSObject *
|
|
|
|
NonNullObject(JSContext *cx, const Value &v);
|
|
|
|
|
2011-05-06 15:47:47 -07:00
|
|
|
extern const char *
|
|
|
|
InformalValueTypeName(const Value &v);
|
2011-09-08 21:18:23 -07:00
|
|
|
|
2012-03-20 03:22:05 -07:00
|
|
|
inline void
|
|
|
|
DestroyIdArray(FreeOp *fop, JSIdArray *ida);
|
|
|
|
|
2012-03-25 19:14:27 -07:00
|
|
|
extern bool
|
2012-07-04 11:12:16 -07:00
|
|
|
GetFirstArgumentAsObject(JSContext *cx, unsigned argc, Value *vp, const char *method,
|
|
|
|
MutableHandleObject objp);
|
2012-03-25 19:14:27 -07:00
|
|
|
|
2012-04-04 17:26:21 -07:00
|
|
|
/* Helpers for throwing. These always return false. */
|
|
|
|
extern bool
|
|
|
|
Throw(JSContext *cx, jsid id, unsigned errorNumber);
|
|
|
|
|
|
|
|
extern bool
|
|
|
|
Throw(JSContext *cx, JSObject *obj, unsigned errorNumber);
|
|
|
|
|
2012-06-13 01:11:18 -07:00
|
|
|
/*
|
|
|
|
* Helper function. To approximate a call to the [[DefineOwnProperty]] internal
|
|
|
|
* method described in ES5, first call this, then call JS_DefinePropertyById.
|
|
|
|
*
|
|
|
|
* JS_DefinePropertyById by itself does not enforce the invariants on
|
|
|
|
* non-configurable properties when obj->isNative(). This function performs the
|
|
|
|
* relevant checks (specified in ES5 8.12.9 [[DefineOwnProperty]] steps 1-11),
|
|
|
|
* but only if obj is native.
|
|
|
|
*
|
|
|
|
* The reason for the messiness here is that ES5 uses [[DefineOwnProperty]] as
|
|
|
|
* a sort of extension point, but there is no hook in js::Class,
|
|
|
|
* js::ProxyHandler, or the JSAPI with precisely the right semantics for it.
|
|
|
|
*/
|
|
|
|
extern bool
|
|
|
|
CheckDefineProperty(JSContext *cx, HandleObject obj, HandleId id, HandleValue value,
|
|
|
|
PropertyOp getter, StrictPropertyOp setter, unsigned attrs);
|
|
|
|
|
2011-09-08 21:18:23 -07:00
|
|
|
} /* namespace js */
|
2011-01-18 14:25:46 -08:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
#endif /* jsobj_h___ */
|