Projects
Essentials
lightspark
Sign Up
Log In
Username
Password
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
Expand all
Collapse all
Changes of Revision 116
View file
lightspark.spec
Changed
@@ -20,7 +20,7 @@ %bcond_without librtmp Name: lightspark -Version: 0.7.2.99+git20160904.1650 +Version: 0.7.2.99+git20160911.1713 Release: 0 Summary: Modern, free, open-source flash player implementation License: LGPL-3.0+
View file
lightspark.tar.xz/src/asobject.cpp
Changed
@@ -726,22 +726,10 @@ } void ASObject::initializeVariableByMultiname(const multiname& name, ASObject* o, multiname* typemname, - ABCContext* context, TRAIT_KIND traitKind, bool bOverwrite) + ABCContext* context, TRAIT_KIND traitKind, uint32_t slot_id) { check(); - if (!bOverwrite) - { - variable* obj=findSettable(name); - if(obj) - { - //Initializing an already existing variable - LOG(LOG_NOT_IMPLEMENTED,"Variable " << name << " already initialized, type:"<<*typemname); - if (o != NULL) - o->decRef(); - return; - } - } - Variables.initializeVar(name, o, typemname, context, traitKind,this); + Variables.initializeVar(name, o, typemname, context, traitKind,this,slot_id); ++varcount; } @@ -865,14 +853,17 @@ return &inserted->second; } -void variables_map::initializeVar(const multiname& mname, ASObject* obj, multiname* typemname, ABCContext* context, TRAIT_KIND traitKind, ASObject* mainObj) +void variables_map::initializeVar(const multiname& mname, ASObject* obj, multiname* typemname, ABCContext* context, TRAIT_KIND traitKind, ASObject* mainObj, uint32_t slot_id) { const Type* type = NULL; + if (typemname->isStatic) + type = typemname->cachedType; + /* If typename is a builtin type, we coerce obj. * It it's not it must be a user defined class, * so we try to find the class it is derived from and create an apropriate uninitialized instance */ if (type == NULL) - type = Type::getBuiltinType(typemname); + type = Type::getBuiltinType(mainObj->getSystemState(),typemname); if (type == NULL) type = Type::getTypeFromMultiname(typemname,context); if(type==NULL) @@ -888,7 +879,6 @@ { //Casting undefined to an object (of unknown class) //results in Null - obj->decRef(); obj = mainObj->getSystemState()->getNullRef(); } } @@ -897,59 +887,29 @@ { if (obj == NULL) // create dynamic object { - if (type == Type::anyType) - { - // type could not be found, so it's stored as an uninitialized variable - LOG_CALL("add uninitialized var:"<<mname<<" "<<*typemname); - uninitializedVar v; - mainObj->incRef(); - v.mainObj = mainObj; - v.mname = &mname; - v.traitKind = traitKind; - v.typemname = typemname; - //context->addUninitializedVar(v); - obj = mainObj->getSystemState()->getUndefinedRef(); - obj = type->coerce(obj); - } - else if(mainObj->is<Class_base>() && - mainObj->as<Class_base>()->class_name.getQualifiedName(mainObj->getSystemState()) == typemname->qualifiedString(mainObj->getSystemState())) + if(mainObj->is<Class_base>() + && mainObj->as<Class_base>()->class_name.nameId == typemname->normalizedNameId(mainObj->getSystemState()) + && mainObj->as<Class_base>()->class_name.nsStringId == typemname->ns[0].nsNameId + && typemname->ns[0].kind == NAMESPACE) { // avoid recursive construction - //obj = mainObj->getSystemState()->getNullRef(); obj = mainObj->getSystemState()->getUndefinedRef(); } - else if (dynamic_cast<const Class_base*>(type) - && type != Class_object::getClass(dynamic_cast<const Class_base*>(type)->getSystemState())) - { - //if (!((Class_base*)type)->super) - { - // super type could not be found, so the class is stored as an uninitialized variable - LOG_CALL("add uninitialized class var:"<<mname); - uninitializedVar v; - mainObj->incRef(); - v.mainObj = mainObj; - v.mname = &mname; - v.traitKind = traitKind; - v.typemname = typemname; - //context->addUninitializedVar(v); - obj = mainObj->getSystemState()->getUndefinedRef(); - //obj = mainObj->getSystemState()->getNullRef(); - obj = type->coerce(obj); - } - //else - // obj = ((Class_base*)type)->getInstance(false,NULL,0); - } else { obj = mainObj->getSystemState()->getUndefinedRef(); obj = type->coerce(obj); } } + if (typemname->isStatic && typemname->cachedType == NULL) + typemname->cachedType = type; } assert(traitKind==DECLARED_TRAIT || traitKind==CONSTANT_TRAIT || traitKind == INSTANCE_TRAIT); uint32_t name=mname.normalizedNameId(mainObj->getSystemState()); - Variables.insert(make_pair(varName(name, mname.ns[0]), variable(traitKind, obj, typemname, type))); + auto inserted = Variables.insert(make_pair(varName(name, mname.ns[0]), variable(traitKind, obj, typemname, type))); + if (slot_id) + initSlot(slot_id,inserted.first); } ASFUNCTIONBODY(ASObject,generator) @@ -1101,6 +1061,10 @@ return NULL; } +void ASObject::initSlot(unsigned int n, variables_map::var_iterator it) +{ + Variables.initSlot(n,it); +} void ASObject::initSlot(unsigned int n, const multiname& name) { Variables.initSlot(n,name.name_s_id,name.ns[0]); @@ -1407,10 +1371,17 @@ return dodestruct; } +void variables_map::initSlot(unsigned int n, var_iterator& it) +{ + if(n>slots_vars.size()) + slots_vars.resize(n+8,Variables.end()); + + slots_vars[n-1]=it; +} void variables_map::initSlot(unsigned int n, uint32_t nameId, const nsNameAndKind& ns) { if(n>slots_vars.size()) - slots_vars.resize(n,Variables.end()); + slots_vars.resize(n+8,Variables.end()); var_iterator ret=Variables.find(varName(nameId,ns));
View file
lightspark.tar.xz/src/asobject.h
Changed
@@ -295,7 +295,7 @@ } //Initialize a new variable specifying the type (TODO: add support for const) - void initializeVar(const multiname& mname, ASObject* obj, multiname *typemname, ABCContext* context, TRAIT_KIND traitKind, ASObject* mainObj); + void initializeVar(const multiname& mname, ASObject* obj, multiname *typemname, ABCContext* context, TRAIT_KIND traitKind, ASObject* mainObj, uint32_t slot_id); void killObjVar(SystemState* sys, const multiname& mname); ASObject* getSlot(unsigned int n) { @@ -312,6 +312,7 @@ * this is verified at optimization time */ void setSlotNoCoerce(unsigned int n,ASObject* o); + void initSlot(unsigned int n, var_iterator &it); void initSlot(unsigned int n, uint32_t nameId, const nsNameAndKind& ns); inline unsigned int size() const { @@ -505,7 +506,7 @@ * Called by ABCVm::buildTraits to create DECLARED_TRAIT or CONSTANT_TRAIT and set their type */ void initializeVariableByMultiname(const multiname& name, ASObject* o, multiname* typemname, - ABCContext* context, TRAIT_KIND traitKind,bool bOverwrite); + ABCContext* context, TRAIT_KIND traitKind, uint32_t slot_id); /* * Called by ABCVm::initProperty (implementation of ABC instruction), it is allowed to set CONSTANT_TRAIT */ @@ -531,6 +532,7 @@ { Variables.setSlotNoCoerce(n,o); } + void initSlot(unsigned int n, variables_map::var_iterator it); void initSlot(unsigned int n, const multiname& name); unsigned int numVariables() const; inline tiny_string getNameAt(int i) const @@ -674,6 +676,7 @@ class ObjectConstructor; class Function_object; class Date; +class Global; template<> inline bool ASObject::is<Number>() const { return type==T_NUMBER; } template<> inline bool ASObject::is<Integer>() const { return type==T_INTEGER; } @@ -698,6 +701,8 @@ template<> inline bool ASObject::is<Class_inherit>() const { return subtype==SUBTYPE_INHERIT; } template<> inline bool ASObject::is<ObjectConstructor>() const { return subtype==SUBTYPE_OBJECTCONSTRUCTOR; } template<> inline bool ASObject::is<Function_object>() const { return subtype==SUBTYPE_FUNCTIONOBJECT; } +template<> inline bool ASObject::is<Global>() const { return subtype==SUBTYPE_GLOBAL; } + }
View file
lightspark.tar.xz/src/scripting/abc.cpp
Changed
@@ -684,7 +684,10 @@ ASObject* rt1 = NULL; ASObject* rt2 = NULL; if(fromStack > 0) + { + assert_and_throw(context); rt1 = context->runtime_stack_pop(); + } if(fromStack > 1) rt2 = context->runtime_stack_pop(); return getMultinameImpl(rt1,rt2,n); @@ -844,6 +847,7 @@ { assert(n && !n2); + ret->isStatic = false; //Testing shows that the namespace from a //QName is used even in MultinameL if (n->is<ASQName>()) @@ -868,6 +872,7 @@ { assert(n && !n2); assert_and_throw(n->classdef==Class<Namespace>::getClass(n->getSystemState())); + ret->isStatic = false; Namespace* tmpns=static_cast<Namespace*>(n); ret->ns.clear(); ret->ns.emplace_back(n->getSystemState(),tmpns->uri,tmpns->nskind); @@ -879,6 +884,7 @@ { assert(n && n2); assert_and_throw(n2->classdef==Class<Namespace>::getClass(n->getSystemState())); + ret->isStatic = false; Namespace* tmpns=static_cast<Namespace*>(n2); ret->ns.clear(); ret->ns.emplace_back(n->getSystemState(),tmpns->uri,tmpns->nskind); @@ -1569,18 +1575,6 @@ entry->decRef(); - // initialize vars where type was not known during script init - // this may happen for variables of private classes defined in this script - LOG(LOG_CALLS,"initialize uninitialized vars"); - auto it = uninitializedVars.begin(); - while (it != uninitializedVars.end()) - { - uninitializedVar v = *it; - v.mainObj->initializeVariableByMultiname(*v.mname,NULL,v.typemname,this,v.traitKind,true); - v.mainObj->decRef(); - uninitializedVars.pop_front(); - it = uninitializedVars.begin(); - } LOG(LOG_CALLS, "Finished script init for script " << i ); } @@ -2044,31 +2038,14 @@ } } -void ABCContext::addUninitializedVar(uninitializedVar &v) -{ - auto it = uninitializedVars.begin(); - bool bfound = false; - while (it != uninitializedVars.end()) - { - if (it->mainObj == v.mainObj && it->mname == v.mname) - { - bfound = true; - break; - } - it++; - } - if (!bfound) - uninitializedVars.push_back(v); -} - -void ABCContext::buildTrait(ASObject* obj, const traits_info* t, bool isBorrowed, int scriptid) +void ABCContext::buildTrait(ASObject* obj, const traits_info* t, bool isBorrowed, int scriptid, bool checkExisting) { multiname* mname=getMultiname(t->name,NULL); //Should be a Qname assert_and_throw(mname->name_type==multiname::NAME_STRING); +#ifndef NDEBUG if(t->kind>>4) LOG(LOG_CALLS,_("Next slot has flags ") << (t->kind>>4)); - if(t->kind&traits_info::Metadata) { for(unsigned int i=0;i<t->metadata_count;i++) @@ -2079,15 +2056,14 @@ LOG(LOG_CALLS," : " << root->getSystemState()->getStringFromUniqueId(getString(minfo.items[j].key)) << " " << root->getSystemState()->getStringFromUniqueId(getString(minfo.items[j].value))); } } - +#endif uint32_t kind = t->kind&0xf; switch(kind) { case traits_info::Class: { //Check if this already defined in upper levels - _NR<ASObject> tmpo=obj->getVariableByMultiname(*mname,ASObject::SKIP_IMPL); - if(!tmpo.isNull()) + if(obj->hasPropertyByMultiname(*mname,false,false)) return; //Check if this already defined in parent applicationdomains @@ -2226,7 +2202,6 @@ obj->incRef(); f->addToScope(scope_entry(_MR(obj),false)); } - //TODO: Avoid string lookup if(kind == traits_info::Getter) obj->setDeclaredMethodByQName(mname->name_s_id,mname->ns[0],f,GETTER_METHOD,isBorrowed); else if(kind == traits_info::Setter) @@ -2238,8 +2213,7 @@ case traits_info::Const: { //Check if this already defined in upper levels - _NR<ASObject> tmpo=obj->getVariableByMultiname(*mname,ASObject::SKIP_IMPL); - if(!tmpo.isNull()) + if(checkExisting && obj->hasPropertyByMultiname(*mname,false,false)) return; multiname* tname=getMultiname(t->type_name,NULL); @@ -2252,19 +2226,13 @@ LOG(LOG_CALLS,_("Const ") << *mname <<_(" type ")<< *tname<< " = " << ret->toDebugString()); - obj->initializeVariableByMultiname(*mname, ret, tname, this, CONSTANT_TRAIT,false); - - if(t->slot_id) - obj->initSlot(t->slot_id, *mname); - //else // slot_id 0 seems to mean appending new slot - // obj->appendSlot(*mname); + obj->initializeVariableByMultiname(*mname, ret, tname, this, CONSTANT_TRAIT,t->slot_id); break; } case traits_info::Slot: { //Check if this already defined in upper levels - _NR<ASObject> tmpo=obj->getVariableByMultiname(*mname,ASObject::SKIP_IMPL); - if(!tmpo.isNull()) + if(checkExisting && obj->hasPropertyByMultiname(*mname,false,false)) return; multiname* tname=getMultiname(t->type_name,NULL); @@ -2272,26 +2240,22 @@ if(t->vindex) { ret=getConstant(t->vkind,t->vindex); - LOG(LOG_CALLS,_("Slot ") << t->slot_id << ' ' << *mname <<_(" type ")<<*tname<< " = " << ret->toDebugString() <<" "<<isBorrowed); + LOG_CALL(_("Slot ") << t->slot_id << ' ' << *mname <<_(" type ")<<*tname<< " = " << ret->toDebugString() <<" "<<isBorrowed); } else { - LOG(LOG_CALLS,_("Slot ")<< t->slot_id<< _(" vindex 0 ") << *mname <<_(" type ")<<*tname<<" "<<isBorrowed); + LOG_CALL(_("Slot ")<< t->slot_id<< _(" vindex 0 ") << *mname <<_(" type ")<<*tname<<" "<<isBorrowed); ret = NULL; } - obj->initializeVariableByMultiname(*mname, ret, tname, this, isBorrowed ? INSTANCE_TRAIT : DECLARED_TRAIT,false); - - if(t->slot_id) - obj->initSlot(t->slot_id, *mname); - //else // slot_id 0 seems to mean appending new slot - // obj->appendSlot(*mname); - + obj->initializeVariableByMultiname(*mname, ret, tname, this, isBorrowed ? INSTANCE_TRAIT : DECLARED_TRAIT,t->slot_id); +; break; } default: LOG(LOG_ERROR,_("Trait not supported ") << *mname << _(" ") << t->kind); obj->setVariableByMultiname(*mname, obj->getSystemState()->getUndefinedRef(), ASObject::CONST_NOT_ALLOWED); + break; } }
View file
lightspark.tar.xz/src/scripting/abc.h
Changed
@@ -148,15 +148,6 @@ ARGS_TYPE type; }; -struct uninitializedVar -{ - uninitializedVar():mname(NULL),mainObj(NULL),typemname(NULL),traitKind(NO_CREATE_TRAIT) {} - const multiname* mname; - ASObject* mainObj; - multiname* typemname; - TRAIT_KIND traitKind; -}; - class ABCContext { friend class ABCVm; @@ -189,9 +180,6 @@ uint32_t namespaceBaseId; std::vector<bool> hasRunScriptInit; - // list of vars that have to be initialized after script init is done - std::list<uninitializedVar> uninitializedVars; - void addUninitializedVar(uninitializedVar& v); /** Construct and insert in the a object a given trait @param obj the tarhget object @@ -199,7 +187,7 @@ @param isBorrowed True if we're building a trait on behalf of an object, False otherwise @param deferred_initialization A pointer to a function that can be used to build the given trait later */ - void buildTrait(ASObject* obj, const traits_info* t, bool isBorrowed, int scriptid=-1); + void buildTrait(ASObject* obj, const traits_info* t, bool isBorrowed, int scriptid=-1, bool checkExisting=true); void runScriptInit(unsigned int scriptid, ASObject* g); void linkTrait(Class_base* obj, const traits_info* t); @@ -371,7 +359,7 @@ static void setSlot(ASObject*, ASObject*, int n); static void kill(int n); static ASObject* pushString(call_context* th, int n); - static void getLex(call_context* th, int n); + static bool getLex(call_context* th, int n); static ASObject* getScopeObject(call_context* th, int n); static bool deleteProperty(ASObject* obj, multiname* name); static void initProperty(ASObject* obj, ASObject* val, multiname* name);
View file
lightspark.tar.xz/src/scripting/abc_interpreter.cpp
Changed
@@ -45,9 +45,6 @@ //This may be non-zero and point to the position of an exception handler code.seekg(context->exec_pos); - - u8 opcode; - #ifdef PROFILING_SUPPORT if(mi->profTime.empty()) mi->profTime.resize(code_len,0); @@ -65,7 +62,7 @@ #ifdef PROFILING_SUPPORT uint32_t instructionPointer=code.tellg(); #endif - opcode = code.readbyte(); + uint8_t opcode = code.readbyte(); //Save ip for exception handling in SyntheticFunction::callImpl context->exec_pos = code.tellg(); @@ -984,8 +981,22 @@ case 0x60: { //getlex + lightspark::method_body_info_cache* cachepos = code.tellcachepos(); + if (cachepos->type == method_body_info_cache::CACHE_TYPE_OBJECT) + { + code.seekpos(cachepos->nextcodepos); + context->runtime_stack_push(cachepos->obj); + cachepos->obj->incRef(); + break; + } uint32_t t = code.readu30(); - getLex(context,t); + if (getLex(context,t)) + { + // put object in cache + cachepos->type =method_body_info_cache::CACHE_TYPE_OBJECT; + cachepos->obj = context->runtime_stack_peek(); + cachepos->obj->incRef(); + } break; } case 0x61:
View file
lightspark.tar.xz/src/scripting/abc_opcodes.cpp
Changed
@@ -184,11 +184,10 @@ multiname* mn = th->context->getMultiname(n,NULL); LOG_CALL("coerce " << *mn); + ASObject** o=th->runtime_stack_pointer(); + const Type* type = Type::getTypeFromMultiname(mn, th->context); - - ASObject* o=th->runtime_stack_pop(); - o=type->coerce(o); - th->runtime_stack_push(o); + *o=type->coerce(*o); } void ABCVm::pop() @@ -1464,7 +1463,7 @@ th->runtime_stack_push(ret.getPtr()); } -void ABCVm::getLex(call_context* th, int n) +bool ABCVm::getLex(call_context* th, int n) { //getlex is specified not to allow runtime multinames assert_and_throw(th->context->getMultinameRTData(n)==0); @@ -1476,6 +1475,8 @@ // stack. ASObject* o = NULL; + bool canCache = true; + //Find out the current 'this', when looking up over it, we have to consider all of it for(uint32_t i = th->curr_scope_stack; i > 0; i--) { @@ -1487,6 +1488,8 @@ ASObject::GET_VARIABLE_OPTION opt=ASObject::XML_STRICT; if(!th->scope_stack_dynamic[i-1]) opt=(ASObject::GET_VARIABLE_OPTION)(opt | ASObject::SKIP_IMPL); + else + canCache = false; checkDeclaredTraits(s); _NR<ASObject> prop=s->getVariableByMultiname(*name, opt); @@ -1508,6 +1511,8 @@ ASObject::GET_VARIABLE_OPTION opt=ASObject::XML_STRICT; if(!it->considerDynamic) opt=(ASObject::GET_VARIABLE_OPTION)(opt | ASObject::SKIP_IMPL); + else + canCache = false; checkDeclaredTraits(it->object.getPtr()); _NR<ASObject> prop=it->object->getVariableByMultiname(*name, opt); @@ -1530,13 +1535,17 @@ throwError<ReferenceError>(kUndefinedVarError,name->normalizedNameUnresolved(th->context->root->getSystemState())); th->runtime_stack_push(th->context->root->getSystemState()->getUndefinedRef()); name->resetNameIfObject(); - return; + return false; } o->incRef(); } + else + // TODO can we cache objects found in the scope_stack? + canCache = false; name->resetNameIfObject(); th->runtime_stack_push(o); + return canCache; } void ABCVm::constructSuper(call_context* th, int m) @@ -1863,8 +1872,6 @@ if(obj->classdef) { - assert_and_throw(type->getObjectType()==T_CLASS); - objc=obj->classdef; } else @@ -2551,7 +2558,7 @@ act->initialized=false; #endif for(unsigned int i=0;i<mi->body->trait_count;i++) - th->context->buildTrait(act,&mi->body->traits[i],false); + th->context->buildTrait(act,&mi->body->traits[i],false,-1,false); #ifndef NDEBUG act->initialized=true; #endif
View file
lightspark.tar.xz/src/scripting/toplevel/Array.cpp
Changed
@@ -29,7 +29,7 @@ using namespace lightspark; Array::Array(Class_base* c):ASObject(c,T_ARRAY),currentsize(0), - data(std::less<arrayType::key_type>(), reporter_allocator<arrayType::value_type>(c->memoryAccount)) + data(std::less<arrayType::key_type>(), reporter_allocator<arrayType::value_type>(c->memoryAccount)),currentpos(data.end()) { } @@ -333,6 +333,7 @@ if(newLen==th->size()) return NULL; th->resize(newLen); + th->currentpos = th->data.end(); return NULL; } @@ -397,6 +398,7 @@ th->data[size-(it->first+1)]=it->second; } th->incRef(); + th->currentpos = th->data.end(); return th; } @@ -498,6 +500,7 @@ th->data.clear(); th->data.insert(tmp.begin(),tmp.end()); th->resize(th->size()-1); + th->currentpos = th->data.end(); return ret; } @@ -611,6 +614,7 @@ th->data[startIndex+i+(argslen > 2 ? argslen-2 : 0)] = tmp[i]; } th->resize((totalSize-deleteCount)+(argslen > 2 ? argslen-2 : 0)); + th->currentpos = th->data.end(); return ret; } @@ -702,6 +706,7 @@ ret = obj->getSystemState()->getUndefinedRef(); th->currentsize--; + th->currentpos = th->data.end(); return ret; } @@ -842,6 +847,7 @@ th->data[i++]= *ittmp; } obj->incRef(); + th->currentpos = th->data.end(); return obj; } @@ -987,6 +993,7 @@ th->data[i++]= *ittmp; } obj->incRef(); + th->currentpos = th->data.end(); return obj; } @@ -1032,6 +1039,7 @@ th->data.clear(); th->data.insert(tmp.begin(),tmp.end()); } + th->currentpos = th->data.end(); return abstract_i(obj->getSystemState(),th->size()); } @@ -1283,6 +1291,7 @@ ds.data_i=value; ds.type=DATA_INT; data[index] = ds; + currentpos = data.end(); } @@ -1378,6 +1387,7 @@ ds.type=DATA_OBJECT; } data[index] = ds; + currentpos = data.end(); } bool Array::deleteVariableByMultiname(const multiname& name) @@ -1396,6 +1406,7 @@ return true; it->second.clear(); data.erase(it); + currentpos = data.end(); return true; } @@ -1463,10 +1474,15 @@ assert_and_throw(implEnable); if(index<=size()) { - index--; - auto it = data.find(index); - if(it == data.end()) + --index; + data_iterator it; + if (currentpos != data.end() && currentpos->first == index-1) + it = ++currentpos; + else + it = data.find(index); + if(it == data.end() || it->first != index) return _MR(getSystemState()->getUndefinedRef()); + currentpos = it; const data_slot& sl = it->second; if(sl.type==DATA_OBJECT) { @@ -1576,6 +1592,7 @@ if (itstart != data.end()) data.erase(itstart,data.end()); currentsize = n; + currentpos = data.end(); } void Array::serialize(ByteArray* out, std::map<tiny_string, uint32_t>& stringMap, @@ -1713,6 +1730,7 @@ ds.type=DATA_OBJECT; } data[index]=ds; + currentpos = data.end(); } else outofbounds(index);
View file
lightspark.tar.xz/src/scripting/toplevel/Array.h
Changed
@@ -60,7 +60,10 @@ uint64_t currentsize; typedef std::map<uint32_t,data_slot,std::less<uint32_t>, reporter_allocator<std::pair<const uint32_t, data_slot>>> arrayType; + + typedef std::map<uint32_t,data_slot>::iterator data_iterator; arrayType data; + data_iterator currentpos; void outofbounds(unsigned int index) const; ~Array(); private: @@ -106,6 +109,7 @@ } data.clear(); currentsize=0; + currentpos = data.end(); return ASObject::destruct(); }
View file
lightspark.tar.xz/src/scripting/toplevel/toplevel.cpp
Changed
@@ -710,8 +710,10 @@ return o; } -Type* Type::getBuiltinType(const multiname* mn) +const Type* Type::getBuiltinType(SystemState *sys, const multiname* mn) { + if(mn->isStatic && mn->cachedType) + return mn->cachedType; assert_and_throw(mn->isQName()); assert(mn->name_type == multiname::NAME_STRING); if(mn == 0) @@ -725,9 +727,9 @@ //Check if the class has already been defined ASObject* target; - ASObject* tmp=getSys()->systemDomain->getVariableAndTargetByMultiname(*mn, target); + ASObject* tmp=sys->systemDomain->getVariableAndTargetByMultiname(*mn, target); if(tmp && tmp->getObjectType()==T_CLASS) - return static_cast<Class_base*>(tmp); + return static_cast<const Class_base*>(tmp); else return NULL; } @@ -742,6 +744,9 @@ if(mn == 0) //multiname idx zero indicates any type return Type::anyType; + if(mn->isStatic && mn->cachedType) + return mn->cachedType; + if(mn->name_type == multiname::NAME_STRING && mn->name_s_id==BUILTIN_STRINGS::ANY && mn->ns.size() == 1 && mn->ns[0].hasEmptyName()) return Type::anyType; @@ -2091,7 +2096,7 @@ } -Global::Global(Class_base* cb, ABCContext* c, int s):ASObject(cb),scriptId(s),context(c) +Global::Global(Class_base* cb, ABCContext* c, int s):ASObject(cb,T_OBJECT,SUBTYPE_GLOBAL),scriptId(s),context(c) { }
View file
lightspark.tar.xz/src/scripting/toplevel/toplevel.h
Changed
@@ -78,7 +78,7 @@ /* * Checks if the type is already in sys->classes */ - static Type* getBuiltinType(const multiname* mn); + static const Type *getBuiltinType(SystemState* sys, const multiname* mn); /* * Converts the given object to an object of this type. * It consumes one reference of 'o'.
View file
lightspark.tar.xz/src/smartrefs.h
Changed
@@ -306,6 +306,13 @@ { m=NULL; } + inline void forceDestruct() + { + assert(m->isConstant()); + if (m) + delete m; + m = NULL; + } template<class D> inline NullableRef<D> cast() const { if(!m)
View file
lightspark.tar.xz/src/swf.cpp
Changed
@@ -221,8 +221,10 @@ null=_MR(new (unaccountedMemory) Null); null->setSystemState(this); + null->setConstant(); undefined=_MR(new (unaccountedMemory) Undefined); undefined->setSystemState(this); + undefined->setConstant(); builtinClasses = new Class_base*[asClassCount]; memset(builtinClasses,0,asClassCount*sizeof(Class_base*)); @@ -237,7 +239,9 @@ classObject->decRef(); trueRef=_MR(Class<Boolean>::getInstanceS(this,true)); + trueRef->setConstant(); falseRef=_MR(Class<Boolean>::getInstanceS(this,false)); + falseRef->setConstant(); systemDomain = _MR(Class<ApplicationDomain>::getInstanceS(this)); _NR<ApplicationDomain> applicationDomain=_MR(Class<ApplicationDomain>::getInstanceS(this,systemDomain)); @@ -508,10 +512,6 @@ invalidateQueueTail.reset(); parameters.reset(); frameListeners.clear(); - null.reset(); - undefined.reset(); - trueRef.reset(); - falseRef.reset(); systemDomain.reset(); mainClip->decRef(); @@ -522,6 +522,10 @@ SystemState::~SystemState() { delete[] builtinClasses; + null.forceDestruct(); + undefined.forceDestruct(); + trueRef.forceDestruct(); + falseRef.forceDestruct(); } void SystemState::destroy() @@ -1805,34 +1809,6 @@ } } -Null* SystemState::getNullRef() const -{ - Null* ret=null.getPtr(); - ret->incRef(); - return ret; -} - -Undefined* SystemState::getUndefinedRef() const -{ - Undefined* ret=undefined.getPtr(); - ret->incRef(); - return ret; -} - -Boolean* SystemState::getTrueRef() const -{ - Boolean* ret=trueRef.getPtr(); - ret->incRef(); - return ret; -} - -Boolean* SystemState::getFalseRef() const -{ - Boolean* ret=falseRef.getPtr(); - ret->incRef(); - return ret; -} - const tiny_string& SystemState::getStringFromUniqueId(uint32_t id) const { Locker l(poolMutex);
View file
lightspark.tar.xz/src/swf.h
Changed
@@ -313,10 +313,25 @@ ThreadProfile* allocateProfiler(const RGB& color); std::list<ThreadProfile*> profilingData; - Null* getNullRef() const; - Undefined* getUndefinedRef() const; - Boolean* getTrueRef() const; - Boolean* getFalseRef() const; + inline Null* getNullRef() const + { + return null.getPtr(); + } + + inline Undefined* getUndefinedRef() const + { + return undefined.getPtr(); + } + + inline Boolean* getTrueRef() const + { + return trueRef.getPtr(); + } + + inline Boolean* getFalseRef() const + { + return falseRef.getPtr(); + } RootMovieClip* mainClip; Stage* stage;
View file
lightspark.tar.xz/src/swftypes.h
Changed
@@ -47,7 +47,7 @@ enum SWFOBJECT_TYPE { T_OBJECT=0, T_INTEGER=1, T_NUMBER=2, T_FUNCTION=3, T_UNDEFINED=4, T_NULL=5, T_STRING=6, /*UNUSED=7,*/ T_BOOLEAN=8, T_ARRAY=9, T_CLASS=10, T_QNAME=11, T_NAMESPACE=12, T_UINTEGER=13, T_PROXY=14, T_TEMPLATE=15}; // this is used to avoid calls to dynamic_cast when testing for some classes -enum CLASS_SUBTYPE { SUBTYPE_NOT_SET, SUBTYPE_PROXY, SUBTYPE_REGEXP, SUBTYPE_XML, SUBTYPE_XMLLIST,SUBTYPE_DATE, SUBTYPE_INHERIT, SUBTYPE_OBJECTCONSTRUCTOR,SUBTYPE_FUNCTIONOBJECT }; +enum CLASS_SUBTYPE { SUBTYPE_NOT_SET, SUBTYPE_PROXY, SUBTYPE_REGEXP, SUBTYPE_XML, SUBTYPE_XMLLIST,SUBTYPE_DATE, SUBTYPE_INHERIT, SUBTYPE_OBJECTCONSTRUCTOR,SUBTYPE_FUNCTIONOBJECT,SUBTYPE_GLOBAL }; enum STACK_TYPE{STACK_NONE=0,STACK_OBJECT,STACK_INT,STACK_UINT,STACK_NUMBER,STACK_BOOLEAN}; inline std::ostream& operator<<(std::ostream& s, const STACK_TYPE& st) @@ -84,6 +84,7 @@ typedef double number_t; +class Type; class SystemState; class ASObject; class ASString; @@ -369,7 +370,9 @@ enum NAME_TYPE {NAME_STRING,NAME_INT,NAME_NUMBER,NAME_OBJECT}; NAME_TYPE name_type; bool isAttribute; - multiname(MemoryAccount* m):name_s_id(UINT32_MAX),name_o(NULL),ns(reporter_allocator<nsNameAndKind>(m)),name_type(NAME_OBJECT),isAttribute(false) + bool isStatic; + const Type* cachedType; + multiname(MemoryAccount* m):name_s_id(UINT32_MAX),name_o(NULL),ns(reporter_allocator<nsNameAndKind>(m)),name_type(NAME_OBJECT),isAttribute(false),isStatic(true),cachedType(NULL) { }
Locations
Projects
Search
Status Monitor
Help
Open Build Service
OBS Manuals
API Documentation
OBS Portal
Reporting a Bug
Contact
Mailing List
Forums
Chat (IRC)
Twitter
Open Build Service (OBS)
is an
openSUSE project
.