diff --git a/README.tests b/README.tests index 18bec18850..8a6dd7deb4 100644 --- a/README.tests +++ b/README.tests @@ -3,23 +3,48 @@ http://opensource.adobe.com/wiki/display/flexsdk/Download+Flex+4 Flex 4 SDK is assumed to be installed in $FLEX_ROOT -To compile tests inside the tests/ directory use the following command: +To compile and run the test suite run: + +./tests + +Run "./tests --help" inside tests/ to see scripts usage. + +Compiling tests manually inside the tests/ directory: $FLEX_ROOT/bin/mxmlc -static-link-runtime-shared-libraries -compiler.omit-trace-statements=false test.mxml -output test.swf +Creating new testcases +---------------------- + +Use template.mxml as a template for new testcases. + +We've provided a simple Tests class which should be used where +possible to test general behaviour of AS classes. See Tests.as for its +usage. + +Please use a naming scheme as follow: + +For toplevel classes: tests/CLASSNAME_test.mxml (CLASSNAME is the +exact name of the class/function) + +For other classes: tests/NAMESPACE_CLASSNAME_test.mxml (NAMESPACE is +for example "net" for "flash.net" classes/functions, e.g.: +tests/net_NetStream_test.mxml) + +Please group all tests for one class in one file. + +Subdirectories +-------------- -NOTE: Use the ./tests script in tests/ to run the tests in an automated way. - Run "./tests --help" inside tests/ to see its usage. +tests/other: -NOTE: Use template.mxml as a template for new testcases. +Tests that aren't suitable for testing with the Tests class should be +put in here. (e.g.: testing video playing, StageScaleMode testing +etc...). The naming schemes still apply to these testcases though. -NOTE: We've provided a simple Tests class which should be used where possible to test general behaviour of AS classes. See Tests.as for its usage. +tests/unimplemented: -NOTE: Please use a naming scheme as follow: - For toplevel classes: tests/CLASSNAME_test.mxml (CLASSNAME is the exact name of the class/function) - For other classes: tests/NAMESPACE_CLASSNAME_test.mxml (NAMESPACE is for example "net" for "flash.net" classes/functions, e.g.: tests/net_NetStream_test.mxml) - Please group all tests for one class in one file. +Tests for unimplemented features. -NOTE: Tests that aren't suitable for testing with the Tests class should be put in tests/other. (e.g.: testing video playing, StageScaleMode testing etc...) - The naming schemes still apply to these testcases though. +tests/performance: -NOTE: Tests for unimplemented features should be placed in tests/unimplemented. +Tests aimed at measuring runtime performance. diff --git a/src/asobject.h b/src/asobject.h index cb06b05871..c639bc0e74 100644 --- a/src/asobject.h +++ b/src/asobject.h @@ -26,6 +26,7 @@ #include "threading.h" #include "memory_support.h" #include +#include #define ASFUNCTION(name) \ static ASObject* name(ASObject* , ASObject* const* args, const unsigned int argslen) @@ -240,7 +241,7 @@ enum METHOD_TYPE { NORMAL_METHOD=0, SETTER_METHOD=1, GETTER_METHOD=2 }; //for toPrimitive enum TP_HINT { NO_HINT, NUMBER_HINT, STRING_HINT }; -class ASObject: public memory_reporter +class ASObject: public memory_reporter, public boost::intrusive::list_base_hook<> { friend class ABCVm; friend class ABCContext; diff --git a/src/scripting/toplevel/toplevel.cpp b/src/scripting/toplevel/toplevel.cpp index de1f216091..d49961e02b 100644 --- a/src/scripting/toplevel/toplevel.cpp +++ b/src/scripting/toplevel/toplevel.cpp @@ -695,14 +695,14 @@ const Type* Type::getTypeFromMultiname(const multiname* mn, const ABCContext* co } Class_base::Class_base(const QName& name, MemoryAccount* m):ASObject(Class_object::getClass()),protected_ns("",NAMESPACE),constructor(NULL), - referencedObjects(std::less(), reporter_allocator(m)),borrowedVariables(m), + borrowedVariables(m), context(NULL),class_name(name),memoryAccount(m),length(1),class_index(-1),isFinal(false),isSealed(false),use_protected(false) { type=T_CLASS; } Class_base::Class_base(const Class_object*):ASObject((MemoryAccount*)NULL),protected_ns("",NAMESPACE),constructor(NULL), - referencedObjects(std::less(), reporter_allocator(NULL)),borrowedVariables(NULL), + borrowedVariables(NULL), context(NULL),class_name("Class",""),memoryAccount(NULL),length(1),class_index(-1),isFinal(false),isSealed(false),use_protected(false) { type=T_CLASS; @@ -878,26 +878,33 @@ void Class_base::handleConstruction(ASObject* target, ASObject* const* args, uns void Class_base::acquireObject(ASObject* ob) { Locker l(referencedObjectsMutex); - bool ret=referencedObjects.insert(ob).second; - assert_and_throw(ret); + assert_and_throw(!ob->is_linked()); + referencedObjects.push_back(*ob); } void Class_base::abandonObject(ASObject* ob) { Locker l(referencedObjectsMutex); - set::size_type ret=referencedObjects.erase(ob); - if(ret!=1) + assert_and_throw(ob->is_linked()); +#ifdef EXPENSIVE_DEBUG + //Check that the object is really referenced by this class + int count=0; + for (auto it=referencedObjects.cbegin(); it!=referencedObjects.cend(); ++it) { - LOG(LOG_ERROR,_("Failure in reference counting in ") << class_name); + if ((&*it) == ob) + count++; } + assert_and_throw(count==1); +#endif + + referencedObjects.erase(referencedObjects.iterator_to(*ob)); } -void Class_base::finalizeObjects() const +void Class_base::finalizeObjects() { while(!referencedObjects.empty()) { - set::iterator it=referencedObjects.begin(); - ASObject* tmp=(*it); + ASObject *tmp=&referencedObjects.front(); tmp->incRef(); //Finalizing the object does also release the classdef and call abandonObject tmp->finalize(); diff --git a/src/scripting/toplevel/toplevel.h b/src/scripting/toplevel/toplevel.h index 52cbbe16d2..8a88a66874 100644 --- a/src/scripting/toplevel/toplevel.h +++ b/src/scripting/toplevel/toplevel.h @@ -32,6 +32,7 @@ //#include "scripting/toplevel/XML.h" #include "memory_support.h" #include +#include namespace lightspark { @@ -152,8 +153,8 @@ template friend class Template; void describeMetadata(xmlpp::Element* node, const traits_info& trait) const; //Naive garbage collection until reference cycles are detected Mutex referencedObjectsMutex; - std::set, reporter_allocator> referencedObjects; - void finalizeObjects() const; + boost::intrusive::list > referencedObjects; + void finalizeObjects(); protected: void copyBorrowedTraitsFromSuper(); ASFUNCTION(_toString); diff --git a/tests/performance/mx_utils_SHA256_test.mxml b/tests/performance/mx_utils_SHA256_test.mxml new file mode 100644 index 0000000000..bfb04d4519 --- /dev/null +++ b/tests/performance/mx_utils_SHA256_test.mxml @@ -0,0 +1,30 @@ + + + + + + + + + +