Bug 966575 part 04 -- Make TI Type Object Addendum refer to actual descriptor and not TypeRepresentation*

This commit is contained in:
Nicholas D. Matsakis 2014-01-28 18:24:23 -05:00
parent af656b7f6b
commit dc956ca97e
6 changed files with 31 additions and 46 deletions

View File

@ -1300,13 +1300,8 @@ TypedDatum::createUnattachedWithClass(JSContext *cx,
// FIXME Bug 929651 ^~~~~~~~~~~~~~~~~~~~~~~~~~~
RootedTypeObject typeObj(cx, obj->getType(cx));
if (typeObj) {
TypeRepresentation *typeRepr = type->typeRepresentation();
if (!typeObj->addTypedObjectAddendum(cx,
types::TypeTypedObject::Datum,
typeRepr))
{
if (!typeObj->addTypedObjectAddendum(cx, type))
return nullptr;
}
}
}

View File

@ -1142,7 +1142,7 @@ ScanTypeObject(GCMarker *gcmarker, types::TypeObject *type)
PushMarkStack(gcmarker, type->newScript()->fun);
PushMarkStack(gcmarker, type->newScript()->templateObject);
} else if (type->hasTypedObject()) {
PushMarkStack(gcmarker, type->typedObject()->typeRepr->ownerObject());
PushMarkStack(gcmarker, type->typedObject()->descrHeapPtr());
}
if (type->interpretedFunction)
@ -1169,7 +1169,7 @@ gc::MarkChildren(JSTracer *trc, types::TypeObject *type)
MarkObject(trc, &type->newScript()->fun, "type_new_function");
MarkObject(trc, &type->newScript()->templateObject, "type_new_template");
} else if (type->hasTypedObject()) {
type->typedObject()->typeRepr->mark(trc);
MarkObject(trc, &type->typedObject()->descrHeapPtr(), "type_heap_ptr");
}
if (type->interpretedFunction)

View File

@ -9831,14 +9831,12 @@ IonBuilder::lookupTypeRepresentationSet(MDefinition *typedObj,
}
types::TemporaryTypeSet *types = typedObj->resultTypeSet();
return typeSetToTypeRepresentationSet(types, out,
types::TypeTypedObject::Datum);
return typeSetToTypeRepresentationSet(types, out);
}
bool
IonBuilder::typeSetToTypeRepresentationSet(types::TemporaryTypeSet *types,
TypeRepresentationSet *out,
types::TypeTypedObject::Kind kind)
TypeRepresentationSet *out)
{
// Extract TypeRepresentationSet directly if we can
if (!types || types->getKnownTypeTag() != JSVAL_TYPE_OBJECT)
@ -9857,10 +9855,8 @@ IonBuilder::typeSetToTypeRepresentationSet(types::TemporaryTypeSet *types,
if (!type->hasTypedObject())
return true;
if (type->typedObject()->kind != kind)
return true;
TypeRepresentation *typeRepr = type->typedObject()->typeRepr;
TypeRepresentation *typeRepr =
type->typedObject()->descr().typeRepresentation();
if (!set.insert(typeRepr))
return false;
}

View File

@ -433,8 +433,7 @@ class IonBuilder : public MIRGenerator
bool lookupTypeRepresentationSet(MDefinition *typedObj,
TypeRepresentationSet *out);
bool typeSetToTypeRepresentationSet(types::TemporaryTypeSet *types,
TypeRepresentationSet *out,
types::TypeTypedObject::Kind kind);
TypeRepresentationSet *out);
bool lookupTypedObjectField(MDefinition *typedObj,
PropertyName *name,
int32_t *fieldOffset,

View File

@ -21,6 +21,7 @@
#include "jsworkers.h"
#include "prmjtime.h"
#include "builtin/TypedObject.h"
#include "gc/Marking.h"
#ifdef JS_ION
#include "jit/BaselineJIT.h"
@ -4633,14 +4634,12 @@ TypeObject::setAddendum(TypeObjectAddendum *addendum)
}
bool
TypeObject::addTypedObjectAddendum(JSContext *cx,
TypeTypedObject::Kind kind,
TypeRepresentation *repr)
TypeObject::addTypedObjectAddendum(JSContext *cx, Handle<TypeDescr*> descr)
{
if (!cx->typeInferenceEnabled())
return true;
JS_ASSERT(repr);
JS_ASSERT(descr);
if (flags() & OBJECT_FLAG_ADDENDUM_CLEARED)
return true;
@ -4649,11 +4648,11 @@ TypeObject::addTypedObjectAddendum(JSContext *cx,
if (addendum) {
JS_ASSERT(hasTypedObject());
JS_ASSERT(typedObject()->typeRepr == repr);
JS_ASSERT(&typedObject()->descr() == descr);
return true;
}
TypeTypedObject *typedObject = js_new<TypeTypedObject>(kind, repr);
TypeTypedObject *typedObject = js_new<TypeTypedObject>(descr);
if (!typedObject)
return false;
addendum = typedObject;
@ -4672,10 +4671,14 @@ TypeNewScript::TypeNewScript()
: TypeObjectAddendum(NewScript)
{}
TypeTypedObject::TypeTypedObject(Kind kind,
TypeRepresentation *repr)
TypeTypedObject::TypeTypedObject(Handle<TypeDescr*> descr)
: TypeObjectAddendum(TypedObject),
kind(kind),
typeRepr(repr)
descr_(descr)
{
}
TypeDescr &
js::types::TypeTypedObject::descr() {
return descr_->as<TypeDescr>();
}

View File

@ -25,13 +25,13 @@
namespace js {
class TypeDescr;
#ifdef DEBUG
bool CurrentThreadCanWriteCompilationData();
bool CurrentThreadCanReadCompilationData();
#endif
class TypeRepresentation;
class TaggedProto
{
public:
@ -847,23 +847,17 @@ struct TypeNewScript : public TypeObjectAddendum
struct TypeTypedObject : public TypeObjectAddendum
{
enum Kind {
TypeDescriptor,
Datum,
};
private:
HeapPtrObject descr_;
TypeTypedObject(Kind kind, TypeRepresentation *repr);
public:
TypeTypedObject(Handle<TypeDescr*> descr);
const Kind kind;
TypeRepresentation *const typeRepr;
bool isTypeDescriptor() const {
return kind == TypeDescriptor;
HeapPtrObject &descrHeapPtr() {
return descr_;
}
bool isDatum() const {
return kind == Datum;
}
TypeDescr &descr();
};
/*
@ -1019,9 +1013,7 @@ struct TypeObject : gc::BarrieredCell<TypeObject>
* this addendum must already be associated with the same TypeRepresentation,
* and the method has no effect.
*/
bool addTypedObjectAddendum(JSContext *cx,
TypeTypedObject::Kind kind ,
TypeRepresentation *repr);
bool addTypedObjectAddendum(JSContext *cx, Handle<TypeDescr*> descr);
private:
/*