Bug 898623 - Root StructType FieldInfo properties. r=terrence

--HG--
extra : rebase_source : 8d9c9a3da29f8289b3c1f0bd2e5bc1fc5c6eb1df
This commit is contained in:
Nikhil Marathe 2013-07-26 16:21:53 -07:00
parent 780648d5ee
commit f8bb181a20
2 changed files with 28 additions and 8 deletions

View File

@ -15,6 +15,7 @@
#include "jsobj.h"
#include "jsutil.h"
#include "gc/Marking.h"
#include "vm/TypedArrayObject.h"
#include "vm/String.h"
#include "vm/StringBuffer.h"
@ -181,9 +182,16 @@ GetAlign(JSContext *cx, HandleObject type)
struct FieldInfo
{
jsid name;
JSObject *type;
HeapId name;
HeapPtrObject type;
size_t offset;
FieldInfo() : offset(0) {}
FieldInfo(const FieldInfo &o)
: name(o.name.get()), type(o.type), offset(o.offset)
{
}
};
Class js::DataClass = {
@ -262,7 +270,7 @@ IsSameStructType(JSContext *cx, HandleObject type1, HandleObject type2)
FieldInfo fieldInfo1 = fieldList1->at(i);
FieldInfo fieldInfo2 = fieldList2->at(i);
if (fieldInfo1.name != fieldInfo2.name)
if (fieldInfo1.name.get() != fieldInfo2.name.get())
return false;
if (fieldInfo1.offset != fieldInfo2.offset)
@ -1427,11 +1435,11 @@ Class StructType::class_ = {
JS_ResolveStub,
JS_ConvertStub,
StructType::finalize,
NULL,
NULL,
NULL,
NULL, /* checkAccess */
NULL, /* call */
NULL, /* hasInstance */
BinaryStruct::construct,
NULL
StructType::trace
};
Class BinaryStruct::class_ = {
@ -1450,8 +1458,8 @@ Class BinaryStruct::class_ = {
BinaryStruct::finalize,
NULL, /* checkAccess */
NULL, /* call */
NULL, /* construct */
NULL, /* hasInstance */
NULL, /* construct */
BinaryStruct::obj_trace,
JS_NULL_CLASS_EXT,
{
@ -1690,6 +1698,17 @@ StructType::finalize(FreeOp *op, JSObject *obj)
delete list;
}
void
StructType::trace(JSTracer *tracer, JSObject *obj)
{
FieldList *fieldList = static_cast<FieldList *>(obj->getPrivate());
JS_ASSERT(fieldList);
for (FieldList::iterator it = fieldList->begin(); it != fieldList->end(); ++it) {
gc::MarkId(tracer, &(it->name), "structtype.field.name");
MarkObject(tracer, &(it->type), "structtype.field.type");
}
}
JSBool
StructType::toString(JSContext *cx, unsigned int argc, Value *vp)
{

View File

@ -277,6 +277,7 @@ class StructType : public JSObject
size_t offset, MutableHandleValue to);
static void finalize(js::FreeOp *op, JSObject *obj);
static void trace(JSTracer *tracer, JSObject *obj);
};
class BinaryStruct : public JSObject